public virtual void Modify(ref ValidationErrors errors, Apps.Models.Sys.SysUserConfigModel model, params string[] updateProperties) { SysUserConfig entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Resource.Disable); return; } if (updateProperties.Count() <= 0) { entity.Id = model.Id; entity.Name = model.Name; entity.Value = model.Value; entity.Type = model.Type; entity.State = model.State; entity.UserId = model.UserId; } else { Type type = typeof(Apps.Models.Sys.SysUserConfigModel); Type typeE = typeof(Apps.Models.SysUserConfig); foreach (var item in updateProperties) { System.Reflection.PropertyInfo pi = type.GetProperty(item); System.Reflection.PropertyInfo piE = typeE.GetProperty(item); piE.SetValue(entity, pi.GetValue(model), null); } } m_Rep.Modify(entity, updateProperties); }
/// <summary> /// 获取最新共享 /// </summary> /// <param name="top"></param> /// <param name="userId"></param> /// <returns></returns> //public List<P_Mis_FileGetMyReadFile_Result> GetPartData8(int top, string userId) //{ // using (SysEntities db = SysDb.getDB()) // { // return db.P_WebPart_GetShareFileByUserId(userId, top).AsQueryable().ToList(); // } //} /// <summary> /// 新建或修改HTML /// </summary> /// <param name="html"></param> public int SaveHtml(string userId, string html) { SysUserConfig ss = new SysUserConfig(); ss.Id = "webpart"; ss.UserId = userId; ss.Value = html; ss.Type = "webpart"; ss.State = true; ss.Name = "webpart"; string strSql = @"if(select COUNT(*) from SysUserConfig where id='webpart' and UserId=@UsrId)=0 begin insert into SysUserConfig values('webpart', 'webpart',@Html, 'webpart', 1, @UsrId) end else begin update SysUserConfig set Value = @Html where id = 'webpart' and UserId = @UsrId end"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Html", html), new SqlParameter("@UsrId", userId), }; return(Context.Database.ExecuteSqlCommand(strSql, para)); }
/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <SysUserConfigModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { SysUserConfig entity = new SysUserConfig(); entity.Id = ResultHelper.NewId; entity.Name = model.Name; entity.Value = model.Value; entity.Type = model.Type; entity.State = model.State; entity.UserId = model.UserId; db.SysUserConfig.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }
public override bool Edit(ref ValidationErrors errors, SysUserConfigModel model) { try { SysUserConfig entity = m_Rep.GetById(model.Id, model.UserId); if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.Id = model.Id; entity.Name = model.Name; entity.Value = model.Value; entity.Type = model.Type; entity.State = model.State; entity.UserId = model.UserId; if (m_Rep.Edit(entity)) { return(true); } else { errors.Add(Resource.NoDataChange); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public JsonResult SetThemes(string theme, string menu, bool topmenu) { SysUserConfig entity = userConfigBLL.GetByUserType("themes", GetUserId()); if (entity != null) { entity.Value = theme; userConfigBLL._SysUserConfigRepository.Update(entity); } else { entity = new SysUserConfig() { Name = "用户自定义主题", Value = theme, Type = "themes", State = "true", UserId = GetUserId() }; userConfigBLL._SysUserConfigRepository.Create(entity); } Session["themes"] = theme; //开启顶部菜单,顶部菜单必须配置多一层 if (topmenu) { menu = menu + ",topmenu"; } SysUserConfig entityMenu = userConfigBLL.GetByUserType("menu", GetUserId()); if (entityMenu != null) { entityMenu.Value = menu; userConfigBLL._SysUserConfigRepository.Update(entityMenu); } else { entityMenu = new SysUserConfig() { Name = "用户自定义菜单", Value = menu, Type = "menu", State = "true", UserId = GetUserId() }; userConfigBLL._SysUserConfigRepository.Create(entityMenu); } Session["menu"] = menu; return(Json("1", JsonRequestBehavior.AllowGet)); }
public ActionResult Desktop() { SysUserConfig ss = webPartBLL.GetByIdAndUserId("webpart", GetUserId()); if (ss != null) { ViewBag.Value = ss.Value; } else { ViewBag.Value = ""; } return(View()); }
public ActionResult Desktop() { string userId = GetUserId(); //获取配置文件里的页面内容,没有就显示默认的。 SysUserConfig ss = webPartBLL.m_Rep.Find(a => a.UserId == userId && a.State == "true"); if (ss != null) { ViewBag.Value = ss.Value; } else { ViewBag.Value = ""; } return(View()); }
public SysUserConfigModel GetById(string type, string userId) { SysUserConfig entity = m_Rep.GetById(type, userId); if (entity == null) { return(null); } SysUserConfigModel model = new SysUserConfigModel(); model.Id = entity.Id; model.Name = entity.Name; model.Value = entity.Value; model.Type = entity.Type; model.State = entity.State; model.UserId = entity.UserId; return(model); }
public virtual void Create(ref ValidationErrors errors, Apps.Models.Sys.SysUserConfigModel model) { SysUserConfig entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return; } entity = new SysUserConfig(); entity.Id = model.Id; entity.Name = model.Name; entity.Value = model.Value; entity.Type = model.Type; entity.State = model.State; entity.UserId = model.UserId; m_Rep.Create(entity); }
public ActionResult Desktop() { string userId = GetUserId(); //SysUserConfig ss = webPartBLL.m_Rep.Find(a => a.Name == "webpart" && a.UserId == userId); SysUserConfig ss = webPartBLL.m_Rep.Find(a => a.UserId == userId && a.State == "true"); Account account = new Account(); account = (Account)Session["Account"]; ViewBag.DepName = structBLL.m_Rep.Find(Convert.ToInt32(account.DepId)).Name; if (ss != null) { ViewBag.Value = ss.Value; } else { ViewBag.Value = ""; } return(View()); }
//public override void Modify(ref ValidationErrors errors, SysUserConfigModel model, params string[] updateProperties) //{ // SysUserConfig entity = new SysUserConfig(); // if (entity == null) // { // errors.Add(Resource.Disable); // return; // } // entity.Id = model.Id; // entity.Name = model.Name; // entity.Value = model.Value; // entity.Type = model.Type; // entity.State = model.State; // entity.UserId = model.UserId; // m_Rep.Modify(entity, updateProperties); //} public override void Create(ref ValidationErrors errors, SysUserConfigModel model) { SysUserConfig entity = m_Rep.GetById(model.Type, model.UserId); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return; } entity = new SysUserConfig(); entity.Id = ResultHelper.NewId; entity.Name = model.Name; entity.Value = model.Value; entity.Type = model.Type; entity.State = model.State; entity.UserId = model.UserId; m_Rep.Create(entity); }
public virtual SysUserConfigModel GetById(string id) { if (IsExists(id)) { SysUserConfig entity = m_Rep.GetById(id); SysUserConfigModel model = new SysUserConfigModel(); model.Id = entity.Id; model.Name = entity.Name; model.Value = entity.Value; model.Type = entity.Type; model.State = entity.State; model.UserId = entity.UserId; return(model); } else { return(null); } }
public virtual async Task <SysUserConfigModel> GetByIdAsync(object id) { if (IsExists(id)) { SysUserConfig entity = await m_Rep.GetByIdAsync(id); SysUserConfigModel model = new SysUserConfigModel(); model.Id = entity.Id; model.Name = entity.Name; model.Value = entity.Value; model.Type = entity.Type; model.State = entity.State; model.UserId = entity.UserId; return(model); } else { return(null); } }
public virtual bool Create(ref ValidationErrors errors, SysUserConfig model) { try { var entity = _sysUserConfigRepository.GetById(model.ID); if (null != entity) { errors.Add(ErrorMessage.PrimaryRepeat); } entity = new SysUserConfig { ID = model.ID, Name = model.Name, Value = model.Value, Type = model.Type, State = model.State, SysUserId = model.SysUserId }; _sysUserConfigRepository.Insert(entity); if (_sysUserConfigRepository.UnitOfWork.Commite() > 0) { return(true); } else { errors.Add(ErrorMessage.InsertFail + $"entity:\n\n{entity.ToJson()}"); return(false); } } catch (Exception ex) { errors.Add(ex.Message); //ExceptionHander.WriteException(ex); return(false); } }
/// <summary> /// 获取最新共享 /// </summary> /// <param name="top"></param> /// <param name="userId"></param> /// <returns></returns> //public List<P_Mis_FileGetMyReadFile_Result> GetPartData8(int top, string userId) //{ // using (SysEntities db = SysDb.getDB()) // { // return db.P_WebPart_GetShareFileByUserId(userId, top).AsQueryable().ToList(); // } //} /// <summary> /// 新建或修改HTML /// </summary> /// <param name="html"></param> public int SaveHtml(string userId, string html) { SysUserConfig ss = new SysUserConfig(); ss.Id = "webpart"; ss.UserId = userId; ss.Value = html; ss.Type = "webpart"; ss.State = true; ss.Name = "webpart"; if (GetByIdAndUserId("webpart", userId) == null) { Context.SysUserConfig.Add(ss); } else { Context.Set <SysUserConfig>().Attach(ss); Context.Entry <SysUserConfig>(ss).State = EntityState.Modified; } return(Context.SaveChanges()); }
public void GetThemes(string userid) { SysUserConfig entity = userConfigBLL.GetByUserType("themes", userid); SysUserConfig menuEntity = userConfigBLL.GetByUserType("menu", userid); if (entity != null) { Session["themes"] = entity.Value; } else { Session["themes"] = "blue"; } if (menuEntity != null) { Session["menu"] = menuEntity.Value; } else { Session["menu"] = "accordion"; } }
/// <summary> /// 获取最新共享 /// </summary> /// <param name="top"></param> /// <param name="userId"></param> /// <returns></returns> //public List<P_Mis_FileGetMyReadFile_Result> GetPartData8(int top, string userId) //{ // using (SysEntities db = SysDb.getDB()) // { // return db.P_WebPart_GetShareFileByUserId(userId, top).AsQueryable().ToList(); // } //} /// <summary> /// 新建或修改HTML /// </summary> /// <param name="html"></param> public int SaveHtml(string userId, string html) { SysUserConfig ss = GetByIdAndUserId("webpart", userId); if (ss == null) { ss = new SysUserConfig(); ss.Id = "webpart"; ss.UserId = userId; ss.Value = html; ss.Type = "webpart"; ss.State = true; ss.Name = "自由桌面"; Context.SysUserConfig.Add(ss); } else { ss.Value = html; new SysUserConfigRepository(Context).Edit(ss); } return(Context.SaveChanges()); }
public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(SysUserConfigModel model) { ValidationErrors errors = new ValidationErrors(); try { SysUserConfig entity = await m_Rep.GetByIdAsync(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new SysUserConfig(); entity.Id = model.Id; entity.Name = model.Name; entity.Value = model.Value; entity.Type = model.Type; entity.State = model.State; entity.UserId = model.UserId; if (await m_Rep.CreateAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.InsertFail); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
public virtual Apps.Models.Sys.SysUserConfigModel GetById(string id) { SysUserConfig entity = m_Rep.GetById(id); if (entity != null) { //SysUserConfig entity = m_Rep.GetById(id); Apps.Models.Sys.SysUserConfigModel model = new Apps.Models.Sys.SysUserConfigModel(); model.Id = entity.Id; model.Name = entity.Name; model.Value = entity.Value; model.Type = entity.Type; model.State = entity.State; model.UserId = entity.UserId; return(model); } else { return(null); } }
/// <summary> /// 新建或修改HTML /// </summary> /// <param name="html"></param> public bool SaveHtml(string userId, string html) { SysUserConfig ss = m_Rep.Find(a => a.Name == "webpart" && a.UserId == userId); if (ss == null) { ss = new SysUserConfig(); ss.UserId = userId; ss.Value = html; ss.Type = "webpart"; ss.State = "true"; ss.Name = "webpart"; return(m_Rep.Create(ss)); } else { ss.Value = html; ss.Type = "webpart"; ss.State = "true"; return(m_Rep.Update(ss)); } }
public virtual bool Create(ref ValidationErrors errors, SysUserConfigModel model) { try { SysUserConfig entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new SysUserConfig(); entity.Id = model.Id; entity.Name = model.Name; entity.Value = model.Value; entity.Type = model.Type; entity.State = model.State; entity.UserId = model.UserId; if (m_Rep.Create(entity)) { return(true); } else { errors.Add(Resource.InsertFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public override bool Create(SysUserConfig model, bool isCommit = true) { string sql = string.Format("INSERT INTO [SysUserConfig]([Id],[Name],[Value],[Type],[State],[UserId]) VALUES('{0}','{1}','{2}','{3}',{4},'{5}')", model.Id, model.Name, model.Value, model.Type, 1, model.UserId); return(ExecuteSqlCommand(sql) > 0); }
public bool ModifyBySql(SysUserConfig model) { string sql = string.Format("update SysUserConfig set value='{0}' where Id='{1}' and UserId='{2}'", model.Value, model.Id, model.UserId); return(ExecuteSqlCommand(sql) > 0); }
public bool CreateBySql(SysUserConfig model) { string sql = string.Format("INSERT INTO [AppsDB].[dbo].[SysUserConfig]([Id],[Name],[Value],[Type],[State],[UserId]) VALUES('{0}','{1}','{2}','{3}',{4},'{5}')", model.Id, model.Name, model.Value, model.Type, 1, model.UserId); return(ExecuteSqlCommand(sql) > 0); }
public override bool Edit(SysUserConfig model, bool isCommit = true) { string sql = string.Format("update SysUserConfig set value='{0}' where Id='{1}' and UserId='{2}'", model.Value, model.Id, model.UserId); return(ExecuteSqlCommand(sql) > 0); }