Example #1
0
        private static void OnAppIdle(object sender, EventArgs e)
        {
            if (applicationContext.MainForm == null)
            {
                Application.Idle -= new EventHandler(OnAppIdle);

                System.Threading.Thread threadDb = new System.Threading.Thread(
                    new System.Threading.ThreadStart(TryConnectDB));
                threadDb.Priority = System.Threading.ThreadPriority.BelowNormal;
                threadDb.Start();

                try
                {
                    if (System.Configuration.ConfigurationSettings.AppSettings["NTier"] != null &&
                        System.Configuration.ConfigurationSettings.AppSettings["NTier"] == "1")
                    {
                        RemotingConfiguration.Configure("BenQGuru.eMES.Client.exe.config");
                    }
                }
                catch (Exception ex)
                {
                    string errorInfo = System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") //error date & time
                                       + "\t" + ex.Message                                 //error message
                                       + "\t" + ex.Source                                  //error object name;
                                       + "\r\n" + ex.StackTrace;

                    UserControl.FileLog.FileLogOut("Client.log", errorInfo);
                }

                System.Diagnostics.Process pr = null;                   //RunningInstance();
                if (pr == null)
                {
                    UserControl.FileLog.FileLogOut("Client.log", System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "\t" + "New FLogin");
                    FLogin loginForm = new FLogin();
                    UserControl.FileLog.FileLogOut("Client.log", System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "\t" + "Show FLogin");
                    loginForm.Show();
                    applicationContext.MainForm = loginForm;
                }
                else
                {
                    HandleRunningInstance(pr);
                }
                splashForm.Close();
                splashForm = null;
            }
        }
Example #2
0
        /// <summary>
        /// 加载自动连续采集的配置文件
        /// </summary>
        public void LoadAutoCollectConfig()
        {
            string strPath = Application.StartupPath;

            if (strPath.EndsWith("\\") == false)
            {
                strPath += "\\";
            }
            string strFile = strPath + "PerformanceAutoCollect.xml";

            if (System.IO.File.Exists(strFile) == false)
            {
                return;
            }
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(strFile);
            XmlNode nodeCurr        = xmlDoc.DocumentElement.SelectSingleNode("//CurrentIndex");
            string  strCurrentIndex = "";

            if (nodeCurr != null)
            {
                strCurrentIndex = nodeCurr.FirstChild.Value;
            }
            else
            {
                throw new Exception("找不到结点:CurrentIndex");
            }

            XmlNode nodeLoad = xmlDoc.DocumentElement.SelectSingleNode("//CollectList/Collect[@Index='" + strCurrentIndex + "']");

            if (nodeLoad == null)
            {
                throw new Exception("找不到配置结点:" + strCurrentIndex);
                return;
            }
            string strConfigFile = nodeLoad.SelectSingleNode("ConfigFileName").FirstChild.Value;

            System.IO.File.Copy(strPath + strConfigFile, strPath + "BenQGuru.eMES.Client.exe.perfconfig", true);

            // 登录
            FLogin flogin = new FLogin();

            flogin.MdiParent              = Service.ApplicationService.Current().MainWindows;
            flogin.ucLEUserCode.Value     = nodeLoad.SelectSingleNode("UserName").FirstChild.Value;
            flogin.ucLEPassword.Text      = nodeLoad.SelectSingleNode("Password").FirstChild.Value;
            flogin.ucLEResourceCode.Value = nodeLoad.SelectSingleNode("Resource").FirstChild.Value;
            flogin.ucBtnLogin_Click(null, EventArgs.Empty);

            // 启动界面
            Form f = this.CreateFormByCollectType(nodeLoad.SelectSingleNode("CollectType").FirstChild.Value);

            if (f == null)
            {
                return;
            }
            this.ShowCollectForm(f);

            bIsAutoCollect = true;

            nodeCurr.FirstChild.Value = (int.Parse(strCurrentIndex) + 1).ToString();
            xmlDoc.Save(strFile);
        }
Example #3
0
        private static void OnAppIdle(object sender, EventArgs e)
        {
            if (applicationContext.MainForm == null)
            {
                Application.Idle -= new EventHandler(OnAppIdle);

                // 初始化ApplicationService.Current
                Service.ApplicationService.Current();

                System.Threading.Thread threadDb = new System.Threading.Thread(
                    new System.Threading.ThreadStart(TryConnectDB));
                threadDb.Start();

                try
                {
                    if (System.Configuration.ConfigurationSettings.AppSettings["NTier"] != null &&
                        System.Configuration.ConfigurationSettings.AppSettings["NTier"] == "1")
                    {
                        RemotingConfiguration.Configure("BenQGuru.eMES.Client.exe.config");
                    }
                }
                catch (Exception ex)
                {
                    string errorInfo = System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") //error date & time
                                       + "\t" + ex.Message                                 //error message
                                       + "\t" + ex.Source                                  //error object name;
                                       + "\r\n" + ex.StackTrace;

                    UserControl.FileLog.FileLogOut("Client.log", errorInfo);
                }

                System.Diagnostics.Process pr = null;   //RunningInstance();
                if (pr == null)
                {
                    FMain mainForm = new FMain();
                    applicationContext.MainForm = mainForm;
                    Service.ApplicationService.Current().MainWindows = mainForm;
                    Application.DoEvents();
                    mainForm.Show();
                    if (appArguments != null && appArguments.Length > 0)
                    {
                        if (appArguments[0].ToUpper() == "AUTOLOGIN" && appArguments.Length >= 4)
                        {
                            FLogin flogin = new FLogin();
                            flogin.MdiParent              = mainForm;
                            flogin.ucLEUserCode.Value     = appArguments[1];
                            flogin.ucLEPassword.Text      = appArguments[2];
                            flogin.ucLEResourceCode.Value = appArguments[3];
                            flogin.ucBtnLogin_Click(null, EventArgs.Empty);

                            if (appArguments.Length >= 5)
                            {
                                FAutoTestConfig fautotest = new FAutoTestConfig();
                                fautotest.CheckAutoLaunchTest();
                            }
                        }
                        else if (appArguments[0].ToUpper() == "AUTOCOLLECT")
                        {
                            FAutoTestConfig fautotest = new FAutoTestConfig();
                            fautotest.LoadAutoCollectConfig();
                        }
                    }
                }
                else
                {
                    HandleRunningInstance(pr);
                }
                splashForm.Close();
                splashForm = null;
            }
        }