public JsonResult Index(SysBasicConfig model1) { var jsonm = new ResultJson(); try { var model = BasicConfig; if (string.IsNullOrEmpty(model1.emailpassword)) { model1.emailpassword = model.emailpassword; } if (string.IsNullOrEmpty(model1.smspassword)) { model1.smspassword = model.smspassword; } SerializationHelper.Save(model1, Utils.GetXmlMapPath(KeyHelper.FILE_SITE_XML_CONFING)); //刷新配置项 BasicConfigHelper.setBasicConfig(); return(Json(new ResultJson() { msg = "修改成功", backurl = "" })); } catch (Exception ex) { jsonm.msg = "修改失败"; jsonm.status = 500; LogProvider.Error("修改配置项", ex.StackTrace, ex.Message); } return(Json(jsonm)); }
public BaseApiController(IConfiguration config, IHostingEnvironment _hostingEnvironment) { Service = new SugarBase(); _config = config; hostingEnvironment = _hostingEnvironment; BasicConfig = BasicConfigHelper.getBasicConfig().Result; }
public BaseController(IConfiguration config, IHostingEnvironment _hostingEnvironment) { Service = new SugarBase(); _config = config; //SugarBase.SetConnectionString(config); //RedisHelper.GetIntance(config); hostingEnvironment = _hostingEnvironment; //Utils.ServerPath = hostingEnvironment.ContentRootPath; SysUserModel = getToken(); BasicConfig = BasicConfigHelper.getBasicConfig().Result; //DataHelper.GetIntance(config); ModuleList = GetSysModule(); }
public JsonResult RefreshCache() { var jsonm = new ResultJson(); try { using (var db = SugarBase.GetIntance()) { //刷新配置项 //RedisHelper.StringSet(KeyHelper.CACHE_SITE_CONFIG, LoadConfig(Utils.GetXmlMapPath(KeyHelper.FILE_SITE_XML_CONFING))); BasicConfigHelper.setBasicConfig(); //刷新菜单 setMenuCache(); //刷新当前登录权限 var usermodel = db.Queryable <SysUser>().Where(m => m.SysUserID == SysUserModel.UserID).First(); if (usermodel != null) { var userModel = new AccountToken(); userModel.UserID = usermodel.SysUserID; userModel.UserName = usermodel.SysNickName; var menu_list = db.Queryable <SysModule, SysRoleModule, SysRole, SysUserRole>((sm, srm, sr, sur) => new object[] { JoinType.Left, sm.ID == srm.ModuleID, JoinType.Left, srm.RoleID == sr.RoleID, JoinType.Left, sr.RoleID == sur.RoleID, }) .Where((sm, srm, sr, sur) => sur.UserID == usermodel.SysUserID) .OrderBy((sm, srm, sr, sur) => sm.Sort, OrderByType.Desc) .Select(sm => new SysModule { ID = sm.ID, Href = sm.Href, Business = sm.Business, Icon = sm.Icon, Name = sm.Name, Sort = sm.Sort, Type = sm.Type, ParentID = sm.ParentID }).ToList(); userModel.MenuList = menu_list; var daySpan = TimeSpan.FromMinutes(30); RedisHelper.StringSet("system:SysToken:" + userModel.UserID, MD5CryptHelper.Encrypt(JsonConvert.Serialize(userModel)), daySpan); } } } catch (Exception ex) { jsonm.status = 500; jsonm.msg = "清理失败"; LogProvider.Error("清理缓存", ex.StackTrace, ex.Message); } return(Json(jsonm)); }