Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string context = "hand?" + Common.Common.Decrypt(HttpContext.Current.Request.Url.Query.TrimStart('?'));

            HttpContext.Current.RewritePath(context);
            string   mailAddress = HttpContext.Current.Request.QueryString.Get("mailAddress");
            string   dateTime    = HttpContext.Current.Request.QueryString.Get("dateTime");
            TimeSpan UseTime     = DateTime.Now - Convert.ToDateTime(dateTime);

            if (UseTime.Seconds >= 60)
            {
                Response.Redirect(ParameterAPI.GetConfig("RegisterFURL").ConfigValue + "?mailaddr=" + mailAddress, false);
            }
            else
            {
                PCBEntities      pCBEntities  = new PCBEntities();
                PCB_EngineerInfo engineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => p.MailAddress == mailAddress);
                if (engineerInfo != null && engineerInfo != default(PCB_EngineerInfo))
                {
                    engineerInfo.UpdateDateTime = DateTime.Now;
                    engineerInfo.StateCode      = true;
                    pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, engineerInfo);
                    bool isok = Convert.ToBoolean(pCBEntities.SaveChanges());
                    if (isok)
                    {
                        Response.Redirect(ParameterAPI.GetConfig("RegisterSURL").ConfigValue + "?mailaddr=" + mailAddress + "&isconfirm=true", false);
                    }
                    else
                    {
                        Response.Redirect(ParameterAPI.GetConfig("RegisterFURL").ConfigValue + "?mailaddr=" + mailAddress, false);
                    }
                }
            }
        }
Esempio n. 2
0
        public Result ChangePassword(string account, string oldPassword, string newPassword)
        {
            Result result = new Result();

            try
            {
                PCBEntities      pCBEntities  = new PCBEntities();
                PCB_EngineerInfo engineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => (p.Account == account || p.MailAddress == account) && p.StateCode == true);
                if (engineerInfo == null || engineerInfo == default(PCB_EngineerInfo))
                {
                    result.IsOK        = false;
                    result.Description = "输入的用户" + account + "不存在";
                    return(result);
                }
                if (oldPassword != engineerInfo.Password)
                {
                    result.IsOK        = false;
                    result.Description = "输入的旧密码有误";
                    return(result);
                }
                if (string.IsNullOrEmpty(newPassword))
                {
                    result.IsOK        = false;
                    result.Description = "输入的新密码不能为空";
                    return(result);
                }

                engineerInfo.Password       = newPassword;
                engineerInfo.UpdateDateTime = DateTime.Now;
                pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, engineerInfo);
                result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges());
                if (!result.IsOK)
                {
                    result.Description = "修改密码失败";
                    return(result);
                }
                result.Description = "账号" + account + "的密码修改成功";
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(GetType()).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.InnerException.Message;
            }
            return(result);
        }
Esempio n. 3
0
        public Result EditeAccountInfo(string account, string password, string accountName, string phoneNo, string weChatAccount)
        {
            Result result = new Result();

            try
            {
                PCBEntities      pCBEntities      = new PCBEntities();
                PCB_EngineerInfo pCB_EngineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => p.Account == account && p.Password == password && p.StateCode == true);
                if (pCB_EngineerInfo == null)
                {
                    result.IsOK        = false;
                    result.Description = "没有该账号信息";
                    return(result);
                }
                if (!string.IsNullOrEmpty(accountName))
                {
                    pCB_EngineerInfo.AccountName = accountName;
                }
                if (!string.IsNullOrEmpty(phoneNo))
                {
                    pCB_EngineerInfo.PhoneNo = phoneNo;
                }
                if (!string.IsNullOrEmpty(weChatAccount))
                {
                    pCB_EngineerInfo.WeChatAccount = weChatAccount;
                }


                pCB_EngineerInfo.UpdateDateTime = DateTime.Now;

                pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, pCB_EngineerInfo);
                result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges());
                if (!result.IsOK)
                {
                    result.Description = "保存异常";
                    return(result);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(GetType()).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.InnerException.Message;
            }
            return(result);
        }
Esempio n. 4
0
        public Result CreateEngineer(string account, string accountName, string password, string phoneNo, string mailAddress, string weChatAccount)
        {
            //  LogHelper.WriteLog(GetType()).Info("CreateEngineer");
            Result result = new Result();

            try
            {
                result.IsOK = true;
                if (string.IsNullOrEmpty(account))
                {
                    result.IsOK        = false;
                    result.Description = "注册账号不能为空";
                    return(result);
                }
                if (string.IsNullOrEmpty(accountName))
                {
                    result.IsOK        = false;
                    result.Description = "注册账号名称不能为空";
                    return(result);
                }
                if (string.IsNullOrEmpty(password))
                {
                    result.IsOK        = false;
                    result.Description = "注册账号密码不能为空";
                    return(result);
                }
                if (string.IsNullOrEmpty(mailAddress))
                {
                    result.IsOK        = false;
                    result.Description = "注册邮箱账号不能为空";
                    return(result);
                }
                if (string.IsNullOrEmpty(weChatAccount))
                {
                    result.IsOK        = false;
                    result.Description = "注册微信账号不能为空";
                    return(result);
                }
                PCBEntities      pCBEntities  = new PCBEntities();
                PCB_EngineerInfo engineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => p.Account == account || p.MailAddress == mailAddress);
                if (engineerInfo != null || engineerInfo != default(PCB_EngineerInfo))
                {
                    if (engineerInfo.StateCode)
                    {
                        if (engineerInfo.Account == account)
                        {
                            result.Description = "用户" + account + "已经存在";
                        }
                        if (engineerInfo.MailAddress == mailAddress)
                        {
                            result.Description = "邮箱" + mailAddress + "已经存在";
                        }
                        result.IsOK = false;
                        return(result);
                    }
                    else
                    {
                        TimeSpan UseTime = DateTime.Now - engineerInfo.CreateDateTime;
                        if (UseTime.TotalSeconds <= 60)
                        {
                            result.Description = "已经提交申请,请勿重复操作";
                            result.IsOK        = false;
                            return(result);
                        }
                        else //超过60s删除预注册信息
                        {
                            pCBEntities.DeleteObject(engineerInfo);
                        }
                    }
                }
                engineerInfo                = new PCB_EngineerInfo();
                engineerInfo.EngineerID     = System.Guid.NewGuid();
                engineerInfo.Account        = account;
                engineerInfo.Password       = password;
                engineerInfo.AccountName    = accountName;
                engineerInfo.MailAddress    = mailAddress;
                engineerInfo.PhoneNo        = phoneNo;
                engineerInfo.WeChatAccount  = weChatAccount;
                engineerInfo.CreateDateTime = DateTime.Now;
                engineerInfo.StateCode      = false;
                pCBEntities.AddToPCB_EngineerInfo(engineerInfo);

                result = Common.Common.SendMail(mailAddress, engineerInfo.CreateDateTime.ToString());
                if (!result.IsOK)
                {
                    return(result);
                }
                result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges());
                if (!result.IsOK)
                {
                    result.Description = "注册账号失败";
                    return(result);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(GetType()).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.InnerException.Message;
            }
            return(result);
        }