816baaee4faca88c134c7e090fcb18cdafab4c07.svn-base 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  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. this.tabControl1.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl1_Selected);
  200. //
  201. // tabPage1
  202. //
  203. this.tabPage1.Controls.Add(this.listBox1);
  204. this.tabPage1.Location = new System.Drawing.Point(4, 22);
  205. this.tabPage1.Name = "tabPage1";
  206. this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
  207. this.tabPage1.Size = new System.Drawing.Size(854, 370);
  208. this.tabPage1.TabIndex = 0;
  209. this.tabPage1.Text = "消息列表";
  210. this.tabPage1.UseVisualStyleBackColor = true;
  211. //
  212. // tabPage2
  213. //
  214. this.tabPage2.AutoScroll = true;
  215. this.tabPage2.Controls.Add(this.Chart1);
  216. this.tabPage2.Location = new System.Drawing.Point(4, 22);
  217. this.tabPage2.Name = "tabPage2";
  218. this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
  219. this.tabPage2.Size = new System.Drawing.Size(854, 370);
  220. this.tabPage2.TabIndex = 1;
  221. this.tabPage2.Text = "服务使用";
  222. this.tabPage2.UseVisualStyleBackColor = true;
  223. //
  224. // Chart1
  225. //
  226. chartArea1.AxisX.InterlacedColor = System.Drawing.Color.WhiteSmoke;
  227. chartArea1.AxisX.IsInterlaced = true;
  228. chartArea1.AxisX.IsLabelAutoFit = false;
  229. chartArea1.AxisX.IsMarksNextToAxis = false;
  230. chartArea1.AxisX.LineColor = System.Drawing.Color.Fuchsia;
  231. chartArea1.AxisX.LineWidth = 2;
  232. chartArea1.AxisX.MajorGrid.Enabled = false;
  233. chartArea1.AxisX.MajorGrid.Interval = 0;
  234. chartArea1.AxisX.MajorTickMark.Enabled = false;
  235. chartArea1.AxisX.MajorTickMark.Interval = 1;
  236. chartArea1.AxisX.MajorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.None;
  237. chartArea1.AxisX.ScaleBreakStyle.Spacing = 1;
  238. chartArea1.AxisX.ScaleView.MinSizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
  239. chartArea1.AxisX.ScaleView.SizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
  240. chartArea1.AxisX.ScaleView.Zoomable = false;
  241. chartArea1.AxisX.TitleAlignment = System.Drawing.StringAlignment.Near;
  242. chartArea1.AxisY.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True;
  243. chartArea1.AxisY.InterlacedColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
  244. chartArea1.AxisY.IsLabelAutoFit = false;
  245. chartArea1.AxisY.IsMarksNextToAxis = false;
  246. chartArea1.AxisY.LineColor = System.Drawing.Color.Blue;
  247. chartArea1.AxisY.LineWidth = 2;
  248. chartArea1.AxisY.MajorGrid.Enabled = false;
  249. chartArea1.AxisY.MajorGrid.IntervalOffset = 0;
  250. chartArea1.AxisY.MajorGrid.LineColor = System.Drawing.Color.Blue;
  251. chartArea1.AxisY.MajorTickMark.LineColor = System.Drawing.Color.Blue;
  252. chartArea1.AxisY.MajorTickMark.LineWidth = 2;
  253. chartArea1.AxisY.MajorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.InsideArea;
  254. chartArea1.AxisY.Minimum = 0;
  255. chartArea1.AxisY2.IsMarksNextToAxis = false;
  256. chartArea1.AxisY2.LabelAutoFitStyle = ((System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles)((((System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles.IncreaseFont | System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont)
  257. | System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles.StaggeredLabels)
  258. | System.Windows.Forms.DataVisualization.Charting.LabelAutoFitStyles.LabelsAngleStep30)));
  259. chartArea1.AxisY2.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
  260. chartArea1.AxisY2.LineWidth = 2;
  261. chartArea1.AxisY2.MajorGrid.Enabled = false;
  262. chartArea1.AxisY2.MajorTickMark.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
  263. chartArea1.AxisY2.MajorTickMark.LineWidth = 2;
  264. chartArea1.AxisY2.MajorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.InsideArea;
  265. chartArea1.AxisY2.Minimum = 0;
  266. chartArea1.AxisY2.MinorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.None;
  267. chartArea1.AxisY2.TitleAlignment = System.Drawing.StringAlignment.Near;
  268. chartArea1.InnerPlotPosition.Auto = false;
  269. chartArea1.InnerPlotPosition.Height = 76.16758F;
  270. chartArea1.InnerPlotPosition.Width = 91.96336F;
  271. chartArea1.InnerPlotPosition.X = 6.68718F;
  272. chartArea1.InnerPlotPosition.Y = 5.76923F;
  273. chartArea1.Name = "ChartArea1";
  274. this.Chart1.ChartAreas.Add(chartArea1);
  275. this.Chart1.Dock = System.Windows.Forms.DockStyle.Fill;
  276. legend1.Name = "Legend1";
  277. this.Chart1.Legends.Add(legend1);
  278. this.Chart1.Location = new System.Drawing.Point(3, 3);
  279. this.Chart1.Margin = new System.Windows.Forms.Padding(0);
  280. this.Chart1.Name = "Chart1";
  281. series1.ChartArea = "ChartArea1";
  282. series1.Legend = "Legend1";
  283. series1.LegendText = "服务已使用数";
  284. series1.Name = "Series1";
  285. series2.BackImageWrapMode = System.Windows.Forms.DataVisualization.Charting.ChartImageWrapMode.TileFlipX;
  286. series2.BackSecondaryColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
  287. series2.BorderColor = System.Drawing.Color.Red;
  288. series2.BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
  289. series2.BorderWidth = 0;
  290. series2.ChartArea = "ChartArea1";
  291. series2.Color = System.Drawing.Color.DarkOrange;
  292. series2.EmptyPointStyle.Color = System.Drawing.Color.Red;
  293. series2.Legend = "Legend1";
  294. series2.LegendText = "服务实例上限";
  295. series2.Name = "Series2";
  296. series2.YAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
  297. this.Chart1.Series.Add(series1);
  298. this.Chart1.Series.Add(series2);
  299. this.Chart1.Size = new System.Drawing.Size(848, 364);
  300. this.Chart1.TabIndex = 0;
  301. //
  302. // tabPage3
  303. //
  304. this.tabPage3.Controls.Add(this.Chart2);
  305. this.tabPage3.Location = new System.Drawing.Point(4, 22);
  306. this.tabPage3.Name = "tabPage3";
  307. this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
  308. this.tabPage3.Size = new System.Drawing.Size(854, 370);
  309. this.tabPage3.TabIndex = 2;
  310. this.tabPage3.Text = "资源使用";
  311. this.tabPage3.UseVisualStyleBackColor = true;
  312. //
  313. // Chart2
  314. //
  315. chartArea2.AxisX.IsMarginVisible = false;
  316. chartArea2.AxisX.IsStartedFromZero = false;
  317. chartArea2.AxisX.LineColor = System.Drawing.Color.Empty;
  318. chartArea2.AxisX.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
  319. chartArea2.AxisX.LineWidth = 0;
  320. chartArea2.AxisX.MajorGrid.Enabled = false;
  321. chartArea2.AxisX.MajorGrid.Interval = 0;
  322. chartArea2.AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  323. chartArea2.AxisX.ScaleBreakStyle.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
  324. chartArea2.AxisY.LineColor = System.Drawing.Color.Red;
  325. chartArea2.AxisY.MajorGrid.Enabled = false;
  326. chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.DarkOrange;
  327. chartArea2.AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  328. chartArea2.AxisY.MajorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.InsideArea;
  329. chartArea2.AxisY2.LineColor = System.Drawing.Color.DodgerBlue;
  330. chartArea2.AxisY2.MajorGrid.LineColor = System.Drawing.Color.DodgerBlue;
  331. chartArea2.AxisY2.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  332. chartArea2.AxisY2.MajorTickMark.TickMarkStyle = System.Windows.Forms.DataVisualization.Charting.TickMarkStyle.InsideArea;
  333. chartArea2.BorderWidth = 2;
  334. chartArea2.Name = "ChartArea1";
  335. this.Chart2.ChartAreas.Add(chartArea2);
  336. this.Chart2.Dock = System.Windows.Forms.DockStyle.Fill;
  337. legend2.BorderWidth = 0;
  338. legendCell1.ForeColor = System.Drawing.Color.OrangeRed;
  339. legendCell1.Name = "cell_Content";
  340. legendCell1.Text = "0";
  341. legendCell2.Name = "Cell_Label";
  342. legendCell2.Text = "空闲内存(MB)";
  343. legendItem1.Cells.Add(legendCell1);
  344. legendItem1.Cells.Add(legendCell2);
  345. legend2.CustomItems.Add(legendItem1);
  346. legend2.LegendItemOrder = System.Windows.Forms.DataVisualization.Charting.LegendItemOrder.SameAsSeriesOrder;
  347. legend2.LegendStyle = System.Windows.Forms.DataVisualization.Charting.LegendStyle.Column;
  348. legend2.Name = "Legend1";
  349. legend2.TableStyle = System.Windows.Forms.DataVisualization.Charting.LegendTableStyle.Tall;
  350. this.Chart2.Legends.Add(legend2);
  351. this.Chart2.Location = new System.Drawing.Point(3, 3);
  352. this.Chart2.Margin = new System.Windows.Forms.Padding(0);
  353. this.Chart2.Name = "Chart2";
  354. series3.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
  355. series3.BorderWidth = 2;
  356. series3.ChartArea = "ChartArea1";
  357. series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
  358. series3.Color = System.Drawing.Color.OrangeRed;
  359. series3.CustomProperties = "LineTension=0.8, LabelStyle=Bottom";
  360. series3.LabelBorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
  361. series3.LabelBorderWidth = 2;
  362. series3.LabelForeColor = System.Drawing.Color.Red;
  363. series3.Legend = "Legend1";
  364. series3.LegendText = "内存(MB)";
  365. series3.MarkerBorderColor = System.Drawing.Color.Red;
  366. series3.MarkerBorderWidth = 2;
  367. series3.Name = "Series1";
  368. series3.ShadowColor = System.Drawing.Color.Transparent;
  369. series3.SmartLabelStyle.AllowOutsidePlotArea = System.Windows.Forms.DataVisualization.Charting.LabelOutsidePlotAreaStyle.No;
  370. series3.SmartLabelStyle.CalloutLineAnchorCapStyle = System.Windows.Forms.DataVisualization.Charting.LineAnchorCapStyle.None;
  371. series3.SmartLabelStyle.CalloutStyle = System.Windows.Forms.DataVisualization.Charting.LabelCalloutStyle.None;
  372. series3.SmartLabelStyle.IsMarkerOverlappingAllowed = true;
  373. series3.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
  374. series3.YValuesPerPoint = 2;
  375. series3.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
  376. series4.BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
  377. series4.BorderWidth = 2;
  378. series4.ChartArea = "ChartArea1";
  379. series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
  380. series4.Color = System.Drawing.Color.DodgerBlue;
  381. series4.CustomProperties = "LineTension=0.8, LabelStyle=Top";
  382. series4.Legend = "Legend1";
  383. series4.LegendText = "CPU (%)";
  384. series4.MarkerBorderWidth = 2;
  385. series4.Name = "Series2";
  386. series4.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Time;
  387. series4.YAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
  388. series4.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
  389. this.Chart2.Series.Add(series3);
  390. this.Chart2.Series.Add(series4);
  391. this.Chart2.Size = new System.Drawing.Size(848, 364);
  392. this.Chart2.TabIndex = 0;
  393. //
  394. // tabPage4
  395. //
  396. this.tabPage4.Controls.Add(this.ugServers);
  397. this.tabPage4.Location = new System.Drawing.Point(4, 22);
  398. this.tabPage4.Name = "tabPage4";
  399. this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
  400. this.tabPage4.Size = new System.Drawing.Size(854, 370);
  401. this.tabPage4.TabIndex = 3;
  402. this.tabPage4.Text = "扩展服务器";
  403. this.tabPage4.UseVisualStyleBackColor = true;
  404. //
  405. // ugServers
  406. //
  407. this.ugServers.DataMember = "Table1";
  408. this.ugServers.DataSource = this.dataSet1;
  409. appearance1.BackColor = System.Drawing.Color.PaleGreen;
  410. appearance1.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
  411. appearance1.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  412. appearance1.TextHAlign = Infragistics.Win.HAlign.Center;
  413. appearance2.BackColor = System.Drawing.Color.Silver;
  414. appearance2.BackColor2 = System.Drawing.Color.Gray;
  415. appearance2.BackHatchStyle = Infragistics.Win.BackHatchStyle.BackwardDiagonal;
  416. appearance2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
  417. appearance2.TextHAlign = Infragistics.Win.HAlign.Center;
  418. appearance3.BackColor = System.Drawing.Color.Silver;
  419. appearance3.BackColor2 = System.Drawing.Color.Gray;
  420. appearance3.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  421. appearance3.TextHAlign = Infragistics.Win.HAlign.Center;
  422. appearance4.BackColor = System.Drawing.Color.PaleGreen;
  423. appearance4.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
  424. appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  425. appearance4.TextHAlign = Infragistics.Win.HAlign.Center;
  426. appearance5.BackColor = System.Drawing.Color.Silver;
  427. appearance5.BackColor2 = System.Drawing.Color.Gray;
  428. appearance5.BackHatchStyle = Infragistics.Win.BackHatchStyle.BackwardDiagonal;
  429. appearance5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
  430. appearance5.TextHAlign = Infragistics.Win.HAlign.Center;
  431. appearance6.BackColor = System.Drawing.Color.Silver;
  432. appearance6.BackColor2 = System.Drawing.Color.Gray;
  433. appearance6.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  434. appearance6.TextHAlign = Infragistics.Win.HAlign.Center;
  435. appearance7.BackColor = System.Drawing.Color.Brown;
  436. appearance7.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
  437. appearance7.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  438. appearance7.ForeColor = System.Drawing.Color.Lime;
  439. appearance7.TextHAlign = Infragistics.Win.HAlign.Center;
  440. appearance8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(108)))), ((int)(((byte)(108)))), ((int)(((byte)(108)))));
  441. appearance8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
  442. appearance8.TextHAlign = Infragistics.Win.HAlign.Center;
  443. appearance9.BackColor = System.Drawing.Color.LemonChiffon;
  444. appearance9.BackColor2 = System.Drawing.Color.Gold;
  445. appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  446. appearance9.ForeColor = System.Drawing.Color.Blue;
  447. appearance9.TextHAlign = Infragistics.Win.HAlign.Center;
  448. appearance10.BackColor = System.Drawing.Color.LemonChiffon;
  449. appearance10.BackColor2 = System.Drawing.Color.Gold;
  450. appearance10.BackGradientStyle = Infragistics.Win.GradientStyle.VerticalBump;
  451. appearance10.ForeColor = System.Drawing.Color.Blue;
  452. appearance10.TextHAlign = Infragistics.Win.HAlign.Center;
  453. this.ugServers.DisplayLayout.Appearances.Add(appearance1);
  454. this.ugServers.DisplayLayout.Appearances.Add(appearance2);
  455. this.ugServers.DisplayLayout.Appearances.Add(appearance3);
  456. this.ugServers.DisplayLayout.Appearances.Add(appearance4);
  457. this.ugServers.DisplayLayout.Appearances.Add(appearance5);
  458. this.ugServers.DisplayLayout.Appearances.Add(appearance6);
  459. this.ugServers.DisplayLayout.Appearances.Add(appearance7);
  460. this.ugServers.DisplayLayout.Appearances.Add(appearance8);
  461. this.ugServers.DisplayLayout.Appearances.Add(appearance9);
  462. this.ugServers.DisplayLayout.Appearances.Add(appearance10);
  463. this.ugServers.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
  464. this.ugServers.DisplayLayout.BorderStyleCaption = Infragistics.Win.UIElementBorderStyle.None;
  465. appearance11.BackColor = System.Drawing.SystemColors.ActiveBorder;
  466. appearance11.BackColor2 = System.Drawing.SystemColors.ControlDark;
  467. appearance11.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
  468. appearance11.BorderColor = System.Drawing.SystemColors.Window;
  469. this.ugServers.DisplayLayout.GroupByBox.Appearance = appearance11;
  470. appearance12.ForeColor = System.Drawing.SystemColors.GrayText;
  471. this.ugServers.DisplayLayout.GroupByBox.BandLabelAppearance = appearance12;
  472. this.ugServers.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
  473. appearance13.BackColor = System.Drawing.SystemColors.ControlLightLight;
  474. appearance13.BackColor2 = System.Drawing.SystemColors.Control;
  475. appearance13.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
  476. appearance13.ForeColor = System.Drawing.SystemColors.GrayText;
  477. this.ugServers.DisplayLayout.GroupByBox.PromptAppearance = appearance13;
  478. this.ugServers.DisplayLayout.MaxColScrollRegions = 1;
  479. this.ugServers.DisplayLayout.MaxRowScrollRegions = 1;
  480. appearance14.BackColor = System.Drawing.SystemColors.Window;
  481. appearance14.ForeColor = System.Drawing.SystemColors.ControlText;
  482. this.ugServers.DisplayLayout.Override.ActiveCellAppearance = appearance14;
  483. appearance15.BackColor = System.Drawing.SystemColors.Highlight;
  484. appearance15.ForeColor = System.Drawing.SystemColors.HighlightText;
  485. this.ugServers.DisplayLayout.Override.ActiveRowAppearance = appearance15;
  486. this.ugServers.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
  487. this.ugServers.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
  488. this.ugServers.DisplayLayout.Override.AllowGroupBy = Infragistics.Win.DefaultableBoolean.False;
  489. this.ugServers.DisplayLayout.Override.AllowGroupMoving = Infragistics.Win.UltraWinGrid.AllowGroupMoving.NotAllowed;
  490. this.ugServers.DisplayLayout.Override.AllowGroupSwapping = Infragistics.Win.UltraWinGrid.AllowGroupSwapping.NotAllowed;
  491. this.ugServers.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;
  492. this.ugServers.DisplayLayout.Override.AllowRowLayoutCellSpanSizing = Infragistics.Win.Layout.GridBagLayoutAllowSpanSizing.None;
  493. this.ugServers.DisplayLayout.Override.AllowRowLayoutLabelSpanSizing = Infragistics.Win.Layout.GridBagLayoutAllowSpanSizing.None;
  494. this.ugServers.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
  495. appearance16.BackColor = System.Drawing.SystemColors.Window;
  496. this.ugServers.DisplayLayout.Override.CardAreaAppearance = appearance16;
  497. appearance17.BorderColor = System.Drawing.Color.Silver;
  498. appearance17.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
  499. this.ugServers.DisplayLayout.Override.CellAppearance = appearance17;
  500. this.ugServers.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.CellSelect;
  501. this.ugServers.DisplayLayout.Override.CellMultiLine = Infragistics.Win.DefaultableBoolean.False;
  502. this.ugServers.DisplayLayout.Override.CellPadding = 0;
  503. this.ugServers.DisplayLayout.Override.ExpansionIndicator = Infragistics.Win.UltraWinGrid.ShowExpansionIndicator.Never;
  504. this.ugServers.DisplayLayout.Override.FixedRowIndicator = Infragistics.Win.UltraWinGrid.FixedRowIndicator.None;
  505. appearance18.BackColor = System.Drawing.SystemColors.Control;
  506. appearance18.BackColor2 = System.Drawing.SystemColors.ControlDark;
  507. appearance18.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
  508. appearance18.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
  509. appearance18.BorderColor = System.Drawing.SystemColors.Window;
  510. this.ugServers.DisplayLayout.Override.GroupByRowAppearance = appearance18;
  511. appearance19.TextHAlign = Infragistics.Win.HAlign.Left;
  512. this.ugServers.DisplayLayout.Override.HeaderAppearance = appearance19;
  513. this.ugServers.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
  514. appearance20.BackColor = System.Drawing.SystemColors.Window;
  515. appearance20.BorderColor = System.Drawing.Color.Silver;
  516. this.ugServers.DisplayLayout.Override.RowAppearance = appearance20;
  517. this.ugServers.DisplayLayout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.RowIndex;
  518. this.ugServers.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
  519. this.ugServers.DisplayLayout.Override.RowSelectorStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
  520. this.ugServers.DisplayLayout.Override.ShowInkButton = Infragistics.Win.ShowInkButton.Never;
  521. appearance21.BackColor = System.Drawing.SystemColors.ControlLight;
  522. this.ugServers.DisplayLayout.Override.TemplateAddRowAppearance = appearance21;
  523. this.ugServers.DisplayLayout.PriorityScrolling = true;
  524. this.ugServers.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
  525. this.ugServers.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
  526. this.ugServers.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.SingleBand;
  527. this.ugServers.Dock = System.Windows.Forms.DockStyle.Fill;
  528. this.ugServers.FlatMode = true;
  529. this.ugServers.Location = new System.Drawing.Point(3, 3);
  530. this.ugServers.Margin = new System.Windows.Forms.Padding(0);
  531. this.ugServers.Name = "ugServers";
  532. this.ugServers.Size = new System.Drawing.Size(848, 364);
  533. this.ugServers.TabIndex = 0;
  534. this.ugServers.Text = "独立运行";
  535. this.ugServers.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ugServers_ClickCellButton);
  536. this.ugServers.DoubleClickHeader += new Infragistics.Win.UltraWinGrid.DoubleClickHeaderEventHandler(this.ugServers_DoubleClickHeader);
  537. this.ugServers.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ugServers_AfterCellUpdate);
  538. this.ugServers.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.ugServers_InitializeRow);
  539. //
  540. // dataSet1
  541. //
  542. this.dataSet1.DataSetName = "NewDataSet";
  543. this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {
  544. this.dataTable1});
  545. //
  546. // dataTable1
  547. //
  548. this.dataTable1.TableName = "Table1";
  549. //
  550. // splitContainer1
  551. //
  552. this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
  553. this.splitContainer1.IsSplitterFixed = true;
  554. this.splitContainer1.Location = new System.Drawing.Point(0, 0);
  555. this.splitContainer1.Margin = new System.Windows.Forms.Padding(0);
  556. this.splitContainer1.Name = "splitContainer1";
  557. this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
  558. //
  559. // splitContainer1.Panel1
  560. //
  561. this.splitContainer1.Panel1.Controls.Add(this.pictureBox1);
  562. this.splitContainer1.Panel1MinSize = 100;
  563. //
  564. // splitContainer1.Panel2
  565. //
  566. this.splitContainer1.Panel2.Controls.Add(this.tabControl1);
  567. this.splitContainer1.Size = new System.Drawing.Size(862, 513);
  568. this.splitContainer1.SplitterDistance = 116;
  569. this.splitContainer1.SplitterWidth = 1;
  570. this.splitContainer1.TabIndex = 3;
  571. //
  572. // FrmSeverMain
  573. //
  574. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  575. this.ClientSize = new System.Drawing.Size(862, 513);
  576. this.Controls.Add(this.splitContainer1);
  577. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  578. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  579. this.MaximizeBox = false;
  580. this.Name = "FrmSeverMain";
  581. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  582. this.Text = "应用服务";
  583. this.Load += new System.EventHandler(this.FrmSeverMain_Load);
  584. this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmSeverMain_Closing);
  585. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  586. this.tabControl1.ResumeLayout(false);
  587. this.tabPage1.ResumeLayout(false);
  588. this.tabPage2.ResumeLayout(false);
  589. ((System.ComponentModel.ISupportInitialize)(this.Chart1)).EndInit();
  590. this.tabPage3.ResumeLayout(false);
  591. ((System.ComponentModel.ISupportInitialize)(this.Chart2)).EndInit();
  592. this.tabPage4.ResumeLayout(false);
  593. ((System.ComponentModel.ISupportInitialize)(this.ugServers)).EndInit();
  594. ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
  595. ((System.ComponentModel.ISupportInitialize)(this.dataTable1)).EndInit();
  596. this.splitContainer1.Panel1.ResumeLayout(false);
  597. this.splitContainer1.Panel2.ResumeLayout(false);
  598. this.splitContainer1.ResumeLayout(false);
  599. this.ResumeLayout(false);
  600. }
  601. #endregion
  602. private void FrmSeverMain_Load(object sender, System.EventArgs e)
  603. {
  604. ugValueList = GetServerVL();
  605. //==>
  606. //if (System.DateTime.Today > new System.DateTime(2007,1,1)) return;
  607. ApplicationStart();
  608. this.pictureBox1.Image = System.Drawing.Image.FromFile(@"Image\登录框.jpg");
  609. cMain = new ClsServerMain();
  610. cMain.ShowLogEvent += new Core.Mes.ServerManager.ClsServerMain.ShowLogDelegate(cMain_ShowLog);
  611. cMain._isLogging = IsLogging;
  612. Application.DoEvents();
  613. this.Show();
  614. InitConfigure();
  615. cMain.InitServerMain(new object[] { _serverConf });
  616. resDaemon = new ResDaemon();
  617. resDaemon.StartDaemon();
  618. srvDaemon = new SrvDaemon(cMain.HtAssemblyService);
  619. srvDaemon.StartDaemon();
  620. InitChart();
  621. extSrvDaemon = new ExtSrvDaemon();
  622. ///////////////服务启动后,方可进行资源监控/////////////////
  623. this.tabControl1.Controls.Add(this.tabPage2);
  624. this.tabControl1.Controls.Add(this.tabPage3);
  625. this.tabControl1.Controls.Add(this.tabPage4);
  626. this.tabControl1.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl1_Selected);
  627. cMain_ShowLog("启动完成");
  628. }
  629. private void InitConfigure()
  630. {
  631. _serverConf = new ServerConfigure();
  632. _serverConf.ssc_event = new Core.Mes.ServerFrameWork.ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv);
  633. _serverConf.OnMasterServerChanged = new InvokeCallback(MasterChanged);
  634. }
  635. private void MasterChanged(string _mName)
  636. {
  637. if (ugServers.InvokeRequired)
  638. {
  639. InvokeCallback method = new InvokeCallback(MasterChanged);
  640. ugServers.Invoke(method, _mName);
  641. return;
  642. }
  643. if (string.IsNullOrEmpty(_mName))
  644. {
  645. ugServers.Text = "独立运行";
  646. }
  647. else
  648. {
  649. UriBuilder ub = new UriBuilder(_mName);
  650. ugServers.Text = string.Format("本机受控于服务器[{0}:{1}]", ub.Host, ub.Port);
  651. }
  652. }
  653. Thread t_ShowRes = null;
  654. Thread t_ShowSrv = null;
  655. Thread t_ShowExt = null;
  656. private void InitChart()
  657. {
  658. Chart1.ChartAreas[0].AxisY.Minimum = 0;
  659. Chart1.ChartAreas[0].AxisX.Minimum = 0;
  660. Chart2.ChartAreas[0].AxisY.Minimum = 0;
  661. Chart2.ChartAreas[0].AxisY2.Minimum = 0;
  662. Chart2.ChartAreas[0].AxisY2.Maximum = 100;
  663. StopShowResData();
  664. StopShowSrvData();
  665. }
  666. private void StartShowResData()
  667. {
  668. if (t_ShowRes == null ||
  669. t_ShowRes.ThreadState == System.Threading.ThreadState.Stopped ||
  670. t_ShowRes.ThreadState == System.Threading.ThreadState.Aborted)
  671. {
  672. t_ShowRes = new Thread(ShowResData);
  673. t_ShowRes.Name = "资源数据读取";
  674. t_ShowRes.Start();
  675. resDaemon.ResumeMe();
  676. }
  677. else
  678. {
  679. resDaemon.ResumeMe();
  680. }
  681. }
  682. private void StartShowSrvData()
  683. {
  684. if (t_ShowSrv == null ||
  685. t_ShowSrv.ThreadState == System.Threading.ThreadState.Stopped ||
  686. t_ShowSrv.ThreadState == System.Threading.ThreadState.Aborted)
  687. {
  688. t_ShowSrv = new Thread(ShowSrvData);
  689. t_ShowSrv.Name = "服务数据读取";
  690. t_ShowSrv.Start();
  691. srvDaemon.ResumeMe();
  692. }
  693. else
  694. {
  695. srvDaemon.ResumeMe();
  696. }
  697. }
  698. private void StartShowExtServer()
  699. {
  700. if (t_ShowExt == null ||
  701. t_ShowExt.ThreadState == System.Threading.ThreadState.Stopped ||
  702. t_ShowExt.ThreadState == System.Threading.ThreadState.Aborted)
  703. {
  704. t_ShowExt = new Thread(ShowExtServer);
  705. t_ShowExt.Name = "扩展服务器读取";
  706. t_ShowExt.Start();
  707. extSrvDaemon.ResumeMe();
  708. }
  709. else
  710. {
  711. extSrvDaemon.ResumeMe();
  712. }
  713. }
  714. private void StopShowResData()
  715. {
  716. if (t_ShowRes != null)
  717. {
  718. resDaemon.SuspendMe();
  719. }
  720. }
  721. private void StopShowSrvData()
  722. {
  723. if (t_ShowSrv != null)
  724. {
  725. srvDaemon.SuspendMe();
  726. }
  727. }
  728. private void StopShowExtServer()
  729. {
  730. if (t_ShowSrv != null)
  731. {
  732. extSrvDaemon.SuspendMe();
  733. }
  734. }
  735. private void ShowResData()
  736. {
  737. try
  738. {
  739. resDaemon.ShowResData(this.Chart2, new ResDaemon.ShowResDataEvent(CallBackShowResData));
  740. }
  741. catch (Exception ex)
  742. {
  743. MessageBox.Show(ex.Message, "资源显示线程错误");
  744. }
  745. }
  746. private void ShowSrvData()
  747. {
  748. try
  749. {
  750. srvDaemon.ShowSrvData(new SrvDaemon.ShowSrvDataEvent(CallBackShowSrvData));
  751. }
  752. catch (Exception ex)
  753. {
  754. MessageBox.Show(ex.Message, "服务显示线程错误");
  755. }
  756. }
  757. private void ShowExtServer()
  758. {
  759. try
  760. {
  761. extSrvDaemon.ShowExtServer(new ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv));
  762. }
  763. catch (Exception ex)
  764. {
  765. MessageBox.Show(ex.Message, "扩展服务器显示线程错误");
  766. }
  767. }
  768. private void CallBackShowResData(List<DataPoint> ps1, List<DataPoint> ps2)
  769. {
  770. if (Chart2.InvokeRequired)
  771. {
  772. ResDaemon.ShowResDataEvent srde = new ResDaemon.ShowResDataEvent(CallBackShowResData);
  773. this.Invoke(srde, new object[] { ps1, ps2 });
  774. return;
  775. }
  776. Series s1 = Chart2.Series[0];
  777. Series s2 = Chart2.Series[1];
  778. s1.Points.Invalidate();
  779. s2.Points.Invalidate();
  780. s1.Points.Clear();
  781. s2.Points.Clear();
  782. foreach (DataPoint dp in ps1)
  783. {
  784. s1.Points.Add(dp);
  785. }
  786. foreach (DataPoint dp in ps2)
  787. {
  788. s2.Points.Add(dp);
  789. }
  790. Chart2.ChartAreas[0].AxisX.Minimum = s1.Points[0].XValue;
  791. Chart2.ChartAreas[0].AxisX.Maximum = s1.Points[s1.Points.Count - 1].XValue;
  792. SystemInfo si = new SystemInfo();
  793. Chart2.Legends[0].CustomItems[0].Cells[0].Text = (si.MemoryAvailable / 1024 / 1024).ToString();
  794. s1.Points.ResumeUpdates();
  795. s2.Points.ResumeUpdates();
  796. }
  797. private void CallBackShowSrvData(List<DataPoint> ps1, List<DataPoint> ps2)
  798. {
  799. if (Chart1.InvokeRequired)
  800. {
  801. SrvDaemon.ShowSrvDataEvent ssde = new SrvDaemon.ShowSrvDataEvent(CallBackShowSrvData);
  802. this.Invoke(ssde, new object[] { ps1, ps2 });
  803. return;
  804. }
  805. Series s1 = Chart1.Series[0];
  806. Series s2 = Chart1.Series[1];
  807. s1.Points.Invalidate();
  808. s2.Points.Invalidate();
  809. s1.Points.Clear();
  810. s2.Points.Clear();
  811. foreach (DataPoint dp in ps1)
  812. {
  813. s1.Points.Add(dp);
  814. }
  815. foreach (DataPoint dp in ps2)
  816. {
  817. s2.Points.Add(dp);
  818. }
  819. s1.Points.ResumeUpdates();
  820. }
  821. private void CallBackShowExtSrv()
  822. {
  823. if (ugServers.InvokeRequired)
  824. {
  825. ExtSrvDaemon.ShowExtSrvEvent sese = new ExtSrvDaemon.ShowExtSrvEvent(CallBackShowExtSrv);
  826. this.Invoke(sese);
  827. return;
  828. }
  829. ugServers.SuspendLayout();
  830. ugServers.SuspendRowSynchronization();
  831. Hashtable extServers = this.cMain.HtExternServer;
  832. DataTable dt = this.dataSet1.Tables[0];
  833. if (dt.Columns.Count == 0)
  834. {
  835. dt.Columns.Add("本地服务", typeof(string));
  836. }
  837. if (dt.Rows.Count == 0)
  838. {
  839. DataRow dr = dt.NewRow();
  840. dr[0] = "1";
  841. dt.Rows.Add(dr);
  842. }
  843. dt.AcceptChanges();
  844. //去除无效服务器
  845. foreach (DataColumn dc in dt.Columns)
  846. {
  847. if (dc.ColumnName == "本地服务") continue;
  848. bool keep_it = false;
  849. foreach (string ServerName in extServers.Keys)
  850. {
  851. UriBuilder ub = new UriBuilder(ServerName);
  852. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  853. if (sn == dc.ColumnName)
  854. {
  855. keep_it = true;
  856. }
  857. }
  858. if (!keep_it)
  859. {
  860. dt.Columns.Remove(dc);
  861. }
  862. }
  863. dt.AcceptChanges();
  864. //新增服务器
  865. foreach (string ServerName in extServers.Keys)
  866. {
  867. UriBuilder ub = new UriBuilder(ServerName);
  868. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  869. if (!dt.Columns.Contains(sn))
  870. {
  871. dt.Columns.Add(sn, typeof(string));
  872. }
  873. RemotingServer rs = (RemotingServer)(extServers[ServerName]);
  874. string status = (rs.Valid != RemoteServerStatus.Normal) ? ((int)(rs.Valid)).ToString() : (rs.Enable ? "1" : "3");
  875. dt.Rows[0][sn] = status;
  876. }
  877. //去除无效服务
  878. for (int idx = 1; idx < dt.Rows.Count; idx++)
  879. {
  880. DataRow dr = dt.Rows[idx];
  881. if (cMain.HTServiceKeys.ContainsKey(dr["本地服务"].ToString())) continue;
  882. dr.Delete();
  883. }
  884. dt.AcceptChanges();
  885. //新增服务项
  886. foreach (string serviceName in this.cMain.HTServiceKeys.Keys)
  887. {
  888. DataRow[] drs = dt.Select(string.Format("本地服务='{0}'", serviceName));
  889. DataRow dr = null;
  890. if (drs.GetLength(0) == 0)
  891. {
  892. dr = dt.NewRow();
  893. dr[0] = serviceName;
  894. dt.Rows.Add(dr);
  895. }
  896. else
  897. {
  898. dr = drs[0];
  899. }
  900. foreach (string serverName in extServers.Keys)
  901. {
  902. UriBuilder ub = new UriBuilder(serverName);
  903. string sn = string.Format("{0}:{1}", ub.Host, ub.Port);
  904. RemotingServer rs = (RemotingServer)(extServers[serverName]);
  905. string server_status = dt.Rows[0][sn].ToString();
  906. if (server_status != "1")
  907. {
  908. dr[sn] = "1" + server_status;
  909. continue;
  910. }
  911. string status = "1";
  912. if (!rs.HTServices.ContainsKey(serviceName))
  913. {
  914. status = "25";
  915. }
  916. else
  917. {
  918. ServiceObject so = (ServiceObject)(rs.HTServices[serviceName]);
  919. switch (so.Valid)
  920. {
  921. case ServiceObjectStatus.Normal:
  922. status = (so.Enable ? "11" : "13");
  923. break;
  924. case ServiceObjectStatus.Unable:
  925. status = "12";
  926. break;
  927. case ServiceObjectStatus.UnMatch:
  928. status = "24";
  929. break;
  930. }
  931. }
  932. dr[sn] = status;
  933. }
  934. }
  935. dt.AcceptChanges();
  936. for (int idx = 0; idx < ugServers.DisplayLayout.Bands[0].Columns.Count; idx++)
  937. {
  938. ugServers.DisplayLayout.Bands[0].Columns[idx].ValueList = ugValueList;
  939. }
  940. ugServers.ResumeRowSynchronization();
  941. ugServers.ResumeLayout();
  942. }
  943. private static ValueList ugValueList = null;
  944. private ValueList GetServerVL()
  945. {
  946. ValueList vl = new ValueList();
  947. vl.ValueListItems.Add("1", "[正常运行]");
  948. vl.ValueListItems.Add("2", "[不可用]");
  949. vl.ValueListItems.Add("3", "[暂停服务]");
  950. vl.ValueListItems.Add("4", "[受控于其他主机]");
  951. vl.ValueListItems.Add("11", "功能正常");
  952. vl.ValueListItems.Add("12", "不可用");
  953. vl.ValueListItems.Add("13", "暂停服务");
  954. vl.ValueListItems.Add("14", "受控其他主机");
  955. vl.ValueListItems.Add("24", "版本不一致");
  956. vl.ValueListItems.Add("25", "缺少服务");
  957. return vl;
  958. }
  959. private void cMain_ShowLog(string log)
  960. {
  961. lock (this.listBox1)
  962. {
  963. this.listBox1.Invalidate();
  964. this.listBox1.Items.Add(log);
  965. this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1;
  966. Application.DoEvents();
  967. this.listBox1.Update();
  968. }
  969. }
  970. private void FrmSeverMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  971. {
  972. if (MessageBox.Show("是否确认退出服务端程序?", "提示", MessageBoxButtons.YesNo,
  973. MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
  974. {
  975. e.Cancel = true;
  976. }
  977. else
  978. {
  979. ApplicationExit();
  980. Application.Exit();
  981. System.Diagnostics.Process.GetCurrentProcess().Kill();
  982. }
  983. }
  984. private static void ApplicationExit()
  985. {
  986. string path = string.Format(@"{0}/log/Application/{1}.txt", Application.StartupPath, System.DateTime.Now.ToString("yyyy_MM_dd"));
  987. using (StreamWriter sw = new StreamWriter(path, true, Encoding.UTF8))
  988. {
  989. StringBuilder sbtxt = new StringBuilder();
  990. sbtxt.AppendLine("==============================================");
  991. sbtxt.AppendLine(string.Format("服务关闭时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm::ss")));
  992. sbtxt.AppendLine("==============================================");
  993. sw.WriteLine(sbtxt.ToString());
  994. }
  995. }
  996. private static void ApplicationStart()
  997. {
  998. string path = string.Format(@"{0}/log/Application/{1}.txt", Application.StartupPath, System.DateTime.Now.ToString("yyyy_MM_dd"));
  999. using (StreamWriter sw = new StreamWriter(path, true, Encoding.UTF8))
  1000. {
  1001. StringBuilder sbtxt = new StringBuilder();
  1002. sbtxt.AppendLine("==============================================");
  1003. sbtxt.AppendLine(string.Format("服务开启时间:{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm::ss")));
  1004. sbtxt.AppendLine("==============================================");
  1005. sw.WriteLine(sbtxt.ToString());
  1006. }
  1007. }
  1008. private void tabControl1_Selected(object sender, TabControlEventArgs e)
  1009. {
  1010. if (e.TabPageIndex == 1)
  1011. {
  1012. StartShowSrvData();
  1013. }
  1014. else
  1015. {
  1016. StopShowSrvData();
  1017. }
  1018. if (e.TabPageIndex == 2)
  1019. {
  1020. StartShowResData();
  1021. }
  1022. else
  1023. {
  1024. StopShowResData();
  1025. }
  1026. if (e.TabPageIndex == 3)
  1027. {
  1028. StartShowExtServer();
  1029. }
  1030. else
  1031. {
  1032. StopShowExtServer();
  1033. }
  1034. }
  1035. private void ugServers_AfterCellUpdate(object sender, CellEventArgs e)
  1036. {
  1037. UltraGridColumn uc = e.Cell.Column;
  1038. try
  1039. {
  1040. if (uc.Index > 0 || e.Cell.Row.Index == 0)
  1041. {
  1042. e.Cell.Appearance = ugServers.DisplayLayout.Appearances[e.Cell.Row.GetCellValue(uc).ToString()];
  1043. }
  1044. }
  1045. catch { }
  1046. }
  1047. private void ugServers_InitializeRow(object sender, InitializeRowEventArgs e)
  1048. {
  1049. for (int idx = 0; idx < e.Row.Band.Columns.Count; idx++)
  1050. {
  1051. UltraGridColumn uc = e.Row.Band.Columns[idx];
  1052. try
  1053. {
  1054. if (uc.Index > 0 || e.Row.Index == 0)
  1055. {
  1056. e.Row.Cells[idx].Appearance = ugServers.DisplayLayout.Appearances[e.Row.GetCellValue(uc).ToString()];
  1057. string cell_value = e.Row.GetCellValue(uc).ToString();
  1058. if (cell_value == "1" || cell_value == "3" || cell_value == "11" || cell_value == "13")
  1059. {
  1060. e.Row.Cells[idx].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
  1061. }
  1062. else
  1063. {
  1064. e.Row.Cells[idx].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Default;
  1065. }
  1066. }
  1067. }
  1068. catch { }
  1069. }
  1070. }
  1071. private void ugServers_ClickCellButton(object sender, CellEventArgs e)
  1072. {
  1073. ugServers.SuspendRowSynchronization();
  1074. UltraGridColumn uc = e.Cell.Column;
  1075. string cell_value = e.Cell.Row.GetCellValue(uc).ToString();
  1076. string ServerName = uc.Header.Caption;
  1077. string ServiceName = e.Cell.Row.GetCellValue(e.Cell.Row.Band.Columns[0]).ToString();
  1078. if (cell_value == "1")
  1079. {
  1080. cMain.SetServerFlag(ServerName, false);
  1081. }
  1082. else if (cell_value == "3")
  1083. {
  1084. cMain.SetServerFlag(ServerName, true);
  1085. }
  1086. else if (cell_value == "11")
  1087. {
  1088. cMain.SetServiceFlag(ServerName, ServiceName, false);
  1089. }
  1090. else if (cell_value == "13")
  1091. {
  1092. cMain.SetServiceFlag(ServerName, ServiceName, true);
  1093. }
  1094. ugServers.ResumeRowSynchronization();
  1095. ugServers.Update();
  1096. }
  1097. private void ugServers_DoubleClickHeader(object sender, DoubleClickHeaderEventArgs e)
  1098. {
  1099. UriBuilder ub = new UriBuilder(e.Header.Caption);
  1100. if (MessageBox.Show(string.Format("是否同步文件到服务器[{0}:{1}]?", ub.Host, ub.Port), "同步文件", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  1101. == DialogResult.Yes)
  1102. {
  1103. try
  1104. {
  1105. foreach (string ServerName in cMain.HtExternServer.Keys)
  1106. {
  1107. UriBuilder ube = new UriBuilder(ServerName);
  1108. if (ub.Host == ube.Host && ub.Port == ube.Port)
  1109. {
  1110. RemotingServer rs = (RemotingServer)(cMain.HtExternServer[ServerName]);
  1111. rs.SyncFiles();
  1112. }
  1113. }
  1114. }
  1115. catch (Exception ex)
  1116. {
  1117. MessageBox.Show(ex.Message);
  1118. }
  1119. }
  1120. }
  1121. }
  1122. }