Esempio n. 1
0
        public async Task <IActionResult> AddPartnerUser(Guid partnerId, Guid userId)
        {
            // Make sure the person adding the user is either an admin or already a user for the partner
            var currentUser = await userRepository.GetUserByNameIdentifier(User.FindFirst(ClaimTypes.NameIdentifier).Value).ConfigureAwait(false);

            if (!currentUser.IsSiteAdmin)
            {
                var currentUserPartner = partnerUserRepository.GetPartnerUsers().FirstOrDefault(pu => pu.PartnerId == partnerId && pu.UserId == currentUser.Id);

                if (currentUserPartner == null)
                {
                    return(Forbid());
                }
            }

            var partnerUser = new PartnerUser()
            {
                PartnerId           = partnerId,
                UserId              = userId,
                CreatedByUserId     = currentUser.Id,
                LastUpdatedByUserId = currentUser.Id
            };

            await partnerUserRepository.AddPartnerUser(partnerUser).ConfigureAwait(false);

            return(CreatedAtAction(nameof(GetPartnerUser), new { partnerId, userId }));
        }
Esempio n. 2
0
        public void CheckInputAccount()
        {
            try
            {
                string UserCode   = Request["username"];
                string VerifyCode = Request["verifycode"];
                if (string.IsNullOrEmpty(UserCode))
                {
                    throw new Exception("账号不能为空");
                }
                if (VerifyCode.ToLower() != Session["LoginVerifyCode"].ToString().ToLower())
                {
                    throw new Exception("验证码错误");
                }
                using (ProxyBE p = new ProxyBE())
                {
                    PartnerUser partner = p.Client.GetPartnerUserByUserCode(null, UserCode);
                    if (partner == null)
                    {
                        throw new Exception("用户不存在");
                    }

                    Session["Step1"] = true;
                    WriteMessage(1, "accountVerify.html");
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message);
            }
        }
Esempio n. 3
0
        public void ModifyPasswordByEgui()
        {
            string OldPassword = Request["OldPassword"];
            string NewPassword = Request["NewPassword"];

            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    PartnerUser partnetUser = p.Client.GetPartnerUser(SenderUser, this.CurrentUser.UserID);
                    if (CEncrypt.DecryptString(partnetUser.Password) != OldPassword)
                    {
                        WriteMessage(-1, "原密码错误,请重新输入");
                        return;
                    }
                    partnetUser.Password = CEncrypt.EncryptString(NewPassword);
                    SavePartnerUserArgs arge = new SavePartnerUserArgs();
                    arge.PartnerUser = partnetUser;
                    p.Client.SavePartnerUser(SenderUser, arge);
                    WriteSuccess();
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
        public void ModifyPwd()
        {
            try
            {
                if (this.CurrentUser.UserID != Guid.Empty || this.CurrentUser != null)
                {
                    using (ProxyBE p = new ProxyBE())
                    {
                        PartnerUser user     = p.Client.GetPartnerUserByUserCode(SenderUser, CurrentUser.UserCode);
                        string      Password = Request["Password"].ToString();
                        user.Password = CEncrypt.EncryptString(Password);

                        SavePartnerUserArgs args = new SavePartnerUserArgs();
                        args.PartnerUser = user;
                        p.Client.SavePartnerUser(SenderUser, args);
                    }
                }
                this.Response.Write("{\"result\":\"success\",\"errorCode\":0}");
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                WriteError(ex.Message, ex);
            }
        }
Esempio n. 5
0
 public void GetPartnerUser()
 {
     try
     {
         if (string.IsNullOrEmpty(Request["UserID"]))
         {
             throw new Exception("参数无效");
         }
         using (ProxyBE p = new ProxyBE())
         {
             Guid        uid         = Guid.Parse(Request["UserID"]);
             PartnerUser partnerUser = p.Client.GetPartnerUser(SenderUser, uid);
             if (partnerUser == null)
             {
                 throw new Exception("查询用户不存在");
             }
             else
             {
                 Response.Write(JSONHelper.Object2Json(partnerUser));
             }
         }
     }
     catch (Exception ex)
     {
         WriteError(ex.Message, ex);
     }
 }
Esempio n. 6
0
        public void Userexist()
        {
            try
            {
                string UserCode = Request["username"];

                using (ProxyBE p = new ProxyBE())
                {
                    PartnerUser partner = p.Client.GetPartnerUserByUserCode(null, UserCode);
                    if (partner == null)
                    {
                        Response.Write("false");
                    }
                    else
                    {
                        Response.Write("true");
                    }
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                WriteError(ex.Message);
            }
        }
Esempio n. 7
0
        public void ResetPwd()
        {
            try
            {
                string password = Request["password"];
                if (string.IsNullOrEmpty(password))
                {
                    throw new Exception("密码不能为空");
                }
                if (Session["Step2"] == null)
                {
                    throw new Exception("账号为空,非法请求");
                }
                using (ProxyBE p = new ProxyBE())
                {
                    PartnerUser partner = p.Client.GetPartnerUserByUserCode(null, Session["Step2"].ToString());
                    if (partner == null)
                    {
                        throw new PException("用户不存在");
                    }
                    partner.Password = CEncrypt.EncryptString(password);

                    SavePartnerUserArgs pargs = new SavePartnerUserArgs();
                    pargs.PartnerUser = partner;
                    p.Client.SavePartnerUser(SenderUser, pargs);
                    Session["Step3"] = true;
                    WriteMessage(1, "resetComplete.html");
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message);
            }
        }
Esempio n. 8
0
        public async Task CreatePartner(PartnerRequest partnerRequest)
        {
            // Convert the partner request to a new partner
            var partner = partnerRequest.ToPartner();

            // Add the partner record
            var newPartner = await partnerRepository.AddPartner(partner).ConfigureAwait(false);

            // Make the creator of the partner request a registered user for the partner
            var partnerUser = new PartnerUser
            {
                PartnerId           = newPartner.Id,
                UserId              = partnerRequest.CreatedByUserId,
                CreatedByUserId     = partnerRequest.CreatedByUserId,
                LastUpdatedByUserId = partnerRequest.LastUpdatedByUserId,
            };

            await partnerUserRepository.AddPartnerUser(partnerUser).ConfigureAwait(false);

            // Notify user when their request has been approved and what to do next
            // Need a template for this
            //var email = new Email
            //{
            //    Message = $"From Email: {partnerRequest.PrimaryEmail}\nFrom Name:{partnerRequest.Name}\nMessage:\n{partnerRequest.Notes}",
            //    Subject = "Partner Request"
            //};
            //email.Addresses.Add(new EmailAddress { Name = Constants.TrashMobEmailName, Email = Constants.TrashMobEmailAddress });

            //await emailManager.SendSystemEmail(email, CancellationToken.None).ConfigureAwait(false);
        }
        // Update the records of a particular Partner User
        public async Task <PartnerUser> UpdatePartnerUser(PartnerUser partnerUser)
        {
            mobDbContext.Entry(partnerUser).State = EntityState.Modified;
            partnerUser.LastUpdatedDate           = DateTimeOffset.UtcNow;
            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.PartnerUsers.FindAsync(partnerUser.PartnerId, partnerUser.UserId).ConfigureAwait(false));
        }
Esempio n. 10
0
        public static int PartnerUserAdd(int pid, string regip, int userid, string username)
        {
            PartnerUser puObject = new PartnerUser();

            puObject.pid      = pid;
            puObject.regip    = regip;
            puObject.userid   = userid;
            puObject.username = username;
            return(PartnerUserAdd(puObject));
        }
Esempio n. 11
0
        /// <summary>
        /// 发送短信
        /// </summary>
        public void PartnerSendSMS()
        {
            try
            {
                if (string.IsNullOrEmpty(Request["UserID"]))
                {
                    Response.Write("{\"result\":\"error\",\"errorCode\":31}");
                    return;
                }
                if (string.IsNullOrEmpty(Request["Token"]))
                {
                    Response.Write("{\"result\":\"error\",\"errorCode\":31}");
                    return;
                }
                using (ProxyBE p = new ProxyBE())
                {
                    PartnerUser user = p.Client.GetPartnerUser(SenderUser, new Guid(Request["UserID"]));
                    if (user == null)
                    {
                        Response.Write("{\"result\":\"error\",\"errorCode\":31}");
                        return;
                    }

                    //Random rd = new Random();
                    string verifycode = "";// rd.Next(1000, 9999).ToString();

                    #region 发送短信
                    //using (ProxyEE pe = new ProxyEE())
                    //{
                    //    verifycode = pe.Client.GetAuthorizationCode(user.Mobile, 10, 4);
                    //    pe.Client.SendMessage(new string[] { user.Mobile }, "MES密码重置验证码:" + verifycode + ",打死也不能告诉别人。验证码10分钟内有效。");
                    //}
                    #endregion

                    //发短信
                    Session["SMSVerify_" + user.Mobile]         = verifycode;
                    Session["SMSVerify_TimeOut_" + user.Mobile] = DateTime.Now.AddMinutes(10);
                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");
                    sb.AppendFormat("\"result\":\"{0}\",", "success");
                    sb.Append("\"data\":");
                    sb.Append("{");
                    sb.AppendFormat("\"UserID\":\"{0}\",", user.UserID);
                    sb.AppendFormat("\"UserCode\":\"{0}\",", user.UserCode);
                    sb.AppendFormat("\"Token\":\"{0}\"", Guid.NewGuid().ToString());
                    sb.Append("}");
                    sb.Append("}");
                    Response.Write(sb.ToString());
                }
            }
            catch
            {
                Response.Write("{\"result\":\"error\",\"errorCode\":10}");
            }
        }
Esempio n. 12
0
        public static int PartnerUserAdd(PartnerUser puObject)
        {
            Database  dbDCenter     = DatabaseFactory.CreateDatabase(sConn);
            DbCommand dcPartnerUser = dbDCenter.GetStoredProcCommand("SP_PartnerUser_Add");

            dbDCenter.AddInParameter(dcPartnerUser, "@userid", DbType.Int32, puObject.userid);
            dbDCenter.AddInParameter(dcPartnerUser, "@username", DbType.String, puObject.username);
            dbDCenter.AddInParameter(dcPartnerUser, "@regip", DbType.String, puObject.regip);
            dbDCenter.AddInParameter(dcPartnerUser, "@pid", DbType.Int32, puObject.pid);

            return(dbDCenter.ExecuteNonQuery(dcPartnerUser));
        }
        public async Task <PartnerUser> AddPartnerUser(PartnerUser partnerUser)
        {
            partnerUser.CreatedDate         = DateTimeOffset.UtcNow;
            partnerUser.LastUpdatedByUserId = partnerUser.CreatedByUserId;
            partnerUser.LastUpdatedDate     = DateTimeOffset.UtcNow;

            mobDbContext.PartnerUsers.Add(partnerUser);

            await mobDbContext.SaveChangesAsync().ConfigureAwait(false);

            return(await mobDbContext.PartnerUsers.FindAsync(partnerUser.PartnerId, partnerUser.UserId).ConfigureAwait(false));
        }
Esempio n. 14
0
        public void ModifyPartner_EGui()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    Partner partner = p.Client.GetPartner(SenderUser, parm.PartnerID);
                    if (partner == null)
                    {
                        partner           = new Partner();
                        partner.PartnerID = parm.PartnerID;
                    }
                    if (Request["Province"] == "")
                    {
                        throw new Exception("请选择省份");
                    }
                    if (Request["City"] == "请选择城市")
                    {
                        throw new Exception("请选择城市");
                    }
                    partner.PartnerName = parm.PartnerName.Trim();
                    partner.LinkMan     = parm.LinkMan.Trim();
                    partner.Province    = parm.Province;
                    partner.City        = parm.City;
                    partner.ShopSize    = parm.ShopSize;
                    partner.Address     = parm.Address.Trim();
                    SavePartnerArgs args = new SavePartnerArgs();
                    args.Partner = partner;
                    p.Client.SavePartner(SenderUser, args);

                    PartnerUser PartnerUser = new PartnerUser();
                    PartnerUser.UserID       = CurrentUser.UserID;
                    PartnerUser.IsFinishInfo = true;
                    SavePartnerUserArgs pargs = new SavePartnerUserArgs();
                    pargs.PartnerUser = PartnerUser;
                    p.Client.UpdatePartnerUserIsFinishInfoByUserID(SenderUser, pargs);

                    CurrentUser.IsFinishInfo = true;
                    WriteSuccess();
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
Esempio n. 15
0
 private async void OnIdTokenChanged(IdTokenEventArgs e, bool forceRefresh)
 {
     if (!isProcessingIdToken)
     {
         isProcessingIdToken = true;
         if (e.Auth.CurrentUser is null)
         {
             wasEmailVerified = wasPartner = false;
         }
         else
         {
             var claims = (await e.Auth.CurrentUser.GetIdTokenResultAsync(forceRefresh)).Claims;
             if (claims.TryGetValue("partner", out var p))
             {
                 isPartner = (bool)p !;
             }
             if (claims.TryGetValue("teamRole", out var tR))
             {
                 teamRole = (string?)tR;
             }
             if (claims.TryGetValue("teamUID", out var tU))
             {
                 teamUID = (string?)tU;
             }
             if (claims.TryGetValue("email_verified", out var eV))
             {
                 emailVerified = (bool)eV !;
             }
             if ((emailVerified != wasEmailVerified) ||
                 (isPartner != wasPartner) ||
                 (teamUID != previousTeamUID) ||
                 (teamRole != previousTeamRole) ||
                 CurrentState.Location.OriginalString == "//Loading")
             {
                 await OnCurrentUserUpdated(PartnerUser.Current);
             }
             (wasEmailVerified, wasPartner)      = (emailVerified, isPartner);
             (previousTeamUID, previousTeamRole) = (teamUID, teamRole);
         }
         PartnerUser.SetCurrent(e.Auth.CurrentUser?.Uid);
         isProcessingIdToken = false;
     }
 }
Esempio n. 16
0
 public PartnerUser GetPartnerUserByMobile(Sender sender, string Mobile)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             PartnerUser user = new PartnerUser();
             user.Mobile = Mobile;
             if (op.LoadPartnerUserByMobile(user) == 0)
             {
                 return(null);
             }
             return(user);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Esempio n. 17
0
 public PartnerUser GetPartnerUser(Sender sender, Guid userId)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             PartnerUser user = new PartnerUser();
             user.UserID = userId;
             if (op.LoadPartnerUserByUserID(user) == 0)
             {
                 return(null);
             }
             return(user);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Esempio n. 18
0
 public bool PartnerUserMobileIsDuplicated(Sender sender, PartnerUser user)
 {
     try
     {
         PartnerUser u = new PartnerUser();
         u.Mobile = user.Mobile;
         using (ObjectProxy op = new ObjectProxy())
         {
             if (op.LoadPartnerUserByMobile(u) == 0)
             {
                 return(false);
             }
             return(u.UserID != user.UserID);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Esempio n. 19
0
        public void SavePartner()
        {
            using (ProxyBE p = new ProxyBE())
            {
                try
                {
                    #region Partner
                    //if (Request["Province"] == "")
                    //{
                    //    throw new Exception("请选择省份");
                    //}
                    //if (Request["City"] == "请选择城市")
                    //{
                    //    throw new Exception("请选择城市");
                    //}
                    Partner Partner = new Partner();
                    //公司
                    Partner.CompanyID   = parm.CompanyID;
                    Partner.PartnerID   = parm.PartnerID;
                    Partner.ShopType    = parm.ShopType;
                    Partner.PartnerName = parm.PartnerName.Trim();
                    Partner.LinkMan     = parm.LinkMan.Trim();
                    Partner.Email       = parm.Email.Trim();
                    Partner.Mobile      = parm.Mobile.Trim();
                    Partner.Tel         = parm.Tel.Trim();
                    Partner.Fax         = parm.Fax.Trim();
                    Partner.Remark      = parm.Remark.Trim();
                    Partner.Province    = parm.Province;
                    Partner.City        = parm.City;
                    Partner.ShopSize    = parm.ShopSize;
                    Partner.Address     = parm.Address.Trim();

                    bool flag = p.Client.PartnerUserIsDuplicated(SenderUser, new PartnerUser()
                    {
                        UserCode = Partner.Mobile
                    });
                    if (flag)
                    {
                        throw new Exception("手机号已注册");
                    }

                    SavePartnerArgs args = new SavePartnerArgs();
                    args.Partner = Partner;
                    p.Client.SavePartner(SenderUser, args);
                    #endregion

                    #region PartnerUser
                    PartnerUser PartnerUser = new PartnerUser();

                    PartnerUser.CompanyID  = parm.CompanyID;
                    PartnerUser.UserID     = Guid.NewGuid();
                    PartnerUser.Created    = DateTime.Now;
                    PartnerUser.CreatedBy  = SenderUser.UserCode + "." + SenderUser.UserName;
                    PartnerUser.Modified   = DateTime.Now;
                    PartnerUser.ModifiedBy = SenderUser.UserCode + "." + SenderUser.UserName;

                    //admin经销商默认密码 123456
                    PartnerUser.Password = MES.Libraries.CEncrypt.EncryptString(UserDefaultPassword);
                    int num = p.Client.GetIncrease(SenderUser, "admin");
                    // PartnerUser.UserCode = "admin" +num.ToString("#000");
                    PartnerUser.UserCode        = Partner.Mobile;
                    PartnerUser.UserName        = parm.PartnerName;
                    PartnerUser.PartnerID       = parm.PartnerID;
                    PartnerUser.Sex             = "男";
                    PartnerUser.Position        = "管理员";
                    PartnerUser.Email           = "";
                    PartnerUser.Mobile          = parm.Mobile.Trim();
                    PartnerUser.Description     = "管理员";
                    PartnerUser.LoginErrorCount = 0;
                    PartnerUser.IsDisabled      = false;
                    PartnerUser.IsLocked        = false;
                    PartnerUser.IsSystem        = true;
                    PartnerUser.MemberClass     = -1;
                    bool flag2 = p.Client.PartnerUserIsDuplicated(SenderUser, PartnerUser);
                    if (flag2)
                    {
                        throw new Exception("服务器忙,请稍候再试");
                    }
                    SavePartnerUserArgs pargs = new SavePartnerUserArgs();
                    pargs.PartnerUser = PartnerUser;
                    p.Client.SavePartnerUser(SenderUser, pargs);
                    #endregion

                    WriteSuccess();
                }
                catch (Exception ex)
                {
                    WriteError(ex.Message, ex);
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// 经销商提出申请
        /// </summary>
        public void PartnerSafeVerify()
        {
            try
            {
                #region 验证码
                string code = Request["ImgVerifyCode"];
                if (!string.IsNullOrEmpty(code))
                {
                    if (string.IsNullOrEmpty(Session["LoginVerifyCode"].ToString()))
                    {
                        Response.Write("{\"result\":\"error\",\"errorCode\":22}");
                        return;
                    }
                    if (code.ToString().ToUpper() != Session["LoginVerifyCode"].ToString().ToUpper())
                    {
                        Response.Write("{\"result\":\"error\",\"errorCode\":23}");
                        return;
                    }

                    string timeout = Session["LoginVerifyCode_TimeOut"].ToString();
                    if (!string.IsNullOrEmpty(timeout))
                    {
                        if (DateTime.Now > DateTime.Parse(timeout))
                        {
                            Response.Write("{\"result\":\"error\",\"errorCode\":24}");
                            return;
                        }
                    }
                }
                else
                {
                    Response.Write("{\"result\":\"error\",\"errorCode\":23}");
                    return;
                }
                #endregion

                #region 验证用户
                string usercode = Request["UserCode"];
                if (string.IsNullOrEmpty(usercode))
                {
                    Response.Write("{\"result\":\"error\",\"errorCode\":30}");
                    return;
                }
                using (ProxyBE be = new ProxyBE())
                {
                    PartnerUser u = be.Client.GetPartnerUserByUserCode(SenderUser, usercode);
                    if (u == null)
                    {
                        Response.Write("{\"result\":\"error\",\"errorCode\":30}");
                        return;
                    }
                    if (string.IsNullOrEmpty(u.Mobile))
                    {
                        Response.Write("{\"result\":\"error\",\"errorCode\":33}");
                        return;
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");
                    sb.AppendFormat("\"result\":\"{0}\",", "success");
                    sb.Append("\"data\":");
                    sb.Append("{");
                    sb.AppendFormat("\"UserID\":\"{0}\",", u.UserID);
                    sb.AppendFormat("\"UserCode\":\"{0}\",", u.UserCode);
                    sb.AppendFormat("\"Mobile\":\"{0}\",", u.Mobile.Replace(u.Mobile.Substring(4, 4), "****"));
                    if (!string.IsNullOrEmpty(u.Email))
                    {
                        string email = u.Email;
                        email = email.Replace(email.Substring(2, email.IndexOf('@') - 1), "****");
                        sb.AppendFormat("\"Email\":\"{0}\",", email);
                    }
                    sb.AppendFormat("\"Token\":\"{0}\"", Guid.NewGuid().ToString());
                    sb.Append("}");
                    sb.Append("}");

                    Response.Write(sb.ToString());
                }
                #endregion
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex.Message);
                Response.Write("{\"result\":\"error\",\"errorCode\":10}");
            }
        }
Esempio n. 21
0
        public void SavePartner()
        {
            using (ProxyBE p = new ProxyBE())
            {
                try
                {
                    #region 验证
                    string phone    = Request["egui-phone"];
                    string password = Request["egui-pwd"];
                    string smsCode  = Request["egui-smscode"];
                    if (string.IsNullOrEmpty(phone))
                    {
                        throw new Exception("手机号不能为空");
                    }
                    Partner partnerModel = p.Client.GetPartnerByMobile(SenderUser, phone);
                    if (partnerModel != null)
                    {
                        throw new Exception("该手机号码已经被注册");
                    }
                    if (string.IsNullOrEmpty(password))
                    {
                        throw new Exception("密码不能为空");
                    }
                    if (string.IsNullOrEmpty(smsCode) || (!string.IsNullOrEmpty(smsCode) && smsCode.ToLower() != Session["RegisterSMSCode"].ToString().ToLower()))
                    {
                        throw new Exception("验证码错误");
                    }
                    #endregion

                    #region Partner
                    if (Request["Province"] == "")
                    {
                        //throw new Exception("请选择省份");
                    }
                    if (Request["City"] == "请选择城市")
                    {
                        //throw new Exception("请选择城市");
                    }
                    Partner Partner = new Partner();
                    Partner.PartnerID   = parm.PartnerID;
                    Partner.ShopType    = "1";
                    Partner.PartnerName = "商户" + phone;  //
                    Partner.LinkMan     = "联系人" + phone; //联系人
                    Partner.Email       = "";
                    Partner.Mobile      = phone;
                    Partner.Tel         = "无(主动注册)";//销售人员
                    Partner.Fax         = "";
                    Partner.Remark      = "";
                    Partner.Province    = "";
                    Partner.City        = "";
                    Partner.ShopSize    = 0;
                    Partner.Address     = "";
                    SavePartnerArgs args = new SavePartnerArgs();
                    args.Partner = Partner;
                    p.Client.SavePartner(SenderUser, args);
                    #endregion

                    #region PartnerUser
                    PartnerUser PartnerUser = new PartnerUser();
                    PartnerUser.UserID  = Guid.NewGuid();
                    PartnerUser.Created = DateTime.Now;
                    //PartnerUser.CreatedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                    PartnerUser.CreatedBy = "Egui.biz";
                    PartnerUser.Modified  = DateTime.Now;
                    //PartnerUser.ModifiedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                    PartnerUser.ModifiedBy = "Egui.biz";
                    //admin经销商默认密码 123456
                    //PartnerUser.Password = MES.Libraries.CEncrypt.EncryptString(UserDefaultPassword);
                    PartnerUser.Password = MES.Libraries.CEncrypt.EncryptString(HttpContext.Current.Request["egui-pwd"]);

                    //int num = p.Client.GetIncrease(SenderUser, "admin");
                    //PartnerUser.UserCode = "admin" + num.ToString("#000
                    PartnerUser.UserCode = phone;


                    PartnerUser.UserName        = "******" + phone;
                    PartnerUser.PartnerID       = parm.PartnerID;
                    PartnerUser.Sex             = "男";
                    PartnerUser.Position        = "管理员";
                    PartnerUser.Email           = "";
                    PartnerUser.Mobile          = phone;
                    PartnerUser.EndDate         = DateTime.Now;
                    PartnerUser.Description     = "管理员";
                    PartnerUser.LoginErrorCount = 0;
                    PartnerUser.IsDisabled      = false;
                    PartnerUser.IsLocked        = false;
                    PartnerUser.IsSystem        = true;
                    PartnerUser.IsFinishInfo    = false;
                    PartnerUser.MemberClass     = -1;
                    bool flag = p.Client.PartnerUserIsDuplicated(SenderUser, PartnerUser);
                    if (flag)
                    {
                        throw new Exception("该手机号码已经被注册");
                    }
                    SavePartnerUserArgs pargs = new SavePartnerUserArgs();
                    pargs.PartnerUser = PartnerUser;
                    p.Client.SavePartnerUser(SenderUser, pargs);
                    #endregion

                    WriteSuccess();
                }
                catch (Exception ex)
                {
                    WriteError(ex.Message, ex);
                }
            }
        }
Esempio n. 22
0
        public void PartnerResetPwdByMobile()
        {
            try
            {
                if (string.IsNullOrEmpty(Request["UserID"]))
                {
                    Response.Write("{\"result\":\"error\",\"errorCode\":31}");
                    return;
                }
                if (string.IsNullOrEmpty(Request["Token"]))
                {
                    Response.Write("{\"result\":\"error\",\"errorCode\":31}");
                    return;
                }
                using (ProxyBE p = new ProxyBE())
                {
                    //User user = p.Client.GetUser(SenderUser, new Guid(Request["UserID"]));
                    PartnerUser user = p.Client.GetPartnerUser(SenderUser, new Guid(Request["UserID"]));
                    if (user == null)
                    {
                        Response.Write("{\"result\":\"error\",\"errorCode\":31}");
                        return;
                    }

                    #region 验证码
                    string code = Request["SMSVerifyCode"];
                    if (!string.IsNullOrEmpty(code))
                    {
                        if (string.IsNullOrEmpty(Session["SMSVerify_" + user.Mobile].ToString()))
                        {
                            Response.Write("{\"result\":\"error\",\"errorCode\":25}");
                            return;
                        }
                        if (code.ToString().ToUpper() != Session["SMSVerify_" + user.Mobile].ToString().ToUpper())
                        {
                            Response.Write("{\"result\":\"error\",\"errorCode\":26}");
                            return;
                        }

                        string timeout = Session["SMSVerify_TimeOut_" + user.Mobile].ToString();
                        if (!string.IsNullOrEmpty(timeout))
                        {
                            if (DateTime.Now > DateTime.Parse(timeout))
                            {
                                Response.Write("{\"result\":\"error\",\"errorCode\":27}");
                                return;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("{\"result\":\"error\",\"errorCode\":23}");
                        return;
                    }
                    #endregion

                    user.Password = CEncrypt.EncryptString(Request["confirmPassword"].ToString());

                    //SaveUserArgs args = new SaveUserArgs();
                    SavePartnerUserArgs args = new SavePartnerUserArgs();
                    args.PartnerUser = user;
                    p.Client.SavePartnerUser(SenderUser, args);

                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");
                    sb.AppendFormat("\"result\":\"{0}\",", "success");
                    sb.AppendFormat("\"errorCode\":{0}", 0);
                    sb.Append("}");
                    Response.Write(sb.ToString());
                }
            }
            catch
            {
                Response.Write("{\"result\":\"error\",\"errorCode\":10}");
            }
        }
Esempio n. 23
0
        public void SavePartnerManagerUser()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    #region  PartnerUser
                    PartnerUser partnerUser = p.Client.GetPartnerUser(SenderUser, parm.UserID);
                    if (partnerUser != null)
                    {
                        partnerUser.UserCode = parm.UserCode.Trim();
                        bool flag = p.Client.PartnerUserIsDuplicated(SenderUser, partnerUser);
                        if (flag)
                        {
                            throw new Exception("该账号已经存在,请重新输入。");
                        }
                        partnerUser.PartnerID       = parm.PartnerID;
                        partnerUser.UserName        = parm.UserName.Trim();
                        partnerUser.Sex             = "";
                        partnerUser.Position        = "";
                        partnerUser.IsSystem        = true;
                        partnerUser.Email           = "";
                        partnerUser.Description     = parm.Description.Trim();
                        partnerUser.Mobile          = parm.Mobile.Trim();
                        partnerUser.LoginErrorCount = 0;
                        partnerUser.IsDisabled      = Convert.ToBoolean(parm.IsDisabled);
                        partnerUser.IsLocked        = parm.IsLocked;
                        partnerUser.IsAxamine       = true;
                        partnerUser.IsFinishInfo    = true;
                        partnerUser.MemberClass     = parm.MemberClass;
                        string strDate = Request["EndDate"];
                        partnerUser.EndDate = Convert.ToDateTime(Request["EndDate"]);
                    }
                    SavePartnerUserArgs args = new SavePartnerUserArgs();
                    args.PartnerUser = partnerUser;
                    p.Client.SavePartnerUser(SenderUser, args);
                    #endregion

                    #region  PartnerUserGroup
                    PartnerUserGroup           UserGroup     = null;
                    SearchPartnerUserGroupArgs UserGroupArgs = new SearchPartnerUserGroupArgs();
                    UserGroupArgs.PartnerID = partnerUser.PartnerID;
                    UserGroupArgs.GroupName = "默认组";
                    Guid         GroupID = Guid.Empty;
                    SearchResult sr      = p.Client.SearchPartnerUserGroup(SenderUser, UserGroupArgs);
                    if (sr.Total > 0)
                    {
                        foreach (DataRow item in sr.DataSet.Tables[0].Rows)
                        {
                            GroupID = Guid.Parse(item["GroupID"].ToString());
                        }
                        UserGroup = p.Client.GetPartnerUserGroup(SenderUser, GroupID);
                    }
                    if (GroupID == Guid.Empty)
                    {
                        UserGroup           = new PartnerUserGroup();
                        UserGroup.GroupID   = Guid.NewGuid();
                        UserGroup.GroupName = "默认组";
                        UserGroup.IsSystem  = true;
                        UserGroup.PartnerID = partnerUser.PartnerID;
                        SavePartnerUserGroupArgs GroupArgs = new SavePartnerUserGroupArgs();
                        GroupArgs.PartnerUserGroup = UserGroup;
                        p.Client.SavePartnerUserGroup(SenderUser, GroupArgs);
                    }
                    #endregion

                    #region  PartnerRole
                    string      PrivilegeItemS   = Request["PrivilegeItemS"];
                    List <Guid> PrivilegeItemIDS = new List <Guid>();
                    if (!string.IsNullOrEmpty(PrivilegeItemS))
                    {
                        string[] ItemS = PrivilegeItemS.Split(',');
                        foreach (var item in ItemS)
                        {
                            PrivilegeItemIDS.Add(new Guid(item));
                        }
                    }
                    PartnerRole partnerRole = p.Client.GetPartnerRoleByName(SenderUser, UserGroup.GroupID, "root");
                    if (partnerRole == null)
                    {
                        partnerRole          = new PartnerRole();
                        partnerRole.GroupID  = UserGroup.GroupID;
                        partnerRole.IsSystem = true;
                        partnerRole.RoleID   = Guid.NewGuid();
                        partnerRole.RoleName = "root";
                    }
                    SavePartnerRoleArgs roleArgs = new SavePartnerRoleArgs();
                    roleArgs.PartnerRole      = partnerRole;
                    roleArgs.PrivilegeItemIDs = PrivilegeItemIDS;
                    p.Client.SavePartnerRole(SenderUser, roleArgs);
                    #endregion

                    #region PartnerUser2Role
                    PartnerUser2Role PartnerUser2Role = new PartnerUser2Role();
                    PartnerUser2Role.UserID = partnerUser.UserID;
                    PartnerUser2Role.RoleID = partnerRole.RoleID;

                    SavePartnerUser2RoleArgs sargs = new SavePartnerUser2RoleArgs();
                    sargs.PartnerUser2Role = PartnerUser2Role;
                    p.Client.SavePartnerUser2Role(SenderUser, sargs);
                    #endregion

                    WriteSuccess();
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
Esempio n. 24
0
        public void SavePartnerUser()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    PartnerUser partnerUser = p.Client.GetPartnerUser(null, parm.UserID);
                    if (partnerUser == null)
                    {
                        //新增
                        partnerUser            = new PartnerUser();
                        partnerUser.UserID     = parm.UserID;
                        partnerUser.Created    = DateTime.Now;
                        partnerUser.CreatedBy  = SenderUser.UserCode + "." + SenderUser.UserName;
                        partnerUser.Modified   = DateTime.Now;
                        partnerUser.ModifiedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                        partnerUser.Password   = MES.Libraries.CEncrypt.EncryptString(UserDefaultPassword);
                    }
                    partnerUser.MemberClass = -1;
                    partnerUser.UserCode    = parm.UserCode.Trim();
                    bool flag = p.Client.PartnerUserIsDuplicated(SenderUser, partnerUser);
                    if (flag)
                    {
                        throw new Exception("该账户已经存在,请重新输入。");
                    }
                    partnerUser.PartnerID = this.CurrentUser.PartnerID;
                    partnerUser.UserName  = parm.UserName.Trim();
                    partnerUser.Sex       = parm.Sex.Trim();
                    if (parm.Position == "" || parm.Position == "请选择")
                    {
                        throw new Exception("请选择职位!");
                    }
                    partnerUser.Position        = parm.Position.Trim();
                    partnerUser.Email           = parm.Email.Trim();
                    partnerUser.Mobile          = parm.Mobile.Trim();
                    partnerUser.Description     = parm.Description.Trim();
                    partnerUser.LoginErrorCount = 0;
                    partnerUser.IsDisabled      = parm.IsDisabled;
                    partnerUser.IsLocked        = parm.IsLocked;

                    SavePartnerUserArgs args = new SavePartnerUserArgs();
                    args.PartnerUser = partnerUser;

                    string roleIDs = Request["RoleIDs"];
                    args.RoleIDs = new List <Guid>();
                    if (!string.IsNullOrEmpty(roleIDs))
                    {
                        string[] roles = roleIDs.Split(',');
                        foreach (var item in roles)
                        {
                            args.RoleIDs.Add(new Guid(item));
                        }
                    }
                    p.Client.SavePartnerUser(SenderUser, args);
                    WriteSuccess();
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
Esempio n. 25
0
        public void Login()
        {
            try
            {
                string UserCode   = Request["username"];
                string Password   = Request["password"];
                string VerifyCode = Request["verifycode"];

                if (string.IsNullOrEmpty(UserCode))
                {
                    throw new Exception("用户名不能为空");
                }
                if (VerifyCode.ToLower() != Session["LoginVerifyCode"].ToString().ToLower())
                {
                    throw new PException("验证码错误");
                }

                using (ProxyBE p = new ProxyBE())
                {
                    #region 登录
                    PartnerUser partner = p.Client.GetPartnerUserByUserCode(null, UserCode);
                    if (partner == null)
                    {
                        throw new PException("用户不存在");
                    }
                    if (partner.IsLocked)
                    {
                        throw new PException("帐号被锁");
                    }
                    if (partner.IsDisabled)
                    {
                        throw new PException("帐号禁用");
                    }
                    if (partner.MemberClass == -1)
                    {
                        throw new PException("帐号待审核,请联系客服专员");
                    }
                    if (partner.LoginErrorCount >= 5)
                    {
                        throw new PException("密码错误次数过多,帐号已被锁定,请联系管理员");
                    }
                    if (DateTime.Now > partner.EndDate)
                    {
                        throw new PException("账户已过期,请联系客服续费");
                    }
                    SavePartnerUserArgs args = new SavePartnerUserArgs();
                    if (CEncrypt.EncryptString(Password) != partner.Password)
                    {
                        partner.LoginErrorCount += 1;
                        PException ex = null;
                        if (partner.LoginErrorCount >= 5)
                        {
                            //登录错误次数过多 帐号锁定
                            partner.IsLocked = true;
                            ex = new PException("密码错误次数过多,帐号已被锁定,请联系管理员");
                        }
                        else
                        {
                            //剩余登录次数
                            ex = new PException("密码错误,您还有{0}机会", 5 - partner.LoginErrorCount);
                        }
                        args.PartnerUser = partner;
                        p.Client.SavePartnerUser(base.SenderUser, args);
                        throw ex;
                    }

                    args.PartnerUser        = partner;
                    partner.LoginErrorCount = 0;
                    partner.LastLoginTime   = DateTime.Now;
                    p.Client.SavePartnerUser(base.SenderUser, args);
                    #endregion

                    #region Session

                    SessionUser su = new SessionUser();
                    su.UserCode  = partner.UserCode;
                    su.UserID    = partner.UserID;
                    su.PartnerID = partner.PartnerID;
                    su.Position  = partner.Position;
                    //su.LoginUrl = PartnerLoginUrl;
                    su.UserName      = partner.UserName;
                    su.UserType      = (int)UserType.D;
                    su.IsSystemUser  = partner.IsSystem;
                    su.LastLoginTime = partner.LastLoginTime;
                    su.IsFinishInfo  = partner.IsFinishInfo;
                    OnlineUser.Lock(su);
                    this.CurrentUser = su;

                    #endregion

                    #region 加载权限
                    //privilegeItem
                    List <PrivilegeItem> privilegeItems = p.Client.GetPrivilegeItemByPartnerUserID(null, partner.UserID);
                    var privilegeItemS = from pi in privilegeItems select pi.PrivilegeItemID;
                    su.PrivilegeItemIDs = privilegeItemS.ToList <Guid>();

                    //privileges
                    List <Privilege> privileges = p.Client.GetPrivilegesByPartnerUserID(null, partner.UserID);
                    var privilegeS = from pl in privileges select pl.PrivilegeID;
                    su.PrivilegeIDs = privilegeS.ToList <Guid>();

                    Dictionary <string, List <string> > PrivilegeCodesDir = new Dictionary <string, List <string> >();
                    foreach (var item in privileges)
                    {
                        if (PrivilegeCodesDir.ContainsKey(item.PrivilegeCode.ToLower()))
                        {
                            continue;
                        }
                        List <string> itemCodes = new List <string>();
                        var           plItems   = privilegeItems.Where(pl => pl.PrivilegeID.ToString() == item.PrivilegeID.ToString() && pl.IsDisabled == false).ToList();
                        if (plItems != null)
                        {
                            foreach (var itemPrivilegeItems in plItems)
                            {
                                itemCodes.Add(itemPrivilegeItems.PrivilegeItemCode.ToLower());
                            }
                        }
                        PrivilegeCodesDir.Add(item.PrivilegeCode.ToLower(), itemCodes);
                    }
                    su.PrivilegeCodes = PrivilegeCodesDir;
                    #endregion

                    string url = "/Index.aspx";
                    //if (MustChangePasswordAtFirstLogin)
                    //{
                    //    if (partner.Password == CEncrypt.EncryptString(UserDefaultPassword))
                    //    {
                    //        url = "/partnerModifypwd.aspx";
                    //    }
                    //}
                    StringBuilder sb = new StringBuilder();
                    sb.Append('{');
                    sb.Append(string.Format("\"isOk\":\"{0}\",\"message\":\"{1}\",\"url\":\"{2}\"", 1, "success", url));
                    sb.Append('}');
                    Response.Write(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                WriteError(ex.Message);
            }
        }
Esempio n. 26
0
 public static int PartnerUserAdd(PartnerUser puObject)
 {
     return(PartnerUserDAL.PartnerUserAdd(puObject));
 }
Esempio n. 27
0
        public void SavePartnerUser(Sender sender, SavePartnerUserArgs args)
        {
            try
            {
                if (string.IsNullOrEmpty(args.PartnerUser.UserCode))
                {
                    throw new Exception(string.Format("用户编号:{0}命名无效,可能存在特殊字符。", args.PartnerUser.UserCode));
                }

                if (string.IsNullOrEmpty(args.PartnerUser.UserName))
                {
                    throw new Exception(string.Format("用户名称:{0}命名无效,可能存在特殊字符。", args.PartnerUser.UserName));
                }

                if (PartnerUserIsDuplicated(sender, args.PartnerUser))
                {
                    throw new Exception(string.Format("用户编号:{0}已存在,请重新输入。", args.PartnerUser.UserCode));
                }
                if (PartnerUserMobileIsDuplicated(sender, args.PartnerUser))
                {
                    throw new Exception(string.Format("用户手机号:{0}已存在,请重新输入。", args.PartnerUser.Mobile));
                }
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    PartnerUser user = new PartnerUser();
                    user.UserID = args.PartnerUser.UserID;
                    if (op.LoadPartnerUserByUserID(user) == 0)
                    {
                        user = null;
                    }

                    if (user == null)
                    {
                        args.PartnerUser.Created    = DateTime.Now;
                        args.PartnerUser.CreatedBy  = sender.UserCode + "." + sender.UserName;
                        args.PartnerUser.Modified   = args.PartnerUser.Created;
                        args.PartnerUser.ModifiedBy = args.PartnerUser.CreatedBy;
                        op.InsertPartnerUser(args.PartnerUser);
                        PartnerUserPassword up = new PartnerUserPassword();
                        up.UserID     = args.PartnerUser.UserID;
                        up.Password   = args.PartnerUser.Password;
                        up.Modified   = DateTime.Now;
                        up.ModifiedBy = sender.UserCode + "." + sender.UserName;
                        op.InsertPartnerUserPassword(up);
                    }
                    else
                    {
                        args.PartnerUser.Modified   = DateTime.Now;
                        args.PartnerUser.ModifiedBy = sender.UserCode + "." + sender.UserName;

                        op.UpdatePartnerUserByUserID(args.PartnerUser);
                        if (args.RoleIDs != null)
                        {
                            op.DeletePartnerUser2RolesByUserID(args.PartnerUser.UserID);
                        }

                        if (args.PartnerUser.Password != user.Password)
                        {
                            PartnerUserPassword up = new PartnerUserPassword();
                            up.UserID     = args.PartnerUser.UserID;
                            up.Password   = args.PartnerUser.Password;
                            up.Modified   = DateTime.Now;
                            up.ModifiedBy = sender.UserCode + "." + sender.UserName;
                            op.InsertPartnerUserPassword(up);
                        }
                    }
                    if (args.RoleIDs != null)
                    {
                        foreach (Guid roleID in args.RoleIDs)
                        {
                            PartnerUser2Role ur = new PartnerUser2Role();
                            ur.UserID = args.PartnerUser.UserID;
                            ur.RoleID = roleID;
                            op.InsertPartnerUser2Role(ur);
                        }
                    }
                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
        public void SavePartnerUser()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    PartnerUser partnerUser = p.Client.GetPartnerUser(null, parm.UserID);
                    if (partnerUser == null)
                    {
                        //新增
                        partnerUser         = new PartnerUser();
                        partnerUser.UserID  = parm.UserID;
                        partnerUser.Created = DateTime.Now;
                        //partnerUser.CreatedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                        partnerUser.CreatedBy = "EGui平台";
                        partnerUser.Modified  = DateTime.Now;
                        //partnerUser.ModifiedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                        partnerUser.ModifiedBy = "EGui平台";
                        //partnerUser.Password = MES.Libraries.CEncrypt.EncryptString(UserDefaultPassword);
                        partnerUser.Password = CEncrypt.EncryptString(HttpContext.Current.Request["UserPwd"]);//PWD
                    }
                    //partnerUser.UserCode = parm.UserCode.Trim();
                    partnerUser.UserCode = HttpContext.Current.Request["UserPhone"];//电话注册
                    bool flag = p.Client.PartnerUserIsDuplicated(SenderUser, partnerUser);
                    if (flag)
                    {
                        throw new Exception("该账户已经存在,请重新输入。");
                    }
                    //partnerUser.PartnerID = this.CurrentUser.PartnerID;
                    partnerUser.PartnerID = new Guid("14D08A0B-D52B-FD09-3B0E-A9C308783C90");//经销商ID
                    //partnerUser.UserName = parm.UserName.Trim();
                    partnerUser.UserName = "******" + HttpContext.Current.Request["UserPhone"];
                    //partnerUser.Sex = parm.Sex.Trim();
                    partnerUser.Sex = "";
                    //if (parm.Position == "" || parm.Position == "请选择")
                    //{
                    //    throw new Exception("请选择职位!");
                    //}
                    //partnerUser.Position = parm.Position.Trim();
                    partnerUser.Position = "量尺";
                    //partnerUser.Email = parm.Email.Trim();
                    partnerUser.Email = "";
                    //partnerUser.Mobile = parm.Mobile.Trim();
                    partnerUser.Mobile = HttpContext.Current.Request["UserPhone"];

                    //partnerUser.Description = parm.Description.Trim();
                    partnerUser.Description     = "";
                    partnerUser.LoginErrorCount = 0;
                    //partnerUser.IsDisabled = parm.IsDisabled;
                    //partnerUser.IsLocked = parm.IsLocked;

                    partnerUser.IsDisabled = false;
                    partnerUser.IsLocked   = false;

                    SavePartnerUserArgs args = new SavePartnerUserArgs();
                    args.PartnerUser = partnerUser;

                    string roleIDs = "33c49247-4d4e-828e-7fc1-b3d7cf4d2078";//角色权限
                    args.RoleIDs = new List <Guid>();
                    if (!string.IsNullOrEmpty(roleIDs))
                    {
                        string[] roles = roleIDs.Split(',');
                        foreach (var item in roles)
                        {
                            args.RoleIDs.Add(new Guid(item));
                        }
                    }
                    p.Client.SavePartnerUser(SenderUser, args);
                    WriteSuccess();
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
        public void SavePartner()
        {
            using (ProxyBE p = new ProxyBE())
            {
                try
                {
                    #region Partner
                    if (Request["Province"] == "")
                    {
                        //throw new Exception("请选择省份");
                    }
                    if (Request["City"] == "请选择城市")
                    {
                        //throw new Exception("请选择城市");
                    }
                    Partner Partner = new Partner();
                    Partner.PartnerID   = parm.PartnerID;
                    Partner.ShopType    = "1";
                    Partner.PartnerName = "用户" + parm.PartnerName; //
                    Partner.LinkMan     = "用户" + parm.PartnerName; //联系人
                    Partner.Email       = "";
                    Partner.Mobile      = "";
                    Partner.Tel         = "";
                    Partner.Fax         = "";
                    Partner.Remark      = "";
                    Partner.Province    = "";
                    Partner.City        = "";
                    Partner.ShopSize    = 0;
                    Partner.Address     = "";
                    SavePartnerArgs args = new SavePartnerArgs();
                    args.Partner = Partner;
                    p.Client.SavePartner(SenderUser, args);
                    #endregion

                    #region PartnerUser
                    PartnerUser PartnerUser = new PartnerUser();
                    PartnerUser.UserID  = Guid.NewGuid();
                    PartnerUser.Created = DateTime.Now;
                    //PartnerUser.CreatedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                    PartnerUser.CreatedBy = "Egui.biz";
                    PartnerUser.Modified  = DateTime.Now;
                    //PartnerUser.ModifiedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                    PartnerUser.ModifiedBy = "Egui.biz";
                    //admin经销商默认密码 123456
                    //PartnerUser.Password = MES.Libraries.CEncrypt.EncryptString(UserDefaultPassword);
                    PartnerUser.Password = MES.Libraries.CEncrypt.EncryptString(HttpContext.Current.Request["UserPwd"]);

                    int num = p.Client.GetIncrease(SenderUser, "admin");
                    //PartnerUser.UserCode = "admin" + num.ToString("#000
                    PartnerUser.UserCode = parm.PartnerName;


                    PartnerUser.UserName        = "******" + parm.PartnerName;
                    PartnerUser.PartnerID       = parm.PartnerID;
                    PartnerUser.Sex             = "男";
                    PartnerUser.Position        = "管理员";
                    PartnerUser.Email           = "";
                    PartnerUser.Mobile          = parm.PartnerName;
                    PartnerUser.Description     = "管理员";
                    PartnerUser.LoginErrorCount = 0;
                    PartnerUser.IsDisabled      = false;
                    PartnerUser.IsLocked        = false;
                    PartnerUser.IsSystem        = true;
                    bool flag = p.Client.PartnerUserIsDuplicated(SenderUser, PartnerUser);
                    if (flag)
                    {
                        throw new Exception("服务器忙,请稍候再试");
                    }
                    SavePartnerUserArgs pargs = new SavePartnerUserArgs();
                    pargs.PartnerUser = PartnerUser;
                    p.Client.SavePartnerUser(SenderUser, pargs);
                    #endregion

                    WriteSuccess();
                }
                catch (Exception ex)
                {
                    WriteError(ex.Message, ex);
                }
            }
        }