示例#1
0
        public void Approve()
        {
            //更新状态
            F_INST_WORKITEM inst = DAL.WorkFlow.WorkItemInstance.Get(this.ID);

            inst.AppValue  = this.AppValue;
            inst.AppRemark = this.AppRemark;
            inst.Actorid   = this.Actorid;
            inst.EndDate   = DateTime.Now;
            inst.State     = WorkItemState.Completed;

            DAL.WorkFlow.WorkItemInstance.Save(inst);


            //调用表单Action
            bool isInner    = this.ActivityInstance.FlowInstance.FlowDefine.IsInner;
            int  flowId     = this.ActivityInstance.FlowInstance.FlowDefine.ID;
            int  flowNo     = this.ActivityInstance.FlowInstance.FlowNo;
            int  activityId = this.ActivityInstance.Activity.ID;

            FlowAction <IApprove> flowAction = new FlowAction <IApprove>(isInner, flowId);

            if (flowAction.action != null)
            {
                if (!flowAction.action.ApproveAction(flowId, flowNo, activityId, this.Actorid, this.AppValue, this.AppRemark))
                {
                    throw new Exception(string.Format("ApproveAction失败,flowId{0},flowNo{1},activityId{2},this.Actorid{3},AppValue{4}", flowId, flowNo, activityId, Actorid, AppValue));
                }
            }
        }
示例#2
0
        public static void Update(object sender, ApproveEventArgs args)
        {
            FlowAction <IComplete> flowAction = new FlowAction <IComplete>(args.IsInner, args.FlowId);

            if (flowAction.action != null)
            {
                if (!flowAction.action.Complete(args.FlowNo, args.AppValue))
                {
                    throw new Exception(string.Format("回写失败,flowId{0},flowNo{1},AppValue{2}", args.FlowId, args.FlowNo, args.AppValue));
                }
            }
            //else
            //{
            //    throw new Exception(string.Format("没有配置回写,flowId{0},flowNo{1},AppValue{2}", args.FlowId, args.FlowNo, args.AppValue));
            //}
        }
示例#3
0
        /// <summary>
        /// 验证摘要
        /// </summary>
        /// <returns></returns>
        public bool VerifyDigest()
        {
            FlowAction <IFormDigest> flowAction = new FlowAction <IFormDigest>(this.FlowDefine.IsInner, this.FlowDefine.ID);

            if (flowAction.action != null)
            {
                string formDigest = flowAction.action.GetFormDigest(this.FlowNo);

                if (formDigest == this.FormDigest)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
示例#4
0
文件: Engine.cs 项目: bertyang/Mobile
        /// <summary>
        /// 转交一下步
        /// </summary>
        /// <param name="flowInstId">流程实例id</param>
        /// <param name="listToActivityId">下一步关卡list</param>
        /// <returns>是否成功</returns>
        public bool TransferBack(int activityInstId, List <int> listToActivityId)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
            {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                try
                {
                    //初始化变量
                    ActivityInstance instActivity = new ActivityInstance(activityInstId);

                    FlowInstance instFlow = instActivity.FlowInstance;

                    instActivity.Close();


                    //实例化后面的关卡
                    foreach (int activityId in listToActivityId)
                    {
                        //检查关卡是否被实例化过
                        ActivityInstance instToActivity = instFlow.FindActivityInstance(activityId);

                        if (instToActivity == null || instToActivity.State == ActivityInstanceStatus.Completed)
                        {
                            instToActivity = new ActivityInstance();

                            instToActivity.Create(instFlow.ID, activityId);
                        }

                        //检查前置关卡完成情况
                        if (instToActivity.CheckFrontActivityState())
                        {
                            //如果是结束关卡,关闭关卡实例
                            if (instToActivity.Activity.Type == ActivityType.END)
                            {
                                instFlow.ApprovePass += new FlowInstance.ApproveEventHandler(Mail.SendMail);

                                instFlow.ApprovePass += new FlowInstance.ApproveEventHandler(CallBack.Update);

                                instToActivity.Close();

                                instFlow.Pass();
                            }

                            //如果不是结束关卡,激活关卡并分配工作
                            else
                            {
                                instToActivity.Active();

                                instToActivity.AssignWork();
                            }

                            //关闭与前置关卡平行的关卡
                            List <ActivityInstance> listParallelActivity =
                                instFlow.ActivityInstances.Where(
                                    t => t.State == ActivityInstanceStatus.Active &&
                                    t.Activity.ID != instToActivity.Activity.ID).ToList();

                            foreach (ActivityInstance p in listParallelActivity)
                            {
                                p.Close();
                            }
                        }
                        else
                        {
                            instToActivity.Pending(); //前置关卡未完成,搁置状态
                        }
                    }


                    if (instActivity.Activity.Type == ActivityType.START)
                    {
                        instFlow.Active();

                        //调用表单申请Action
                        FlowAction <IApply> flowAction = new FlowAction <IApply>(instFlow.FlowDefine.IsInner, instFlow.FlowDefine.ID);

                        if (flowAction.action != null)
                        {
                            if (!flowAction.action.ApplyAction(instFlow.FlowDefine.ID, instFlow.FlowNo, instFlow.ApplerID))
                            {
                                throw new Exception(string.Format("ApplyAction失败,flowId:{0},flowNo:{1},ApplerID:{2}", instFlow.FlowDefine.ID, instFlow.FlowNo, instFlow.ApplerID));
                            }
                        }

                        //知会
                        List <F_FLOW_CONFIG> listConfig = DAL.WorkFlow.Flow.GetFlowConfig(instFlow.FlowDefine.ID, "Notice");

                        List <int> listWorkerId = new List <int>();

                        foreach (F_FLOW_CONFIG config in listConfig)
                        {
                            listWorkerId.Add(int.Parse(config.ItemValue));
                        }

                        new Flow().Notify(instFlow.FlowDefine.ID, instFlow.FlowNo, listWorkerId);
                    }

                    scope.Complete();

                    return(true);
                }
                catch (Exception ex)
                {
                    Log4Net.LogError("Workflow_Engine", string.Format("ActivityInstId:{0},Message:{1}", activityInstId, ex.ToString()));

                    return(false);
                }
            }
        }