private void SendNotifys(WF_WORKFLOW_INST mainRow, IUnitOfData source)
        {
            try
            {
                INotifyAction notifyAction;
                if (!NotifyActions.IsNotEmpty())
                {
                    NotifyActions.Add("DefaultNotifyAction");
                }
                //if (NotifyActions.IndexOf("NotifyAction") < 0 )
                //{
                //    NotifyActions.Add("NotifyAction");
                //}

                foreach (var notify in NotifyActions)
                {
                    notifyAction = notify.CodePlugIn <INotifyAction>();
                    notifyAction.DoPush(QuoteIdList.LoadFromString(mainRow.WI_RECEIVE_LIST), null, mainRow, source);
                    //DoActionDelegate doActionDelegate = new DoActionDelegate(notifyAction.DoAction);
                    foreach (var userID in QuoteIdList.LoadFromString(mainRow.WI_RECEIVE_LIST))
                    {
                        notifyAction.DoAction(userID, mainRow, null, source);
                        //doActionDelegate.BeginInvoke(userID, mainRow, WorkflowInstUtil.CreateContent(mainRow), source, null, null);
                    }
                }

                //----------
            }
            catch (Exception ex)
            {
                string str = "工作流触发异常:" + ex.Message;
                AtawAppContext.Current.Logger.Debug(str);
                AtawTrace.WriteFile(LogType.Error, str);
            }
        }
Example #2
0
        public static void SendStep(Workflow workflow, StepConfig nextStep, IUnitOfData source)
        {
            DateTime now = DateTime.Now;
            //  = AtawIocContext.Current.FetchInstance<IUnitOfData>();
            WorkflowDbContext dbContext   = source as WorkflowDbContext;
            WF_WORKFLOW_INST  workflowRow = workflow.WorkflowRow;
            WorkflowContent   content     = WorkflowInstUtil.CreateContent(workflowRow);

            using (dbContext)
            {
                //拷贝新步骤
                WF_STEP_INST stepRow = new WF_STEP_INST();
                (source as WorkflowDbContext).WF_STEP_INST.Add(stepRow);
                CopyWorkflowToStep(dbContext, workflowRow, stepRow, FlowAction.Flow);
                //人工步骤的处理
                bool isManual = workflow.CurrentStep.Config.StepType == StepType.Manual;
                if (isManual)
                {
                    CopyManualInfo(workflow.WorkflowRow, stepRow);
                }
                //更新工作流实例
                workflowRow.WI_INDEX = workflowRow.WI_INDEX.Value <int>() + 1;
                if (isManual)
                {
                    workflowRow.WI_LAST_MANUAL      = workflowRow.WI_CURRENT_STEP;
                    workflowRow.WI_LAST_MANUAL_NAME = workflowRow.WI_CURRENT_STEP_NAME;
                    //更新参与人列表
                    string      refIds    = workflowRow.WI_REF_LIST;
                    QuoteIdList ulRef     = QuoteIdList.LoadFromString(refIds);
                    string      receiveId = workflowRow.WI_RECEIVE_ID;
                    string      sendId    = workflowRow.WI_SEND_ID;
                    string      processId = workflowRow.WI_PROCESS_ID;
                    ulRef.Add(receiveId);
                    ulRef.Add(sendId);
                    ulRef.Add(processId);
                    int outInt;
                    workflowRow.WI_REF_LIST = ulRef.ToString(out outInt);
                    //接收人  处理人  重新置为空
                    workflowRow.WI_RECEIVE_ID      = "";
                    workflowRow.WI_LAST_PROCESS_ID = workflowRow.WI_PROCESS_ID;
                    workflowRow.WI_PROCESS_ID      = "";
                    workflowRow.WI_RECEIVE_LIST    = "";
                    //清空超时和提醒标识
                    if (workflowRow.WI_IS_TIMEOUT.Value <bool>() == true)
                    {
                        workflowRow.WI_IS_TIMEOUT = false;
                    }
                    //清空错误处理信息 WI_ERROR_TYPE WI_MAX_RETRY_TIMES WI_RETRY_TIMES  WI_NEXT_EXE_DATE
                    WorkflowInstUtil.ClearError(workflowRow);
                }
                //更新主表信息
                SetWorkflowByStep(source, workflowRow, nextStep);
                content.SetMainRowStatus(source, nextStep);
                dbContext.Submit();
            }
            // IUnitOfData dbContext = AtawIocContext.Current.FetchInstance<IUnitOfData>();
            //ATAW_WORKFLOWContext context = dbContext as ATAW_WORKFLOWContext;
            //拷贝新步骤
            //WF_STEP_INST stepRow = new WF_STEP_INST();
        }
Example #3
0
        public ActionResult Index()
        {
            WorkflowDbContext context = new WorkflowDbContext(PlugAreaRegistration.CONN);
            string            sql     = string.Format(ObjectUtil.SysCulture,
                                                      @" UPDATE WF_WORKFLOW_INST SET WI_STATUS = {0}, WI_RECEIVE_ID = {1}, "
                                                      + "WI_RECEIVE_DATE = {2}  WHERE WI_STEP_TYPE = {3} AND WI_STATUS = {4} "
                                                      + "AND WI_RECEIVE_COUNT = {5} AND WI_RECEIVE_LIST LIKE {6}",
                                                      context.GetSqlParamName("NEWWI_STATUS"), context.GetSqlParamName("WI_RECEIVE_ID"),
                                                      context.GetSqlParamName("WI_RECEIVE_DATE"), context.GetSqlParamName("WI_STEP_TYPE"),
                                                      context.GetSqlParamName("WI_STATUS"), context.GetSqlParamName("WI_RECEIVE_COUNT"),
                                                      context.GetSqlParamName("WI_RECEIVE_LIST"));

            // s dblist = new DbParameterList();
            List <SqlParameter> dblist = new List <SqlParameter>();

            dblist.Add(new SqlParameter("@NEWWI_STATUS", (int)StepState.OpenNotProcess)
            {
                DbType = DbType.Int32, Value = (int)StepState.OpenNotProcess
            });
            dblist.Add(new SqlParameter("@WI_RECEIVE_ID", GlobalVariable.UserId.ToString())
            {
                DbType = DbType.String
            });
            dblist.Add(new SqlParameter("@WI_RECEIVE_DATE", DateTime.Now)
            {
                DbType = DbType.DateTime
            });
            dblist.Add(new SqlParameter("@WI_STEP_TYPE", (int)StepType.Manual)
            {
                DbType = DbType.Int32
            });
            dblist.Add(new SqlParameter("@WI_STATUS", (int)StepState.NotReceive)
            {
                DbType = DbType.Int32, Value = (int)StepState.NotReceive
            });
            dblist.Add(new SqlParameter("@WI_RECEIVE_COUNT", 1)
            {
                DbType = DbType.Int32
            });
            dblist.Add(new SqlParameter("@WI_RECEIVE_LIST", QuoteIdList.GetQuoteId(GlobalVariable.UserId.ToString()))
            {
                DbType = DbType.String
            });

            int res = context.ExecuteSqlCommand(sql, dblist.ToArray());

            return(View());
        }
 private void SetReceiveUserList(WF_WORKFLOW_INST workflowRow, IUnitOfData source)
 {
     try
     {
         QuoteIdList          list = new QuoteIdList();
         int                  count;
         IActor               actorPlug = AtawIocContext.Current.FetchInstance <IActor>(ActorRegName);
         IEnumerable <string> actors    = actorPlug.GetActors(workflowRow, source);
         list.Add(actors);
         workflowRow.WI_RECEIVE_LIST  = list.ToString(out count);
         workflowRow.WI_RECEIVE_COUNT = count;
         if (count == 0)
         {
             throw new NoActorException(this, Error, new Exception("找不到一个人"));
         }
     }
     catch (Exception ex)
     {
         throw new NoActorException(this, Error, ex);
     }
 }
Example #5
0
        public static bool BackStep(Workflow workflow, StepConfig backStep)
        {
            var workflowRow = workflow.WorkflowRow;
            var source      = workflow.Source as WorkflowDbContext;

            var stepInst = GetBackStep(workflow, backStep);

            var newStepInst = new WF_STEP_INST();

            source.WF_STEP_INST.Add(newStepInst);
            CopyWorkflowToStep(source, workflow.WorkflowRow, newStepInst, FlowAction.Back);
            CopyManualInfo(workflow.WorkflowRow, newStepInst);
            //回退步骤 修改接收人列表 和 接收人个数
            //从步骤实例表中查询上次接收的人


            workflowRow.WI_INDEX         = stepInst.SI_INDEX;
            workflowRow.WI_RECEIVE_ID    = stepInst.SI_RECEIVE_ID;//上次接收的人
            workflowRow.WI_RECEIVE_LIST  = QuoteIdList.GetQuoteId(stepInst.SI_RECEIVE_ID);
            workflowRow.WI_RECEIVE_COUNT = 1;
            workflowRow.WI_SEND_ID       = GlobalVariable.UserId.ToString();
            workflowRow.WI_SEND_DATE     = source.Now;

            workflowRow.WI_LAST_MANUAL         = stepInst.SI_LAST_MANUAL;
            workflowRow.WI_LAST_MANUAL_NAME    = stepInst.SI_LAST_MANUAL_NAME;
            workflowRow.WI_LAST_STEP           = stepInst.SI_LAST_STEP;
            workflowRow.WI_LAST_STEP_NAME      = stepInst.SI_LAST_STEP_NAME;
            workflowRow.WI_CURRENT_CREATE_DATE = DateTime.Now;
            // stepInst.SI_VALID_FLAG = 1;
            WorkflowInstUtil.ClearError(workflowRow);
            WorkflowInstUtil.SetWorkflowByStep(workflowRow, backStep);
            WorkflowContent workflowContent = WorkflowInstUtil.CreateContent(workflow.WorkflowRow);

            workflowContent.SetMainRowStatus(source, backStep);
            backStep.Prepare(workflowRow, source);
            source.Submit();
            return(true);
        }
Example #6
0
        public Workflow(IUnitOfData source, string name, RegNameList <KeyValueItem> parameter, string createUser,
                        int?parentId)
            : this(source)
        {
            //  Source = source;
            WorkflowDbContext dbContext = source as WorkflowDbContext;
            Config      = WorkflowConfig.GetByName(name, source);
            WorkflowRow = new WF_WORKFLOW_INST();
            //WorkflowRow.BeginEdit();
            WorkflowRow.WI_ID = dbContext.GetUniId();
            //WorkflowRow["WI_ID"] = id;
            WorkflowId                 = WorkflowRow.WI_ID;
            WorkflowRow.WI_WD_NAME     = name;
            WorkflowRow.WI_CREATE_USER = createUser;
            // WorkflowRow["WI_RETRIEVABLE"] = Config.Retrievable;
            ////初始化参与人列表
            WorkflowRow.WI_REF_LIST    = QuoteIdList.GetQuoteId(createUser);
            WorkflowRow.WI_CREATE_DATE = dbContext.Now;

            BeginStep step = Config.Steps.BeginStep.CreateStep(this) as BeginStep;
            step.Parameter = parameter;
            CurrentStep    = step;
            CurrentState   = BeginNRState.Instance;
        }
Example #7
0
        public bool ProcessManualWorkflow(WF_WORKFLOW_INST workflowRow, string userId)
        {
            WorkflowDbContext dbContext = Source as WorkflowDbContext;
            StepState         state     = (StepState)workflowRow.WI_STATUS;

            switch (state)
            {
            case StepState.NotReceive:
                // NR:
                // 检查userId是否在接受人列表中,是接收并打开,返回true,否则返回false
                //如果接受人有多个,你只是其中的一个,并且你是上个流程的处理者,不能接收 这一点可以根据配置来.....
                string      receiveIds = workflowRow.WI_RECEIVE_LIST;
                QuoteIdList ulReceive  = QuoteIdList.LoadFromString(receiveIds);
                if (ulReceive.Contains(userId))
                {
                    bool   _isAppAutoStep = "WrokflowAutoStep".AppKv <bool>(false);
                    string _ManualAskUser = AtawAppContext.Current.GetItem("ManualAskUser").Value <string>();
                    if (ulReceive.Count > 0 && (_ManualAskUser == userId) && !_isAppAutoStep)
                    {
                        //.............
                        return(false);
                    }
                    else
                    {
                        workflowRow.WI_RECEIVE_ID   = userId;
                        workflowRow.WI_STATUS       = (int)StepState.OpenNotProcess;
                        workflowRow.WI_RECEIVE_DATE = dbContext.Now;
                        Source.Submit();
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }

            case StepState.ReceiveNotOpen:
                // RNO:
                // 检查接收人是否是userId,是打开,返回true,否则返回false
                if (userId == workflowRow.WI_RECEIVE_ID)
                {
                    workflowRow.WI_STATUS = (int)StepState.OpenNotProcess;
                    Source.Submit();
                    return(true);
                }
                else
                {
                    return(false);
                }

            case StepState.OpenNotProcess:
                // ONP:
                // 检查接收人是否是userId,是返回true,否则返回false
                return(userId == workflowRow.WI_RECEIVE_ID);

            default:
                AtawDebug.ThrowImpossibleCode(this);
                break;
            }

            return(false);
        }