////[SupportFilter] public ActionResult Index() { SysConfigBLL bll = new SysConfigBLL(); SysConfigModel model = bll.loadConfig(Utils.GetXmlMapPath(ContextKeys.FILE_SITE_XML_CONFING)); return(View(model)); }
public void SaveConfig(SysConfigModel model, String configFilePath) { lock (lockHelper) { SerializationHelper.Save(model, configFilePath); } }
public SysConfigModel SaveConifg(SysConfigModel model, string configFilePath) { lock (lockHelper) { SerializationHelper.Save(model, configFilePath); } return(model); }
public Task <IActionResult> Edit(SysConfigModel model) { return(this.JsonResultAsync(() => { model.OperateUserID = AdminID; return _sysConfigApplication.EditConfigAsync(model); })); }
/// <summary> /// 获取json格式的Expand,返回对象 /// </summary> public static T GetExpand <T>(this SysConfigModel dictionaryConfig) { if (dictionaryConfig == null) { return(default(T)); } return(Deserialize <T>(dictionaryConfig.Expand)); }
public static T GetDescription <T>(this SysConfigModel dictionaryConfig) { if (dictionaryConfig == null) { return(default(T)); } return(Deserialize <T>(dictionaryConfig.Description)); }
public ActionResult Index() { ViewBag.Perm = GetPermission(); Apps.BLL.SysConfigBLL bll = new Apps.BLL.SysConfigBLL(); SysConfigModel model = bll.loadConfig(Utils.GetXmlMapPath(ContextKeys.FILE_SITE_XML_CONFING)); return(View(model)); }
public ActionResult SysConfigEdit(SysConfigModel model) { var result = new JsonModel(); var opType = OperationType.Update; SysConfig config = null; if (model.Id == 0) { config = new SysConfig(); opType = OperationType.Insert; } else { config = SysConfigRepository.Get(model.Id); if (config == null) { result.msg = "记录不存在!"; return(Json(result)); } } Mapper.Map(model, config); switch (config.ConfigType) { case SysConfigType.String: config.ConValue = JsonConvert.SerializeObject(model.StringValue); break; case SysConfigType.Bool: config.ConValue = JsonConvert.SerializeObject(model.BoolValue); break; case SysConfigType.TextArea: config.ConValue = JsonConvert.SerializeObject(model.TextAreaValue); break; case SysConfigType.Int: config.ConValue = JsonConvert.SerializeObject(model.IntValue); break; case SysConfigType.Long: config.ConValue = JsonConvert.SerializeObject(model.LongValue); break; case SysConfigType.StringArray: config.ConValue = JsonConvert.SerializeObject(model.StringArrayValue.Split(',')); break; default: break; } SysConfigRepository.Save(config); LogRepository.Insert(TableSource.SysConfig, opType, config.Id); result.code = JsonModelCode.Succ; result.msg = "保存成功!"; return(Json(result)); }
/// <summary> /// 读取配置文件 /// </summary> public SysConfigModel LoadConfig(string configFilePath) { SysConfigModel model = CacheHelper.Get <SysConfigModel>(ContextKeys.CACHE_SITE_CONFIG); if (model == null) { CacheHelper.Insert(ContextKeys.CACHE_SITE_CONFIG, Load(configFilePath), configFilePath); model = CacheHelper.Get <SysConfigModel>(ContextKeys.CACHE_SITE_CONFIG); } return(model); }
/// <summary> /// 读取客户端站点配置信息 /// </summary> public SysConfigModel LoadConfig(string configFilePath, bool isClient) { SysConfigModel model = CacheHelper.Get <SysConfigModel>(ContextKeys.CACHE_SITE_CONFIG_CLIENT); if (model == null) { model = Load(configFilePath); model.templateskin = model.webpath + "templates/" + model.templateskin; CacheHelper.Insert(ContextKeys.CACHE_SITE_CONFIG_CLIENT, model, configFilePath); } return(model); }
public SysConfigModel loadConfig(string configPath) { SysConfigModel sysConfigModel = null; if (File.Exists(configPath)) { System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(configPath); sysConfigModel = XmlUtil <SysConfigModel> .Deserialize(xmlDoc.ToString()); } return(sysConfigModel); }
public JsonResult Edit(SysConfigModel model) { Apps.BLL.SysConfigBLL bll = new Apps.BLL.SysConfigBLL(); try { bll.saveConifg(model, Utils.GetXmlMapPath(ContextKeys.FILE_SITE_XML_CONFING)); return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed))); } catch { return(Json(JsonHandler.CreateMessage(0, Resource.EditFail))); } }
public ActionResult Update(SysConfigModel model) { model.LastOpUserId = base.AdminUserId; var result = SysConfigService.Update(model); if (result.Code == ResultCode.Success) { return(RedirectToAction("List", new { id = model.TypeId })); } else { ViewData["Message"] = "修改失败!" + result.Message; return(View(model)); } }
public ActionResult SysConfigEdit(long id, string reUrl) { ViewBag.ReUrl = reUrl ?? Url.Action("SysConfigList"); var model = new SysConfigModel(); if (id == 0) { return(View(model)); } var config = SysConfigRepository.Get(id); if (config == null) { ShowErrorMsg(); return(Redirect(ViewBag.ReUrl)); } Mapper.Map(config, model); switch (model.ConfigType) { case SysConfigType.String: model.StringValue = JsonConvert.DeserializeObject <string>(model.ConValue); break; case SysConfigType.Bool: model.BoolValue = JsonConvert.DeserializeObject <bool>(model.ConValue); break; case SysConfigType.TextArea: model.TextAreaValue = JsonConvert.DeserializeObject <string>(model.ConValue); break; case SysConfigType.Int: model.IntValue = JsonConvert.DeserializeObject <int>(model.ConValue); break; case SysConfigType.Long: model.LongValue = JsonConvert.DeserializeObject <long>(model.ConValue); break; case SysConfigType.StringArray: model.StringArrayValue = string.Join(",", JsonConvert.DeserializeObject <string[]>(model.ConValue)); break; default: break; } return(View(model)); }
private void ts_SetPath_Click(object sender, EventArgs e) { SetName setName = new SetName(true); var model = SysConfigModel.F_DBInfo; if (!string.IsNullOrEmpty(model.Path)) { setName.TValue = model.Path.ConvertString(); } if (setName.ShowDialog() == DialogResult.OK) { SysConfigModel savePathModel = new SysConfigModel(); savePathModel.Path = setName.TValue.ConvertString(); savePathModel.AddOrUpdate(); } }
public ActionResult Index() { if (OpeCur.AccountNow != null) { SysConfigModel siteConfig = OpeCur.ServiceSession.SysConfig.LoadConfig(Utils.GetXmlMapPath("Configpath")); ViewBag.IsEnable = siteConfig.webimstatus; ViewBag.NewMesTime = siteConfig.refreshnewmessage; ViewBag.WebName = siteConfig.webname; ViewBag.ComName = siteConfig.webcompany; ViewBag.CopyRight = siteConfig.webcopyright; return(View(OpeCur.AccountNow)); } else { return(RedirectToAction("Index", "Account")); } }
// GET: Account public ActionResult Index() { if (Session["uinfo"] != null) { return(RedirectToAction("Index", "Home")); } SysConfigModel siteConfig = OpeCur.ServiceSession.SysConfig.LoadConfig(Common.Utils.GetXmlMapPath("ConfigPath")); //系统名称 ViewBag.WebName = siteConfig.webname; //公司名称 ViewBag.ComName = siteConfig.webcompany; // ViewBag.CopyRight = siteConfig.webcopyright; return(View()); }
/// <summary> /// 修改配置信息 /// </summary> /// <param name="sysConfigModel">配置信息</param> /// <returns>操作结果</returns> public Task <OperateResult> EditConfigAsync(SysConfigModel sysConfigModel) { return(OperateUtil.ExecuteAsync(async() => { var sysConfigInfo = _sysConfigDomainService.Create(sysConfigModel); var flag = await LockUtil.ExecuteWithLockAsync(Lock_SysConfigModify, sysConfigInfo.FKey, TimeSpan.FromMinutes(2), async() => { await _sysConfigDomainService.CheckAsync(sysConfigInfo); await _sysConfigRepository.UpdateAsync(sysConfigInfo, m => m.FID == sysConfigInfo.FID, ignoreFields: IDAndCreate); _operateLogDomainService.AddOperateLog(sysConfigModel.OperateUserID.Value, OperateModule.SysConfig, OperateModuleNode.Edit, $"{sysConfigInfo.GetOperateDesc()}"); _sysConfigDomainService.ConfigChanged(OperateType.Modify, sysConfigInfo.FID); return true; }, defaultValue: false); if (!flag) { throw new BizException("修改失败"); } }, callMemberName: "SysConfigApplication-EditConfigAsync")); }
/// <summary> /// 添加配置信息 /// </summary> /// <param name="sysConfigModel">配置信息</param> /// <returns>操作结果</returns> public Task <OperateResult> AddConfigAsync(SysConfigModel sysConfigModel) { return(OperateUtil.ExecuteAsync(async() => { var sysConfigInfo = _sysConfigDomainService.Create(sysConfigModel); int id = await LockUtil.ExecuteWithLockAsync(Lock_SysConfigModify, sysConfigInfo.FKey, TimeSpan.FromMinutes(2), async() => { await _sysConfigDomainService.CheckAsync(sysConfigInfo); var configID = (await _sysConfigRepository.InsertOneAsync(sysConfigInfo, keyName: "FID", ignoreFields: FID)).ToSafeInt32(0); _operateLogDomainService.AddOperateLog(sysConfigModel.OperateUserID.Value, OperateModule.SysConfig, OperateModuleNode.Add, $"{sysConfigInfo.GetOperateDesc()}"); _sysConfigDomainService.ConfigChanged(OperateType.Add, configID); return configID; }, defaultValue: -1); if (id <= 0) { throw new BizException("添加失败"); } }, callMemberName: "SysConfigApplication-AddConfigAsync")); }
private void btn_GenerateData_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(SysConfigModel.F_DBInfo.Path)) { SysConfigModel sysConfigModel = new SysConfigModel() { Path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) }; sysConfigModel.AddOrUpdate(); } if (tcl_tabList.SelectedTab.Name == tbp_TableScript.Name) { TableScript_Generate(); } else { DataScript_Generate(); } }
/// <summary> /// 添加通用键值对配置信息 /// </summary> /// <returns></returns> public static Result <bool> Add(SysConfigModel ent) { #region 数据验证 var result = ParamsCheck(ent); if (result.Code != ResultCode.Success) { return(result); } var exists = SysConfigRepository.Exists(ent.KeyName); if (exists.HasValue) { if (exists.Value) { result.Message = "存在相同的键名"; } } else { result.Message = "键值对查询数据库异常"; } if (!string.IsNullOrEmpty(result.Message)) { result.Code = ResultCode.Error; return(result); } #endregion ent.InsertTime = ent.UpdateTime = DateTime.Now; ent.IsActive = true; var dbResult = SysConfigRepository.Add(ent); if (dbResult) { result.Code = ResultCode.Success; CacheHelper.Set(ent.KeyName, ent, TimeSpan.FromMinutes(10)); } else { result.Code = ResultCode.Error; result.Message = "数据库操作异常"; } return(result); }
/// <summary> /// 创建配置信息 /// </summary> /// <param name="sysConfigModel">配置信息</param> /// <returns>配置信息</returns> public SysConfigInfo Create(SysConfigModel sysConfigModel) { sysConfigModel.NotNull("配置信息不能为空"); sysConfigModel.FKey.NotNullAndNotEmptyWhiteSpace("Key不能为空"); var sysConfigInfo = new SysConfigInfo { FComment = sysConfigModel.FComment, FCreateTime = DateTimeUtil.Now, FCreateUserID = sysConfigModel.OperateUserID.Value, FIsDeleted = false, FKey = sysConfigModel.FKey.Trim(), FValue = sysConfigModel.FValue, FID = sysConfigModel.FID ?? 0 }; if (sysConfigInfo.FID > 0) { sysConfigInfo.FLastModifyTime = DateTimeUtil.Now; sysConfigInfo.FLastModifyUserID = sysConfigModel.OperateUserID; } return(sysConfigInfo); }
private static Result <bool> ParamsCheck(SysConfigModel ent) { var result = new Result <bool>(); ent.GroupName = string.IsNullOrEmpty(ent.GroupName) ? null : ent.GroupName.Trim(); ent.KeyName = string.IsNullOrEmpty(ent.KeyName) ? null : ent.KeyName.Trim(); if (string.IsNullOrEmpty(ent.GroupName)) { result.Message = "组名称不能为空!"; return(result); } if (string.IsNullOrEmpty(ent.KeyName)) { result.Message = "键名称不能为空!"; return(result); } if (string.IsNullOrEmpty(ent.Value.Trim())) { result.Message = "值不能为空!"; return(result); } if (string.IsNullOrEmpty(ent.OwnerName.Trim())) { result.Message = "所有者不能为空!"; return(result); } if (ent.LastOpUserId <= 0) { result.Message = "最后操作人不能为空!"; return(result); } if (string.IsNullOrEmpty(ent.Description.Trim())) { result.Message = "描述信息不能为空!"; return(result); } result.Code = ResultCode.Success; return(result); }
/// <summary> /// 写入日志 /// </summary> /// <param name="oper">操作人</param> /// <param name="mes">操作信息</param> /// <param name="result">结果</param> /// <param name="type">类型</param> /// <param name="module">操作模块</param> public static void WriteServiceLog(string oper, string mes, string result, string type, string module) { SysConfigModel siteConfig = OperationContext.Current.ServiceSession.SysConfig.LoadConfig(Utils.GetXmlMapPath("Configpath")); //后台管理日志开启 if (siteConfig.logstatus == 1) { ValidationErrors errors = new ValidationErrors(); Apps.Models.Sys.SysLogModel entity = new Apps.Models.Sys.SysLogModel(); entity.Id = ResultHelper.NewId; entity.Operator = oper; entity.Message = mes; entity.Result = result; entity.Type = type; entity.Module = module; entity.CreateTime = ResultHelper.NowTime; OperationContext.Current.ServiceSession.SysLog.Create(ref errors, entity); } else { return; } }
public void SaveConfig(SysConfigModel model, string configFilePath) => _sysConfig.SaveConfig(model, configFilePath);
private void ManagerFile(HttpContext context) { SysConfigModel siteConfig = OperationContext.Current.ServiceSession.SysConfig.LoadConfig(Utils.GetXmlMapPath("Configpath")); //String aspxUrl = context.Request.Path.Substring(0, context.Request.Path.LastIndexOf("/") + 1); //根目录路径,相对路径 String rootPath = siteConfig.webpath + siteConfig.attachpath + "/"; //站点目录+上传目录 //根目录URL,可以指定绝对路径,比如 http://www.App.com/attached/ String rootUrl = siteConfig.webpath + siteConfig.attachpath + "/"; //图片扩展名 String fileTypes = "gif,jpg,jpeg,png,bmp"; String currentPath = ""; String currentUrl = ""; String currentDirPath = ""; String moveupDirPath = ""; String dirPath = Utils.GetMapPath(rootPath); String dirName = context.Request.QueryString["dir"]; //if (!String.IsNullOrEmpty(dirName)) //{ // if (Array.IndexOf("image,flash,media,file".Split(','), dirName) == -1) // { // context.Response.Write("Invalid Directory name."); // context.Response.End(); // } // dirPath += dirName + "/"; // rootUrl += dirName + "/"; // if (!Directory.Exists(dirPath)) // { // Directory.CreateDirectory(dirPath); // } //} //根据path参数,设置各路径和URL String path = context.Request.QueryString["path"]; path = String.IsNullOrEmpty(path) ? "" : path; if (path == "") { currentPath = dirPath; currentUrl = rootUrl; currentDirPath = ""; moveupDirPath = ""; } else { currentPath = dirPath + path; currentUrl = rootUrl + path; currentDirPath = path; moveupDirPath = Regex.Replace(currentDirPath, @"(.*?)[^\/]+\/$", "$1"); } //排序形式,name or size or type String order = context.Request.QueryString["order"]; order = String.IsNullOrEmpty(order) ? "" : order.ToLower(); //不允许使用..移动到上一级目录 if (Regex.IsMatch(path, @"\.\.")) { context.Response.Write("Access is not allowed."); context.Response.End(); } //最后一个字符不是/ if (path != "" && !path.EndsWith("/")) { context.Response.Write("Parameter is not valid."); context.Response.End(); } //目录不存在或不是目录 if (!Directory.Exists(currentPath)) { context.Response.Write("Directory does not exist."); context.Response.End(); } //遍历目录取得文件信息 string[] dirList = Directory.GetDirectories(currentPath); string[] fileList = Directory.GetFiles(currentPath); switch (order) { case "size": Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new SizeSorter()); break; case "type": Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new TypeSorter()); break; case "name": default: Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new NameSorter()); break; } Hashtable result = new Hashtable(); result["moveup_dir_path"] = moveupDirPath; result["current_dir_path"] = currentDirPath; result["current_url"] = currentUrl; result["total_count"] = dirList.Length + fileList.Length; List <Hashtable> dirFileList = new List <Hashtable>(); result["file_list"] = dirFileList; for (int i = 0; i < dirList.Length; i++) { DirectoryInfo dir = new DirectoryInfo(dirList[i]); Hashtable hash = new Hashtable(); hash["is_dir"] = true; hash["has_file"] = (dir.GetFileSystemInfos().Length > 0); hash["filesize"] = 0; hash["is_photo"] = false; hash["filetype"] = ""; hash["filename"] = dir.Name; hash["datetime"] = dir.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); dirFileList.Add(hash); } for (int i = 0; i < fileList.Length; i++) { FileInfo file = new FileInfo(fileList[i]); Hashtable hash = new Hashtable(); hash["is_dir"] = false; hash["has_file"] = false; hash["filesize"] = file.Length; hash["is_photo"] = (Array.IndexOf(fileTypes.Split(','), file.Extension.Substring(1).ToLower()) >= 0); hash["filetype"] = file.Extension.Substring(1); hash["filename"] = file.Name; hash["datetime"] = file.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); dirFileList.Add(hash); } context.Response.AddHeader("Content-Type", "application/json; charset=UTF-8"); context.Response.Write(JsonMapper.ToJson(result)); context.Response.End(); }