コード例 #1
0
        protected void btnSend_Click(object sender, System.EventArgs e)
        {
            string @string = WebUtils.GetString(this.TextBox5.Text);
            ISMS   iSMS    = SMSProvider.Create(PageBase.config.SMSClass);

            if (iSMS == null)
            {
                base.ShowMsg("短信接口配置不正确");
            }
            else if (!ValidateUtils.IsMobilePhone(@string))
            {
                base.ShowMsg("无效的手机号码");
            }
            else
            {
                string value = iSMS.SendMsg(@string, "这是一条测试短信,如果您收到此短信,表示短信服务有效![" + PageBase.config.SiteName + "]");
                if (iSMS.IsSuccess)
                {
                    base.ShowMsg("测试短信发送成功");
                }
                else
                {
                    base.ShowMsg(WebUtils.GetString(value));
                }
            }
        }
コード例 #2
0
ファイル: MsgService.cs プロジェクト: ngochoanhbr/dahuco
 protected void SendSystemMsg2Mger(MessageSet setting, Dictionary <string, string> msgParams)
 {
     if (setting.IsSendMsg)
     {
         Message.SendSysMsg(setting.MessageTitle, this.ReplaceTemplate(setting.MessageTemplate, msgParams));
     }
     if (setting.IsSendMail && !string.IsNullOrEmpty(ConfigProvider.Configs.ManagerMail))
     {
         string[] array = ConfigProvider.Configs.ManagerMail.Split(new char[]
         {
             ','
         });
         for (int i = 0; i < array.Length; i++)
         {
             string text = array[i];
             if (ValidateUtils.IsEmail(text))
             {
                 MsgService.SendMail(text, setting.MailTitle, this.ReplaceTemplate(setting.MailTemplate, msgParams));
             }
         }
     }
     if (setting.IsSendSMS && !string.IsNullOrEmpty(ConfigProvider.Configs.ManagerMobile))
     {
         string[] array = ConfigProvider.Configs.ManagerMobile.Split(new char[]
         {
             ','
         });
         for (int i = 0; i < array.Length; i++)
         {
             string text = array[i];
             if (ValidateUtils.IsMobilePhone(text))
             {
                 MsgService.SendSMS(text, this.ReplaceTemplate(setting.SMSTemplate, msgParams));
             }
         }
     }
 }
コード例 #3
0
ファイル: Register.cs プロジェクト: ngochoanhbr/dahuco
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (base.IsPost)
            {
                RegType regType      = (RegType)System.Enum.Parse(typeof(RegType), WebUtils.GetFormString("_regtype", "Normal"));
                string  strGroupName = WebUtils.GetFormString("_usergroupname", "个人会员");
                System.Collections.Generic.IEnumerable <UserGroupInfo> source = from p in UserGroup.GetCacheUserGroupList()
                                                                                where p.GroupName.Equals(strGroupName)
                                                                                select p;
                System.Collections.Generic.IEnumerable <UserLevelInfo> source2 = (from p in UserLevel.GetCacheUserLevelList()
                                                                                  orderby p.Integral
                                                                                  select p).Take(1);
                TaoBaoAreaInfo iPAreaFromTaoBao = IPUtils.GetIPAreaFromTaoBao(IPUtils.GetIP());
                UserInfo       userInfo         = new UserInfo
                {
                    UserName      = WebUtils.GetFormString("_regname"),
                    Password      = WebUtils.GetFormString("_regpwd"),
                    GroupID       = ((source.Count <UserGroupInfo>() > 0) ? source.First <UserGroupInfo>().AutoID : 0),
                    LevelID       = ((source2.Count <UserLevelInfo>() > 0) ? source2.First <UserLevelInfo>().AutoID : 0),
                    Email         = ((regType == RegType.ByEmail) ? WebUtils.GetFormString("_regname") : WebUtils.GetFormString("_regemail")),
                    Mobile        = ((regType == RegType.ByMobile) ? WebUtils.GetFormString("_regname") : WebUtils.GetFormString("_regmobile")),
                    Country       = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country),
                    Province      = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.region),
                    City          = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.city),
                    County        = ((iPAreaFromTaoBao == null) ? string.Empty : iPAreaFromTaoBao.data.country),
                    Status        = 99,
                    AutoTimeStamp = System.DateTime.Now
                };
                string[] array = PageBase.config.SysUserName.Split(new char[]
                {
                    ','
                });
                string strA = string.Empty;
                switch (regType)
                {
                case RegType.ByMobile:
                {
                    SMSInfo lastCheckCode = SMS.GetLastCheckCode(userInfo.Mobile);
                    if (lastCheckCode != null)
                    {
                        strA = lastCheckCode.ValidateCode;
                    }
                    goto IL_27A;
                }

                case RegType.ByEmail:
                {
                    SMSInfo lastCheckCode = SMS.GetLastCheckCode(userInfo.Email);
                    if (lastCheckCode != null)
                    {
                        strA = lastCheckCode.ValidateCode;
                    }
                    goto IL_27A;
                }
                }
                strA = base.ValidateCode;
IL_27A:
                if (PageBase.config.VerifycodeForReg && string.Compare(strA, WebUtils.GetFormString("_regyzm"), true) != 0)
                {
                    base.WriteJsonTip(base.GetCaption("ValidateCodeIncorrect"));
                }
                else if (userInfo.GroupID.Equals(0) || userInfo.LevelID.Equals(0))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_MemberInfoNotComplete"));
                }
                else if (!SinGooCMS.BLL.User.IsValidUserName(userInfo.UserName) && !ValidateUtils.IsEmail(userInfo.UserName) && !ValidateUtils.IsMobilePhone(userInfo.UserName))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_InvalidUserName"));
                }
                else if (array.Length > 0 && array.Contains(userInfo.UserName))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_SystemRetainsUserName").Replace("${username}", userInfo.UserName));
                }
                else if (SinGooCMS.BLL.User.IsExistsByName(userInfo.UserName))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_UserNameAlreadyExists"));
                }
                else if (userInfo.Password.Length < 6)
                {
                    base.WriteJsonTip(base.GetCaption("Reg_UserPwdLenNeed"));
                }
                else if (userInfo.Password != WebUtils.GetFormString("_regpwdagain"))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_2PwdInputNoMatch"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Email) && !ValidateUtils.IsEmail(userInfo.Email))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_EmailTypeError"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Email) && SinGooCMS.BLL.User.IsExistsByEmail(userInfo.Email))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_EmailAddressAlreadyExists"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Mobile) && !ValidateUtils.IsMobilePhone(userInfo.Mobile))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_MobileTypeError"));
                }
                else if (!string.IsNullOrEmpty(userInfo.Mobile) && SinGooCMS.BLL.User.IsExistsByMobile(userInfo.Mobile))
                {
                    base.WriteJsonTip(base.GetCaption("Reg_MobileAlreadyExists"));
                }
                else
                {
                    int autoID = 0;
                    System.Collections.Generic.IList <UserFieldInfo> fieldListByModelID      = UserField.GetFieldListByModelID(userInfo.GroupID, true);
                    System.Collections.Generic.Dictionary <string, UserFieldInfo> dictionary = new System.Collections.Generic.Dictionary <string, UserFieldInfo>();
                    foreach (UserFieldInfo current in fieldListByModelID)
                    {
                        current.Value = WebUtils.GetFormString(current.FieldName);
                        dictionary.Add(current.FieldName, current);
                    }
                    UserStatus userStatus = SinGooCMS.BLL.User.Reg(userInfo, dictionary, ref autoID);
                    if (userStatus.Equals(UserStatus.Success))
                    {
                        new MsgService(userInfo).SendRegMsg();
                        new MsgService().SendRegMsg2Mger();
                        if (PageBase.config.RegGiveIntegral > 0)
                        {
                            userInfo.AutoID = autoID;
                            AccountDetail.AddIntegral(userInfo, 1, (double)PageBase.config.RegGiveIntegral, "注册赠送积分");
                        }
                        UserInfo    userInfo2   = new UserInfo();
                        LoginStatus loginStatus = SinGooCMS.BLL.User.UserLogin(userInfo.UserName, userInfo.Password, ref userInfo2);
                        string      text        = base.Server.UrlDecode(WebUtils.GetFormString("_regreturnurl"));
                        if (!string.IsNullOrEmpty(text))
                        {
                            base.WriteJsonTip(true, base.GetCaption("Reg_Success"), text);
                        }
                        else
                        {
                            base.WriteJsonTip(true, base.GetCaption("Reg_Success"), "/user/regsuccess.html?info=" + base.Server.UrlEncode(base.GetCaption("Reg_SuccessWillJumpMemberCenter")));
                        }
                    }
                    else
                    {
                        base.WriteJsonTip(base.GetCaption("Reg_FailWithMsg").Replace("${msg}", base.GetCaption("UserStatus_" + userStatus.ToString())));
                    }
                }
            }
            else
            {
                System.Collections.Generic.IEnumerable <UserGroupInfo> source3 = from p in UserGroup.GetCacheUserGroupList()
                                                                                 where p.GroupName.Equals("个人会员")
                                                                                 select p;
                base.Put("usermodel", UserField.GetFieldListByModelID((source3.Count <UserGroupInfo>() > 0) ? source3.First <UserGroupInfo>().AutoID : 0, true));
                base.Put("returnurl", WebUtils.GetQueryString("returnurl"));
                base.UsingClient("user/注册.html");
            }
        }
コード例 #4
0
ファイル: ModifyUser.cs プロジェクト: ngochoanhbr/dahuco
        protected void btnok_Click(object sender, System.EventArgs e)
        {
            base.ShowMsg("Ờ");
            if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
            {
                base.ShowMsg("Không có thẩm quyền");
            }
            else
            {
                UserInfo userInfo = new UserInfo();
                if (base.IsEdit)
                {
                    userInfo = SinGooCMS.BLL.User.GetDataById(base.OpID);
                }
                userInfo.UserName  = WebUtils.GetString(this.TextBox1.Text);
                userInfo.GroupID   = this.intGroupID;
                userInfo.LevelID   = WebUtils.GetInt(this.DropDownList3.SelectedValue);
                userInfo.Email     = WebUtils.GetString(this.TextBox5.Text);
                userInfo.Mobile    = WebUtils.GetString(this.TextBox6.Text);
                userInfo.Amount    = WebUtils.GetDecimal(this.TextBox10.Text);
                userInfo.Integral  = WebUtils.GetInt(this.TextBox11.Text);
                userInfo.CertType  = this.DropDownList12.SelectedItem.Text;
                userInfo.CertNo    = WebUtils.GetString(this.TextBox13.Text);
                userInfo.Status    = (this.isaudit.Checked ? 99 : 0);
                userInfo.FileSpace = WebUtils.GetInt(this.FileSpace.Text) * 1024 * 1024;
                System.Collections.Generic.Dictionary <string, UserFieldInfo> fieldDicWithValues = this.GetFieldDicWithValues();
                string[] array = PageBase.config.SysUserName.Split(new char[]
                {
                    ','
                });
                if (userInfo.GroupID.Equals(0) || userInfo.LevelID.Equals(0))
                {
                    base.ShowMsg("会员信息不完整,会员组及会员等级信息不可缺少");
                }
                else if (!SinGooCMS.BLL.User.IsValidUserName(userInfo.UserName) && !ValidateUtils.IsEmail(userInfo.UserName) && !ValidateUtils.IsMobilePhone(userInfo.UserName))
                {
                    base.ShowMsg("无效的会员名称");
                }
                else if (array.Length > 0 && array.Contains(userInfo.UserName))
                {
                    base.ShowMsg(userInfo.UserName + " 是系统保留会员名称,请选择其它会员名称");
                }
                else if (!base.IsEdit && this.TextBox4.Text.Length < 6)
                {
                    base.ShowMsg("密码长度不少于6位");
                }
                else if (base.IsEdit && !string.IsNullOrEmpty(this.TextBox4.Text) && this.TextBox4.Text.Length < 6)
                {
                    base.ShowMsg("密码长度不少于6位");
                }
                else if (!string.IsNullOrEmpty(userInfo.Email) && !ValidateUtils.IsEmail(userInfo.Email))
                {
                    base.ShowMsg("邮箱格式不正确");
                }
                else if (!string.IsNullOrEmpty(userInfo.Email) && SinGooCMS.BLL.User.IsExistsByEmail(userInfo.Email, userInfo.AutoID))
                {
                    base.ShowMsg("邮箱已经存在");
                }
                else if (!string.IsNullOrEmpty(userInfo.Mobile) && !ValidateUtils.IsMobilePhone(userInfo.Mobile))
                {
                    base.ShowMsg("手机号码格式不正确");
                }
                else if (!string.IsNullOrEmpty(userInfo.Mobile) && SinGooCMS.BLL.User.IsExistsByMobile(userInfo.Mobile, userInfo.AutoID))
                {
                    base.ShowMsg("手机号码已经存在");
                }
                else
                {
                    if (base.Action.Equals(ActionType.Add.ToString()))
                    {
                        userInfo.Password = SinGooCMS.BLL.User.GetEncodePwd(this.TextBox4.Text);
                        UserStatus userStatus = SinGooCMS.BLL.User.Reg(userInfo, fieldDicWithValues);
                        switch (userStatus)
                        {
                        case UserStatus.Error:
                            base.ShowMsg("添加会员失败");
                            goto IL_54B;

                        case UserStatus.WaitingForAudit:
                        case UserStatus.MobileNoValidate:
                            break;

                        case UserStatus.UserNameNoValidate:
                            base.ShowMsg("用户名非法");
                            goto IL_54B;

                        case UserStatus.EmailNoValidate:
                            base.ShowMsg("邮箱地址非法");
                            goto IL_54B;

                        case UserStatus.ExistsUserName:
                            base.ShowMsg("用户名已存在");
                            goto IL_54B;

                        case UserStatus.ExistsEmail:
                            base.ShowMsg("邮箱地址已存在");
                            goto IL_54B;

                        case UserStatus.ExistsMobile:
                            base.ShowMsg("手机号码已存在");
                            goto IL_54B;

                        default:
                            if (userStatus == UserStatus.Success)
                            {
                                PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加会员[" + userInfo.UserName + "] thành công");
                                base.Response.Redirect(string.Concat(new object[]
                                {
                                    "UserList.aspx?CatalogID=",
                                    base.CurrentCatalogID,
                                    "&Module=",
                                    base.CurrentModuleCode,
                                    "&GroupID=",
                                    userInfo.GroupID,
                                    "&action=View"
                                }));
                                goto IL_54B;
                            }
                            break;
                        }
                        base.ShowMsg("Lỗi Unknown");
                        IL_54B :;
                    }
                    if (base.Action.Equals(ActionType.Modify.ToString()))
                    {
                        if (!this.TextBox4.Text.IsNullOrEmpty())
                        {
                            userInfo.Password = SinGooCMS.BLL.User.GetEncodePwd(this.TextBox4.Text);
                        }
                        UserStatus userStatus = SinGooCMS.BLL.User.Update(userInfo, fieldDicWithValues);
                        switch (userStatus)
                        {
                        case UserStatus.Error:
                            base.ShowMsg("更新会员失败");
                            goto IL_6DC;

                        case UserStatus.WaitingForAudit:
                        case UserStatus.MobileNoValidate:
                            break;

                        case UserStatus.UserNameNoValidate:
                            base.ShowMsg("用户名非法");
                            goto IL_6DC;

                        case UserStatus.EmailNoValidate:
                            base.ShowMsg("邮箱地址非法");
                            goto IL_6DC;

                        case UserStatus.ExistsUserName:
                            base.ShowMsg("用户名已存在");
                            goto IL_6DC;

                        case UserStatus.ExistsEmail:
                            base.ShowMsg("邮箱地址已存在");
                            goto IL_6DC;

                        case UserStatus.ExistsMobile:
                            base.ShowMsg("手机号码已存在");
                            goto IL_6DC;

                        default:
                            if (userStatus == UserStatus.Success)
                            {
                                PageBase.log.AddEvent(base.LoginAccount.AccountName, "更新会员[" + userInfo.UserName + "] thành công");
                                base.Response.Redirect(string.Concat(new object[]
                                {
                                    "UserList.aspx?CatalogID=",
                                    base.CurrentCatalogID,
                                    "&Module=",
                                    base.CurrentModuleCode,
                                    "&GroupID=",
                                    userInfo.GroupID,
                                    "&action=View"
                                }));
                                goto IL_6DC;
                            }
                            break;
                        }
                        base.ShowMsg("Lỗi Unknown");
                        IL_6DC :;
                    }
                }
            }
        }