Exemplo n.º 1
0
 public List<string> GetEmployeeIDsByPostID(string postID)
 {
     using (EmployeeBLL bll = new EmployeeBLL())
     {
         var q = bll.GetEmployeeIDsByPostID(postID);
         return q.Count() > 0 ? q.ToList() : null;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 非默认消息时,自动发起流程
        /// </summary>
        private void AutoCallFlow( EnginFlowDAL dal, T_WF_DOTASK Entity, DataTable dtFlowTrigger, DataTable sourceTable, ref FlowUser sUser,string strAppFieldValue, ref string ErroMessage)
        {
            DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务
            if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0)
            {
                #region 非默认消息时,自动发起流程
                foreach (DataRow dr1 in NotDefaultMsg)
                {
                    string strAppMsg = string.Empty;
                    CallWCFService( dr1, sourceTable, ref sUser, ref strAppMsg, ref  ErroMessage);//调用WCF服务
                    if (!string.IsNullOrEmpty(strAppMsg))
                    {
                        #region 执行自动发起流程结果返回不为空
                        try
                        {
                            string IsNewFlow = "1";
                            string NewFormID = string.Empty;
                            string strFormTypes = string.Empty;//表单状态
                            DataRow DRNewTrigger = null;
                            if (ApplicationValueToDataTable( strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger))
                            {
                                //通过岗位查找用户,并且取第一个用户为发送消息的对像

                                //PersonnelServiceClient HRClient = new PersonnelServiceClient();
                                if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString()))
                                {
                                    if (DRNewTrigger != null)
                                    {
                                        Tracer.Debug("自动发起流程 消息规则设置中 选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ":MODELCODE=" + string.Concat(DRNewTrigger["MODELCODE"]) + ";AutoCallFlow() FORMID=" + sUser.FormID);
                                    }
                                    else
                                    {
                                        Tracer.Debug("DRNewTrigger=null 自动发起流程的第三方消息规则中没有设置没有消息规则,当前的模块消息规则设置中 选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ":MODELCODE=null;AutoCallFlow() FORMID=" + sUser.FormID);
                                    }
                                    List<string> Employees = new List<string>();// HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());

                                    using (EmployeeBLL bll = new EmployeeBLL())
                                    {
                                        var q = bll.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString());
                                        Employees= q.Count() > 0 ? q.ToList() : null;
                                    }
                                    if (Employees != null && Employees.Count() > 0)
                                    {
                                        Entity.SYSTEMCODE = dr1["SYSTEMCODE"].ToString();//解决傅意成遇到的问题(发起员工入职手续的待办,数据库中数据存在问题,系统代号是错误的RM代号,应是HR代号)
                                        dal.AddDoTask( Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息
                                        //FlowEngine.TaskCacheReflesh(Employees[0]);
                                    }
                                }
                                else
                                {
                                    string cMessage = "";
                                    if (DRNewTrigger != null)
                                    {
                                        cMessage = "SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID;
                                    }
                                    else
                                    {
                                        cMessage = "DRNewTrigger=null 消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID;
                                    }
                                    //string cMessage = "SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID;
                                    ErroMessage = cMessage;

                                    if (DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_businesstrip" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_businessreport" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_salaryrecordbatch" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_attendancesolutionasign" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_attendancesolution" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_employeesalaryrecord" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_employeeentry" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_leftoffice" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_travelreimbursement" ||
                                        DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_leftofficeconfirm"
                                        )
                                    {//不需要接收岗位的:
                                        //出差申请	T_OA_BUSINESSTRIP
                                        //出差报告	T_OA_BUSINESSREPORT
                                        //月薪批量审核	T_HR_SALARYRECORDBATCH
                                        //考勤方案分配	T_HR_ATTENDANCESOLUTIONASIGN
                                        //考勤方案定义	T_HR_ATTENDANCESOLUTION
                                        //薪资记录	T_HR_EMPLOYEESALARYRECORD
                                        //员工入职	T_HR_EMPLOYEEENTRY
                                        //员工离职	T_HR_LEFTOFFICE
                                        //离职确认	T_HR_LEFTOFFICECONFIRM
                                        //出差报销 T_OA_TRAVELREIMBURSEMENT
                                        Tracer.Debug("自动发起流程 消息规则中非默认的设置中 不需要 选定岗位: AutoCallFlow() FORMID=" + sUser.FormID + "   " + cMessage);
                                    }
                                    else
                                    {
                                        Tracer.Debug("自动发起流程(失败) 消息规则中非默认的设置中没有选定岗位:AutoCallFlow() FORMID=" + sUser.FormID + "   " + cMessage);
                                        throw new Exception("自动发起流程(失败) 消息规则中非默认的设置中没有选定岗位 \r\n FORMID=" + sUser.FormID);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Tracer.Debug("自动发起流程(失败):消息规则中非默认的设置中检查选定岗位出错 消息=" + string.Concat(dr1["MESSAGEBODY"]) + " AutoCallFlow() FORMID=" + sUser.FormID + " 异常信息:\r\n" + ex.Message);
                            throw new Exception("自动发起流程(失败):消息规则中非默认的设置中检查选定岗位出错 \r\n FORMID=" + sUser.FormID);
                        }
                        #endregion
                    }
                    else
                    {
                        Tracer.Debug("自动发起流程成功,但返回的结果为空 消息规则设置中 ;选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ";MODELCODE=" + string.Concat(dr1["MODELCODE"]) + ":AutoCallFlow() FORMID=" + sUser.FormID);
                    }
                }
                #endregion
            }
        }