protected void Page_Load(object sender, EventArgs e)
    {
        profMsg      = Profile.ProfileMsg.MsgList;
        warnMsg.Text = string.Empty;


        if (!IsPostBack)
        {
            //检查是否需要继续上次未完成的任务
            SendMsgHelper helper = new SendMsgHelper
            {
                uidUser = (Guid)Membership.GetUser(User.Identity.Name).ProviderUserKey,
            };
            if (helper.IsHasWaitingTasks())
            {
                Response.Redirect("./Submitting.aspx");
                return;
            }

            if (profMsg.Count == 0)
            {
                profMsg.Add(new WxMsg());
            }

            LoadProfMsg(0);
        }
    }
Exemple #2
0
        public ActionResult GetAuthCode(string telphone = "", string act = "")
        {
            if (!Regex.IsMatch(telphone, @"^1[3-9]+\d{9}$"))
            {
                result.msg = "手机号码格式不正确!";
                return(Json(result));
            }
            PinStore store = PinStoreBLL.SingleModel.GetStoreByPhone(telphone);

            if (store != null && act == "")
            {
                result.msg = "用户名已存在,请登陆";
                return(Json(result));
            }
            SendMsgHelper sendMsgHelper = new SendMsgHelper();
            string        authCode      = RedisUtil.Get <string>(telphone);

            if (string.IsNullOrEmpty(authCode))
            {
                authCode = EncodeHelper.CreateRandomCode(4);
            }
            bool sendResult = sendMsgHelper.AliSend(telphone, "{\"code\":\"" + authCode + "\",\"product\":\" " + Enum.GetName(typeof(SendTypeEnum), 11) + "\"}", "小未科技", 401);

            if (sendResult)
            {
                RedisUtil.Set <string>(telphone, authCode, TimeSpan.FromMinutes(5));
                result.code = 1;
                result.msg  = "验证码发送成功!";
            }
            else
            {
                result.msg = "验证码发送失败,请稍后再试!";
            }
            return(Json(result));
        }
Exemple #3
0
        public ActionResult SendSMS(int aid = 0, int storeId = 0)
        {
            try
            {
                PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, storeId);
                if (store == null)
                {
                    result.msg = "店铺不存在!";
                    return(Json(result));
                }
                C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(store.userId);
                if (userInfo == null)
                {
                    result.msg = "用户信息错误!";
                    return(Json(result));
                }
                if (string.IsNullOrEmpty(userInfo.TelePhone) || !Regex.IsMatch(userInfo.TelePhone, @"^1[3-9]+\d{9}$"))
                {
                    result.msg = "手机号码格式不正确!";
                    return(Json(result));
                }
                XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);
                if (xcx == null)
                {
                    result.msg = "小程序信息错误!";
                    return(Json(result));
                }

                SendMsgHelper sendMsgHelper = new SendMsgHelper();
                string        authCode      = RedisUtil.Get <string>(userInfo.TelePhone);
                if (string.IsNullOrEmpty(authCode))
                {
                    authCode = Utility.EncodeHelper.CreateRandomCode(4);
                }
                bool sendResult = sendMsgHelper.AliSend(userInfo.TelePhone, "{\"code\":\"" + authCode + "\",\"product\":\" " + Enum.GetName(typeof(SendTypeEnum), 11) + "\"}", "小未科技", 401);
                if (sendResult)
                {
                    RedisUtil.Set <string>(userInfo.TelePhone, authCode, TimeSpan.FromMinutes(5));
                    result.code = 1;
                    result.msg  = "验证码发送成功!";
                }
                else
                {
                    result.msg = "验证码发送失败,请稍后再试!";
                }

                result.obj = authCode;
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.msg = "系统异常!" + ex.Message;
                return(Json(result));;
            }
        }
Exemple #4
0
        public ActionResult getMsgCode()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId  = Context.GetRequest("appId", string.Empty);
            string phone  = Context.GetRequest("phone", string.Empty);
            int    userId = Context.GetRequestInt("userId", 0);

            if (string.IsNullOrEmpty(appId) || userId <= 0 || string.IsNullOrEmpty(phone))
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            phone = phone.Trim();
            //校验手机号码
            if (!Regex.IsMatch(phone, @"\d") || phone.Length > 11)
            {
                returnObj.Msg = "请填写合法的手机号码";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            SendMsgHelper sendMsgHelper = new SendMsgHelper();
            string        codeKey       = string.Format(CITY_BINDPHONE, phone);
            string        authCode      = RedisUtil.Get <string>(codeKey);

            if (string.IsNullOrEmpty(authCode))
            {
                authCode = Utility.EncodeHelper.CreateRandomCode(4);//生成4位数验证码
            }
            bool senMsgCodeResult = sendMsgHelper.AliSend(phone, "{\"code\":\"" + authCode + "\",\"product\":\" " + Enum.GetName(typeof(SendTypeEnum), 8) + "\"}", "小未科技", 401);

            if (senMsgCodeResult)//表示发送成功
            {
                RedisUtil.Set <string>(codeKey, authCode, TimeSpan.FromMinutes(1));
                returnObj.dataObj = new { authCode = authCode };
                returnObj.isok    = true;
                returnObj.Msg     = "验证码发送成功!";
            }
            else
            {
                returnObj.Msg = "验证码发送失败,请稍后再试!";
            }

            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        /// <summary>
        /// 发生短信消息验证
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public ActionResult SendCode(string phone = "")
        {
            SendTypeEnum sendType   = SendTypeEnum.提现号码验证;
            Return_Msg   returnData = new Return_Msg();

            try
            {
                if (string.IsNullOrEmpty(phone))
                {
                    returnData.Msg = "手机号不能为空!";
                    return(Json(returnData));
                }
                C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModelByTelephone_appid(phone, _pxhAppId);
                if (userinfo == null)
                {
                    returnData.Msg = "没有找到用户信息!";
                    return(Json(returnData));
                }

                string        redisKey      = string.Format(_redis_PhoneKey, phone);
                SendMsgHelper sendMsgHelper = new SendMsgHelper();
                string        authCode      = RedisUtil.Get <string>(redisKey);
                if (string.IsNullOrEmpty(authCode))
                {
                    authCode = EncodeHelper.CreateRandomCode(4);
                }
                bool result = sendMsgHelper.AliSend(phone, "{\"code\":\"" + authCode + "\",\"product\":\" " + Enum.GetName(typeof(SendTypeEnum), sendType) + "\"}", "小未科技", 401);
                if (result)
                {
                    RedisUtil.Set <string>(redisKey, authCode, TimeSpan.FromMinutes(5));
                    returnData.isok = true;
                    returnData.Msg  = "验证码发送成功!";
                }
                else
                {
                    returnData.Msg = "验证码发送失败,请稍后再试!";
                }
                returnData.dataObj = authCode;
                return(Json(returnData));
            }
            catch (Exception ex)
            {
                returnData.Msg = "系统异常!" + ex.Message;
                return(Json(returnData));
            }
        }
Exemple #6
0
    private void SubmitMsg()
    {
        Logger logger = new Logger(logFile);

        logger.Log(startToken);
        logger.Log("初始化SendMsgHelper");
        SendMsgHelper helper = new SendMsgHelper
        {
            uidUser  = Guid.Parse(uidUser),
            logger   = logger,
            ImgsPath = Server.MapPath("~/UploadedImages/" + uidUser)
        };

        try
        {
            logger.Log("检查遗留任务");
            if (helper.IsHasWaitingTasks())
            {
                logger.Log("发现之前还有未发送的信息!");
                helper.ExecTask(profMsg);
                logger.Log(completeToken);
                return;
            }

            logger.Log("初始化任务数据库");
            if (0 == helper.InitTask())
            {
                logger.Log(completeToken);
                return;
            }
            logger.Log("初始化成功");

            logger.Log("开始发送信息");
            helper.ExecTask(profMsg);
            logger.Log(completeToken);
        }
        catch (Exception ex)
        {
            //sw = new StreamWriter(logFile, true);
            logger.Log(string.Format("系统异常:{0}", ex.ToString()));
            logger.Log(completeToken);
            //sw.Close();
            return;
        }
    }
Exemple #7
0
        public ReturnMsg SendSMS(string utoken, dynamic postData)
        {
            try
            {
                string tel   = postData.tel;
                string appid = postData.appid;
                int    type  = postData.type;
                if (string.IsNullOrEmpty(tel) || !Regex.IsMatch(tel, @"^1[3-9]+\d{9}$"))
                {
                    result.msg = "手机号码格式不正确!";
                    return(result);
                }
                if (C_UserInfoBLL.SingleModel.ExistsTelePhone(tel, appid))
                {
                    result.msg = "该手机号已绑定!";
                    return(result);
                }

                SendMsgHelper sendMsgHelper = new SendMsgHelper();
                string        authCode      = RedisUtil.Get <string>(tel);
                if (string.IsNullOrEmpty(authCode))
                {
                    authCode = Utility.EncodeHelper.CreateRandomCode(4);
                }
                bool sendResult = sendMsgHelper.AliSend(tel, "{\"code\":\"" + authCode + "\",\"product\":\" " + Enum.GetName(typeof(SendTypeEnum), type) + "\"}", "小未科技", 401);
                if (sendResult)
                {
                    RedisUtil.Set <string>(tel, authCode, TimeSpan.FromMinutes(5));
                    result.code = 1;
                    result.msg  = "验证码发送成功!";
                }
                else
                {
                    result.msg = "验证码发送失败,请稍后再试!";
                }

                result.obj = authCode;
                return(result);
            }
            catch (Exception ex)
            {
                result.msg = "系统异常!" + ex.Message;
                return(result);
            }
        }