Пример #1
0
        /// <summary>
        /// 修改计划状态为进行中
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="instance"></param>
        /// <param name="stepTran"></param>
        public void ExecuteTran(int UserId, BsonDocument instance, BsonDocument stepTran)
        {
            var DataOp = new DataOperation();

            if (instance != null)
            {
                FlowInstanceHelper helper = new FlowInstanceHelper();
                SendFinishMsg      msg    = new SendFinishMsg();

                var currentInstrance = DataOp.FindOneByKeyVal("BusFlowInstance", "flowInstanceId", instance.String("flowInstanceId"));
                var userIdListInt    = helper.GetFlowInstanceAssociateUser(instance.Int("flowId"), instance.Int("flowInstanceId"));
                userIdListInt.Add(instance.Int("approvalUserId"));
                List <string> userIdList = (from t in userIdListInt
                                            select t.ToString()).Distinct().ToList();
                var userList = DataOp.FindAllByKeyValList("SysUser", "userId", userIdList);     //获取流程涉及的所有人员

                string          smsTemple   = "您{0}的流程已被审批通过: {1}项目 {2}任务";
                BsonDocument    task        = DataOp.FindOneByKeyVal("XH_DesignManage_Task", "taskId", instance.Text("referFieldValue"));
                BsonDocument    project     = DataOp.FindOneByKeyVal("XH_DesignManage_Project", "projId", task.Text("projId"));
                BsonDocument    user        = DataOp.FindOneByKeyVal("SysUser", "userId", UserId.ToString());
                BsonDocument    trace       = DataOp.FindAllByKeyVal("BusFlowTrace", "flowInstanceId", instance.Text("flowInstanceId")).OrderByDescending(t => t.Date("createDate")).FirstOrDefault();
                List <SmsClass> smsSendList = new List <SmsClass>();
                foreach (var item in userList)
                {
                    SmsClass smsc = new SmsClass();
                    if (!string.IsNullOrEmpty(item.Text("mobileNumber")))
                    {
                        smsc.mobileNumber = item.Text("mobileNumber");
                        if (item.Int("userId") == instance.Int("approvalUserId"))
                        {
                            smsc.content = string.Format(smsTemple, "发起", project.Text("name"), task.Text("name"));
                        }
                        else
                        {
                            smsc.content = string.Format(smsTemple, "参与", project.Text("name"), task.Text("name"));;
                        }

                        smsSendList.Add(smsc);
                    }
                }

                msg.Send1(smsSendList);
            }
        }
Пример #2
0
        public JsonResult SendCheckCode(string username, string operationtype)
        {                                               //operationtype0,注册;1修改密码
            StatusData myStatusData = new StatusData(); //返回状态

            //
            #region 手机号错误
            if (!FunctionClass.isMobilePhone(username))
            {//手机号规则判断
                myStatusData.operateStatus = 400;
                myStatusData.operateMsg    = "手机号错误";
                return(Json(myStatusData));
            }
            #endregion
            //
            DateTime myNowDate     = DateTime.Now;
            DateTime myExpiredDate = DateTime.Now;
            //验证码有效期---调试屏蔽
            myExpiredDate = DateTime.Now.AddSeconds(int.Parse(StaticVarClass.CheckCodeExpiredDate));
            //
            string myMsg = FunctionClass.RandomCode();
            //
            try
            {
                bool allowSend = false;
                using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作
                {
                    if (String.IsNullOrWhiteSpace(operationtype))
                    {
                        operationtype = "";
                    }
                    #region 发送验证码的类型判断
                    int isExist = 0;//
                    switch (operationtype)
                    {
                    case "0":    //注册
                        isExist = myOperating.User_UserName.Count(p => p.MobilePhone == username);
                        if (isExist > 0)
                        {
                            allowSend = false;
                            myStatusData.operateStatus = 7;
                        }
                        else
                        {
                            allowSend = true;
                        }
                        //allowSend = true;
                        break;

                    case "1":    //修改密码
                        isExist = myOperating.User_UserName.Count(p => p.MobilePhone == username);
                        if (isExist > 0)
                        {
                            allowSend = true;
                        }
                        else
                        {
                            myStatusData.operateStatus = 400;
                            myStatusData.operateMsg    = "该号码不存在";
                            allowSend = false;
                        }
                        break;

                    default:
                        myStatusData.operateStatus = 400;
                        myStatusData.operateMsg    = "参数错误";
                        allowSend = false;
                        break;
                    }
                    #endregion
                    //
                    if (allowSend)
                    {
                        #region 发送验证码
                        bool IsSendOk = true;
                        //
                        int deleteNum = myOperating.User_CheckCode.Where(p => p.ExpiredDate < myNowDate).Delete();
                        if (deleteNum > 0)
                        {
                            EFCachClear.ClearTable("User_CheckCode");
                        }
                        //
                        User_CheckCode myCheckCode = new User_CheckCode();
                        myCheckCode = myOperating.User_CheckCode.FirstOrDefault(p => p.MobilePhone == username);
                        if (myCheckCode != null)
                        {
                            if (myCheckCode.AddDate > myNowDate.AddMinutes(-1))
                            {
                                myStatusData.operateStatus = 0;
                                myStatusData.operateMsg    = "不能频繁操作,稍后重试";
                            }
                            else
                            {
                                SmsClass mySmsClass = new SmsClass();
                                IsSendOk = mySmsClass.sendSmsMsg(username, 0, myMsg);
                                //
                                if (IsSendOk)
                                {
                                    myCheckCode.CheckCode   = myMsg;
                                    myCheckCode.ExpiredDate = myExpiredDate;
                                    myCheckCode.AddDate     = myNowDate;
                                    myCheckCode.AlreadCheck = false;
                                    myOperating.SaveChanges();
                                    //
                                    myStatusData.operateStatus = 200;
                                    myStatusData.operateMsg    = "完成";
                                }
                                else
                                {
                                    myStatusData.operateStatus = 0;
                                    myStatusData.operateMsg    = "发送失败!请重试";
                                }
                            }
                        }
                        else
                        {
                            //调试暂时屏蔽
                            SmsClass mySmsClass = new SmsClass();
                            IsSendOk = mySmsClass.sendSmsMsg(username, 0, myMsg);
                            //
                            if (IsSendOk)
                            {
                                User_CheckCode newCheckCode = new User_CheckCode();
                                newCheckCode.MobilePhone = username;
                                newCheckCode.CheckCode   = myMsg;
                                newCheckCode.ExpiredDate = myExpiredDate;
                                newCheckCode.AddDate     = myNowDate;
                                newCheckCode.AlreadCheck = false;
                                myOperating.User_CheckCode.Add(newCheckCode);
                                myOperating.SaveChanges();
                                //
                                myStatusData.operateStatus = 200;
                                myStatusData.operateMsg    = "完成";
                            }
                            else
                            {
                                myStatusData.operateStatus = 0;
                                myStatusData.operateMsg    = "发送失败!请重试";
                            }
                        }
                        #endregion
                    }
                }
            }
            catch
            {
                myStatusData.operateStatus = -1;
                throw;
            }
            return(Json(myStatusData));
        }
Пример #3
0
 public SmsRepository()
 {
     _smsClass = new SmsClass();
 }
Пример #4
0
        /// <summary>
        /// 对所有流程人员发送消息
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="instance"></param>
        /// <param name="stepTran"></param>
        public void ExecuteTran(int UserId, BsonDocument instance, BsonDocument stepTran)
        {
            var DataOp = new DataOperation();

            if (instance != null)
            {
                FlowInstanceHelper helper = new FlowInstanceHelper();


                var currentInstrance = DataOp.FindOneByKeyVal("BusFlowInstance", "flowInstanceId", instance.String("flowInstanceId"));
                var stepObj          = currentInstrance.SourceBson("stepId");
                var userIdListInt    = new List <int>();
                if (stepObj != null && stepObj.Int("actTypeId") == (int)FlowActionType.Launch)
                {
                    userIdListInt.Add(currentInstrance.Int("approvalUserId"));
                }
                else
                {
                    userIdListInt = helper.GetFlowInstanceAvaiableStepUser(instance.Int("flowId"), instance.Int("flowInstanceId"), currentInstrance.Int("stepId"));
                }
                List <string> userIdList = new List <string>();
                userIdList = (from t in userIdListInt
                              select t.ToString()).Distinct().ToList();
                //userIdList.Add(instance.Text("approvalUserId"));
                var userList = DataOp.FindAllByKeyValList("SysUser", "userId", userIdList); //获取流程涉及的所有人员


                //string strPre = "参与的";
                bool         isSend    = true;
                string       smsTemple = "请审批{0}提交的流程:{1}项目 {2}任务";//"您{4}流程{3}已被{0}审批通过: {1}项目 {2}任务";
                BsonDocument task      = DataOp.FindOneByKeyVal("XH_DesignManage_Task", "taskId", instance.Text("referFieldValue"));
                BsonDocument project   = DataOp.FindOneByKeyVal("XH_DesignManage_Project", "projId", task.Text("projId"));
                BsonDocument user      = DataOp.FindOneByKeyVal("SysUser", "userId", UserId.ToString());
                string       content   = string.Format(smsTemple, user.Text("name"), project.Text("name"), task.Text("name"), instance.Text("instanceName"));
                BsonDocument trace     = DataOp.FindAllByKeyVal("BusFlowTrace", "flowInstanceId", instance.Text("flowInstanceId")).OrderByDescending(t => t.Date("createDate")).FirstOrDefault();
                string       actId     = trace != null?trace.Text("actId") : "0";

                List <string>   numList     = new List <string>();
                List <SmsClass> smsSendList = new List <SmsClass>();

                if (trace.Int("traceType") == 0 || trace.Int("traceType") == -1)  // 发起审批
                {
                    smsTemple = "请审批{0}提交的流程:{1}项目 {2}任务";
                    content   = string.Format(smsTemple, user.Text("name"), project.Text("name"), task.Text("name"), instance.Text("instanceName"));
                    isSend    = false; //不对发起人发送发起短信
                }
                else
                {
                    if (actId != "0")
                    {
                        BsonDocument action = DataOp.FindOneByKeyVal("BusFlowAction", "actId", actId); //驳回审批
                        if (action.Int("type") == 3)
                        {
                            smsTemple = "您正在处理的流程已被{0}驳回: {1}项目 {2}任务";// "您{4}流程{3}已被{0}审批驳回: {1}项目 {2}任务";
                            content   = string.Format(smsTemple, user.Text("name"), project.Text("name"), task.Text("name"), instance.Text("instanceName"));
                        }
                    }
                }
                foreach (var item in userList)
                {
                    SmsClass smsc = new SmsClass();
                    if (!string.IsNullOrEmpty(item.Text("mobileNumber")))
                    {
                        numList.Add(item.Text("mobileNumber"));
                        smsc.mobileNumber = item.Text("mobileNumber");
                        smsc.content      = content;
                        smsSendList.Add(smsc);
                    }
                }

                //if (isSend)
                //{
                //    strPre = "发起的";
                //    string apprvoeContent = string.Format(smsTemple, user.Text("name"), project.Text("name"), task.Text("name"), instance.Text("instanceName"), strPre);
                //    var apprUser = userList.Where(t => t.Int("userId") == instance.Int("approvalUserId")).FirstOrDefault();
                //    if (!string.IsNullOrEmpty(apprUser.Text("mobileNumber")))
                //    {
                //        SmsClass smsc = new SmsClass();
                //        smsc.mobileNumber = apprUser.Text("mobileNumber");
                //        smsc.content = apprvoeContent;
                //        smsSendList.Add(smsc);

                //    }
                //}

                Send1(smsSendList);
            }
        }