Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.6 KiB

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Windows.Forms;
  7. using System.Xml.Serialization;
  8. using UDDI;
  9. using UDDI.API;
  10. using UDDI.Replication;
  11. namespace UDDI.Tools
  12. {
  13. public class ChangeLogControl : UserControl
  14. {
  15. public delegate void ChangeRecordSelectedHandler( bool isLocal, string changeRecordXml );
  16. public event ChangeRecordSelectedHandler ChangeRecordSelect;
  17. private ListView changeLogListView;
  18. private Splitter splitter;
  19. private TextBox rawXmlTextBox;
  20. public ChangeLogControl()
  21. {
  22. InitializeComponent();
  23. UpdateView();
  24. }
  25. public void UpdateView()
  26. {
  27. //
  28. // Clear our controls out
  29. //
  30. changeLogListView.Items.Clear();
  31. rawXmlTextBox.Text = "";
  32. //
  33. // Populate our list view with the change log.
  34. //
  35. GetChangeRecords changeRecords = new GetChangeRecords();
  36. ChangeRecordDetail detail = changeRecords.Get();
  37. foreach( ChangeRecord changeRecord in detail.ChangeRecords )
  38. {
  39. ListViewItem listViewItem = new ListViewItem();
  40. listViewItem.Text = Convert.ToString( changeRecord.ChangeID.OriginatingUSN );
  41. listViewItem.SubItems.Add( changeRecord.ChangeID.NodeID );
  42. listViewItem.SubItems.Add( changeRecord.Payload.ChangeRecordPayloadType.ToString() );
  43. ChangeRecordTag changeRecordTag = new ChangeRecordTag();
  44. changeRecordTag.xml = changeRecord.ToString();
  45. if( Config.GetString( "OperatorKey" ).ToLower().Equals( changeRecord.ChangeID.NodeID.ToLower() ) )
  46. {
  47. changeRecordTag.isLocal = true;
  48. if( changeRecord.Payload.ChangeRecordPayloadType == ChangeRecordPayloadType.ChangeRecordCorrection )
  49. {
  50. listViewItem.ForeColor = Color.Gray;
  51. }
  52. else
  53. {
  54. listViewItem.ForeColor = Color.Green;
  55. }
  56. }
  57. else
  58. {
  59. changeRecordTag.isLocal = false;
  60. listViewItem.ForeColor = Color.Gray;
  61. }
  62. listViewItem.Tag = changeRecordTag;
  63. changeLogListView.Items.Add( listViewItem );
  64. }
  65. }
  66. public bool ShowRawXML
  67. {
  68. get
  69. {
  70. return rawXmlTextBox.Visible;
  71. }
  72. set
  73. {
  74. rawXmlTextBox.Visible = value;
  75. }
  76. }
  77. public ListView ChangeRecords
  78. {
  79. get
  80. {
  81. return changeLogListView;
  82. }
  83. }
  84. private void InitializeComponent()
  85. {
  86. this.changeLogListView = new ListView();
  87. this.rawXmlTextBox = new TextBox();
  88. this.splitter = new Splitter();
  89. this.SuspendLayout();
  90. //
  91. // changeLogListView
  92. //
  93. this.changeLogListView.Dock = DockStyle.Top;
  94. this.changeLogListView.FullRowSelect = true;
  95. this.changeLogListView.Name = "changeLogListView";
  96. this.changeLogListView.TabIndex = 0;
  97. this.changeLogListView.View = View.Details;
  98. this.changeLogListView.Columns.Add( "Originating USN", -2, HorizontalAlignment.Center );
  99. this.changeLogListView.Columns.Add( "Node ID", -2, HorizontalAlignment.Center );
  100. this.changeLogListView.Columns.Add( "Type", -2, HorizontalAlignment.Center );
  101. this.changeLogListView.SelectedIndexChanged += new System.EventHandler(this.ChangeLogListView_Select);
  102. //
  103. // splitter
  104. //
  105. this.splitter.Dock = DockStyle.Top;
  106. this.splitter.Name = "splitter";
  107. this.splitter.TabIndex = 2;
  108. this.splitter.TabStop = false;
  109. //
  110. // rawXmlTextBox
  111. //
  112. this.rawXmlTextBox.Dock = DockStyle.Fill;
  113. this.rawXmlTextBox.Multiline = true;
  114. this.rawXmlTextBox.Name = "rawXmlTextBox";
  115. this.rawXmlTextBox.ReadOnly = true;
  116. this.rawXmlTextBox.ScrollBars = ScrollBars.Both;
  117. this.rawXmlTextBox.Size = new System.Drawing.Size(672, 391);
  118. this.rawXmlTextBox.TabIndex = 1;
  119. //
  120. // ChangeLogControl
  121. //
  122. this.Controls.AddRange( new Control[] { this.splitter,
  123. this.rawXmlTextBox,
  124. this.changeLogListView } );
  125. this.Name = "ChangeLogControl";
  126. this.ResumeLayout(false);
  127. }
  128. private void ChangeLogListView_Select( object sender, EventArgs eventArgs )
  129. {
  130. if( changeLogListView.SelectedItems.Count == 1 )
  131. {
  132. ListViewItem selectedItem = changeLogListView.SelectedItems[ 0 ];
  133. ChangeRecordTag changeRecordTag = ( ChangeRecordTag ) selectedItem.Tag;
  134. rawXmlTextBox.Text = changeRecordTag.xml;
  135. //
  136. // Fire our event.
  137. //
  138. ChangeRecordSelect( changeRecordTag.isLocal, changeRecordTag.xml );
  139. }
  140. }
  141. private struct ChangeRecordTag
  142. {
  143. public string xml;
  144. public bool isLocal;
  145. }
  146. }
  147. }