Example #1
0
        /*
         * 201事件 业务服务启动
         * 202事件 成功触发报警通知
         * 203事件 报警执行失败
         * 204事件 业务线程终止
         * 205事件 业务线程因为未捕捉错误终止
         */
        void bclass_ProcessEvent(object sender, ProcessEventArg e)
        {
            if (this.server == e.GetPara(1))
            {
                try {
                    switch (e.EventNumber)
                    {
                    case 201:
                        //201事件 业务服务启动
                        this.bunStart.Enabled = false;
                        this.bunStop.Enabled  = true;
                        break;

                    case 204:
                        //204事件 业务线程终止
                        this.bunStop.Enabled  = false;
                        this.bunStart.Enabled = true;
                        break;
                    }
                    this.AddListContent(string.Format("{0}事件,{1}", e.GetEventNumber(), e.ToStringOfPara(0)));
                } catch (Exception ex) {
                    this.AddListContent(ex.ToString());
                }
            }
        }
Example #2
0
        void server_ProcessEvent(object sender, ProcessEventArg e)
        {
            if (e.Level == EventLevel.Importent)
            {
                switch (e.State)
                {
                case ProcessState.INIT:
                    this.AddListContent(serverName + "开始初始化!");
                    break;

                case ProcessState.READY:
                    this.AddListContent(serverName + "准备就绪!");
                    break;

                case ProcessState.START:
                    this.AddListContent(serverName + "启动!");
                    this.bunStart.Enabled = false;
                    this.bunStop.Enabled  = true;
                    break;

                case ProcessState.STOP:
                    this.AddListContent(serverName + "停止!");
                    this.bunStop.Enabled  = false;
                    this.bunStart.Enabled = true;
                    break;

                case ProcessState.DISPOSE:
                    this.AddListContent(serverName + "清除资源完成运行!");
                    break;

                case ProcessState.EXCEPTION:
                    this.AddListContent("服务发生致命错误!终止运行错误描述" + e.Exception.Message + "");
                    break;
                }
            }
            else
            {
                this.AddListContent(e.GetEventNumber() + "事件," + e.ToStringOfPara(0));
            }
        }
Example #3
0
        void bClass_ProcessEvent(object sender, ProcessEventArg e)
        {
            try {
                if (e.Level == EventLevel.Importent)
                {
                    #region 处理进程级事件
                    switch (e.State)
                    {
                    case ProcessState.INIT:
                        this.AddProcessLog(Properties.Settings.Default.ApplicationName + "开始初始化!");
                        break;

                    case ProcessState.READY:
                        this.AddProcessLog(Properties.Settings.Default.ApplicationName + "准备就绪!");
                        this.bunStart.Enabled = true;
                        break;

                    case ProcessState.START:
                        this.AddProcessLog(Properties.Settings.Default.ApplicationName + "开始启动!");

                        this.labSTdesc.Text = "启动时间:";
                        this.startTime      = DateTime.Now;
                        this.labSTime.Text  = Tool.FormatDate(startTime);
                        this.recTimer.Start();

                        this.waitTimer.Stop();
                        this.firstRun         = false;
                        this.bunStart.Enabled = false;
                        this.bunStop.Enabled  = true;
                        break;

                    case ProcessState.STOP:
                        this.AddProcessLog(Properties.Settings.Default.ApplicationName + "停止!");

                        this.labSTdesc.Text = "停止时间:";
                        this.recTimer.Stop();

                        this.firstRun = true;
                        this.waitTimer.Start();

                        this.labSTime.Text = Tool.FormatNow();
                        this.niMain.Text   = Properties.Settings.Default.ApplicationName;
                        bClass.RecordLog(string.Format("此次执行处理时间共", this.labRTime.Text));
                        this.bunStart.Enabled = true;
                        this.bunStop.Enabled  = false;
                        break;

                    case ProcessState.DISPOSE:
                        waitTimer.Stop();
                        waitTimer.Enabled = false;
                        this.AddProcessLog(Properties.Settings.Default.ApplicationName + "清除资源完成运行!");
                        this.Close();
                        //Application.ExitThread();
                        break;

                    case ProcessState.EXCEPTION:
                        string desc = "";
                        switch (((AbstractProcess)sender).GetState())
                        {
                        case ProcessState.INIT:
                            desc = "初始化";
                            break;

                        case ProcessState.START:
                            desc = "启动进程";
                            break;

                        case ProcessState.STOP:
                            desc = "关闭进程";
                            break;

                        case ProcessState.DISPOSE:
                            desc = "终止进程";
                            break;
                        }
                        this.AddProcessLog("程序" + desc + "发生致命错误!终止运行错误描述" + e.Exception.Message);
                        this.bunStop_Click(this, new EventArgs());
                        this.firstRun = true;
                        this.waitTimer.Start();
                        break;
                    }
                    #endregion
                }
                else
                {
                    #region 处理普通事件

                    /*事件说明:
                     * 101事件 读取配置信息
                     * 102事件 业务服务注册
                     * 103事件 刷新Settings列表
                     * 201事件 业务服务启动
                     * 202事件 成功触发报警通知
                     * 203事件 报警执行失败
                     * 204事件 业务线程终止
                     * 205事件 业务线程因为未捕捉错误终止
                     * 206事件 执行测试命令成功!
                     * 207事件 执行测试命令出错
                     * 208事件 服务撤销
                     * 209事件 服务初始化
                     * 210事件 服务准备就绪
                     */
                    string desc = string.Format("{0}事件,{1}", e.GetEventNumber(), e.ToStringOfPara(0));
                    switch (e.EventNumber)
                    {
                        #region 进程级事件
                    case 101:
                        //101 事件读取配置信息
                        //进程级事件
                        this.AddProcessLog(desc);
                        break;

                    case 102:
                        //102事件 业务服务注册
                        this.AddTabPage((ABusinessServer)e.GetPara(1));
                        this.AddProcessLog(desc);
                        break;

                    case 103:
                        this.txtSettings.Text = e.ToStringOfPara(1);
                        break;
                        #endregion

                    default:
                        if (e.Length > 1 && e.GetPara(1) is ABusinessServer)
                        {
                            this.AddListContent(this.lstAll, e.GetPara(1).GetType().Name + "服务 " + desc);
                        }
                        else
                        {
                            this.AddListContent(this.lstAll, desc);
                        }
                        break;
                    }
                    #endregion
                }
            } catch (Exception ex) {
                this.AddProcessLog("程序出现未捕捉错误 " + ex.ToString());
                //this.ShowMessage("程序出现未捕捉错误 " + ex.ToString(), MessageBoxIcon.Stop);
            }
        }
Example #4
0
 void bClass_ProcessEvent1(object sender, ProcessEventArg e)
 {
     //调用contral的方法以这个窗体的权限触发事件处理
     this.Invoke(new ProcessEventHandle(bClass_ProcessEvent), new object[] { sender, e });
 }
Example #5
0
 void bclass_ProcessEvent1(object sender, ProcessEventArg e)
 {
     this.Invoke(new ProcessEventHandle(this.bclass_ProcessEvent), sender, e);
 }
Example #6
0
 void server_ProcessEvent1(object sender, ProcessEventArg e)
 {
     this.Invoke(new ProcessEventHandle(server_ProcessEvent), sender, e);
 }