Example #1
0
        public OperationResult <bool> UpdateProfile(UserExt user)
        {
            try
            {
                using (DbMain.EFDbContext.ChatEntities db = new DbMain.EFDbContext.ChatEntities())
                {
                    var userDb = db.Users.FirstOrDefault(x => x.Id == curUser.Id);

                    userDb.Name      = user.Name;
                    userDb.Icon      = user.Icon;
                    userDb.Phone     = user.Phone;
                    userDb.Birthdate = user.BirthDate;

                    // db.Users.AddOrUpdate(curUser);
                    if (db.SaveChanges() > 0)
                    {
                        curUser = userDb;
                        return(new OperationResult <bool>(true));
                    }
                    return(new OperationResult <bool>(false, false, "Nothing to Update"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(new OperationResult <bool>(false, false, "InternalError"));
        }
Example #2
0
        public void TestInsert()
        {
            try
            {
                User user = new User()
                {
                    BsonId     = Guid.NewGuid().ToString("N"),
                    CreateTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc)
                };

                dbHelper.Insert(user);

                UserExt userExt = new UserExt()
                {
                    BsonId = Guid.NewGuid().ToString("N"),
                    UserId = user.BsonId,
                    IDCode = "123"
                };

                dbHelper.Insert(userExt);

                Console.WriteLine("true");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #3
0
 public ActionResult updatePwd(UserExt u)
 {
     if (u != null)
     {
         reflectModel.setValues(u);
         if (u.nick_name.Length >= 3 && u.pwd.Length >= 6 && u.newpwd.Length >= 6 && !u.pwd.Equals(u.newpwd))
         {
             try
             {
                 string old_hash_pwd = HashTools.SHA1_Hash(u.pwd);   // 旧的hash密码
                 using (WeiQingEntities db = new WeiQingEntities())
                 {
                     var user = db.user.Where(p => p.nick_name.Equals(u.nick_name) && p.pwd.Equals(old_hash_pwd)).FirstOrDefault();
                     if (user != null && u.nick_name.Equals(user.nick_name))
                     {
                         user.pwd = HashTools.SHA1_Hash(u.newpwd);
                         int res = db.SaveChanges();   // 修改密码
                         if (res > 0)
                         {
                             Session["user"] = null;
                         }
                         return(Content(res.ToString()));
                     }
                     return(Content("旧密码不正确"));
                 }
             }
             catch (Exception ex)
             {
                 return(Content("后台出现错误"));
             }
         }
         return(Content("修改失败"));
     }
     return(Content("参数错误"));
 }
Example #4
0
        // GET: Users/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id != LogedUserId)
            {
                return(RedirectToAction(nameof(Index)));
            }

            if (id == null)
            {
                return(NotFound());
            }


            var user = await _context.Users.FindAsync(id);

            if (user == null)
            {
                return(NotFound());
            }
            ViewData["RoleId"] = new SelectList(_context.Roles, "Id", "Name", user.RoleId);

            UserExt ue = new UserExt(user);

            return(View(ue));
        }
Example #5
0
        //internal async Task<bool> AddRole (string name)
        //{
        //    AspNetRole role = new AspNetRole() { Id = Guid.NewGuid().ToString() };
        //    role.Name = name;

        //    this.context.AspNetRoles.Add(role);
        //}


        internal async Task <bool> UpdateUser(dynamic dto)
        {
            var    email    = Convert.ToString(dto.Email);
            var    password = Convert.ToString(dto.Password);
            var    userName = Convert.ToString(dto.UserName);
            var    fn       = Convert.ToString(dto.FirstName);
            var    ln       = Convert.ToString(dto.LastName);
            string Id       = Convert.ToString(dto.Id);

            //   var user = await this.context.AspNetUsers.FirstOrDefaultAsync(q => q.Id == Id);
            //  user.UserName = userName;
            //  user.Email = email;
            var userExt = await this.context.UserExts.FirstOrDefaultAsync(q => q.Id == Id);

            if (userExt == null)
            {
                userExt    = new UserExt();
                userExt.Id = Id;
                this.context.UserExts.Add(userExt);
            }
            userExt.FirstName = fn;
            userExt.LastName  = ln;

            return(true);
        }
Example #6
0
        public void Connect()
        {
            InstanceContext context = new InstanceContext(_client);

            duplexChannelFactory = new DuplexChannelFactory <IChatService>(context, connectionString);
            chatService          = duplexChannelFactory.CreateChannel();
            OperationResult <UserExt> res;

            try
            {
                res = chatService.Authentication(_token);
            }
            catch (Exception ex)
            {
                res = new OperationResult <UserExt>(null, false, ex.Message);
            }
            if (res.IsOk)
            {
                User = res.Response;
            }
            else
            {
                Error?.Invoke("Chat Authentication", res.ErrorMessage);
            }
        }
Example #7
0
        public List <UserExt> GetAll()
        {
            List <UserExt> lst = new List <UserExt>();

            using (var context = (HRM_ROHTOEntities)Activator.CreateInstance(typeof(HRM_ROHTOEntities), _connectionStr))
            {
                var ds = from b in context.SYS_USER
                         where b.IsActive == true
                         select b;

                if (ds.Any())
                {
                    foreach (var i in ds)
                    {
                        UserExt ext = new UserExt
                        {
                            FullName = i.FullName,
                            Username = i.UserName,
                            RoleID   = i.RoleID,
                            RoleName = i.RoleID == null ? "" : GetRoleNameFromID((int)i.RoleID),
                            UserID   = i.UserID,
                            //ListZoneName = GetListZoneNameStringFromUserID(i.UserID),
                        };
                        lst.Add(ext);
                    }
                }
                return(lst);
            }
        }
Example #8
0
        /// <summary>
        /// 更新用户登录时间
        /// </summary>
        /// <param name="objUserExt"></param>
        /// <returns></returns>
        public int UpdateLoginTime(UserExt objUserExt)
        {
            string sql = "UPDATE [dbo].[tbUserLoginInfo]SET" +
                         "[LoginTime] ='" + objUserExt.LoginTime + @"'
                                  WHERE UserName = '******'";

            return(SQLHelper.Update(sql));
        }
Example #9
0
        private void OpenUserDetails(UserExt user)
        {
            var parameters = new NavigationParameters();

            parameters.Add("AuthenticatedUser", AuthenticatedUser);
            parameters.Add("ID", user.ID);

            this.RegionManager.RequestNavigate(RegionNames.MainContentRegion, new Uri(userDetailsViewName + parameters, UriKind.Relative));
        }
Example #10
0
        /// <summary>
        /// 存储用户名到combUserName中
        /// </summary>
        /// <param name="objUserExt"></param>
        /// <returns></returns>
        public int AddUserLogin(UserExt objUserExt)
        {
            UserExt user = new UserExt();
            string  sql  = @"INSERT INTO [dbo].[tbUserLoginInfo]
                                       ([UserName])
                                 VALUES
                                       ('" + objUserExt.UserName + @"')";

            return(SQLHelper.Update(sql));
        }
        public UserList GetAdminUserList(int pageIndex = 1, int pageSize = 10, string order = "")
        {
            var dao         = new UserDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
            var userOpenIds = dao.GetUserOpenIdListByApiLog(pageIndex, pageSize, "and (usertype='普通用户' or usertype is null) ");
            var count       = dao.GetListCount("and (usertype='普通用户' or usertype is null) ");

            var usersExt  = new List <UserExt>();
            var apiLogDao = new ApiLogDao(ConfigurationManager.AppSettings["mysqlConnStr"]);

            userOpenIds.ForEach(openId =>
            {
                if (!string.IsNullOrEmpty(openId))
                {
                    var user = dao.GetUser(openId);

                    var log              = apiLogDao.GetByOpenId(user.openId);
                    UserExt userExt      = new UserExt();
                    userExt.id           = user.id;
                    userExt.openId       = user.openId;
                    userExt.nickName     = user.nickName;
                    userExt.province     = user.province;
                    userExt.city         = user.city;
                    userExt.phone        = user.phone;
                    userExt.sex          = user.sex;
                    userExt.headpic      = user.headpic;
                    userExt.usertype     = user.usertype;
                    userExt.note         = user.note;
                    userExt.expertise    = user.expertise;
                    userExt.verified     = user.verified;
                    userExt.displayinapp = user.displayinapp;
                    userExt.detailimage  = user.detailimage;
                    userExt.createdAt    = user.createdAt;

                    userExt.lastVisitedAt      = apiLogDao.GetLastVisitedTime(user.openId); //log.lastVisitedAt;
                    userExt.visitCountLastWeek = apiLogDao.GetLastWeekCount(user.openId);   //log.visitCountLastWeek;

                    usersExt.Add(userExt);
                }
            });

            if (order == "descend")
            {
                usersExt = usersExt.OrderByDescending(user => user.lastVisitedAt).ToList();
            }
            else if (order == "ascend")
            {
                usersExt = usersExt.OrderBy(user => user.lastVisitedAt).ToList();
            }

            return(new UserList()
            {
                list = usersExt, count = count
            });
        }
Example #12
0
        /// <summary>
        /// 修改 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultInfo Update(UserExt model, SqlTransaction tran = null)
        {
            ResultInfo ri = new ResultInfo();

            if (Edit(model, tran))
            {
                ri.Ok  = true;
                ri.Msg = "修改成功";
            }

            return(ri);
        }
Example #13
0
        /// <summary>
        /// 重置封禁的账号
        /// </summary>
        private void ReSetCloseAccount()
        {
            #region MyRegion
            //string[] sendEmailAccount = ConfigHelper.AppSettings("Emailor").Split('|');
            //EmailHelper email = new EmailHelper();

            //email.From = sendEmailAccount[0];
            //email.FromName = "百晓堂";

            ////string[] receiveMails = ConfigHelper.AppSettings("ReceiveEmail").Split(',');

            //email.Recipients = new List<EmailHelper.RecipientClass>();
            //email.Recipients.Add(new EmailHelper.RecipientClass()
            //{
            //    Recipient = "*****@*****.**",
            //    RecipientName = "Staton"
            //});

            //email.Subject = "Web应用程序开始启动.重置封禁的账号";
            //email.Body = "Web应用程序开始启动.重置封禁的账号";
            //email.IsBodyHtml = false;
            //string emailhost = ConfigHelper.AppSettings("EmailHost");
            //email.ServerHost = emailhost.IsNotNullOrEmpty() ? emailhost : "smtp.{0}".FormatWith(sendEmailAccount[0].Split('@')[1]);
            //email.ServerPort = 465;
            //email.Username = sendEmailAccount[0];
            //email.Password = sendEmailAccount[1];

            //bool ok = email.Send2();
            #endregion
            UserExtBLL ubll = UserExtBLL.Instance;
            Thread     t    = new Thread(() =>
            {
                while (true)
                {
                    UserExt u = ubll.FindNearCloseAccount();
                    if (u != null)
                    {
                        int time = (int)Convert.ToDateTime(u.CloseTime).Subtract(DateTime.Now).TotalSeconds;
                        if (time > 0)
                        {
                            Thread.Sleep((time + 1) * 1000);
                        }
                        ubll.ReSetCloseAccount((long)u.UserID);
                    }
                    else
                    {
                        Thread.Sleep(10 * 60 * 1000);
                    }
                }
            });
            t.IsBackground = true;
            t.Start();
        }
Example #14
0
        /// <summary>
        /// 管理员在后台修改用户的资料
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public ActionResult updateUser(UserExt u)
        {
            if (u != null && u.id > 0)
            {
                if (u.id == 1 && (u.state == 0 || u.is_admin == false))
                {
                    return(Content("超级管理员的权限不能更改"));
                }

                var cur_user = (user)Session["user"];
                if (u.pwd != null && u.pwd.Length >= 6)
                {
                    if (u.id == 1 && cur_user.id != 1)
                    {
                        return(Content("超级管理员的密码不能更改"));
                    }
                    u.pwd = HashTools.SHA1_Hash(u.pwd);
                }
                else
                {
                    u.pwd = u.oldpwd;
                }

                if (u.email != null && u.email.Length > 0)
                {
                    if (u.reg_date == DateTime.MinValue)
                    {
                        return(Content("注册时间参数错误"));
                    }
                    reflectModel.setValues(u);
                    try
                    {
                        var model = reflectModel.AutoCopyToBase <user, UserExt>(u);
                        int res   = EfExt.Update(model);
                        if (res > 0)
                        {
                            return(Content("1"));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(Content(ex.Message));
                    }

                    return(Content("修改失败"));
                }
                else
                {
                    return(Content("邮箱不能为空"));
                }
            }
            return(Content("参数错误"));
        }
Example #15
0
        //退出系统
        private void tuichuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //更新用户登录时间
            UserExt userExt = new UserExt()
            {
                LoginTime = DateTime.Today,
                UserName  = Program.currentUser.UserName
            };

            objUserService.UpdateLoginTime(userExt);

            this.Close();
        }
Example #16
0
        /// <summary>
        /// 判断用户是否拥有足够的积分/VIP分
        /// </summary>
        /// <param name="type">1积分 2金钱/VIP分</param>
        /// <param name="coin">数量</param>
        /// <param name="userID">用户ID</param>
        /// <returns></returns>
        public bool HasEnoughCoin(int type, int coin, long userID)
        {
            UserExt ext = GetExtInfo(userID);

            if (type == 1)
            {
                return(ext.TotalScore >= coin);
            }
            else
            {
                return(ext.TotalCoin >= coin);
            }
        }
Example #17
0
        public bool CalcUserLevel(long userId)
        {
            bool ok = false;
            //计算积分等级
            List <BBSEnum> levels     = BBSEnumBLL.Instance.Query(3, true);
            var            coinSource = CoinSourceEnum.Sign.GetHashCode();

            //select UserID, LevelName,
            // (select count(1) from ScoreCoinLog where UserID = a.UserID and CoinSource = 3) SignCount
            // from userext a where a.UserID = @uid

            //SignCountAndLevel userext = UserExtBLL.Instance.GetSignAndLevelByUserID(Tran, UserID);
            UserExt userExt   = _amazonBBSDBContext.UserExt.FirstOrDefault(a => a.UserID == userId);
            int     signCount = _amazonBBSDBContext.ScoreCoinLog.Count(t => t.UserID == userId && t.CoinSource == coinSource);
            //string sqlTemp = "update UserExt set LevelName={0} where UserID={1};";
            //string empty = "null";
            //StringBuilder sb = new StringBuilder();
            var tempLevel = levels.LastOrDefault(item => { return(item.SortIndex <= signCount); });

            if (tempLevel == null)
            {
                if (userExt.LevelName.HasValue)
                {
                    //sb.Append(sqlTemp.FormatWith(empty, userext.UserID.ToString()));
                    userExt.LevelName = null;
                }
            }
            else
            {
                if (tempLevel.BBSEnumId != userExt.LevelName)
                {
                    //sb.Append(sqlTemp.FormatWith(tempLevel.BBSEnumId.ToString(), userext.UserID.ToString()));
                    userExt.LevelName = tempLevel.BBSEnumId;
                }
            }
            ok = true;
            //if (sb.ToString().IsNotNullOrEmpty())
            //{
            //    if (SqlHelper.ExecuteSql(Tran, System.Data.CommandType.Text, sb.ToString(), null) > 0)
            //    {
            //        ok = true;
            //    }
            //}
            //else
            //{
            //    ok = true;
            //}
            return(ok);
        }
Example #18
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //判断信息是否为空

            if (txtNewUserName.Text.Trim() == null)
            {
                MessageBox.Show("请填写新用户名!", "修改提示");
                this.txtNewUserName.Focus();
                return;
            }
            //判断是否存在用户名
            if (objUserService.IsUserNameExisted(txtNewUserName.Text.Trim()) && objUserService.IsUserNameLogin(txtNewUserName.Text.Trim()))
            {
                MessageBox.Show("用户名已存在!", "修改提示");
                this.txtNewUserName.Focus();
                return;
            }
            //提交对象
            //判断是否保存成功
            try
            {
                int result  = objUserService.UpdateUserName(txtUserName.Text.Trim(), txtNewUserName.Text.Trim());
                int result1 = objUserService.UpdateUserLoginName(txtUserName.Text.Trim(), txtNewUserName.Text.Trim());
                if (result == 1 && result == 1)
                {
                    MessageBox.Show("用户名修改成功!请重新登录", "修改提示");
                    this.DialogResult = DialogResult.OK;
                    //更新用户登录时间
                    UserExt userExt = new UserExt()
                    {
                        LoginTime = DateTime.Today,
                        UserName  = txtNewUserName.Text.Trim()
                    };
                    objUserService.UpdateLoginTime(userExt);

                    System.Environment.Exit(0);
                }
                else
                {
                    MessageBox.Show("用户名修改失败", "修改提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "修改提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            objUserService.UpdateUserName(txtUserName.Text.Trim(), txtNewUserName.Text.Trim());
        }
Example #19
0
        private UserService objUserService = new UserService();//创建数据访问对象

        public FrmUserManage()
        {
            InitializeComponent();
            //显示当前用户名
            txtUserName.Text = Program.currentUser.UserName;
            //显示注册时间
            User objUser = objUserService.SelectUserRegisterTime(Program.currentUser.UserName);

            dtpRegisterTime.Text = objUser.RegisterTime.ToString();


            //显示上次登录时间
            UserExt objUserExt = objUserService.SelectUserLoginTime(Program.currentUser.UserName);

            dtpLoginTime.Text = objUserExt.LoginTime.ToString();
        }
Example #20
0
        /// <summary>
        /// 查询登录时间
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        public UserExt SelectUserLoginTime(string UserName)
        {
            string        sql        = "SELECT LoginTime FROM tbUserLoginInfo WHERE UserName = '******'";
            SqlDataReader objReader  = SQLHelper.GetReader(sql);
            UserExt       objUserExt = null;

            if (objReader.Read())
            {
                objUserExt = new UserExt()
                {
                    LoginTime = Convert.ToDateTime(objReader["LoginTime"]),
                };
            }
            objReader.Close();
            return(objUserExt);
        }
 public OperationResult <bool> UpdateProfile(UserExt user)
 {
     try
     {
         return(channel.UpdateProfile(user));
     }
     catch (CommunicationException ex)
     {
         // ReloadChannel();
         //   var res = UpdateProfile(user);
         //  if (!res.IsOk)
         //  {
         //  }
         var res = new OperationResult <bool>(false, false, ex.Message);
         return(res);
     }
 }
Example #22
0
        private IQueryable <OrderDetail> GetAccountSummaryDetail()
        {
            AccountSummary acc = new AccountSummary();

            UserExt uex = _service.GetUserAccountSummary(user.ID, Site.ID);

            if (uex != null)
            {
                acc.TotalInCompleteOrders = Convert.ToInt32(uex.TotalInCompleteOrders);
                acc.Balance              = Convert.ToDecimal(uex.CuurentBalance);
                acc.TotalOrders          = Convert.ToInt32(uex.TotalOrders);
                acc.TotalTransaction     = Convert.ToDecimal(uex.TotalPurchase);
                acc.TotalSupportIncident = Convert.ToInt32(uex.TotalSupportIncident);
            }
            ViewBag.AccountSummary = acc;

            return(_repository.Find(x => x.Order.UserID == user.ID && x.Order.SiteID == Site.ID && (x.ExternalOrderID == null || x.ExternalOrderID == string.Empty)).Include(o => o.Order).Include(o => o.Product).Include(o => o.CertificateRequest).Include(o => o.AuditDetails).Include(o => o.StoreAPIInteraction).OrderBy(o => o.ID));
        }
        private async Task LoadSharedKeyAndQrCodeUriAsync(UserExt user)
        {
            // Load the authenticator key & QR code URI to display on the form
            var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);

            if (string.IsNullOrEmpty(unformattedKey))
            {
                await _userManager.ResetAuthenticatorKeyAsync(user);

                unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
            }

            SharedKey = FormatKey(unformattedKey);

            var email = await _userManager.GetEmailAsync(user);

            AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey);
        }
Example #24
0
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            //更新用户登录时间
            UserExt userExt = new UserExt()
            {
                LoginTime = DateTime.Today,
                UserName  = Program.currentUser.UserName
            };

            objUserService.UpdateLoginTime(userExt);

            DialogResult result = MessageBox.Show("确认退出吗?", "退出询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
            {
                e.Cancel = true;
            }
        }
Example #25
0
        /// <summary>
        /// 保存 (可能有其他业务逻辑检查)
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns></returns>
        public ResultInfo Create(UserExt model)
        {
            ResultInfo ri = new ResultInfo();

            if (model == null)
            {
                return(ri);
            }

            int result = Add(model, null);

            if (result > 0)
            {
                ri.Ok  = true;
                ri.Msg = "添加成功";
            }

            return(ri);
        }
Example #26
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(UserExt model, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserExt set ");
            strSql.Append("UserID=@UserID,TotalScore=@TotalScore,TotalCoin=@TotalCoin,LevelName=@LevelName,OnlyLevelName=@OnlyLevelName,CloseTime=@CloseTime,UserV=@UserV,RealName=@RealName,CardID=@CardID,CompanyName=@CompanyName,CompanyTel=@CompanyTel,CardPic=@CardPic,FaRenPic=@FaRenPic,CheckBBS=@CheckBBS,VIP=@VIP,VIPExpiryTime=@VIPExpiryTime,HeadNameShowType=@HeadNameShowType,UserCenterSkin=@UserCenterSkin");

            strSql.Append(" where UserExtId=@UserExtId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID",           model.UserID),
                new SqlParameter("@TotalScore",       model.TotalScore),
                new SqlParameter("@TotalCoin",        model.TotalCoin),
                new SqlParameter("@LevelName",        model.LevelName),
                new SqlParameter("@OnlyLevelName",    model.OnlyLevelName),
                new SqlParameter("@CloseTime",        model.CloseTime),
                new SqlParameter("@UserV",            model.UserV),
                new SqlParameter("@RealName",         model.RealName),
                new SqlParameter("@CardID",           model.CardID),
                new SqlParameter("@CompanyName",      model.CompanyName),
                new SqlParameter("@CompanyTel",       model.CompanyTel),
                new SqlParameter("@CardPic",          model.CardPic),
                new SqlParameter("@FaRenPic",         model.FaRenPic),
                new SqlParameter("@CheckBBS",         model.CheckBBS),
                new SqlParameter("@VIP",              model.VIP),
                new SqlParameter("@VIPExpiryTime",    model.VIPExpiryTime),
                new SqlParameter("@HeadNameShowType", model.HeadNameShowType),
                new SqlParameter("@UserCenterSkin",   model.UserCenterSkin),


                new SqlParameter("@UserExtId",        model.UserExtId)
            };

            if (tran == null)
            {
                return(SqlHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters) > 0);
            }
            else
            {
                return(SqlHelper.ExecuteSql(tran, CommandType.Text, strSql.ToString(), parameters) > 0);
            }
        }
Example #27
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(UserExt model, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserExt(");
            strSql.Append(" UserID,TotalScore,TotalCoin,LevelName,OnlyLevelName,CloseTime,UserV,RealName,CardID,CompanyName,CompanyTel,CardPic,FaRenPic,CheckBBS,VIP,VIPExpiryTime,HeadNameShowType,UserCenterSkin )");
            strSql.Append(" values (");
            strSql.Append("@UserID,@TotalScore,@TotalCoin,@LevelName,@OnlyLevelName,@CloseTime,@UserV,@RealName,@CardID,@CompanyName,@CompanyTel,@CardPic,@FaRenPic,@CheckBBS,@VIP,@VIPExpiryTime,@HeadNameShowType,@UserCenterSkin);select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID",           model.UserID),
                new SqlParameter("@TotalScore",       model.TotalScore),
                new SqlParameter("@TotalCoin",        model.TotalCoin),
                new SqlParameter("@LevelName",        model.LevelName),
                new SqlParameter("@OnlyLevelName",    model.OnlyLevelName),
                new SqlParameter("@CloseTime",        model.CloseTime),
                new SqlParameter("@UserV",            model.UserV),
                new SqlParameter("@RealName",         model.RealName),
                new SqlParameter("@CardID",           model.CardID),
                new SqlParameter("@CompanyName",      model.CompanyName),
                new SqlParameter("@CompanyTel",       model.CompanyTel),
                new SqlParameter("@CardPic",          model.CardPic),
                new SqlParameter("@FaRenPic",         model.FaRenPic),
                new SqlParameter("@CheckBBS",         model.CheckBBS),
                new SqlParameter("@VIP",              model.VIP),
                new SqlParameter("@VIPExpiryTime",    model.VIPExpiryTime),
                new SqlParameter("@HeadNameShowType", model.HeadNameShowType),
                new SqlParameter("@UserCenterSkin",   model.UserCenterSkin),
            };

            object obj;

            if (tran == null)
            {
                obj = SqlHelper.GetSingle(strSql.ToString(), CommandType.Text, parameters);
            }
            else
            {
                obj = SqlHelper.GetSingle(tran, CommandType.Text, strSql.ToString(), parameters);
            }
            return(obj == null ? 0 : Convert.ToInt32(obj));
        }
        public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            // Get the information about the user from the external login provider
            var info = await _signInManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                ErrorMessage = "Error loading external login information during confirmation.";
                return(RedirectToPage("./Login", new { ReturnUrl = returnUrl }));
            }

            if (ModelState.IsValid)
            {
                var user = new UserExt {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await _userManager.AddLoginAsync(user, info);

                    if (result.Succeeded)
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider);
                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            LoginProvider = info.LoginProvider;
            ReturnUrl     = returnUrl;
            return(Page());
        }
Example #29
0
        private void lblExit_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("确认退出吗?", "退出询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                //更新用户登录时间
                UserExt userExt = new UserExt()
                {
                    LoginTime = DateTime.Today,
                    UserName  = Program.currentUser.UserName
                };
                objUserService.UpdateLoginTime(userExt);

                System.Environment.Exit(0);
            }
            else
            {
                return;
            }
        }
Example #30
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            if (ModelState.IsValid)
            {
                var user = new UserExt {
                    UserName = Input.UserName, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(returnUrl));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }