Example #1
0
        public string WF_Submit(Case_WorkFlowClass workflow)
        {
            string FunctionName  = workflow.FunctionName;  //具体表名
            string WFID          = workflow.WFID;          //工作流编号
            string WFDID         = workflow.WFDID;         //工作流环节编号
            string WFSID         = workflow.WFSID;         //活动实例编号
            string WFSAID        = workflow.WFSAID;        //当前环节实例编号
            string dealContent   = workflow.DEALCONTENT;   //会签意见
            string NextWFDID     = workflow.NextWFDID;     //下一个环节编号
            string NextWFUSERIDS = workflow.NextWFUSERIDS; //获取下一个环节的用户
            string IsSendMsg     = workflow.IsSendMsg;     //是否发送短信


            int?     casetype     = workflow.casetype;     //案件类型
            int?     casesourceid = workflow.casesourceid; //案件来源
            string   casebh       = workflow.casebh;       //立案编号
            string   casereason   = workflow.casereason;   //案由
            string   casetypeid   = workflow.casetypeid;   //案件类型
            string   contact      = workflow.contact;      //联系人
            string   contactphone = workflow.contactphone; //联系电话
            string   address      = workflow.address;      //案发地址
            string   cswfsid      = workflow.cswfsid;      //案源表标识
            string   casemode     = workflow.casemode;     //一般案件状态
            string   casestatus   = workflow.casestatus;   //案件属于类型
            int?     caseid       = workflow.caseid;
            DateTime?stime        = workflow.STIME;
            DateTime?etime        = workflow.ETIME;


            #region 检查是否存在当前实例,如果不存在则增加当前活动实例
            case_workflowdetails cwfsmodel = new Case_WorkFlowDetailsDAL().GetSingle(NextWFDID);
            string wfsname = cwfsmodel.wfdname;//活动流程名称
            case_workflowspecifics WFSModel = null;
            if (!string.IsNullOrEmpty(workflow.WFSID))
            {
                WFSModel = new Case_WorkFlowSpecificsDAL().GetSingle(workflow.WFSID);
                if (WFSModel == null)
                {
                    WFSID = "";
                }
                else
                {
                    WFSModel.wfsname = wfsname;
                    new Case_WorkFlowSpecificsDAL().Update(WFSModel);
                }
            }

            if (string.IsNullOrEmpty(WFSID))
            {
                WFSModel               = new case_workflowspecifics();
                WFSModel.wfsid         = GetNewId();
                WFSModel.wfid          = WFID;
                WFSModel.createuserid  = workflow.WFCreateUserID;
                WFSModel.createtime    = DateTime.Now;
                WFSModel.status        = 1;
                WFSModel.wfsname       = wfsname;
                WFSModel.currentwfsaid = WFDID;
                WFSModel.filestatus    = 1;
                WFSModel.casetype      = casetype;
                WFSModel.casebh        = casebh;
                WFSModel.casesourceid  = casesourceid;
                WFSModel.casereason    = casereason;
                WFSModel.casetypeid    = casetypeid;
                WFSModel.contact       = contact;
                WFSModel.contactphone  = contactphone;
                WFSModel.address       = address;
                WFSModel.cswfsid       = cswfsid;
                WFSModel.casemode      = casemode;
                WFSModel.caseid        = caseid;
                WFSModel.casestatus    = casestatus;
                new Case_WorkFlowSpecificsDAL().Add(WFSModel);
                WFSID = WFSModel.wfsid;
            }
            #endregion
            string  wfdname = "当前环节名称";
            decimal oldStatus;//当前环节是否已经处理完成 1:未处理,2已经处理
            //更新或者增加当前流程的具体事例---返回当前环节编号
            WFSAID = function_Case_DealCurentActivity(WFSAID, WFSID, workflow.WFCreateUserID.Value, 2, WFDID, out oldStatus, stime, etime);
            //更新或者增加当前环节用户处理的意见---返回当前环节用户需要处理的编号
            string WFSUID = function_WF_DealCurentActivityUser(WFSAID, workflow.WFCreateUserID.Value, dealContent, 2, DateTime.Now, "false", wfsname, workflow.WFCreateUserID.Value);
            #region 附件处理
            //增加当前处理用户的附件
            //switch (workflow.FunctionName)
            //{
            //    case "case_casesources"://案源管理
            //        function_Case_WorkFlowAttrach_smsj(WFSAID, workflow.WfsasModel);
            //        break;
            //    default:
            //        break;
            //}
            #endregion

            //当前状态为处理,则说明是第一个人处理,则需要增加下一个环节,如果当前环节已经处理,则不需要增加下一个环节
            string NextWFSAID = "";
            if (oldStatus == 1)
            {
                //获取该环节是否为最后一个环节
                case_workflowdetails wfdModel = new Case_WorkFlowDetailsDAL().GetSingle(NextWFDID);
                //如果下一个环节的子环节存在,则状态为执行中,内容为空,否则下一个环节状态为结束,内容为已结束
                int    status_wfsa  = 0;
                string content_wfsa = string.Empty;
                if (wfdModel != null && !string.IsNullOrEmpty(wfdModel.nextid))
                {
                    status_wfsa  = 1;
                    content_wfsa = "";
                }
                else
                {
                    wfdname = wfdModel.wfdname;
                    //结束该流程
                    WFSModel = new Case_WorkFlowSpecificsDAL().GetSingle(WFSID);
                    if (WFSModel != null)
                    {
                        WFSModel.status = 2;
                        new Case_WorkFlowSpecificsDAL().Update(WFSModel);
                    }
                    status_wfsa  = 2;
                    content_wfsa = "已结束";
                }
                wfdname = wfdModel.wfdname;

                #region 增加下一个环节

                //增加环节
                NextWFSAID = function_Case_DealCurentActivity("", WFSID, workflow.WFCreateUserID.Value, status_wfsa, NextWFDID, out oldStatus, stime, etime);

                #region 更新活动实例的当前环节编号
                WFSModel = new Case_WorkFlowSpecificsDAL().GetSingle(WFSID);
                if (WFSModel != null)
                {
                    WFSModel.currentwfsaid = NextWFSAID;
                    WFSModel.status        = status_wfsa;
                    WFSModel.wfsname       = wfsname;
                    new Case_WorkFlowSpecificsDAL().Update(WFSModel);
                }
                #endregion

                //增加下一个环节的能操作的用户
                if (!string.IsNullOrEmpty(NextWFUSERIDS))
                {
                    string[] NextWFUSERIDS_split = NextWFUSERIDS.Split(',');
                    foreach (var item in NextWFUSERIDS_split)
                    {
                        decimal  userid;
                        DateTime?dealTime = null;
                        if (decimal.TryParse(item, out userid))
                        {
                            if (status_wfsa == 2)
                            {
                                userid    = workflow.WFCreateUserID.Value;
                                dealTime  = DateTime.Now;
                                IsSendMsg = "false";
                            }
                            //增加流程能操作的用户
                            function_WF_DealCurentActivityUser(NextWFSAID, (int)userid, content_wfsa, status_wfsa, dealTime, IsSendMsg, wfsname, workflow.WFCreateUserID);
                        }
                    }
                }

                #endregion
            }
            return("\"wfsid\":\"" + WFSID + "\",\"wfsaid\":\"" + WFSAID + "\",\"nextwfsaid\":\"" + NextWFSAID + "\",\"wfdid\":\"" + WFDID + "\",\"wfdname\":\"" + wfdname + "\"");
        }
Example #2
0
        /// <summary>
        /// 活动流程
        /// </summary>
        /// <param name="WFID">流程ID</param>
        /// <param name="WFSID">实例编号</param>
        /// <returns></returns>
        public Casr_WorkFlowClass ProcessIndex(string WFID, string WFDID)//, string WFSID, string WFSAID)
        {
            Casr_WorkFlowClass   workflow = new Casr_WorkFlowClass();
            List <nextwfdidname> list     = new List <nextwfdidname>();

            if (!string.IsNullOrEmpty(WFID))
            {
                IList <case_workflowdetails> wfdList = new Case_WorkFlowDetailsDAL().GetList().Where(a => a.wfid == WFID).ToList();//获取当前流程所有环节
                if (wfdList == null && wfdList.Count() <= 0)
                {
                    workflow.WorkFlowState = 2;
                    return(workflow);
                }
                #region 获取下一步流程

                //下一步流程编号集合 格式为:【,流程编号,流程编号,流程编号,】
                string nextWFDIDS             = string.Empty;
                case_workflowdetails wfdModel = new Case_WorkFlowDetailsDAL().GetSingle(WFDID);
                if (wfdModel != null)
                {
                    nextWFDIDS = wfdModel.nextid;
                }
                else
                {
                    workflow.WorkFlowState = 2;
                    return(workflow);
                }
                workflow.wfdname = wfdModel.wfdname;
                workflow.wfdid   = wfdModel.wfdid;
                if (!string.IsNullOrEmpty(nextWFDIDS))
                {
                    #region  一步的所有流程
                    //下一步流程 格式为:【;流程编号,流程名称,是否有下一个流程;流程编号,流程名称,是否有下一个流程;流程编号,流程名称,是否有下一个流程;】
                    string[] nextWFDIDS_split = nextWFDIDS.Split(',');
                    foreach (string NEXTID in nextWFDIDS_split)
                    {
                        nextwfdidname nextmodel = new nextwfdidname();
                        if (!string.IsNullOrEmpty(NEXTID))
                        {
                            //string temp = "";
                            string WFDNAME = string.Empty;
                            case_workflowdetails wfdMpdel = wfdList.FirstOrDefault(a => a.wfdid == NEXTID);
                            if (wfdMpdel == null || string.IsNullOrEmpty(wfdMpdel.wfdname))
                            {
                                workflow.WorkFlowState = 2;
                                return(workflow);
                            }
                            else
                            {
                                WFDNAME = wfdMpdel.wfdname;
                            }
                            nextmodel.nextid     = NEXTID;
                            nextmodel.wfdname    = wfdMpdel.wfdname;
                            nextmodel.nextroleid = wfdMpdel.nextroleid;
                            nextmodel.nextunitid = wfdMpdel.nextunitid;
                            list.Add(nextmodel);
                        }
                    }
                    workflow.nextwfdidname = list;//下一步流程
                    #endregion
                }
                #endregion
            }
            return(workflow);
        }