예제 #1
0
파일: frmMain.cs 프로젝트: chanhan/subao_ap
        public frmMain()
        {
            InitializeComponent();
            // 設定
            this.Icon = Properties.Resources.Console;
            // 讀取設定檔
            XmlAdapter xmlAdapter;
            // 設定 IP
            xmlAdapter = new XmlAdapter(CONFIG_FILE_PATH);
            xmlAdapter.GoToNode("XML", "Server");
            this.tsptxbServerIp.Text = xmlAdapter.ReadXmlNode("Ip");
            this.tsptxbServerPort.Text = xmlAdapter.ReadXmlNode("Port");
            // 讀取執行程式清單
            xmlAdapter = new XmlAdapter(CONFIG_FILE_PATH);
            xmlAdapter.GoToNode("XML", "Processes");
            // 建立執行程式
            try
            {
                this.ProcessList = xmlAdapter.GetAllSubNodes("Process", "Name", "Path", "Command", "Description", "Default");
            }catch
            {
                MessageBox.Show(this, "載入Process設定檔失敗。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                // 寫入記錄
                ServerWork.Error("載入Process設定檔失敗");
                Application.Exit();
            }

            // 多跟分來源的當前來源
            this.CurProcessType = new Dictionary<string, string>();
            this.CurProcessTime = new Dictionary<string, string>();

            //設定預設值 KEY統一大寫
            foreach (var process in this.ProcessList)
            {
                if (process["Default"] == "true")
                {
                    string key = process["Name"].Replace("(", "").Replace(")", "").ToUpper();
                    if (key.IndexOf("-") != -1)
                        key = key.Substring(0, key.IndexOf("-"));

                    this.CurProcessType.Add(key, process["Name"]);
                }
            }

            logClear = new LogClear();
            Task.Factory.StartNew(() => logClear.Work(), TaskCreationOptions.LongRunning);
        }
예제 #2
0
파일: frmMain.cs 프로젝트: chanhan/subao_ap
        public FrmMain()
        {
            InitializeComponent();
            // 設定
            this.Icon = Properties.Resources.Control;
            // 建立記錄檔操作
            //this.FileLog = new SHGG.FileService.ErrorNote(LOG_FILE_PATH);
            // 讀取設定檔
            XmlAdapter xmlAdapter;
            // 讀取伺服器清單
            xmlAdapter = new XmlAdapter(CONFIG_FILE_PATH);
            xmlAdapter.GoToNode("XML", "Servers");
            this.ServersList = xmlAdapter.GetAllSubNodes("Server", "Name", "Ip", "Port");
            // 加入清單
            foreach (Dictionary<string, string> server in this.ServersList)
            {
                this.tspcbbServerIp.Items.Add(string.Format("{0}", server["Name"]));
            }
            // 預設
            this.tspcbbServerIp.SelectedIndex = 0;
            // 讀取執行程式清單
            xmlAdapter = new XmlAdapter(CONFIG_FILE_PATH);
            xmlAdapter.GoToNode("XML", "Processes");
            this.ProcessList = xmlAdapter.GetAllSubNodes("Process", "Name", "Description");

            // WS client timeout 時間
            int timeout;
            if (!Int32.TryParse(ConfigurationManager.AppSettings["WSTimeout"], out timeout))
            {
                timeout = 120;
            }

            // 轉為毫秒
            timeout *= 1000;
            _wsCommon.Timeout = timeout;
        }