private void MainForm_Load(object sender, EventArgs e) { try { this.WindowState = FormWindowState.Maximized; this.btnPause.Enabled = false; this.labelVersion.Text = this.version; #region 数据库配置 string dbSrc = ConfigurationManager.AppSettings["DBSource"]; //CtlDBAccess.DBUtility.PubConstant.ConnectionString = string.Format(@"{0}Initial Catalog=ACEcams;User ID=sa;Password=123456;", dbSrc); string dbConn1 = string.Format(@"{0}Initial Catalog=AoyouEcams;User ID=sa;Password=123456;", dbSrc); CtlDBAccess.DBUtility.DbHelperSQL.SetConnstr(dbConn1); string dbConn2 = string.Format(@"{0}Initial Catalog=AoyouLocalMes;User ID=sa;Password=123456;", dbSrc); MesDBAccess.DBUtility.DbHelperSQL.SetConnstr(dbConn2); AsrsStorDBAcc.DbHelperSQL.SetConnstr(string.Format(@"{0}Initial Catalog=AoyouWMSDB;User ID=sa;Password=123456;", dbSrc)); #endregion string mesAddr = ConfigurationManager.AppSettings["MesSvcAddr"]; PrcsCtlModelsAoyou.WShelper.url = mesAddr; presenter = new MainPresenter(this); childList = new List <string>(); childViews = new List <BaseChildView>(); Console.SetOut(new TextBoxWriter(this.richTextBoxLog)); // corePresenter = new CtlcorePresenter(); this.labelUser.Text = "当前用户:" + this.userName; this.MainTabControl.DrawMode = TabDrawMode.OwnerDrawFixed; this.MainTabControl.Padding = new System.Drawing.Point(CLOSE_SIZE, CLOSE_SIZE); this.MainTabControl.DrawItem += new DrawItemEventHandler(this.tabControlMain_DrawItem); this.MainTabControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tabControlMain_MouseDown); if (!presenter.SysCtlInit()) { return; } if (!LoadModules())//加载子模块 { MessageBox.Show("子模块加载错误"); return; } this.configView.BatteryCfgView.dlgtSndPalletCfg = presenter.SendDevlinePalletCfg; this.configView.BatteryCfgView.dlgtGetPalletCfg = presenter.ReadPalletCfgFromPlc; List <string> logSrcs = new List <string>(); logSrcs.AddRange(presenter.GetLogSrcList()); List <string> storLogSrcs = storageView.GetLogsrcList(); if (storLogSrcs != null) { logSrcs.AddRange(storLogSrcs); } logView.SetLogsrcList(logSrcs); presenter.SetLogRecorder(logView.GetLogrecorder()); AllocateModuleInface(); nodeMonitorView.Init(); this.nodeMonitorView.InitDevDic(presenter.DevCommManager.GetPLCConnStatDic()); this.nodeMonitorView.DevMonitorView.devCommMonitor = presenter.DevCommManager; string[] taskNodeIDS = new string[] { "1001", "1002", "1003", "1004", "1005", "1006", "6001", "6002", "6003" }; IDictionary <string, string> taskNodeMap = new Dictionary <string, string>(); foreach (string nodeID in taskNodeIDS) { FlowCtlBaseModel.CtlNodeBaseModel node = presenter.CtlNodeManager.GetNodeByID(nodeID); if (node != null) { taskNodeMap[nodeID] = node.NodeName; } } asrsCtlView.SetTaskNodeNames(taskNodeMap); string licenseFile = AppDomain.CurrentDomain.BaseDirectory + @"\NBSSLicense.lic"; this.licenseMonitor = new LicenseMonitor(this, 60000, licenseFile, "zzkeyFT1"); if (!this.licenseMonitor.StartMonitor()) { throw new Exception("license 监控失败"); } string reStr = ""; if (!this.licenseMonitor.IslicenseValid(ref reStr)) { MessageBox.Show(reStr); return; } presenter.LoadAsrsExtSvc(); //宿主状态监控服务 PublicMonitorSvc(); Console.WriteLine("系统初始化完成!"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }