/// <summary> /// 添加日志 /// </summary> /// <param name="Title">日志内容</param> /// <param name="LogType">日志类型,1:用户登录日志,2:内容操作日志,3:菜单操作日志,4:模板管理日志,5:数据备份日志,6:组件操作日志</param> /// <param name="LogGrade">日志级别,升序</param> public void SetSysLog(string Title, int LogType, int LogGrade) { try { var logModel = new SysLog() { UserName = SysUserModel.UserName, UserID = SysUserModel.UserID, Title = Title, IP = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(), LogType = LogType, LogGrade = LogGrade.ToString(), RequestUrl = FytRequest.GetRawUrl(), AddDate = DateTime.Now }; using (var db = SugarBase.GetIntance()) { db.Insertable(logModel).ExecuteCommandAsync(); } } catch (Exception) { throw; } }
/// <summary> /// 添加/编辑页面 /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Change(string id) { var pid = FytRequest.GetQueryString("pid"); var model = new SysUser(); var rel_list = new List <string>(); using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(id)) { model = db.Queryable <SysUser>().Where(m => m.SysUserID == id).First(); var rel_list1 = db.Queryable <SysUserRole>().Where(m => m.UserID == model.SysUserID).ToList(); if (rel_list1 != null) { foreach (var item in rel_list1) { rel_list.Add(item.RoleID); } } } else { model.SysUserID = ""; } var role_list = db.Queryable <SysRole>().Where(m => m.Status).ToList(); ViewBag.RoleList = role_list; ViewBag.RelRoleList = rel_list; } return(View(model)); }
public JsonResult Delete() { var jsonm = new ResultJson(); try { string idlist = FytRequest.GetFormString("id"); if (idlist.Contains(",")) { string[] str = idlist.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string t in str) { FileHelper.DeleteFile(Utils.GetMapPath("/wwwroot/upload/backdb/") + t); } } else { FileHelper.DeleteFile(Utils.GetMapPath("/wwwroot/upload/backdb/") + idlist); } SetSysLog("【删除】备份数据库文件", 8, 1); } catch (Exception e) { jsonm.msg = e.Message; jsonm.status = 500; } return(Json(jsonm)); }
/// <summary> /// 下载数据库备份文件 /// </summary> /// <returns></returns> public IActionResult FileDown() { try { var file = FytRequest.GetQueryString("file"); SetSysLog("【下载】备份数据库文件", 8, 1); string spath = "/wwwroot/upload/backdb/" + file; var stream = System.IO.File.OpenRead(Utils.GetMapPath(spath)); string fileExt = FileHelper.GetFileExt(file); //获取文件的ContentType //var provider = new FileExtensionContentTypeProvider(); //var memi = provider.Mappings[fileExt]; return(File(stream, "application/pdf", Path.GetFileName(spath))); } catch (Exception ex) { return(NotFound()); } }
public JsonResult DeleteBy() { var jsonm = new ResultJson(); try { var path = FytRequest.GetFormString("path"); var isFile = FytRequest.GetFormInt("isfile"); if (isFile == 0) { //删除文件夹 FileHelper.ClearDirectory(Utils.GetMapPath(path)); } else { //删除文件 FileHelper.DeleteFile(Utils.GetMapPath(path)); } } catch (Exception e) { jsonm.msg = e.Message; jsonm.status = 500; } return(Json(jsonm)); }
/// <summary> /// 修改操作 /// </summary> /// <param name="db"></param> /// <param name="model"></param> /// <param name="adminUser"></param> /// <returns></returns> public ResultJson Change(SqlSugarClient db, sysmenu model, string adminUser) { var json = new ResultJson() { backurl = "close", msg = "保存成功~" }; model.UpdateDate = DateTime.Now; model.SysID = 1; if (model.ID == 0) { var tempM = db.Insertable(model).ExecuteReutrnIdentity(); if (model.ParentId > 0) { //说明有父级 根据父级,查询对应的模型 var parModel = db.Queryable <sysmenu>().InSingle(model.ParentId); if (parModel != null) { model.ClassList = parModel.ClassList + Convert.ToInt32(tempM) + ","; model.ClassLayer = parModel.ClassLayer + 1; model.ID = Convert.ToInt32(tempM); } } else { //没有父级 model.ClassList = "," + Convert.ToInt32(tempM) + ","; } db.Updateable(model).ExecuteCommand(); } else { //判断修改之前的父级栏目是否和当前的相当 if (FytRequest.GetFormInt("SouParentId") != model.ParentId) { //不相等更改等级 var parModel = db.Queryable <sysmenu>().InSingle(model.ParentId); if (parModel != null) { model.ClassList = parModel.ClassList + model.ID + ","; model.ClassLayer = parModel.ClassLayer + 1; } } db.Updateable(model).ExecuteCommand(); } db.Insertable(new syslog() { UserName = adminUser, Title = "修改菜单:" + model.Name, IP = FytRequest.GetIp(), LogType = 6, LogGrade = "1", RequestUrl = FytRequest.GetUrl(), AddDate = DateTime.Now }).ExecuteCommand(); return(json); }
/// <summary> /// 菜单栏目自定义排序 /// </summary> /// <returns></returns> public JsonResult ColSort() { var jsonm = new ResultJson(); int p = FytRequest.GetFormInt("p"), i = FytRequest.GetFormInt("i"), ob = FytRequest.GetFormInt("o"); Service.Command <MenuOutsourcing>((db, o) => { o.MenuSort(db, p, i, ob); }); return(Json(jsonm)); }
/// <summary> /// 菜单栏目自定义排序 /// </summary> /// <returns></returns> public JsonResult ColSort() { var jsonm = new ResultJson(); var p = FytRequest.GetFormString("p"); var i = FytRequest.GetFormString("i"); var ob = FytRequest.GetFormInt("o"); Service.Command <SysModuleOutsourcing>((db, o) => { o.ModuleSort(db, p, i, ob); }); return(Json(jsonm)); }
public ActionResult Change(int id) { var pid = FytRequest.GetQueryInt("pid", 0); var model = new sysmenu(); Service.Command <MenuOutsourcing>((db, o) => { model = db.Queryable <sysmenu>().Single(m => m.ID == id) ?? new sysmenu() { ParentId = pid, SysID = 1, Sort = 0, IsShow = true }; #region 拉框父级 var list = db.Queryable <sysmenu>().ToList(); var sList = o.RecursiveModule(list); var selectList = sList.Select(p => new SelectListItem { Text = Utils.LevelName(p.Name, p.ClassLayer), Value = p.ID.ToString(CultureInfo.InvariantCulture) }).ToList(); selectList.Insert(0, new SelectListItem() { Text = "父级", Value = "0" }); ViewBag.selectList = selectList.AsEnumerable().ToList(); #endregion #region 查询排序的最大值 if (id == 0) { var pModel = db.Queryable <sysmenu>().OrderBy(m => m.Sort, OrderByType.Desc).First(); if (pModel != null) { model.Sort = pModel.Sort + 1; } else { model.Sort = 1; } } #endregion }); if (model != null) { return(View(model)); } return(View()); }
public JsonResult GetFileData() { string path = FytRequest.GetFormString("path"); path = "/" + BasicConfig.filerootpath + "/" + path; var jsonm = new ResultJson(); try { jsonm.data = ConvertHelper <FileModel> .ConvertToList(FileHelper.GetFileTable(Utils.GetMapPath(path))); } catch (Exception e) { jsonm.msg = e.Message; jsonm.status = 500; } return(Json(jsonm)); }
public IActionResult Change(string id) { var pid = FytRequest.GetQueryString("pid"); var model = new SysModule(); Service.Command <Outsourcing>((db, o) => { if (!string.IsNullOrEmpty(id)) { model = db.Queryable <SysModule>().Where(m => m.ID == id).First(); } else { model.ParentID = pid; model.ID = ""; } }); return(View(model)); }
public IActionResult Change(string id) { var pid = FytRequest.GetQueryString("pid"); SysRole model = new SysRole(); var rel_list = new List <string>(); using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(id)) { model = db.Queryable <SysRole>().Where(m => m.RoleID == id).First(); var rel_list1 = db.Queryable <SysRoleModule>().Where(m => m.RoleID == model.RoleID).ToList(); if (rel_list1 != null) { foreach (var item in rel_list1) { rel_list.Add(item.ModuleID); } } } else { model.RoleID = ""; } var menu_list = db.Queryable <SysModule>().ToList(); if (rel_list.Count > 0) { foreach (var item in menu_list) { if (rel_list.Contains(item.ID)) { item.LAY_CHECKED = true; } } } ViewBag.MenuList = menu_list; ViewBag.RelMenuList = rel_list; } return(View(model)); }
public JsonResult GetModuleList() { var jsonm = new ResultJson(); try { var alist = new List <SysModule>(); var url = FytRequest.GetViewUrl(); var model = ModuleList.Where(m => url.Equals(m.Href)).FirstOrDefault(); if (model != null) { var chlidList = ModuleList.Where(m => m.Type == 3 && model.ID == m.ParentID).ToList(); var list = SysUserModel.MenuList.Where(m => m.Type == 3 && model.ID == m.ParentID).ToList(); foreach (var item in chlidList) { foreach (var item2 in list) { if (item.ID == item2.ID) { item.LAY_CHECKED = true; break; } } } alist = chlidList; } jsonm.status = 200; jsonm.data = alist; jsonm.msg = "获取成功"; } catch (Exception ex) { jsonm.status = 500; jsonm.msg = ex.Message; } return(Json(jsonm)); }
public JsonResult SignUpFile() { var jsonm = new ResultJson(); try { IFormFile photo = Request.Form.Files["fileUp"]; var upFiles = FytRequest.GetQueryString("upFiles"); if (upFiles == "openfileUp") { photo = Request.Form.Files["openfileUp"]; } if (upFiles == "scfile") { photo = Request.Form.Files["scfile"]; } if (upFiles == "fileUrlMd") { photo = Request.Form.Files["editormd-image-file"]; } //是否缩略图 0=不压缩 1=压缩 var isThum = FytRequest.GetQueryInt("isThum", 0); //是否添加水印 var isWater = FytRequest.GetQueryInt("isWater", 0); if (photo == null) { jsonm.status = 401; jsonm.msg = "请选择要上传文件!"; return(Json(jsonm)); } var jsFile = _up.SingleUpload(photo, Convert.ToBoolean(isThum), Convert.ToBoolean(isWater)); jsonm.status = jsFile.status; jsonm.msg = jsFile.msg; //var fileModels = (UploadFileInfo)jsFile.data; jsonm.data = jsFile.data; //fileModels.Paths; if (upFiles == "fileUrlMd") { if (jsonm.status == 200) { var fileModels = (UploadFileInfo)jsFile.data; var obj = new { success = 1, message = jsonm.msg, url = fileModels.Paths }; return(Json(obj)); } } } catch (Exception e) { jsonm.msg = e.Message; jsonm.status = 500; } return(Json(jsonm)); }
public IActionResult Index() { ViewBag.httpUrl = FytRequest.GetUrlNoParm(); return(View()); }