public LoginUserInfo(User user)
        {
            this.UserId = user.Id;
            this.UserName = user.UserName;
            this.UserDisplayName = user.DisplayName;
            this.LoginUserLastLoginDate = user.LastLoginDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
            //string tempPath = user.PicPath;
            string uploadSite = System.Configuration.ConfigurationManager.AppSettings["uploadSite"];
            this.UploadSitePath = System.Configuration.ConfigurationManager.AppSettings["uploadSitePath"];
            this.RoleLevel = user.Level;
            //this.UserFolderUrlPath = System.Web.HttpContext.Current.Server.UrlPathEncode(System.Web.HttpContext.Current.Request.ApplicationPath + "//Upload//User//" + user.UserName + "//");
            //this.UserFolderPath = System.Web.HttpContext.Current.Server.MapPath("~") + "\\upload\\User\\" + user.UserName + "\\";

            this.UserFolderUrlPath = System.Web.HttpContext.Current.Server.UrlPathEncode(uploadSite + "User//" + user.UserName + "//");
            this.UserFolderPath = this.UploadSitePath + "User\\" + user.UserName + "\\";
            this.LoginUserPicPath = System.Web.HttpContext.Current.Server.UrlPathEncode(uploadSite + "defaultIcon/woman.jpg");
            if (System.IO.File.Exists(this.UploadSitePath + user.PicPath))
                this.LoginUserPicPath = System.Web.HttpContext.Current.Server.UrlPathEncode(uploadSite + user.PicPath);
        }
 public JsonResult ChangePsd(User model)
 {
     try
     {
         var oldPsd = Request.Form["OldPassword"];
         Dictionary<string, object> updates = new Dictionary<string, object>() { { "Password", RobinCore.Instance.EncodePassword(Request.Form["Password"]) }, { "LastPasswordChangedDate", DateTime.Now } };
         QueryModel queryModel = new QueryModel();
         queryModel.AddAndQuery("id", "=", model.Id);
         queryModel.AddAndQuery("Password", "=", RobinCore.Instance.EncodePassword(oldPsd));
         bool jsonResult = UnityInstance.Instance.GetObject<IAccountService>().ChangePsd(updates, queryModel);//AccountManager.Instance.ChangePsd(update);
         BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", jsonResult);
         return Json(new { result = jsonResult, text = jsonResult ? "The password updated successfully!" : "something was wrong!", callbackapi = "SystemDefine/User" });
     }
     catch (Exception ex)
     {
         BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", false, ex.Message);
         throw ex;
     }
 }
 public JsonResult UpdateById(User model)
 {
     try
     {
         Dictionary<string, object> updates = new Dictionary<string, object>() { { "Address", model.Address }, { "Sex", model.Sex }, { "Email", model.Email }, { "PasswordQuestion", model.PasswordQuestion }, { "PasswordAnswer", model.PasswordAnswer }, { "Comment", model.Comment }, { "CultrueType", model.CultrueType }, { "IsEnabled", model.IsEnabled } };
         bool jsonResult = this.superService.UpdateFields<User>(updates, new QueryModel("id", model.Id)); //SuperManager.Instance.UpdateById<User>(update);
         if (jsonResult == true)
         {
             DataCache.Instance.ReInitUser();
         }
         BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", jsonResult);
         return Json(new { result = jsonResult, text = jsonResult ? "record  updated successfully!" : "something was wrong!", callbackapi = "SystemDefine/User" });
     }
     catch (Exception ex)
     {
         BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", false, ex.Message);
         throw ex;
     }
 }
 public JsonResult Create(User model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             bool exist = UnityInstance.Instance.GetObject<IAccountService>().UserExist(model.UserName);// AccountManager.Instance.UserExist(model.UserName);
             if (exist)
             {
                 return Json(new { result = false, text = "the username  already exists!", callbackapi = "" });
             }
             else
             {
                 model.CreateDate = DateTime.Now;
                 model.Password = RobinCore.Instance.EncodePassword(model.Password);
                 model.PicPath = "User/" + model.UserName + "/UserIcon/" + model.UserName + ".jpg";
                 //   model.PicPath = System.Configuration.ConfigurationManager.AppSettings["uploadSite"] + model.UserName + "/UserIcon/" + model.UserName + ".jpg";
                 if (string.IsNullOrWhiteSpace(model.CultrueType))
                     model.CultrueType = "EN";
                 bool jsonResult = this.superService.Insert<User>(model); //SuperManager.Instance.Create<User>(model);
                 BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", jsonResult);
                 return Json(new { result = jsonResult, text = jsonResult ? "One record created successfully!" : "something was wrong!", callbackapi = "SystemDefine/User" });
             }
         }
         catch (Exception ex)
         {
             BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", false, ex.Message);
             throw ex;
         }
     }
     else
         throw new Exception("ModelState.IsValid is false");
 }
 /// <summary>
 /// 重新初始化用户
 /// </summary>
 public void ReInitUser()
 {
     if (VerificationSession())
     {
         var userId = HttpContext.Current.Session["loginUserId"].ToString();// HttpContext.Session["loginUserId"];
         string json = UnityInstance.Instance.GetObject<ISuperService>().FindOne<User>(new DTO.Query.QueryModel("UserName", string.IsNullOrWhiteSpace(HttpContext.Current.User.Identity.Name) ? userId : HttpContext.Current.User.Identity.Name));
         this.user = Newtonsoft.Json.JsonConvert.DeserializeObject<User>(json);
     }
 }