d1a075cfc51a6c96013a00e3dcc3c38f25834312.svn-base 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  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.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;
  440. this.ugServers.DisplayLayout.Override.AllowRowLayoutCellSpanSizing = Infragistics.Win.Layout.GridBagLayoutAllowSpanSizing.None;
  441. this.ugServers.DisplayLayout.Override.AllowRowLayoutLabelSpanSizing = Infragistics.Win.Layout.GridBagLayoutAllowSpanSizing.None;
  442. this.ugServers.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
  443. appearance16.BackColor = System.Drawing.SystemColors.Window;
  444. this.ugServers.DisplayLayout.Override.CardAreaAppearance = appearance16;
  445. appearance17.BorderColor = System.Drawing.Color.Silver;
  446. appearance17.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
  447. this.ugServers.DisplayLayout.Override.CellAppearance = appearance17;
  448. this.ugServers.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.CellSelect;
  449. this.ugServers.DisplayLayout.Override.CellMultiLine = Infragistics.Win.DefaultableBoolean.False;
  450. this.ugServers.DisplayLayout.Override.CellPadding = 0;
  451. this.ugServers.DisplayLayout.Override.ExpansionIndicator = Infragistics.Win.UltraWinGrid.ShowExpansionIndicator.Never;
  452. this.ugServers.DisplayLayout.Override.FixedRowIndicator = Infragistics.Win.UltraWinGrid.FixedRowIndicator.None;
  453. appearance18.BackColor = System.Drawing.SystemColors.Control;
  454. appearance18.BackColor2 = System.Drawing.SystemColors.ControlDark;
  455. appearance18.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
  456. appearance18.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
  457. appearance18.BorderColor = System.Drawing.SystemColors.Window;
  458. this.ugServers.DisplayLayout.Override.GroupByRowAppearance = appearance18;
  459. appearance19.TextHAlign = Infragistics.Win.HAlign.Left;
  460. this.ugServers.DisplayLayout.Override.HeaderAppearance = appearance19;
  461. this.ugServers.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
  462. appearance20.BackColor = System.Drawing.SystemColors.Window;
  463. appearance20.BorderColor = System.Drawing.Color.Silver;
  464. this.ugServers.DisplayLayout.Override.RowAppearance = appearance20;
  465. this.ugServers.DisplayLayout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.RowIndex;
  466. this.ugServers.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
  467. this.ugServers.DisplayLayout.Override.RowSelectorStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
  468. this.ugServers.DisplayLayout.Override.ShowInkButton = Infragistics.Win.ShowInkButton.Never;
  469. appearance21.BackColor = System.Drawing.SystemColors.ControlLight;
  470. this.ugServers.DisplayLayout.Override.TemplateAddRowAppearance = appearance21;
  471. this.ugServers.DisplayLayout.PriorityScrolling = true;
  472. this.ugServers.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
  473. this.ugServers.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
  474. this.ugServers.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.SingleBand;
  475. this.ugServers.Dock = System.Windows.Forms.DockStyle.Fill;
  476. this.ugServers.FlatMode = true;
  477. this.ugServers.Location = new System.Drawing.Point(3, 3);
  478. this.ugServers.Margin = new System.Windows.Forms.Padding(0);
  479. this.ugServers.Name = "ugServers";
  480. this.ugServers.Size = new System.Drawing.Size(848, 364);
  481. this.ugServers.TabIndex = 0;
  482. this.ugServers.Text = "独立运行";
  483. this.ugServers.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ugServers_ClickCellButton);
  484. this.ugServers.DoubleClickHeader += new Infragistics.Win.UltraWinGrid.DoubleClickHeaderEventHandler(this.ugServers_DoubleClickHeader);
  485. this.ugServers.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ugServers_AfterCellUpdate);
  486. this.ugServers.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.ugServers_InitializeRow);
  487. //
  488. // dataSet1
  489. //
  490. this.dataSet1.DataSetName = "NewDataSet";
  491. this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {
  492. this.dataTable1});
  493. //
  494. // dataTable1
  495. //
  496. this.dataTable1.TableName = "Table1";
  497. //
  498. // splitContainer1
  499. //
  500. this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
  501. this.splitContainer1.IsSplitterFixed = true;
  502. this.splitContainer1.Location = new System.Drawing.Point(0, 0);
  503. this.splitContainer1.Margin = new System.Windows.Forms.Padding(0);
  504. this.splitContainer1.Name = "splitContainer1";
  505. this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
  506. //
  507. // splitContainer1.Panel1
  508. //
  509. this.splitContainer1.Panel1.Controls.Add(this.pictureBox1);
  510. this.splitContainer1.Panel1MinSize = 100;
  511. //
  512. // splitContainer1.Panel2
  513. //
  514. this.splitContainer1.Panel2.Controls.Add(this.tabControl1);
  515. this.splitContainer1.Size = new System.Drawing.Size(862, 513);
  516. this.splitContainer1.SplitterDistance = 116;
  517. this.splitContainer1.SplitterWidth = 1;
  518. this.splitContainer1.TabIndex = 3;
  519. //
  520. // FrmSeverMain
  521. //
  522. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  523. this.ClientSize = new System.Drawing.Size(862, 513);
  524. this.Controls.Add(this.splitContainer1);
  525. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  526. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  527. this.MaximizeBox = false;
  528. this.Name = "FrmSeverMain";
  529. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  530. this.Text = "应用服务";
  531. this.Load += new System.EventHandler(this.FrmSeverMain_Load);
  532. this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmSeverMain_Closing);
  533. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  534. this.tabControl1.ResumeLayout(false);
  535. this.tabPage1.ResumeLayout(false);
  536. this.tabPage2.ResumeLayout(false);
  537. ((System.ComponentModel.ISupportInitialize)(this.Chart1)).EndInit();
  538. this.tabPage3.ResumeLayout(false);
  539. ((System.ComponentModel.ISupportInitialize)(this.Chart2)).EndInit();
  540. this.tabPage4.ResumeLayout(false);
  541. ((System.ComponentModel.ISupportInitialize)(this.ugServers)).EndInit();
  542. ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
  543. ((System.ComponentModel.ISupportInitialize)(this.dataTable1)).EndInit();
  544. this.splitContainer1.Panel1.ResumeLayout(false);
  545. this.splitContainer1.Panel2.ResumeLayout(false);
  546. this.splitContainer1.ResumeLayout(false);
  547. this.ResumeLayout(false);
  548. }
  549. #endregion
  550. private void FrmSeverMain_Load(object sender, System.EventArgs e)
  551. {
  552. ugValueList = GetServerVL();
  553. //==>
  554. //if (System.DateTime.Today > new System.DateTime(2007,1,1)) return;
  555. ApplicationStart();
  556. this.pictureBox1.Image = System.Drawing.Image.FromFile(@"Image\登录框.jpg");
  557. cMain = new ClsServerMain();
  558. cMain.ShowLogEvent += new Core.Mes.ServerManager.ClsServerMain.ShowLogDelegate(cMain_ShowLog);
  559. cMain._isLogging = IsLogging;
  560. Application.DoEvents();
  561. this.Show();
  562. InitConfigure();
  563. cMain.InitServerMain(new object[] { _serverConf });
  564. resDaemon = new ResDaemon();
  565. resDaemon.StartDaemon();
  566. srvDaemon = new SrvDaemon(cMain.HtAssemblyService);
  567. srvDaemon.StartDaemon();
  568. InitChart();
  569. extSrvDaemon = new ExtSrvDaemon();
  570. ///////////////服务启动后,方可进行资源监控/////////////////
  571. this.tabControl1.Controls.Add(this.tabPage2);
  572. this.tabControl1.Controls.Add(this.tabPage3);
  573. this.tabControl1.Controls.Add(this.tabPage4);
  574. this.tabControl1.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl1_Selected);
  575. cMain_ShowLog("启动完成");
  576. }
  577. private void InitConfigure()
  578. {
  579. _serverConf = new ServerConfigure();
  580. _serverConf.ssc_event = new Core.Mes.ServerFrameWork.ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv);
  581. _serverConf.OnMasterServerChanged = new InvokeCallback(MasterChanged);
  582. }
  583. private void MasterChanged(string _mName)
  584. {
  585. if (ugServers.InvokeRequired)
  586. {
  587. InvokeCallback method = new InvokeCallback(MasterChanged);
  588. ugServers.Invoke(method, _mName);
  589. return;
  590. }
  591. if (string.IsNullOrEmpty(_mName))
  592. {
  593. ugServers.Text = "独立运行";
  594. }
  595. else
  596. {
  597. UriBuilder ub = new UriBuilder(_mName);
  598. ugServers.Text = string.Format("本机受控于服务器[{0}:{1}]", ub.Host, ub.Port);
  599. }
  600. }
  601. Thread t_ShowRes = null;
  602. Thread t_ShowSrv = null;
  603. Thread t_ShowExt = null;
  604. private void InitChart()
  605. {
  606. Chart1.ChartAreas[0].AxisY.Minimum = 0;
  607. Chart1.ChartAreas[0].AxisX.Minimum = 0;
  608. Chart2.ChartAreas[0].AxisY.Minimum = 0;
  609. Chart2.ChartAreas[0].AxisY2.Minimum = 0;
  610. Chart2.ChartAreas[0].AxisY2.Maximum = 100;
  611. StopShowResData();
  612. StopShowSrvData();
  613. }
  614. private void StartShowResData()
  615. {
  616. if (t_ShowRes == null ||
  617. t_ShowRes.ThreadState == System.Threading.ThreadState.Stopped ||
  618. t_ShowRes.ThreadState == System.Threading.ThreadState.Aborted)
  619. {
  620. t_ShowRes = new Thread(ShowResData);
  621. t_ShowRes.Name = "资源数据读取";
  622. t_ShowRes.Start();
  623. resDaemon.ResumeMe();
  624. }
  625. else
  626. {
  627. resDaemon.ResumeMe();
  628. }
  629. }
  630. private void StartShowSrvData()
  631. {
  632. if (t_ShowSrv == null ||
  633. t_ShowSrv.ThreadState == System.Threading.ThreadState.Stopped ||
  634. t_ShowSrv.ThreadState == System.Threading.ThreadState.Aborted)
  635. {
  636. t_ShowSrv = new Thread(ShowSrvData);
  637. t_ShowSrv.Name = "服务数据读取";
  638. t_ShowSrv.Start();
  639. srvDaemon.ResumeMe();
  640. }
  641. else
  642. {
  643. srvDaemon.ResumeMe();
  644. }
  645. }
  646. private void StartShowExtServer()
  647. {
  648. if (t_ShowExt == null ||
  649. t_ShowExt.ThreadState == System.Threading.ThreadState.Stopped ||
  650. t_ShowExt.ThreadState == System.Threading.ThreadState.Aborted)
  651. {
  652. t_ShowExt = new Thread(ShowExtServer);
  653. t_ShowExt.Name = "扩展服务器读取";
  654. t_ShowExt.Start();
  655. extSrvDaemon.ResumeMe();
  656. }
  657. else
  658. {
  659. extSrvDaemon.ResumeMe();
  660. }
  661. }
  662. private void StopShowResData()
  663. {
  664. if (t_ShowRes != null)
  665. {
  666. resDaemon.SuspendMe();
  667. }
  668. }
  669. private void StopShowSrvData()
  670. {
  671. if (t_ShowSrv != null)
  672. {
  673. srvDaemon.SuspendMe();
  674. }
  675. }
  676. private void StopShowExtServer()
  677. {
  678. if (t_ShowSrv != null)
  679. {
  680. extSrvDaemon.SuspendMe();
  681. }
  682. }
  683. private void ShowResData()
  684. {
  685. try
  686. {
  687. resDaemon.ShowResData(this.Chart2, new ResDaemon.ShowResDataEvent(CallBackShowResData));
  688. }
  689. catch (Exception ex)
  690. {
  691. MessageBox.Show(ex.Message, "资源显示线程错误");
  692. }
  693. }
  694. private void ShowSrvData()
  695. {
  696. try
  697. {
  698. srvDaemon.ShowSrvData(new SrvDaemon.ShowSrvDataEvent(CallBackShowSrvData));
  699. }
  700. catch (Exception ex)
  701. {
  702. MessageBox.Show(ex.Message, "服务显示线程错误");
  703. }
  704. }
  705. private void ShowExtServer()
  706. {
  707. try
  708. {
  709. extSrvDaemon.ShowExtServer(new ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv));
  710. }
  711. catch (Exception ex)
  712. {
  713. MessageBox.Show(ex.Message, "扩展服务器显示线程错误");
  714. }
  715. }
  716. private void CallBackShowResData(List<DataPoint> ps1, List<DataPoint> ps2)
  717. {
  718. if (Chart2.InvokeRequired)
  719. {
  720. ResDaemon.ShowResDataEvent srde = new ResDaemon.ShowResDataEvent(CallBackShowResData);
  721. this.Invoke(srde, new object[] { ps1, ps2 });
  722. return;
  723. }
  724. Series s1 = Chart2.Series[0];
  725. Series s2 = Chart2.Series[1];
  726. s1.Points.Invalidate();
  727. s2.Points.Invalidate();
  728. s1.Points.Clear();
  729. s2.Points.Clear();
  730. foreach (DataPoint dp in ps1)
  731. {
  732. s1.Points.Add(dp);
  733. }
  734. foreach (DataPoint dp in ps2)
  735. {
  736. s2.Points.Add(dp);
  737. }
  738. Chart2.ChartAreas[0].AxisX.Minimum = s1.Points[0].XValue;
  739. Chart2.ChartAreas[0].AxisX.Maximum = s1.Points[s1.Points.Count - 1].XValue;
  740. SystemInfo si = new SystemInfo();
  741. Chart2.Legends[0].CustomItems[0].Cells[0].Text = (si.MemoryAvailable / 1024 / 1024).ToString();
  742. s1.Points.ResumeUpdates();
  743. s2.Points.ResumeUpdates();
  744. }
  745. private void CallBackShowSrvData(List<DataPoint> ps1, List<DataPoint> ps2)
  746. {
  747. if (Chart1.InvokeRequired)
  748. {
  749. SrvDaemon.ShowSrvDataEvent ssde = new SrvDaemon.ShowSrvDataEvent(CallBackShowSrvData);
  750. this.Invoke(ssde, new object[] { ps1, ps2 });
  751. return;
  752. }
  753. Series s1 = Chart1.Series[0];
  754. Series s2 = Chart1.Series[1];
  755. s1.Points.Invalidate();
  756. s2.Points.Invalidate();
  757. s1.Points.Clear();
  758. s2.Points.Clear();
  759. foreach (DataPoint dp in ps1)
  760. {
  761. s1.Points.Add(dp);
  762. }
  763. foreach (DataPoint dp in ps2)
  764. {
  765. s2.Points.Add(dp);
  766. }
  767. s1.Points.ResumeUpdates();
  768. }
  769. private void CallBackShowExtSrv()
  770. {
  771. if (ugServers.InvokeRequired)
  772. {
  773. ExtSrvDaemon.ShowExtSrvEvent sese = new ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv);
  774. this.Invoke(sese);
  775. return;
  776. }
  777. ugServers.SuspendLayout();
  778. ugServers.SuspendRowSynchronization();
  779. Hashtable extServers = this.cMain.HtExternServer;
  780. DataTable dt = this.dataSet1.Tables[0];
  781. if (dt.Columns.Count == 0)
  782. {
  783. dt.Columns.Add("本地服务", typeof(string));
  784. }
  785. if (dt.Rows.Count == 0)
  786. {
  787. DataRow dr = dt.NewRow();
  788. dr[0] = "1";
  789. dt.Rows.Add(dr);
  790. }
  791. dt.AcceptChanges();
  792. //去除无效服务器
  793. foreach (DataColumn dc in dt.Columns)
  794. {
  795. if (dc.ColumnName == "本地服务") continue;
  796. bool keep_it = false;
  797. foreach (string ServerName in extServers.Keys)
  798. {
  799. UriBuilder ub = new UriBuilder(ServerName);
  800. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  801. if (sn == dc.ColumnName)
  802. {
  803. keep_it = true;
  804. }
  805. }
  806. if (!keep_it)
  807. {
  808. dt.Columns.Remove(dc);
  809. }
  810. }
  811. dt.AcceptChanges();
  812. //新增服务器
  813. foreach (string ServerName in extServers.Keys)
  814. {
  815. UriBuilder ub = new UriBuilder(ServerName);
  816. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  817. if (!dt.Columns.Contains(sn))
  818. {
  819. dt.Columns.Add(sn, typeof(string));
  820. }
  821. RemotingServer rs = (RemotingServer)(extServers[ServerName]);
  822. string status = (rs.Valid != RemoteServerStatus.Normal) ? ((int)(rs.Valid)).ToString() : (rs.Enable ? "1" : "3");
  823. dt.Rows[0][sn] = status;
  824. }
  825. //去除无效服务
  826. for (int idx = 1; idx < dt.Rows.Count; idx++)
  827. {
  828. DataRow dr = dt.Rows[idx];
  829. if (cMain.HTServiceKeys.ContainsKey(dr["本地服务"].ToString())) continue;
  830. dr.Delete();
  831. }
  832. dt.AcceptChanges();
  833. //新增服务项
  834. foreach (string serviceName in this.cMain.HTServiceKeys.Keys)
  835. {
  836. DataRow[] drs = dt.Select(string.Format("本地服务='{0}'", serviceName));
  837. DataRow dr = null;
  838. if (drs.GetLength(0) == 0)
  839. {
  840. dr = dt.NewRow();
  841. dr[0] = serviceName;
  842. dt.Rows.Add(dr);
  843. }
  844. else
  845. {
  846. dr = drs[0];
  847. }
  848. foreach (string serverName in extServers.Keys)
  849. {
  850. UriBuilder ub = new UriBuilder(serverName);
  851. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  852. RemotingServer rs = (RemotingServer)(extServers[serverName]);
  853. string server_status = dt.Rows[0][sn].ToString();
  854. if (server_status != "1")
  855. {
  856. dr[sn] = "1" + server_status;
  857. continue;
  858. }
  859. string status = "1";
  860. if (!rs.HTServices.ContainsKey(serviceName))
  861. {
  862. status = "25";
  863. }
  864. else
  865. {
  866. ServiceObject so = (ServiceObject)(rs.HTServices[serviceName]);
  867. switch (so.Valid)
  868. {
  869. case ServiceObjectStatus.Normal:
  870. status = (so.Enable ? "11" : "13");
  871. break;
  872. case ServiceObjectStatus.Unable:
  873. status = "12";
  874. break;
  875. case ServiceObjectStatus.UnMatch:
  876. status = "24";
  877. break;
  878. }
  879. }
  880. dr[sn] = status;
  881. }
  882. }
  883. dt.AcceptChanges();
  884. for (int idx = 0; idx < ugServers.DisplayLayout.Bands[0].Columns.Count; idx++)
  885. {
  886. ugServers.DisplayLayout.Bands[0].Columns[idx].ValueList = ugValueList;
  887. }
  888. ugServers.ResumeRowSynchronization();
  889. ugServers.ResumeLayout();
  890. }
  891. private static ValueList ugValueList = null;
  892. private ValueList GetServerVL()
  893. {
  894. ValueList vl = new ValueList();
  895. vl.ValueListItems.Add("1", "[正常运行]");
  896. vl.ValueListItems.Add("2", "[不可用]");
  897. vl.ValueListItems.Add("3", "[暂停服务]");
  898. vl.ValueListItems.Add("4", "[受控于其他主机]");
  899. vl.ValueListItems.Add("11", "功能正常");
  900. vl.ValueListItems.Add("12", "不可用");
  901. vl.ValueListItems.Add("13", "暂停服务");
  902. vl.ValueListItems.Add("14", "受控其他主机");
  903. vl.ValueListItems.Add("24", "版本不一致");
  904. vl.ValueListItems.Add("25", "缺少服务");
  905. return vl;
  906. }
  907. private void cMain_ShowLog(string log)
  908. {
  909. lock (this.listBox1)
  910. {
  911. this.listBox1.Invalidate();
  912. this.listBox1.Items.Add(log);
  913. this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1;
  914. Application.DoEvents();
  915. this.listBox1.Update();
  916. }
  917. }
  918. private void FrmSeverMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  919. {
  920. if (MessageBox.Show("是否确认退出服务端程序?", "提示", MessageBoxButtons.YesNo,
  921. MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
  922. {
  923. e.Cancel = true;
  924. }
  925. else
  926. {
  927. ApplicationExit();
  928. Application.Exit();
  929. System.Diagnostics.Process.GetCurrentProcess().Kill();
  930. }
  931. }
  932. private static void ApplicationExit()
  933. {
  934. string path = string.Format(@"{0}/log/Application/{1}.txt", Application.StartupPath, System.DateTime.Now.ToString("yyyy_MM_dd"));
  935. using (StreamWriter sw = new StreamWriter(path, true, Encoding.UTF8))
  936. {
  937. StringBuilder sbtxt = new StringBuilder();
  938. sbtxt.AppendLine("==============================================");
  939. sbtxt.AppendLine(string.Format("服务关闭时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm::ss")));
  940. sbtxt.AppendLine("==============================================");
  941. sw.WriteLine(sbtxt.ToString());
  942. }
  943. }
  944. private static void ApplicationStart()
  945. {
  946. string path = string.Format(@"{0}/log/Application/{1}.txt", Application.StartupPath, System.DateTime.Now.ToString("yyyy_MM_dd"));
  947. using (StreamWriter sw = new StreamWriter(path, true, Encoding.UTF8))
  948. {
  949. StringBuilder sbtxt = new StringBuilder();
  950. sbtxt.AppendLine("==============================================");
  951. sbtxt.AppendLine(string.Format("服务开启时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm::ss")));
  952. sbtxt.AppendLine("==============================================");
  953. sw.WriteLine(sbtxt.ToString());
  954. }
  955. }
  956. private void tabControl1_Selected(object sender, TabControlEventArgs e)
  957. {
  958. if (e.TabPageIndex == 1)
  959. {
  960. StartShowSrvData();
  961. }
  962. else
  963. {
  964. StopShowSrvData();
  965. }
  966. if (e.TabPageIndex == 2)
  967. {
  968. StartShowResData();
  969. }
  970. else
  971. {
  972. StopShowResData();
  973. }
  974. if (e.TabPageIndex == 3)
  975. {
  976. StartShowExtServer();
  977. }
  978. else
  979. {
  980. StopShowExtServer();
  981. }
  982. }
  983. private void ugServers_AfterCellUpdate(object sender, CellEventArgs e)
  984. {
  985. UltraGridColumn uc = e.Cell.Column;
  986. try
  987. {
  988. if (uc.Index > 0 || e.Cell.Row.Index == 0)
  989. {
  990. e.Cell.Appearance = ugServers.DisplayLayout.Appearances[e.Cell.Row.GetCellValue(uc).ToString()];
  991. }
  992. }
  993. catch { }
  994. }
  995. private void ugServers_InitializeRow(object sender, InitializeRowEventArgs e)
  996. {
  997. for (int idx = 0; idx < e.Row.Band.Columns.Count; idx++)
  998. {
  999. UltraGridColumn uc = e.Row.Band.Columns[idx];
  1000. try
  1001. {
  1002. if (uc.Index > 0 || e.Row.Index == 0)
  1003. {
  1004. e.Row.Cells[idx].Appearance = ugServers.DisplayLayout.Appearances[e.Row.GetCellValue(uc).ToString()];
  1005. string cell_value = e.Row.GetCellValue(uc).ToString();
  1006. if (cell_value == "1" || cell_value == "3" || cell_value == "11" || cell_value == "13")
  1007. {
  1008. e.Row.Cells[idx].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
  1009. }
  1010. else
  1011. {
  1012. e.Row.Cells[idx].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Default;
  1013. }
  1014. }
  1015. }
  1016. catch { }
  1017. }
  1018. }
  1019. private void ugServers_ClickCellButton(object sender, CellEventArgs e)
  1020. {
  1021. ugServers.SuspendRowSynchronization();
  1022. UltraGridColumn uc = e.Cell.Column;
  1023. string cell_value = e.Cell.Row.GetCellValue(uc).ToString();
  1024. string ServerName = uc.Header.Caption;
  1025. string ServiceName = e.Cell.Row.GetCellValue(e.Cell.Row.Band.Columns[0]).ToString();
  1026. if (cell_value == "1")
  1027. {
  1028. cMain.SetServerFlag(ServerName, false);
  1029. }
  1030. else if (cell_value == "3")
  1031. {
  1032. cMain.SetServerFlag(ServerName, true);
  1033. }
  1034. else if (cell_value == "11")
  1035. {
  1036. cMain.SetServiceFlag(ServerName, ServiceName, false);
  1037. }
  1038. else if (cell_value == "13")
  1039. {
  1040. cMain.SetServiceFlag(ServerName, ServiceName, true);
  1041. }
  1042. ugServers.ResumeRowSynchronization();
  1043. ugServers.Update();
  1044. }
  1045. private void ugServers_DoubleClickHeader(object sender, DoubleClickHeaderEventArgs e)
  1046. {
  1047. UriBuilder ub = new UriBuilder(e.Header.Caption);
  1048. if (MessageBox.Show(string.Format("是否同步文件到服务器[{0}:{1}]?", ub.Host, ub.Port), "同步文件", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  1049. == DialogResult.Yes)
  1050. {
  1051. try
  1052. {
  1053. foreach (string ServerName in cMain.HtExternServer.Keys)
  1054. {
  1055. UriBuilder ube = new UriBuilder(ServerName);
  1056. if (ub.Host == ube.Host && ub.Port == ube.Port)
  1057. {
  1058. RemotingServer rs = (RemotingServer)(cMain.HtExternServer[ServerName]);
  1059. rs.SyncFiles();
  1060. }
  1061. }
  1062. }
  1063. catch (Exception ex)
  1064. {
  1065. MessageBox.Show(ex.Message);
  1066. }
  1067. }
  1068. }
  1069. }
  1070. }