Exemplo n.º 1
0
        /// <summary>
        /// 开始流程
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1">启动流程的应用Code</param>
        /// <param name="P2">审核人信息</param>
        /// <param name="UserInfo"></param>
        public void STARTWF(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            try
            {
                string strModelCode = P1;
                string strCSR       = context.Request("csr") ?? "";
                string strZSR       = context.Request("zsr") ?? "";
                string strContent   = context.Request("content") ?? "";



                int PDID = 0;
                int.TryParse(context.Request("PDID") ?? "0", out PDID);
                Yan_WF_PD PD = new Yan_WF_PDB().GetEntity(d => d.ID == PDID && d.ComId == UserInfo.User.ComId);

                if (PD == null)
                {
                    //没有流程,直接返回
                    return;
                }
                Yan_WF_PIB    PIB          = new Yan_WF_PIB();
                List <string> ListNextUser = new List <string>();//获取下一任务的处理人
                Yan_WF_PI     PI           = new Yan_WF_PI();
                PI.CRUserName   = UserInfo.User.UserRealName;
                PI.BranchName   = UserInfo.BranchInfo.DeptName;
                PI.BranchNO     = UserInfo.BranchInfo.DeptCode;
                PI.Content      = strContent;
                PI.PDID         = PD.ID;
                PI.WFFormNum    = new Yan_WF_PIB().CreateWFNum(PI.PDID.ToString());
                PI.ComId        = PD.ComId;
                PI.StartTime    = DateTime.Now;
                PI.CRUser       = UserInfo.User.UserName;
                PI.CRDate       = DateTime.Now;
                PI.PITYPE       = PD.ProcessType;
                PI.ChaoSongUser = strCSR;
                PI.isGD         = "N";
                new Yan_WF_PIB().Insert(PI);



                Yan_WF_TI TI = PIB.StartWF(PD, strModelCode, UserInfo.User.UserName, strZSR, strCSR, PI, ref ListNextUser);

                //返回新增的任务
                msg.Result  = PI;
                msg.Result1 = TI;


                //发送消息给审核人员
                string jsr = ListNextUser.ListTOString(',');
                if (!string.IsNullOrEmpty(jsr))
                {
                    SZHL_TXSX TX = new SZHL_TXSX();
                    TX.Date               = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    TX.APIName            = "FORMBI";
                    TX.ComId              = UserInfo.User.ComId;
                    TX.FunName            = "LCSPCHECK";
                    TX.intProcessStanceid = TI.PIID;
                    TX.CRUserRealName     = UserInfo.User.UserRealName;
                    TX.MsgID              = TI.PIID.ToString();
                    TX.TXContent          = UserInfo.User.UserRealName + "发起了一个" + PD.ProcessName + ",请您查阅审核";
                    TX.TXUser             = jsr;
                    TX.TXMode             = strModelCode;
                    TX.CRUser             = UserInfo.User.UserName;
                    TXSXAPI.AddALERT(TX); //时间为发送时间
                }
                //发送消息
            }
            catch (Exception ex)
            {
                msg.ErrorMsg = ex.Message;
            }
        }
Exemplo n.º 2
0
        public void MANAGEWF(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            try
            {
                string strShUser  = context.Request("SHUser") ?? "";
                string strCSUser  = context.Request("csr") ?? "";
                string modelcode  = context.Request("formcode") ?? "";
                string strContent = context.Request("content") ?? "";

                int PID = int.Parse(P1);



                Yan_WF_PIB PIB = new Yan_WF_PIB();
                if (PIB.isCanSP(UserInfo.User.UserName, PID) == "Y")//先判断用户能不能处理此流程
                {
                    List <string> ListNextUser = new List <string>();
                    PIB.MANAGEWF(UserInfo.User.UserName, PID, P2, ref ListNextUser, strShUser);//处理任务
                    Yan_WF_PI PI = PIB.GetEntity(d => d.ID == PID);
                    //更新抄送人
                    PI.ChaoSongUser = strCSUser;
                    PIB.Update(PI);
                    //更新抄送人

                    Yan_WF_PD PD = new Yan_WF_PDB().GetEntity(d => d.ID == PI.PDID.Value);

                    string content   = PI.CRUserName + "发起了" + PD.ProcessName + "表单,等待您审阅";
                    string strTXUser = ListNextUser.ListTOString(',');
                    string funName   = "LCSPCHECK";
                    //添加消息提醒
                    string strIsComplete = ListNextUser.Count() == 0 ? "Y" : "N"; //结束流程,找不到人了
                    if (strIsComplete == "Y")                                     //找不到下家就结束流程,并且给流程发起人发送消息
                    {
                        PIB.ENDWF(PID);
                        msg.Result = "Y";//已结束
                        content    = UserInfo.User.UserRealName + "审批完成了您发起的" + PD.ProcessName + "表单";
                        strTXUser  = PI.CRUser;
                        funName    = "LCSPCHECK";
                        //发送消息给抄送人
                        if (!string.IsNullOrEmpty(PI.ChaoSongUser))
                        {
                            SZHL_TXSX CSTX = new SZHL_TXSX();
                            CSTX.Date               = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            CSTX.APIName            = "FORMBI";
                            CSTX.ComId              = UserInfo.User.ComId;
                            CSTX.FunName            = "LCSPCHECK";
                            CSTX.intProcessStanceid = PID;
                            CSTX.CRUserRealName     = UserInfo.User.UserRealName;
                            CSTX.MsgID              = PID.ToString();
                            CSTX.TXContent          = new JH_Auth_UserB().GetEntity(p => p.ComId == PI.ComId && p.UserName == PI.CRUser).UserRealName + "抄送一个" + PD.ProcessName + ",请您查阅接收";
                            CSTX.ISCS               = "Y";
                            CSTX.TXUser             = PI.ChaoSongUser;
                            CSTX.TXMode             = modelcode;
                            CSTX.CRUser             = UserInfo.User.UserName;
                            TXSXAPI.AddALERT(CSTX); //时间为发送时间
                        }
                    }
                    SZHL_TXSX TX = new SZHL_TXSX();
                    TX.Date               = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    TX.APIName            = "FORMBI";
                    TX.ComId              = UserInfo.User.ComId;
                    TX.FunName            = funName;
                    TX.intProcessStanceid = PID;
                    TX.CRUser             = PI.CRUser;
                    TX.CRUserRealName     = UserInfo.User.UserRealName;
                    TX.MsgID              = PID.ToString();
                    TX.TXContent          = content;
                    TX.TXUser             = strTXUser;
                    TX.TXMode             = modelcode;
                    TXSXAPI.AddALERT(TX); //时间为发送时间
                }
                else
                {
                    msg.ErrorMsg = "该流程已被处理,您已无法处理此流程";
                }
            }
            catch (Exception ex)
            {
                msg.ErrorMsg = ex.Message;
            }
        }