コード例 #1
0
        private void Main_Form_FormClosing(object sender, FormClosingEventArgs e)
        {
            AppCloseMessage = "Exit?";
            // 確認對話方框 show confirm message dialog ..
            DialogResult result = MessageBox.Show(this, AppCloseMessage, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
            {
                e.Cancel = true;
            }
            else
            {
                // stop running state thread ..//停止運行狀態線程
                requeststop = true;

                // change status flag ..//改變狀態標志
                this.Base.IsOffLine = true;

                // start machine registry ..//開始機器注冊
                this.Base.RegistryMachine(false);

                // clean up base class object resource ..//清空base類對象資源
                this.Base.Dispose();

                // append to logs object ..//追加到日志對象
                RenderEvents.AppendLog(string.Format("{0}", "close renbar for render server application."));

                // save current all log message ..//保存黨前所有日志信息
                RenderEvents.SaveLog();
            }
        }
コード例 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // create render instance ..//創建render instance
            this.Base = new RenderBase();//先去執行構造函數

            // create render log instance ..//創建render日志instance
            this.LogMsg = new RenderEvents();

            // append to logs object ..//追加到日志對象
            RenderEvents.AppendLog(string.Format("{0}", "initialize render base service has successful."));

            // setting list view sort provider ..//設置list view排序provider
            this.ListView_Render_Status.ListViewItemSorter = ListViewSorter;
            this.ListViewSorter.Order = SortOrder.Descending;

            // start read server data information thread ..//開始讀服務器數據信息線程
            Thread StateThread = new Thread(new ThreadStart(this.ReadData));

            StateThread.Priority = ThreadPriority.BelowNormal;
            StateThread.Start();

            // append to logs object ..//追加到日志對象
            RenderEvents.AppendLog(string.Format("{0}", "start data object delegate thread."));
        }
コード例 #3
0
        private void ReadData()
        {
            global::System.Collections.Generic.IList <string>
            RenderItemList       = new global::System.Collections.Generic.List <string>(),
                RenderDeleteList = new global::System.Collections.Generic.List <string>();

            do
            {
                while (this.Base.HasChange)//如果得到或者設置數據狀態改變
                {
                    // read current job information ..//讀黨前的工作信息
                    DataTable DataStatus = this.Base.GetQueueStatus;

                    if (DataStatus != null)
                    {
                        #region Invoke Render Status Data Object Delegate Procedure調用Render狀態數據對象代表Procedure
                        RenderDataCallBack RenderData = delegate(ListViewItem Item, string DeleteItemText)
                        {
                            if (!string.IsNullOrEmpty(DeleteItemText))
                            {
                                for (int i = 0; i < ListView_Render_Status.Items.Count; i++)
                                {
                                    // processing application all events ..//進程應用程序所有事件
                                    Application.DoEvents();

                                    if (this.ListView_Render_Status.Items[i].SubItems[0].Text == DeleteItemText)
                                    {
                                        // remove item ..//移除項
                                        this.ListView_Render_Status.Items[i].Remove();
                                    }

                                    // refresh control ..//刷新控制
                                    this.ListView_Render_Status.Update();
                                }

                                return;
                            }

                            foreach (ListViewItem RenderItem in this.ListView_Render_Status.Items)
                            {
                                // processing application all events ..//進程應用程序所有事件
                                Application.DoEvents();

                                if (RenderItem.Text == Item.Text)
                                {
                                    // update the item of sub items ..//修改子項的項
                                    for (int i = 0; i < RenderItem.SubItems.Count; i++)
                                    {
                                        RenderItem.SubItems[i] = Item.SubItems[i];
                                    }

                                    // refresh control ..//刷新控制
                                    this.ListView_Render_Status.Update();

                                    return;
                                }
                            }

                            // processing application all events ..//processing應用程序所有事件
                            Application.DoEvents();

                            // add new items to the listview control ..//添加新項到listview控制
                            this.ListView_Render_Status.Items.Add(Item);

                            // sorting ..//排序
                            this.ListViewSorter.SortColumn = 0;
                            this.ListView_Render_Status.Sort();

                            // refresh control ..//刷新控制
                            this.ListView_Render_Status.Update();

                            // append to logs object ..//追加到日志對象
                            RenderEvents.AppendLog(string.Format("{0}", "refresh listview render data."));
                        };

                        foreach (global::System.Data.DataRow row in DataStatus.Rows)
                        {
                            if (!RenderItemList.Contains(row["Job_Id"].ToString().Trim()))
                            {
                                RenderItemList.Add(row["Job_Id"].ToString().Trim());
                            }

                            string[] subitems =
                            {
                                row["Job_Id"].ToString().Trim(),
                                row["Job_Group_Id"].ToString().Trim(),
                                row["Proc_Id"].ToString().Trim(),
                                row["Proc_Type"].ToString().Trim(),
                                row["Command"].ToString().Trim(),
                                row["Args"].ToString().Trim(),
                                row["Status"].ToString().Trim(),
                                row["Start_Time"].ToString().Trim(),
                                row["Finish_Time"].ToString().Trim()
                            };

                            try
                            {
                                // invoke job list view delegate control ..//調用工作列view代表控制
                                this.Invoke(RenderData, new object[] { new ListViewItem(subitems), null });//調用RenderData
                            }
                            catch (InvalidOperationException)
                            {
                                // if delegate object already clean, exit loop ..//如果代表對象已經清空,退出loop
                                break;
                            }
                        }

                        // search deleted items ..//查看刪除項
                        foreach (string s in RenderItemList)
                        {
                            if (DataStatus.PrimaryKey.Length == 0)
                            {
                                break;
                            }

                            if (!DataStatus.Rows.Contains(s))
                            {
                                try
                                {
                                    // invoke job list view delegate control ..//調用工作列視圖代表控制
                                    this.Invoke(RenderData, new object[] { new ListViewItem(), s });

                                    // add to remove list ..//添加到移除列
                                    RenderDeleteList.Add(s);
                                }
                                catch (InvalidOperationException)
                                {
                                    // if delegate object already clean, exit loop ..//如果代表對象已經清空,退出loop
                                    break;
                                }
                            }
                        }

                        foreach (string s in RenderDeleteList)
                        {
                            // remove data record ..//移除數據記錄
                            RenderItemList.Remove(s);
                        }

                        // clear all delete list ..//清空所有刪除列
                        RenderDeleteList.Clear();
                        #endregion
                    }

                    // reset change flag ..//重置改變標志
                    this.Base.HasChange = false;
                }

                // set access state timespan ..//設置接口狀態timespan
                Thread.Sleep(500);
            } while (!requeststop);
        }