Exemple #1
0
 void do_End_Flow(clsThreadInfo _ti, System.Diagnostics.Stopwatch _tmr, string vFlowId)
 {
     // _flow
     _flow.lastCase = _flow.currCase;
     if (_flow.eState == eWF_State.Running)
     {
         _flow.eState = eWF_State.End;
     }
     _dao_comm_set_arr_str800();// 消息  arr_str[0][800 + _flowNo]
     // _ti
     _ti.allowWhile    = eSwitch.No;
     _ti.allowBusiness = eSwitch.No;
     _ti.cnt_heart     = -1;
     // _tmr
     _tmr.Stop(); //结束计时
     #region      // 日志
     // _log1
     clsLogs _logs = new clsLogs();
     _logs.No   = _flow.currCase;
     _logs.Name = _flow.currCase + "_结束 *** ";
     _flow.RunLog.Add(_logs);
     // _log 2
     FACC.F_Log.Debug_1(this.GetType().Name, String.Format("--- 流程:{0} 结束, 状态:{1} ---",
                                                           vFlowId,
                                                           _flow.eState.ToString()));
     #endregion
 }
Exemple #2
0
        bool doPartA(clsFaim3 v_faim3, DAL_CommData v_dao_comm, string vflowName)
        {
            string  _cls_Name = "DAL_PartA";
            clsLogs _logs     = new clsLogs();
            clsFlow _flow     = v_faim3.dict_Flow[vflowName];
            string  _currCase = _flow.nextCase;

            F_Log.Debug_1(_cls_Name, String.Format("流程:{0}: 步骤:{1}",
                                                   vflowName, _currCase));
            _flow.alartCase = _currCase;
            if (!v_faim3.dict_CaseState.ContainsKey(_currCase))
            {
                //'A: 步骤.txt 文件中没有注册该步骤参数
                _logs.No   = v_faim3.dict_CaseState[_currCase].No;
                _logs.Name = (_currCase + "_没注册 步骤");
                _flow.RunLog.Add(_logs);
                F_Log.Debug_1(_cls_Name, string.Format("--->>>> 没注册 流程:{0}: 步骤:{1}", vflowName, _currCase));
                return(true);
            }
            clsCaseState _en_State = v_faim3.dict_CaseState[_currCase];

            if ((_en_State.Times > 0))                                                            // 逻辑模型: 执行次数至少有一次, 如 <1, 则不执行AR(),  只执行判断, 以实现流程在等待联动消息的逻辑
            {
                F_Delegate.delCasePartA_R _doPartA = _dao_comm.dict_Methods.doPartA_R[_currCase]; // 通过代理, 从步骤集中取出一个步骤, 执行其方法()
                //
                _logs.No   = v_faim3.dict_CaseState[_currCase].No;
                _logs.Name = _currCase;
                _flow.RunLog.Add(_logs);
                _doPartA(v_faim3, v_dao_comm);
                // AR
                // Delay
                if ((_en_State.Delay > -1))//
                {
                    Thread.Sleep(_en_State.Delay);
                }
                //
            }
            if (string.IsNullOrEmpty(_en_State.No))//逻辑模型:  无BT报警号 检测的步骤, 只执行 AR(), 不执行AR(), 实现两个 AR() 串联(直通)的逻辑
            {
                doGet_NextCase(_faim3, ref _flow, _currCase);
            }
            else
            {
                // 逻辑模型:  无BT报警号 无报警延时, 只执行 AR(), 不执行AR(), 实现两个 AR() 串联(直通)的逻辑
                string _testCase = (_currCase + F_Const.fix_CaseT);
                if (_flow.nextCase == _flow.currCase)
                {
                    _flow.alartCase = _currCase;
                    _flow.nextCase  = _testCase; // ==> Test  当前流程名 + _T
                    F_Log.Debug_1(_cls_Name, String.Format("取到 测试步骤名:{0}", _flow.nextCase));
                }
            }
            return(true);
        }
Exemple #3
0
        protected override void do_While(string vFlowId)
        {
            //int _loc = 0;
            _bl = true;
            #region                            // _flow 初始化

            _flow.currCase = _flow.firstCase;  // 恢复 第1步

            _flow.alartCase = _flow.firstCase; // 恢复
            //if (_faim3.dict_CaseState.ContainsKey(_flow.alartCase))
            //{
            clsCaseState _caseState = _faim3.dict_CaseState[_flow.alartCase];
            _caseState.beginMode = eCaseFlag.Next;
            _caseState.endMode   = eCaseFlag.Next;
            //}
            _flow.nextCase = _flow.firstCase;
            _flow.lastCase = "Free";
            _flow.stepCase = "Free";  // 初始化单步的步骤名

            _flow.breakSkipCase = ""; // 断点无效的步骤名
            _flow.times        += 1;  // 累加, 显示流程 启动的次数

            _flow.Tag     = "";
            _flow.NGtimes = 0;
            #endregion
            #region // 日志 1 2
            F_Log.Debug_1(this.GetType().Name, String.Format("*** 流程开始:{0}.{1}, 状态:{2}, 计数:{3} ***",
                                                             vFlowId,
                                                             _flow.currCase,
                                                             _flow.eState.ToString(),
                                                             _flow.times));
            // 日志 2
            clsLogs _logs2 = new clsLogs();
            _logs2.No   = _flow.currCase;
            _logs2.Name = "*** " + _flow.currCase + " _开始";
            _flow.RunLog.Add(_logs2);                                // 累加, 内存日志
            #endregion
            #region                                                  // 流程条件
            clsThreadInfo _ti = _faim3.dict_Threads[vFlowId].Info;
            _ti.allowWhile    = eSwitch.Yes;                         //控制流程之1, 线程终止  false
            _ti.allowBusiness = eSwitch.No;                          // 控制流程之2 业务等待/暂停
            System.Diagnostics.Stopwatch _tmr = do_th_Name_pre(_ti); // 计时
            #endregion
            _faim3.dict_Threads[_flowName].Info.tmr_real = 0;        // 当前步骤 实际占用总时长



            #region                                           // while
            while (((int)_ti.allowWhile == (int)eSwitch.Yes)) // 允许线程运行 1
            {
                #region                                       // break
                // 急停
                if (_faim3.isEmergency > 0)
                {
                    _flow.eState      = eWF_State.Emergency;
                    _ti.allowWhile    = eSwitch.No;
                    _ti.allowBusiness = eSwitch.No;
                    break;
                }
                // 最后一步


                if (_flow.nextCase.ToUpper() == "FREE")
                {
                    break;// 结束流程
                }
                #endregion
                #region                     // continue
                // 暂停
                if (!do_allowBusiness(_ti)) //_flow.eState = eWF_State.Wait;
                {
                    continue;               // 线程延时+ 业务是否允许 流程信息 2
                }
                if (do_NG_hasTimes())
                {
                    continue; //_flow.currCase
                }
                #endregion
                // 显示执行后的 curr
                //_dao_comm_set_arr_str800();
                //string _caseName_old = _flow.currCase;
                clsCaseState _caseState_old = _faim3.dict_CaseState[_flow.alartCase];
                _flow.currCase = _flow.nextCase;  // 准备执行下一步, 即将下一步设为当前步骤


                if (_flow.currCase.EndsWith(F_Const.fix_CaseT)) // “_T”, 测试步骤
                {
                }
                else
                {
                    _flow.alartCase = _flow.currCase; // 非测试步骤


                    clsCaseState _caseState_new = _faim3.dict_CaseState[_flow.alartCase];
                    if (_caseState_new.beginMode == eCaseFlag.Free)
                    {
                        _caseState_new.beginMode = _caseState_old.endMode;
                    }
                    //if (_caseName_old.EndsWith(F_Const.fix_CaseT)) // “_T”, 测试步骤
                    //    _caseState_new.beginMode = eCaseFlag.TT;
                    //else
                }
                //_dao_comm_set_arr_str800();
                // 指定预执行的 curr
                do_WaitBreak();
                do_WaitStep();

                _flow.caseTimes++; // 累加, 显示步骤 通过的次数


                // 状态为运行中


                _flow.eState = eWF_State.Running;
                long _trm_begin = _tmr.ElapsedMilliseconds;                    // 毫秒
                _ti.caseName = _flow.currCase;
                if (_dao_comm.dict_Methods.doCase.ContainsKey(_flow.currCase)) // 条件:Case名存在,XX() 或 XX_T()
                {
                    if (!_flow.currCase.EndsWith(F_Const.fix_CaseT))           // 条件:无“_T”, 则新步骤开始, 先找到该配置文档的行号
                    {
                        _ti.cnt_business++;                                    // Case完成数


                        // 发消息, 上一步骤信息和本步骤位置
                        doGet_CmdLineStart(_flow.currCase, ref _faim3);                          // 预处理 分解Case的各语法结构
                    }
                    #region                                                                      // 流程代码 代理1   Switch  &  Select Case
                    F_Delegate.delCase _delCase = _dao_comm.dict_Methods.doCase[_flow.currCase]; //通过代理, 从步骤集中取出一个步骤, 执行其方法()
                    _delCase(_dao_comm, _flow.FlowName);                                         // 执行步骤
                    do_end_CalcTimer(_ti, _tmr, _trm_begin);                                     // 流程信息2
                    #endregion
                    if (_flow.Delay > -1)
                    {
                        System.Threading.Thread.Sleep(_flow.Delay);
                    }
                }
                else  // 结束 flow
                {
                    _ti.allowWhile = eSwitch.Off;               // 控制流程之2 , 步骤名不存在 无方法


                    _flow.eState = eWF_State.End;
                    FACC.F_Log.Debug_1(this.GetType().Name, String.Format("--->>>> 无 步骤 :{0}.{1}->{2} - 状态:{3}, 计数:{4} ",
                                                                          vFlowId,
                                                                          _flow.lastCase, _flow.currCase,
                                                                          _flow.eState.ToString(),
                                                                          _flow.times));
                }
            }
            #endregion
            do_End_Flow(_ti, _tmr, vFlowId);
        }