public OperateResult SaveStoreUserInfo(SysStoreUserInfo model) { var obj = _sysStoreUserInfoRepository.GetByUid(model.UID); if (obj == null) { if (string.IsNullOrWhiteSpace(model.OperateAuth)) { return(OperateResult.Fail("请选择用户门店角色")); } var user = GetEntities().FirstOrDefault(o => o.UID == model.UID); obj = new SysStoreUserInfo(); user.ToCopyProperty(obj); _sysStoreUserInfoRepository.Create(obj); } if (!string.IsNullOrWhiteSpace(model.OperateAuth)) { obj.OperateAuth = model.OperateAuth; } else { _sysStoreUserInfoRepository.Delete(new object[] { obj.Id }); } SaveChanges(); return(OperateResult.Success()); }
/// <summary> /// 统一登录写入cookie /// </summary> /// <param name="user">Entity.SysUserInfo 用户信息类</param> /// <param name="remember">记住用户和密码,默认false</param> public void StoreLogin(SysStoreUserInfo user, string store, bool remember = false) { Dictionary <string, string> kv = new Dictionary <string, string>(); kv.Add(key_cid, user.CompanyId.ToString()); kv.Add(key_uid, user.UID); kv.Add(key_uname, user.LoginName); kv.Add(key_fname, HttpUtility.UrlEncode(user.FullName)); //kv.Add(key_branchId, user.BranchId.ToString()); //kv.Add(key_bumenId, user.BumenId.ToString()); //kv.Add(key_photo, user.PhotoUrl); kv.Add(key_storeId, HttpUtility.UrlEncode(store)); //kv.Add(key_roleId, user.RoleIds); Cookies.Remove("storeremuc"); if (remember) { //kv.Add("_pwd", user.LoginPwd); Cookies.Set("storeremuc", kv, 100, true);//防止退出删除 } //StoreId { get { return "d4ab4325c87c4863b1419b6862d8454c"; } } SettingLimits(user.UID); //Cookies.Set(uc, kv); Cookies.Set(Url.CurDomain, "", uc, kv, 1, false); log.WriteLogin(string.Format("用户({0},{1})成功登录门店系统!", user.LoginName, user.FullName), LogModule.其他); }
/// <summary> /// 根据id获取门店用户信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public SysStoreUserInfo GetStoreUserInfoByUId(string uid) { var user = _storedal.GetByColumn(uid, "uid"); if (user == null) { user = new SysStoreUserInfo(); user.UserCode = SysCommonRules.UserCode; } return(user); }
/// <summary> /// 根据id获取门店用户信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public SysStoreUserInfo GetStoreUserInfoById(int id) { var user = _storedal.GetById(id); if (user == null) { user = new SysStoreUserInfo(); user.UserCode = SysCommonRules.UserCode; } return(user); }
public ActionResult UserSettingStoreRole(string uid) { var obj = AutofacDependencyResolver.Current.GetService <ISysStoreUserInfoRepository>().GetByUid(uid); if (obj == null) { obj = new SysStoreUserInfo() { UID = uid }; } return(View(obj)); }
public ActionResult UserSettingStoreRole(SysStoreUserInfo model) { var result = _sysUserRespository.SaveStoreUserInfo(model); return(Content(result.ToJson())); }
public OpResult SaveStoreUserInfo(SysStoreUserInfo model) { var result = OpResult.Fail("数据保存失败!"); try { var obj = _storedal.GetByColumn(model.UID, "UID"); if (obj != null) { if (model.LoginPwd == null) { model.LoginPwd = obj.LoginPwd; } } var auths = model.OperateAuth; if (obj != null) { var re = false; if (!string.IsNullOrEmpty(model.OperateAuth)) { re = _storedal.UpdataOperateAuth(model); } else { auths = obj.OperateAuth; re = _storedal.Delete(obj.Id); } if (re) { result = OpResult.Success("数据保存成功"); } } else { if (!string.IsNullOrEmpty(model.OperateAuth)) { // new SqlParameter("@FullName",model.FullName), //new SqlParameter("@UserCode",model.UserCode), //new SqlParameter("@LoginPwd",model.LoginPwd), //new SqlParameter("@Sex",model.Sex), //new SqlParameter("@OperateAuth",model.OperateAuth), //new SqlParameter("@Status",model.Status), //new SqlParameter("@LoginName",model.LoginName) if (string.IsNullOrEmpty(model.FullName) || string.IsNullOrEmpty(model.UserCode) || string.IsNullOrEmpty(model.LoginName) || string.IsNullOrEmpty(model.LoginPwd)) { var oUser = _dal.GetByColumn(model.UID, "UID"); if (string.IsNullOrEmpty(model.FullName)) { model.FullName = oUser.FullName; } if (string.IsNullOrEmpty(model.UserCode)) { model.UserCode = oUser.UserCode; } if (string.IsNullOrEmpty(model.LoginName)) { model.LoginName = oUser.LoginName; } if (string.IsNullOrEmpty(model.LoginPwd)) { model.LoginPwd = oUser.LoginPwd; } if (model.LoginDT == default(DateTime)) { model.LoginDT = DateTime.Now; } if (model.Status == 0) { model.Status = oUser.Status; } } var re = _storedal.Insert(model); if (re > 0) { result = OpResult.Success("数据保存成功"); } } else { result = OpResult.Fail("请选择用户门店角色。"); } } if (result.Successed && !string.IsNullOrWhiteSpace(auths)) { var stores = new List <string>(); foreach (var a in auths.Split('|')) { stores.Add(a.Split(',')[0]); } var storeIds = string.Join(",", stores); //Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged() { CompanyId = SysCommonRules.CompanyId, StoreId = storeIds, Target = "SysStoreUserInfo" }); } } catch (Exception ex) { result = OpResult.Fail("数据保存失败!" + ex.Message); } return(result); }