43d5d0412f569ade21d16f13b82cce13a03d11f7.svn-base 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Collections;
  5. using System.Configuration;
  6. using System.ComponentModel;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Windows.Forms.DataVisualization.Charting;
  12. using System.Diagnostics;
  13. using System.Collections.Generic;
  14. using Core.Mes.ServerFrameWork;
  15. using Infragistics.Win;
  16. using Infragistics.Win.UltraWinGrid;
  17. namespace Core.Mes.ServerManager
  18. {
  19. /// <summary>
  20. /// FrmSeverMain 的摘要说明。
  21. /// </summary>
  22. public class FrmSeverMain : System.Windows.Forms.Form
  23. {
  24. #region 变量定义
  25. private IContainer components = null;
  26. private string[] _args;
  27. private TabControl tabControl1;
  28. private TabPage tabPage1;
  29. private TabPage tabPage2;
  30. private TabPage tabPage3;
  31. private SplitContainer splitContainer1;
  32. private System.Windows.Forms.DataVisualization.Charting.Chart Chart1;
  33. private System.Windows.Forms.DataVisualization.Charting.Chart Chart2;
  34. private System.Windows.Forms.PictureBox pictureBox1;
  35. private System.Windows.Forms.ListBox listBox1;
  36. private ResDaemon resDaemon;
  37. private SrvDaemon srvDaemon;
  38. private ExtSrvDaemon extSrvDaemon;
  39. private ClsServerMain cMain;
  40. private TabPage tabPage4;
  41. private Infragistics.Win.UltraWinGrid.UltraGrid ugServers;
  42. private DataSet dataSet1;
  43. private DataTable dataTable1;
  44. private ServerConfigure _serverConf;
  45. private bool IsLogging = false;
  46. #endregion
  47. public FrmSeverMain(string[] args)
  48. {
  49. _args = args;
  50. if (_args != null)
  51. {
  52. foreach (string arg in _args)
  53. {
  54. if (arg.Trim().ToUpper() == "LOG")
  55. {
  56. IsLogging = true;
  57. }
  58. }
  59. }
  60. //
  61. // Windows 窗体设计器支持所必需的
  62. //
  63. InitializeComponent();
  64. //
  65. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  66. //
  67. this.tabControl1.Controls.Remove(this.tabPage2);
  68. this.tabControl1.Controls.Remove(this.tabPage3);
  69. this.tabControl1.Controls.Remove(this.tabPage4);
  70. }
  71. /// <summary>
  72. /// 清理所有正在使用的资源。
  73. /// </summary>
  74. protected override void Dispose(bool disposing)
  75. {
  76. try
  77. {
  78. if (disposing)
  79. {
  80. if (cMain != null)
  81. {
  82. cMain.Dispose();
  83. }
  84. if (components != null)
  85. {
  86. components.Dispose();
  87. }
  88. }
  89. System.GC.Collect();
  90. base.Dispose(disposing);
  91. }
  92. catch
  93. {
  94. }
  95. }
  96. #region Windows 窗体设计器生成的代码
  97. /// <summary>
  98. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  99. /// 此方法的内容。
  100. /// </summary>
  101. private void InitializeComponent()
  102. {
  103. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSeverMain));
  104. System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
  105. System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
  106. System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
  107. System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
  108. System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
  109. System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
  110. System.Windows.Forms.DataVisualization.Charting.LegendItem legendItem1 = new System.Windows.Forms.DataVisualization.Charting.LegendItem();
  111. System.Windows.Forms.DataVisualization.Charting.LegendCell legendCell1 = new System.Windows.Forms.DataVisualization.Charting.LegendCell();
  112. System.Windows.Forms.DataVisualization.Charting.LegendCell legendCell2 = new System.Windows.Forms.DataVisualization.Charting.LegendCell();
  113. System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
  114. System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
  115. Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance("1", 65116440);
  116. Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance("2", 65174161);
  117. Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance("3", 65316418);
  118. Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance("11", 65318540);
  119. Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance("12", 65321145);
  120. Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance("13", 65325154);
  121. Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance("24", 65327806);
  122. Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance("25", 65329756);
  123. Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance("4", 22929605);
  124. Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance("14", 23236973);
  125. Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
  126. Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance();
  127. Infragistics.Win.Appearance appearance13 = new Infragistics.Win.Appearance();
  128. Infragistics.Win.Appearance appearance14 = new Infragistics.Win.Appearance();
  129. Infragistics.Win.Appearance appearance15 = new Infragistics.Win.Appearance();
  130. Infragistics.Win.Appearance appearance16 = new Infragistics.Win.Appearance();
  131. Infragistics.Win.Appearance appearance17 = new Infragistics.Win.Appearance();
  132. Infragistics.Win.Appearance appearance18 = new Infragistics.Win.Appearance();
  133. Infragistics.Win.Appearance appearance19 = new Infragistics.Win.Appearance();
  134. Infragistics.Win.Appearance appearance20 = new Infragistics.Win.Appearance();
  135. Infragistics.Win.Appearance appearance21 = new Infragistics.Win.Appearance();
  136. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  137. this.listBox1 = new System.Windows.Forms.ListBox();
  138. this.tabControl1 = new System.Windows.Forms.TabControl();
  139. this.tabPage1 = new System.Windows.Forms.TabPage();
  140. this.tabPage2 = new System.Windows.Forms.TabPage();
  141. this.Chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
  142. this.tabPage3 = new System.Windows.Forms.TabPage();
  143. this.Chart2 = new System.Windows.Forms.DataVisualization.Charting.Chart();
  144. this.tabPage4 = new System.Windows.Forms.TabPage();
  145. this.ugServers = new Infragistics.Win.UltraWinGrid.UltraGrid();
  146. this.dataSet1 = new System.Data.DataSet();
  147. this.dataTable1 = new System.Data.DataTable();
  148. this.splitContainer1 = new System.Windows.Forms.SplitContainer();
  149. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  150. this.tabControl1.SuspendLayout();
  151. this.tabPage1.SuspendLayout();
  152. this.tabPage2.SuspendLayout();
  153. ((System.ComponentModel.ISupportInitialize)(this.Chart1)).BeginInit();
  154. this.tabPage3.SuspendLayout();
  155. ((System.ComponentModel.ISupportInitialize)(this.Chart2)).BeginInit();
  156. this.tabPage4.SuspendLayout();
  157. ((System.ComponentModel.ISupportInitialize)(this.ugServers)).BeginInit();
  158. ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
  159. ((System.ComponentModel.ISupportInitialize)(this.dataTable1)).BeginInit();
  160. this.splitContainer1.Panel1.SuspendLayout();
  161. this.splitContainer1.Panel2.SuspendLayout();
  162. this.splitContainer1.SuspendLayout();
  163. this.SuspendLayout();
  164. //
  165. // pictureBox1
  166. //
  167. this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  168. this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
  169. this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
  170. this.pictureBox1.Location = new System.Drawing.Point(0, 0);
  171. this.pictureBox1.Name = "pictureBox1";
  172. this.pictureBox1.Size = new System.Drawing.Size(862, 116);
  173. this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
  174. this.pictureBox1.TabIndex = 0;
  175. this.pictureBox1.TabStop = false;
  176. //
  177. // listBox1
  178. //
  179. this.listBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  180. this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
  181. this.listBox1.ItemHeight = 12;
  182. this.listBox1.Location = new System.Drawing.Point(3, 3);
  183. this.listBox1.Name = "listBox1";
  184. this.listBox1.Size = new System.Drawing.Size(848, 362);
  185. this.listBox1.TabIndex = 1;
  186. //
  187. // tabControl1
  188. //
  189. this.tabControl1.Controls.Add(this.tabPage1);
  190. this.tabControl1.Controls.Add(this.tabPage2);
  191. this.tabControl1.Controls.Add(this.tabPage3);
  192. this.tabControl1.Controls.Add(this.tabPage4);
  193. this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
  194. this.tabControl1.Location = new System.Drawing.Point(0, 0);
  195. this.tabControl1.Name = "tabControl1";
  196. this.tabControl1.SelectedIndex = 0;
  197. this.tabControl1.Size = new System.Drawing.Size(862, 396);
  198. this.tabControl1.TabIndex = 2;
  199. //
  200. // tabPage1
  201. //
  202. this.tabPage1.Controls.Add(this.listBox1);
  203. this.tabPage1.Location = new System.Drawing.Point(4, 22);
  204. this.tabPage1.Name = "tabPage1";
  205. this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
  206. this.tabPage1.Size = new System.Drawing.Size(854, 370);
  207. this.tabPage1.TabIndex = 0;
  208. this.tabPage1.Text = "消息列表";
  209. this.tabPage1.UseVisualStyleBackColor = true;
  210. //
  211. // tabPage2
  212. //
  213. this.tabPage2.AutoScroll = true;
  214. this.tabPage2.Controls.Add(this.Chart1);
  215. this.tabPage2.Location = new System.Drawing.Point(4, 22);
  216. this.tabPage2.Name = "tabPage2";
  217. this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
  218. this.tabPage2.Size = new System.Drawing.Size(854, 370);
  219. this.tabPage2.TabIndex = 1;
  220. this.tabPage2.Text = "服务使用";
  221. this.tabPage2.UseVisualStyleBackColor = true;
  222. //
  223. // Chart1
  224. //
  225. chartArea1.AxisX.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.False;
  226. chartArea1.AxisX.MajorGrid.Enabled = false;
  227. chartArea1.AxisX.MajorTickMark.Enabled = false;
  228. chartArea1.AxisX.ScaleBreakStyle.Spacing = 1;
  229. chartArea1.AxisX.ScaleView.MinSizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
  230. chartArea1.AxisX.ScaleView.SizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
  231. chartArea1.AxisX.ScaleView.Zoomable = false;
  232. chartArea1.InnerPlotPosition.Auto = false;
  233. chartArea1.InnerPlotPosition.Height = 76.16758F;
  234. chartArea1.InnerPlotPosition.Width = 91.96336F;
  235. chartArea1.InnerPlotPosition.X = 6.68718F;
  236. chartArea1.InnerPlotPosition.Y = 5.76923F;
  237. chartArea1.Name = "ChartArea1";
  238. this.Chart1.ChartAreas.Add(chartArea1);
  239. this.Chart1.Dock = System.Windows.Forms.DockStyle.Fill;
  240. legend1.Name = "Legend1";
  241. this.Chart1.Legends.Add(legend1);
  242. this.Chart1.Location = new System.Drawing.Point(3, 3);
  243. this.Chart1.Margin = new System.Windows.Forms.Padding(0);
  244. this.Chart1.Name = "Chart1";
  245. series1.ChartArea = "ChartArea1";
  246. series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
  247. series1.Legend = "Legend1";
  248. series1.LegendText = "服务已使用数";
  249. series1.Name = "Series1";
  250. series2.ChartArea = "ChartArea1";
  251. series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
  252. series2.Legend = "Legend1";
  253. series2.LegendText = "服务实例上限";
  254. series2.Name = "Series2";
  255. this.Chart1.Series.Add(series1);
  256. this.Chart1.Series.Add(series2);
  257. this.Chart1.Size = new System.Drawing.Size(848, 364);
  258. this.Chart1.TabIndex = 0;
  259. //
  260. // tabPage3
  261. //
  262. this.tabPage3.Controls.Add(this.Chart2);
  263. this.tabPage3.Location = new System.Drawing.Point(4, 22);
  264. this.tabPage3.Name = "tabPage3";
  265. this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
  266. this.tabPage3.Size = new System.Drawing.Size(854, 370);
  267. this.tabPage3.TabIndex = 2;
  268. this.tabPage3.Text = "资源使用";
  269. this.tabPage3.UseVisualStyleBackColor = true;
  270. //
  271. // Chart2
  272. //
  273. chartArea2.AxisX.IsMarginVisible = false;
  274. chartArea2.AxisX.IsStartedFromZero = false;
  275. chartArea2.AxisX.LineColor = System.Drawing.Color.Empty;
  276. chartArea2.AxisX.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
  277. chartArea2.AxisX.LineWidth = 0;
  278. chartArea2.AxisX.MajorGrid.Enabled = false;
  279. chartArea2.AxisX.MajorGrid.Interval = 0;
  280. chartArea2.AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  281. chartArea2.AxisX.ScaleBreakStyle.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
  282. chartArea2.AxisY.LineColor = System.Drawing.Color.Red;
  283. chartArea2.AxisY.MajorGrid.Enabled = false;
  284. chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.DarkOrange;
  285. chartArea2.AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  286. chartArea2.AxisY.MajorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.InsideArea;
  287. chartArea2.AxisY2.LineColor = System.Drawing.Color.DodgerBlue;
  288. chartArea2.AxisY2.MajorGrid.LineColor = System.Drawing.Color.DodgerBlue;
  289. chartArea2.AxisY2.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  290. chartArea2.AxisY2.MajorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.InsideArea;
  291. chartArea2.BorderWidth = 2;
  292. chartArea2.Name = "ChartArea1";
  293. this.Chart2.ChartAreas.Add(chartArea2);
  294. this.Chart2.Dock = System.Windows.Forms.DockStyle.Fill;
  295. legend2.BorderWidth = 0;
  296. legendCell1.ForeColor = System.Drawing.Color.OrangeRed;
  297. legendCell1.Name = "cell_Content";
  298. legendCell1.Text = "0";
  299. legendCell2.Name = "Cell_Label";
  300. legendCell2.Text = "空闲内存(MB)";
  301. legendItem1.Cells.Add(legendCell1);
  302. legendItem1.Cells.Add(legendCell2);
  303. legend2.CustomItems.Add(legendItem1);
  304. legend2.LegendItemOrder = System.Windows.Forms.DataVisualization.Charting.LegendItemOrder.SameAsSeriesOrder;
  305. legend2.LegendStyle = System.Windows.Forms.DataVisualization.Charting.LegendStyle.Column;
  306. legend2.Name = "Legend1";
  307. legend2.TableStyle = System.Windows.Forms.DataVisualization.Charting.LegendTableStyle.Tall;
  308. this.Chart2.Legends.Add(legend2);
  309. this.Chart2.Location = new System.Drawing.Point(3, 3);
  310. this.Chart2.Margin = new System.Windows.Forms.Padding(0);
  311. this.Chart2.Name = "Chart2";
  312. series3.BorderWidth = 2;
  313. series3.ChartArea = "ChartArea1";
  314. series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
  315. series3.Color = System.Drawing.Color.OrangeRed;
  316. series3.LabelBorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  317. series3.LabelBorderWidth = 2;
  318. series3.LabelForeColor = System.Drawing.Color.Red;
  319. series3.Legend = "Legend1";
  320. series3.LegendText = "内存(MB)";
  321. series3.MarkerBorderWidth = 2;
  322. series3.Name = "Series1";
  323. series3.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
  324. series3.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
  325. series4.BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  326. series4.BorderWidth = 2;
  327. series4.ChartArea = "ChartArea1";
  328. series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
  329. series4.Color = System.Drawing.Color.DodgerBlue;
  330. series4.Legend = "Legend1";
  331. series4.LegendText = "CPU (%)";
  332. series4.MarkerBorderWidth = 2;
  333. series4.Name = "Series2";
  334. series4.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
  335. series4.YAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
  336. series4.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
  337. this.Chart2.Series.Add(series3);
  338. this.Chart2.Series.Add(series4);
  339. this.Chart2.Size = new System.Drawing.Size(848, 364);
  340. this.Chart2.TabIndex = 0;
  341. //
  342. // tabPage4
  343. //
  344. this.tabPage4.Controls.Add(this.ugServers);
  345. this.tabPage4.Location = new System.Drawing.Point(4, 22);
  346. this.tabPage4.Name = "tabPage4";
  347. this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
  348. this.tabPage4.Size = new System.Drawing.Size(854, 370);
  349. this.tabPage4.TabIndex = 3;
  350. this.tabPage4.Text = "扩展服务器";
  351. this.tabPage4.UseVisualStyleBackColor = true;
  352. //
  353. // ugServers
  354. //
  355. this.ugServers.DataMember = "Table1";
  356. this.ugServers.DataSource = this.dataSet1;
  357. appearance1.BackColor = System.Drawing.Color.PaleGreen;
  358. appearance1.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
  359. appearance1.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  360. appearance1.TextHAlign = Infragistics.Win.HAlign.Center;
  361. appearance2.BackColor = System.Drawing.Color.Silver;
  362. appearance2.BackColor2 = System.Drawing.Color.Gray;
  363. appearance2.BackHatchStyle = Infragistics.Win.BackHatchStyle.BackwardDiagonal;
  364. appearance2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
  365. appearance2.TextHAlign = Infragistics.Win.HAlign.Center;
  366. appearance3.BackColor = System.Drawing.Color.Silver;
  367. appearance3.BackColor2 = System.Drawing.Color.Gray;
  368. appearance3.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  369. appearance3.TextHAlign = Infragistics.Win.HAlign.Center;
  370. appearance4.BackColor = System.Drawing.Color.PaleGreen;
  371. appearance4.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
  372. appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  373. appearance4.TextHAlign = Infragistics.Win.HAlign.Center;
  374. appearance5.BackColor = System.Drawing.Color.Silver;
  375. appearance5.BackColor2 = System.Drawing.Color.Gray;
  376. appearance5.BackHatchStyle = Infragistics.Win.BackHatchStyle.BackwardDiagonal;
  377. appearance5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
  378. appearance5.TextHAlign = Infragistics.Win.HAlign.Center;
  379. appearance6.BackColor = System.Drawing.Color.Silver;
  380. appearance6.BackColor2 = System.Drawing.Color.Gray;
  381. appearance6.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  382. appearance6.TextHAlign = Infragistics.Win.HAlign.Center;
  383. appearance7.BackColor = System.Drawing.Color.Brown;
  384. appearance7.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
  385. appearance7.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  386. appearance7.ForeColor = System.Drawing.Color.Lime;
  387. appearance7.TextHAlign = Infragistics.Win.HAlign.Center;
  388. appearance8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(108)))), ((int)(((byte)(108)))), ((int)(((byte)(108)))));
  389. appearance8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
  390. appearance8.TextHAlign = Infragistics.Win.HAlign.Center;
  391. appearance9.BackColor = System.Drawing.Color.LemonChiffon;
  392. appearance9.BackColor2 = System.Drawing.Color.Gold;
  393. appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  394. appearance9.ForeColor = System.Drawing.Color.Blue;
  395. appearance9.TextHAlign = Infragistics.Win.HAlign.Center;
  396. appearance10.BackColor = System.Drawing.Color.LemonChiffon;
  397. appearance10.BackColor2 = System.Drawing.Color.Gold;
  398. appearance10.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  399. appearance10.ForeColor = System.Drawing.Color.Blue;
  400. appearance10.TextHAlign = Infragistics.Win.HAlign.Center;
  401. this.ugServers.DisplayLayout.Appearances.Add(appearance1);
  402. this.ugServers.DisplayLayout.Appearances.Add(appearance2);
  403. this.ugServers.DisplayLayout.Appearances.Add(appearance3);
  404. this.ugServers.DisplayLayout.Appearances.Add(appearance4);
  405. this.ugServers.DisplayLayout.Appearances.Add(appearance5);
  406. this.ugServers.DisplayLayout.Appearances.Add(appearance6);
  407. this.ugServers.DisplayLayout.Appearances.Add(appearance7);
  408. this.ugServers.DisplayLayout.Appearances.Add(appearance8);
  409. this.ugServers.DisplayLayout.Appearances.Add(appearance9);
  410. this.ugServers.DisplayLayout.Appearances.Add(appearance10);
  411. this.ugServers.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
  412. this.ugServers.DisplayLayout.BorderStyleCaption = Infragistics.Win.UIElementBorderStyle.None;
  413. appearance11.BackColor = System.Drawing.SystemColors.ActiveBorder;
  414. appearance11.BackColor2 = System.Drawing.SystemColors.ControlDark;
  415. appearance11.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  416. appearance11.BorderColor = System.Drawing.SystemColors.Window;
  417. this.ugServers.DisplayLayout.GroupByBox.Appearance = appearance11;
  418. appearance12.ForeColor = System.Drawing.SystemColors.GrayText;
  419. this.ugServers.DisplayLayout.GroupByBox.BandLabelAppearance = appearance12;
  420. this.ugServers.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
  421. appearance13.BackColor = System.Drawing.SystemColors.ControlLightLight;
  422. appearance13.BackColor2 = System.Drawing.SystemColors.Control;
  423. appearance13.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
  424. appearance13.ForeColor = System.Drawing.SystemColors.GrayText;
  425. this.ugServers.DisplayLayout.GroupByBox.PromptAppearance = appearance13;
  426. this.ugServers.DisplayLayout.MaxColScrollRegions = 1;
  427. this.ugServers.DisplayLayout.MaxRowScrollRegions = 1;
  428. appearance14.BackColor = System.Drawing.SystemColors.Window;
  429. appearance14.ForeColor = System.Drawing.SystemColors.ControlText;
  430. this.ugServers.DisplayLayout.Override.ActiveCellAppearance = appearance14;
  431. appearance15.BackColor = System.Drawing.SystemColors.Highlight;
  432. appearance15.ForeColor = System.Drawing.SystemColors.HighlightText;
  433. this.ugServers.DisplayLayout.Override.ActiveRowAppearance = appearance15;
  434. this.ugServers.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
  435. this.ugServers.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
  436. this.ugServers.DisplayLayout.Override.AllowGroupBy = Infragistics.Win.DefaultableBoolean.False;
  437. this.ugServers.DisplayLayout.Override.AllowGroupMoving = Infragistics.Win.UltraWinGrid.AllowGroupMoving.NotAllowed;
  438. this.ugServers.DisplayLayout.Override.AllowGroupSwapping = Infragistics.Win.UltraWinGrid.AllowGroupSwapping.NotAllowed;
  439. this.ugServers.DisplayLayout.Override.AllowRowLayoutCellSpanSizing = Infragistics.Win.Layout.GridBagLayoutAllowSpanSizing.None;
  440. this.ugServers.DisplayLayout.Override.AllowRowLayoutLabelSpanSizing = Infragistics.Win.Layout.GridBagLayoutAllowSpanSizing.None;
  441. this.ugServers.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
  442. appearance16.BackColor = System.Drawing.SystemColors.Window;
  443. this.ugServers.DisplayLayout.Override.CardAreaAppearance = appearance16;
  444. appearance17.BorderColor = System.Drawing.Color.Silver;
  445. appearance17.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
  446. this.ugServers.DisplayLayout.Override.CellAppearance = appearance17;
  447. this.ugServers.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.CellSelect;
  448. this.ugServers.DisplayLayout.Override.CellMultiLine = Infragistics.Win.DefaultableBoolean.False;
  449. this.ugServers.DisplayLayout.Override.CellPadding = 0;
  450. this.ugServers.DisplayLayout.Override.ExpansionIndicator = Infragistics.Win.UltraWinGrid.ShowExpansionIndicator.Never;
  451. this.ugServers.DisplayLayout.Override.FixedRowIndicator = Infragistics.Win.UltraWinGrid.FixedRowIndicator.None;
  452. appearance18.BackColor = System.Drawing.SystemColors.Control;
  453. appearance18.BackColor2 = System.Drawing.SystemColors.ControlDark;
  454. appearance18.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
  455. appearance18.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
  456. appearance18.BorderColor = System.Drawing.SystemColors.Window;
  457. this.ugServers.DisplayLayout.Override.GroupByRowAppearance = appearance18;
  458. appearance19.TextHAlign = Infragistics.Win.HAlign.Left;
  459. this.ugServers.DisplayLayout.Override.HeaderAppearance = appearance19;
  460. this.ugServers.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
  461. appearance20.BackColor = System.Drawing.SystemColors.Window;
  462. appearance20.BorderColor = System.Drawing.Color.Silver;
  463. this.ugServers.DisplayLayout.Override.RowAppearance = appearance20;
  464. this.ugServers.DisplayLayout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.RowIndex;
  465. this.ugServers.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
  466. this.ugServers.DisplayLayout.Override.RowSelectorStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
  467. this.ugServers.DisplayLayout.Override.ShowInkButton = Infragistics.Win.ShowInkButton.Never;
  468. appearance21.BackColor = System.Drawing.SystemColors.ControlLight;
  469. this.ugServers.DisplayLayout.Override.TemplateAddRowAppearance = appearance21;
  470. this.ugServers.DisplayLayout.PriorityScrolling = true;
  471. this.ugServers.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
  472. this.ugServers.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
  473. this.ugServers.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.SingleBand;
  474. this.ugServers.Dock = System.Windows.Forms.DockStyle.Fill;
  475. this.ugServers.FlatMode = true;
  476. this.ugServers.Location = new System.Drawing.Point(3, 3);
  477. this.ugServers.Margin = new System.Windows.Forms.Padding(0);
  478. this.ugServers.Name = "ugServers";
  479. this.ugServers.Size = new System.Drawing.Size(848, 364);
  480. this.ugServers.TabIndex = 0;
  481. this.ugServers.Text = "独立运行";
  482. this.ugServers.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ugServers_ClickCellButton);
  483. this.ugServers.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ugServers_AfterCellUpdate);
  484. this.ugServers.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.ugServers_InitializeRow);
  485. //
  486. // dataSet1
  487. //
  488. this.dataSet1.DataSetName = "NewDataSet";
  489. this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {
  490. this.dataTable1});
  491. //
  492. // dataTable1
  493. //
  494. this.dataTable1.TableName = "Table1";
  495. //
  496. // splitContainer1
  497. //
  498. this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
  499. this.splitContainer1.IsSplitterFixed = true;
  500. this.splitContainer1.Location = new System.Drawing.Point(0, 0);
  501. this.splitContainer1.Margin = new System.Windows.Forms.Padding(0);
  502. this.splitContainer1.Name = "splitContainer1";
  503. this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
  504. //
  505. // splitContainer1.Panel1
  506. //
  507. this.splitContainer1.Panel1.Controls.Add(this.pictureBox1);
  508. this.splitContainer1.Panel1MinSize = 100;
  509. //
  510. // splitContainer1.Panel2
  511. //
  512. this.splitContainer1.Panel2.Controls.Add(this.tabControl1);
  513. this.splitContainer1.Size = new System.Drawing.Size(862, 513);
  514. this.splitContainer1.SplitterDistance = 116;
  515. this.splitContainer1.SplitterWidth = 1;
  516. this.splitContainer1.TabIndex = 3;
  517. //
  518. // FrmSeverMain
  519. //
  520. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  521. this.ClientSize = new System.Drawing.Size(862, 513);
  522. this.Controls.Add(this.splitContainer1);
  523. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  524. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  525. this.MaximizeBox = false;
  526. this.Name = "FrmSeverMain";
  527. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  528. this.Text = "应用服务";
  529. this.Load += new System.EventHandler(this.FrmSeverMain_Load);
  530. this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmSeverMain_Closing);
  531. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  532. this.tabControl1.ResumeLayout(false);
  533. this.tabPage1.ResumeLayout(false);
  534. this.tabPage2.ResumeLayout(false);
  535. ((System.ComponentModel.ISupportInitialize)(this.Chart1)).EndInit();
  536. this.tabPage3.ResumeLayout(false);
  537. ((System.ComponentModel.ISupportInitialize)(this.Chart2)).EndInit();
  538. this.tabPage4.ResumeLayout(false);
  539. ((System.ComponentModel.ISupportInitialize)(this.ugServers)).EndInit();
  540. ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
  541. ((System.ComponentModel.ISupportInitialize)(this.dataTable1)).EndInit();
  542. this.splitContainer1.Panel1.ResumeLayout(false);
  543. this.splitContainer1.Panel2.ResumeLayout(false);
  544. this.splitContainer1.ResumeLayout(false);
  545. this.ResumeLayout(false);
  546. }
  547. #endregion
  548. private void FrmSeverMain_Load(object sender, System.EventArgs e)
  549. {
  550. ugValueList = GetServerVL();
  551. //==>
  552. //if (System.DateTime.Today > new System.DateTime(2007,1,1)) return;
  553. ApplicationStart();
  554. this.pictureBox1.Image = System.Drawing.Image.FromFile(@"Image\登录框.jpg");
  555. cMain = new ClsServerMain();
  556. cMain.ShowLogEvent += new Core.Mes.ServerManager.ClsServerMain.ShowLogDelegate(cMain_ShowLog);
  557. cMain._isLogging = IsLogging;
  558. Application.DoEvents();
  559. this.Show();
  560. InitConfigure();
  561. cMain.InitServerMain(new object[] { _serverConf });
  562. resDaemon = new ResDaemon();
  563. resDaemon.StartDaemon();
  564. srvDaemon = new SrvDaemon(cMain.HtAssemblyService);
  565. srvDaemon.StartDaemon();
  566. InitChart();
  567. extSrvDaemon = new ExtSrvDaemon();
  568. ///////////////服务启动后,方可进行资源监控/////////////////
  569. this.tabControl1.Controls.Add(this.tabPage2);
  570. this.tabControl1.Controls.Add(this.tabPage3);
  571. this.tabControl1.Controls.Add(this.tabPage4);
  572. this.tabControl1.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl1_Selected);
  573. }
  574. private void InitConfigure()
  575. {
  576. _serverConf = new ServerConfigure();
  577. _serverConf.ssc_event = new Core.Mes.ServerFrameWork.ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv);
  578. _serverConf.OnMasterServerChanged = new InvokeCallback(MasterChanged);
  579. }
  580. private void MasterChanged(string _mName)
  581. {
  582. if (ugServers.InvokeRequired)
  583. {
  584. InvokeCallback method = new InvokeCallback(MasterChanged);
  585. ugServers.Invoke(method, _mName);
  586. return;
  587. }
  588. if (string.IsNullOrEmpty(_mName))
  589. {
  590. ugServers.Text = "独立运行";
  591. }
  592. else
  593. {
  594. UriBuilder ub = new UriBuilder(_mName);
  595. ugServers.Text = string.Format("本机受控于服务器[{0}:{1}]", ub.Host, ub.Port);
  596. }
  597. }
  598. Thread t_ShowRes = null;
  599. Thread t_ShowSrv = null;
  600. Thread t_ShowExt = null;
  601. private void InitChart()
  602. {
  603. Chart1.ChartAreas[0].AxisY.Minimum = 0;
  604. Chart1.ChartAreas[0].AxisX.Minimum = 0;
  605. Chart2.ChartAreas[0].AxisY.Minimum = 0;
  606. Chart2.ChartAreas[0].AxisY2.Minimum = 0;
  607. Chart2.ChartAreas[0].AxisY2.Maximum = 100;
  608. StopShowResData();
  609. StopShowSrvData();
  610. }
  611. private void StartShowResData()
  612. {
  613. if (t_ShowRes == null ||
  614. t_ShowRes.ThreadState == System.Threading.ThreadState.Stopped ||
  615. t_ShowRes.ThreadState == System.Threading.ThreadState.Aborted)
  616. {
  617. t_ShowRes = new Thread(ShowResData);
  618. t_ShowRes.Name = "资源数据读取";
  619. t_ShowRes.Start();
  620. resDaemon.ResumeMe();
  621. }
  622. else
  623. {
  624. resDaemon.ResumeMe();
  625. }
  626. }
  627. private void StartShowSrvData()
  628. {
  629. if (t_ShowSrv == null ||
  630. t_ShowSrv.ThreadState == System.Threading.ThreadState.Stopped ||
  631. t_ShowSrv.ThreadState == System.Threading.ThreadState.Aborted)
  632. {
  633. t_ShowSrv = new Thread(ShowSrvData);
  634. t_ShowSrv.Name = "服务数据读取";
  635. t_ShowSrv.Start();
  636. srvDaemon.ResumeMe();
  637. }
  638. else
  639. {
  640. srvDaemon.ResumeMe();
  641. }
  642. }
  643. private void StartShowExtServer()
  644. {
  645. if (t_ShowExt == null ||
  646. t_ShowExt.ThreadState == System.Threading.ThreadState.Stopped ||
  647. t_ShowExt.ThreadState == System.Threading.ThreadState.Aborted)
  648. {
  649. t_ShowExt = new Thread(ShowExtServer);
  650. t_ShowExt.Name = "扩展服务器读取";
  651. t_ShowExt.Start();
  652. extSrvDaemon.ResumeMe();
  653. }
  654. else
  655. {
  656. extSrvDaemon.ResumeMe();
  657. }
  658. }
  659. private void StopShowResData()
  660. {
  661. if (t_ShowRes != null)
  662. {
  663. resDaemon.SuspendMe();
  664. }
  665. }
  666. private void StopShowSrvData()
  667. {
  668. if (t_ShowSrv != null)
  669. {
  670. srvDaemon.SuspendMe();
  671. }
  672. }
  673. private void StopShowExtServer()
  674. {
  675. if (t_ShowSrv != null)
  676. {
  677. extSrvDaemon.SuspendMe();
  678. }
  679. }
  680. private void ShowResData()
  681. {
  682. try
  683. {
  684. resDaemon.ShowResData(this.Chart2, new ResDaemon.ShowResDataEvent(CallBackShowResData));
  685. }
  686. catch (Exception ex)
  687. {
  688. MessageBox.Show(ex.Message, "资源显示线程错误");
  689. }
  690. }
  691. private void ShowSrvData()
  692. {
  693. try
  694. {
  695. srvDaemon.ShowSrvData(new SrvDaemon.ShowSrvDataEvent(CallBackShowSrvData));
  696. }
  697. catch (Exception ex)
  698. {
  699. MessageBox.Show(ex.Message, "服务显示线程错误");
  700. }
  701. }
  702. private void ShowExtServer()
  703. {
  704. try
  705. {
  706. extSrvDaemon.ShowExtServer(new ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv));
  707. }
  708. catch (Exception ex)
  709. {
  710. MessageBox.Show(ex.Message, "扩展服务器显示线程错误");
  711. }
  712. }
  713. private void CallBackShowResData(List<DataPoint> ps1, List<DataPoint> ps2)
  714. {
  715. if (Chart2.InvokeRequired)
  716. {
  717. ResDaemon.ShowResDataEvent srde = new ResDaemon.ShowResDataEvent(CallBackShowResData);
  718. this.Invoke(srde, new object[] { ps1, ps2 });
  719. return;
  720. }
  721. Series s1 = Chart2.Series[0];
  722. Series s2 = Chart2.Series[1];
  723. s1.Points.Invalidate();
  724. s2.Points.Invalidate();
  725. s1.Points.Clear();
  726. s2.Points.Clear();
  727. foreach (DataPoint dp in ps1)
  728. {
  729. s1.Points.Add(dp);
  730. }
  731. foreach (DataPoint dp in ps2)
  732. {
  733. s2.Points.Add(dp);
  734. }
  735. Chart2.ChartAreas[0].AxisX.Minimum = s1.Points[0].XValue;
  736. Chart2.ChartAreas[0].AxisX.Maximum = s1.Points[s1.Points.Count - 1].XValue;
  737. SystemInfo si = new SystemInfo();
  738. Chart2.Legends[0].CustomItems[0].Cells[0].Text = (si.MemoryAvailable / 1024 / 1024).ToString();
  739. s1.Points.ResumeUpdates();
  740. s2.Points.ResumeUpdates();
  741. }
  742. private void CallBackShowSrvData(List<DataPoint> ps1, List<DataPoint> ps2)
  743. {
  744. if (Chart1.InvokeRequired)
  745. {
  746. SrvDaemon.ShowSrvDataEvent ssde = new SrvDaemon.ShowSrvDataEvent(CallBackShowSrvData);
  747. this.Invoke(ssde, new object[] { ps1, ps2 });
  748. return;
  749. }
  750. Series s1 = Chart1.Series[0];
  751. Series s2 = Chart1.Series[1];
  752. s1.Points.Invalidate();
  753. s2.Points.Invalidate();
  754. s1.Points.Clear();
  755. s2.Points.Clear();
  756. foreach (DataPoint dp in ps1)
  757. {
  758. s1.Points.Add(dp);
  759. }
  760. foreach (DataPoint dp in ps2)
  761. {
  762. s2.Points.Add(dp);
  763. }
  764. s1.Points.ResumeUpdates();
  765. }
  766. private void CallBackShowExtSrv()
  767. {
  768. if (ugServers.InvokeRequired)
  769. {
  770. ExtSrvDaemon.ShowExtSrvEvent sese = new ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv);
  771. this.Invoke(sese);
  772. return;
  773. }
  774. ugServers.SuspendLayout();
  775. ugServers.SuspendRowSynchronization();
  776. Hashtable extServers = this.cMain.HtExternServer;
  777. DataTable dt = this.dataSet1.Tables[0];
  778. if (dt.Columns.Count == 0)
  779. {
  780. dt.Columns.Add("本地服务", typeof(string));
  781. }
  782. if (dt.Rows.Count == 0)
  783. {
  784. DataRow dr = dt.NewRow();
  785. dr[0] = "1";
  786. dt.Rows.Add(dr);
  787. }
  788. dt.AcceptChanges();
  789. //去除无效服务器
  790. foreach (DataColumn dc in dt.Columns)
  791. {
  792. if (dc.ColumnName == "本地服务") continue;
  793. bool keep_it = false;
  794. foreach (string ServerName in extServers.Keys)
  795. {
  796. UriBuilder ub = new UriBuilder(ServerName);
  797. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  798. if (sn == dc.ColumnName)
  799. {
  800. keep_it = true;
  801. }
  802. }
  803. if (!keep_it)
  804. {
  805. dt.Columns.Remove(dc);
  806. }
  807. }
  808. dt.AcceptChanges();
  809. //新增服务器
  810. foreach (string ServerName in extServers.Keys)
  811. {
  812. UriBuilder ub = new UriBuilder(ServerName);
  813. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  814. if (!dt.Columns.Contains(sn))
  815. {
  816. dt.Columns.Add(sn, typeof(string));
  817. }
  818. RemotingServer rs = (RemotingServer)(extServers[ServerName]);
  819. string status = (rs.Valid != RemoteServerStatus.Normal) ? ((int)(rs.Valid)).ToString() : (rs.Enable ? "1" : "3");
  820. dt.Rows[0][sn] = status;
  821. }
  822. //去除无效服务
  823. for (int idx = 1; idx < dt.Rows.Count; idx++)
  824. {
  825. DataRow dr = dt.Rows[idx];
  826. if (cMain.HTServiceKeys.ContainsKey(dr["本地服务"].ToString())) continue;
  827. dr.Delete();
  828. }
  829. dt.AcceptChanges();
  830. //新增服务项
  831. foreach (string serviceName in this.cMain.HTServiceKeys.Keys)
  832. {
  833. DataRow[] drs = dt.Select(string.Format("本地服务='{0}'", serviceName));
  834. DataRow dr = null;
  835. if (drs.GetLength(0) == 0)
  836. {
  837. dr = dt.NewRow();
  838. dr[0] = serviceName;
  839. dt.Rows.Add(dr);
  840. }
  841. else
  842. {
  843. dr = drs[0];
  844. }
  845. foreach (string serverName in extServers.Keys)
  846. {
  847. UriBuilder ub = new UriBuilder(serverName);
  848. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  849. RemotingServer rs = (RemotingServer)(extServers[serverName]);
  850. string server_status = dt.Rows[0][sn].ToString();
  851. if (server_status != "1")
  852. {
  853. dr[sn] = "1" + server_status;
  854. continue;
  855. }
  856. string status = "1";
  857. if (!rs.HTServices.ContainsKey(serviceName))
  858. {
  859. status = "25";
  860. }
  861. else
  862. {
  863. ServiceObject so = (ServiceObject)(rs.HTServices[serviceName]);
  864. switch (so.Valid)
  865. {
  866. case ServiceObjectStatus.Normal:
  867. status = (so.Enable ? "11" : "13");
  868. break;
  869. case ServiceObjectStatus.Unable:
  870. status = "12";
  871. break;
  872. case ServiceObjectStatus.UnMatch:
  873. status = "24";
  874. break;
  875. }
  876. }
  877. dr[sn] = status;
  878. }
  879. }
  880. dt.AcceptChanges();
  881. for (int idx = 0; idx < ugServers.DisplayLayout.Bands[0].Columns.Count; idx++)
  882. {
  883. ugServers.DisplayLayout.Bands[0].Columns[idx].ValueList = ugValueList;
  884. }
  885. ugServers.ResumeRowSynchronization();
  886. ugServers.ResumeLayout();
  887. }
  888. private static ValueList ugValueList = null;
  889. private ValueList GetServerVL()
  890. {
  891. ValueList vl = new ValueList();
  892. vl.ValueListItems.Add("1", "[正常运行]");
  893. vl.ValueListItems.Add("2", "[不可用]");
  894. vl.ValueListItems.Add("3", "[暂停服务]");
  895. vl.ValueListItems.Add("4", "[受控于其他主机]");
  896. vl.ValueListItems.Add("11", "功能正常");
  897. vl.ValueListItems.Add("12", "不可用");
  898. vl.ValueListItems.Add("13", "暂停服务");
  899. vl.ValueListItems.Add("14", "受控其他主机");
  900. vl.ValueListItems.Add("24", "版本不一致");
  901. vl.ValueListItems.Add("25", "缺少服务");
  902. return vl;
  903. }
  904. private void cMain_ShowLog(string log)
  905. {
  906. lock (this.listBox1)
  907. {
  908. this.listBox1.Invalidate();
  909. this.listBox1.Items.Add(log);
  910. this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1;
  911. Application.DoEvents();
  912. this.listBox1.Update();
  913. }
  914. }
  915. private void FrmSeverMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  916. {
  917. if (MessageBox.Show("是否确认退出服务端程序?", "提示", MessageBoxButtons.YesNo,
  918. MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
  919. {
  920. e.Cancel = true;
  921. }
  922. else
  923. {
  924. ApplicationExit();
  925. Application.Exit();
  926. System.Diagnostics.Process.GetCurrentProcess().Kill();
  927. }
  928. }
  929. private static void ApplicationExit()
  930. {
  931. string path = string.Format(@"{0}/log/Application/{1}.txt", Application.StartupPath, System.DateTime.Now.ToString("yyyy_MM_dd"));
  932. using (StreamWriter sw = new StreamWriter(path, true, Encoding.UTF8))
  933. {
  934. StringBuilder sbtxt = new StringBuilder();
  935. sbtxt.AppendLine("==============================================");
  936. sbtxt.AppendLine(string.Format("服务关闭时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm::ss")));
  937. sbtxt.AppendLine("==============================================");
  938. sw.WriteLine(sbtxt.ToString());
  939. }
  940. }
  941. private static void ApplicationStart()
  942. {
  943. string path = string.Format(@"{0}/log/Application/{1}.txt", Application.StartupPath, System.DateTime.Now.ToString("yyyy_MM_dd"));
  944. using (StreamWriter sw = new StreamWriter(path, true, Encoding.UTF8))
  945. {
  946. StringBuilder sbtxt = new StringBuilder();
  947. sbtxt.AppendLine("==============================================");
  948. sbtxt.AppendLine(string.Format("服务开启时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm::ss")));
  949. sbtxt.AppendLine("==============================================");
  950. sw.WriteLine(sbtxt.ToString());
  951. }
  952. }
  953. private void tabControl1_Selected(object sender, TabControlEventArgs e)
  954. {
  955. if (e.TabPageIndex == 1)
  956. {
  957. StartShowSrvData();
  958. }
  959. else
  960. {
  961. StopShowSrvData();
  962. }
  963. if (e.TabPageIndex == 2)
  964. {
  965. StartShowResData();
  966. }
  967. else
  968. {
  969. StopShowResData();
  970. }
  971. if (e.TabPageIndex == 3)
  972. {
  973. StartShowExtServer();
  974. }
  975. else
  976. {
  977. StopShowExtServer();
  978. }
  979. }
  980. private void ugServers_AfterCellUpdate(object sender, CellEventArgs e)
  981. {
  982. UltraGridColumn uc = e.Cell.Column;
  983. try
  984. {
  985. if (uc.Index > 0 || e.Cell.Row.Index == 0)
  986. {
  987. e.Cell.Appearance = ugServers.DisplayLayout.Appearances[e.Cell.Row.GetCellValue(uc).ToString()];
  988. }
  989. }
  990. catch { }
  991. }
  992. private void ugServers_InitializeRow(object sender, InitializeRowEventArgs e)
  993. {
  994. for (int idx = 0; idx < e.Row.Band.Columns.Count; idx++)
  995. {
  996. UltraGridColumn uc = e.Row.Band.Columns[idx];
  997. try
  998. {
  999. if (uc.Index > 0 || e.Row.Index == 0)
  1000. {
  1001. e.Row.Cells[idx].Appearance = ugServers.DisplayLayout.Appearances[e.Row.GetCellValue(uc).ToString()];
  1002. string cell_value = e.Row.GetCellValue(uc).ToString();
  1003. if (cell_value == "1" || cell_value == "3" || cell_value == "11" || cell_value == "13")
  1004. {
  1005. e.Row.Cells[idx].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
  1006. }
  1007. else
  1008. {
  1009. e.Row.Cells[idx].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Default;
  1010. }
  1011. }
  1012. }
  1013. catch { }
  1014. }
  1015. }
  1016. private void ugServers_ClickCellButton(object sender, CellEventArgs e)
  1017. {
  1018. ugServers.SuspendRowSynchronization();
  1019. UltraGridColumn uc = e.Cell.Column;
  1020. string cell_value = e.Cell.Row.GetCellValue(uc).ToString();
  1021. string ServerName = uc.Header.Caption;
  1022. string ServiceName = e.Cell.Row.GetCellValue(e.Cell.Row.Band.Columns[0]).ToString();
  1023. if (cell_value == "1")
  1024. {
  1025. cMain.SetServerFlag(ServerName, false);
  1026. }
  1027. else if (cell_value == "3")
  1028. {
  1029. cMain.SetServerFlag(ServerName, true);
  1030. }
  1031. else if (cell_value == "11")
  1032. {
  1033. cMain.SetServiceFlag(ServerName, ServiceName, false);
  1034. }
  1035. else if (cell_value == "13")
  1036. {
  1037. cMain.SetServiceFlag(ServerName, ServiceName, true);
  1038. }
  1039. ugServers.ResumeRowSynchronization();
  1040. ugServers.Update();
  1041. }
  1042. }
  1043. }