public void ActionIndex(SysModuleModel model) { // sap xep tu dong string orderBy = AutoSort(model.Sort, "[Type],[Order]"); // tao danh sach var dbQuery = SysModuleService.Instance.CreateQuery() .Take(model.PageSize) .OrderBy(orderBy) .Skip(model.PageIndex * model.PageSize); ViewBag.Data = dbQuery.ToList(); model.TotalRecord = dbQuery.TotalRecord; ViewBag.Model = model; }
public JsonResult Edit(SysModuleModel model) { if (model != null && ModelState.IsValid) { EAP_Resource _m = GetObjByID <EAP_Resource>(model.Id, "EAP_MOUDLE"); LoginInfo _login = LoginUser; _m.ParentId = int.Parse(model.ParentId); _m.Name = model.Name; _m.PageId = model.Url; _m.AddBy = _login.User.TrueName; _m.Flag_Delete = !model.Enable; _m.Description = model.Remark; _m.EditBy = LoginUser.User.UserName; _m.EditOn = DateTime.Now; _m.VRow = model.isnewWin ? 0 : 1; _m.SortBy = model.Sort == null?0:(int)(model.Sort); _m.Description = model.Remark; _m.Image = model.Iconic; CommandResult r = SaveObj <EAP_Resource>(_m); if (r.IntResult > 0) // if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(_login.User.UserName, "Id" + model.Id + ",Name" + model.Name, "成功", "修改", "系统菜单"); return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed))); } else { string ErrorCol = r.Message; LogHandler.WriteServiceLog(_login.User.UserName, "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "修改", "系统菜单"); return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail))); } }
public bool Create(ref ValidationErrors errors, SysModuleModel model) { try { SysModule entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Suggestion.PrimaryRepeat); return(false); } entity = new SysModule(); entity.Id = model.Id; entity.Name = model.Name; entity.EnglishName = model.EnglishName; entity.ParentId = model.ParentId; entity.Url = model.Url; entity.Iconic = model.Iconic; entity.Sort = model.Sort; entity.Remark = model.Remark; entity.Enable = model.Enable; entity.CreatePerson = model.CreatePerson; entity.CreateTime = model.CreateTime; entity.IsLast = model.IsLast; if (m_Rep.Create(entity) == 1) { db.P_Sys_InsertSysRight(); return(true); } else { errors.Add(Suggestion.InsertFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHandler.WriteException(ex); return(false); } }
public virtual SysModuleModel GetById(string id) { if (IsExists(id)) { tbl_SysModule entity = m_Rep.GetById(id); SysModuleModel model = new SysModuleModel(); model.Id = entity.Id; model.ModuleId = entity.ModuleId; model.ModuleName = entity.ModuleName; model.ParentId = entity.ParentId; model.ModuleURL = entity.ModuleURL; model.IsShow = entity.IsShow; model.IsLast = entity.IsLast; return(model); } else { return(null); } }
public void ActionAdd(SysModuleModel model) { if (model.RecordID > 0) { entity = SysModuleService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update } else { entity = new SysModuleEntity(); // khoi tao gia tri mac dinh khi insert entity.TypeName = "HL.Lib.Controllers.[Name]Controller"; entity.AssemblyName = "HLv1.0.MVC.Lib, Version=1.0.0.0, Culture=Neutral,PublicKeyToken=null"; entity.Order = GetMaxOrder(model); } ViewBag.Data = entity; ViewBag.Model = model; }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; SysModuleModel moduleModel = new SysModuleModel(); if (context.Request.QueryString["0"] != null) { moduleModel.Id = context.Request.QueryString["Id"]; moduleModel.ModuleId = context.Request.QueryString["ModuleId"]; moduleModel.ModuleName = context.Request.QueryString["ModuleName"]; moduleModel.ParentId = context.Request.QueryString["ParentId"]; moduleModel.ModuleURL = context.Request.QueryString["ModuleURL"]; moduleModel.IsShow = Convert.ToBoolean(context.Request.QueryString["IsShow"]); moduleModel.IsLast = Convert.ToBoolean(context.Request.QueryString["IsLast"]); var jsondata = delete(moduleModel); context.Response.Clear(); context.Response.Write(jsondata); context.Response.End(); } context.Response.Write("Hello World"); }
public JsonResult Create(SysModuleModel model) { if (model != null && ModelState.IsValid) { model.Created = DateTime.Now; model.IsDelete = false; model.Creator = ((AccountModel)Session["Account"]).Id; if (moduleBLL.Create(model)) { return(Json(new { type = 1, message = "插入成功!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { type = 0, message = "插入失败!" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { type = 0, message = "插入失败!" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Edit(SysModuleModel model) { if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "修改", "系统菜单"); return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "修改", "系统菜单"); return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail))); } }
public JsonResult Create(SysModuleModel model) { model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; model.CreatePerson = "aa"; // GetUserId(); if (model != null && ModelState.IsValid) { EAP_Resource _m = new EAP_Resource(); LoginInfo _login = LoginUser; _m.ParentId = int.Parse(model.ParentId); _m.Name = model.Name; _m.PageId = model.Url; _m.AddBy = _login.User.TrueName; _m.Flag_Delete = !model.Enable; _m.Type = "menu"; _m.Description = model.Remark; _m.VRow = model.isnewWin ? 0 : 1; _m.SortBy = model.Sort == null ? 0 : (int)(model.Sort); _m.Image = model.Iconic; CommandResult r = SaveObj <EAP_Resource>(_m); if (r.IntResult > 0) // if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(_login.User.UserName, "Id" + model.Id + ",Name" + model.Name, "成功", "创建", "系统菜单"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } else { string ErrorCol = r.Message; LogHandler.WriteServiceLog(_login.User.UserName, "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "创建", "系统菜单"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail))); } }
public JsonResult Create(SysModuleModel model) { model.CreateTime = ResultHelper.NowTime; model.CreatePerson = GetUserId(); if (model != null && ModelState.IsValid) { if (moduleBLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "id:" + model.Id + ",Name:" + model.Name, "成功", "创建", "SysModule"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } else { string errorMes = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "id:" + model.Id + ",Name:" + model.Name + "," + errorMes, "失败", "创建", "SysModule"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + errorMes))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail))); } }
public override bool Edit(ref ValidationErrors errors, SysModuleModel model) { try { SysModule entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Suggestion.Disable); return(false); } entity.Name = model.Name; entity.EnglishName = model.EnglishName; entity.ParentId = model.ParentId; entity.Url = model.Url; entity.Iconic = model.Iconic; entity.Sort = model.Sort; entity.Remark = model.Remark; entity.Enable = model.Enable; entity.IsLast = model.IsLast; if (m_Rep.Edit(entity) == true) { return(true); } else { errors.Add(Suggestion.EditFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
/// <summary> /// 创建一个实体 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public bool Create(SysModuleModel model) { try { SysModule entity = moduleRepository.GetEntityById(model.Id); if (entity != null) { return(false); } entity = new SysModule(); entity.Id = model.Id; entity.ModuleName = model.ModuleName; entity.ParentId = model.ParentId; entity.Code = model.Code; entity.Url = model.Url; entity.Icon = model.Icon; entity.Sort = model.Sort; entity.Description = model.Description; entity.Enable = model.Enable; entity.IsDelete = model.IsDelete; entity.Created = model.Created; entity.Creator = model.Creator; if (moduleRepository.Create(entity) == 1)//成功 { return(true); } else { return(false); } } catch (Exception) { return(false); } }
public SysModuleModel GetById(string id) { if (IsExist(id)) { SysModule entity = m_rep.GetById(id); SysModuleModel model = new SysModuleModel { Id = entity.Id, Name = entity.Name, EnglishName = entity.EnglishName, ParentId = entity.ParentId, Url = entity.Url, Iconic = entity.Iconic, Sort = entity.Sort, Remark = entity.Remark, Enable = (bool)entity.Enable, CreatePerson = entity.CreatePerson, CreateTime = entity.CreateTime, IsLast = entity.IsLast }; return(model); } return(null); }
public JsonResult Create(SysModuleModel model) { model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; model.CreatePerson = GetUserId(); if (model != null && ModelState.IsValid) { if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "创建", "SysModule"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "创建", "SysModule"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail))); } }
public JsonResult GetModelList(string id) { if (id == null) { id = "0"; } EntityProviderOP <EAP_Resource> _op = new EntityProviderOP <EAP_Resource>(LoginUser, DataProvider.GetEAP_Provider()); SearchCriteria _search = new SearchCriteria("EAP_MOUDLE"); _search["parentid"] = id; SearchResult <EAP_Resource> _rs = _op.Search(_search); // var list = m_BLL.GetListByParentId(id); var json = new List <SysModuleModel>(); foreach (EAP_Resource r in _rs.Items) { SysModuleModel _m = new SysModuleModel() { Id = r.ID.ToString(), Url = r.PageId, Name = r.Name, ParentId = r.ParentId.ToString(), Sort = r.SortBy, Enable = !r.Flag_Delete, CreateTime = r.AddOn, IsLast = (r.HasChild_G == 0), state = (r.HasChild_G == 1) ? "closed" : "open" }; json.Add(_m); } return(Json(json)); }
public JsonResult GetList(string id) { if (id == null) { id = "0"; } EntityProviderOP <EAP_Resource> _op = new EntityProviderOP <EAP_Resource>(LoginUser, DataProvider.GetEAP_Provider()); SearchCriteria _search = new SearchCriteria("EAP_MOUDLE"); _search["parentid"] = id; SearchResult <EAP_Resource> _rs = _op.Search(_search); // var list = m_BLL.GetListByParentId(id); var json = new List <SysModuleModel>(); foreach (EAP_Resource r in _rs.Items) { SysModuleModel _m = new SysModuleModel() { Id = r.ID.ToString(), Url = r.PageId, Name = r.Name, ParentId = r.ParentId.ToString(), Sort = r.SortBy, Enable = !r.Flag_Delete, Remark = r.Description, Iconic = r.Image, CreateTime = r.AddOn, IsLast = (r.HasChild_G == 0), state = (r.HasChild_G == 1) ? "closed" : "open" }; json.Add(_m); } return(Json(json)); /* * if (id == null) * id = "0"; * List<SysModuleModel> list = m_BLL.GetList(id); * var json = from r in list * select new SysModuleModel() * { * Id = r.Id, * Name = r.Name, * EnglishName = r.EnglishName, * ParentId = r.ParentId, * Url = r.Url, * Iconic = r.Iconic, * Sort = r.Sort, * Remark = r.Remark, * Enable = r.Enable, * CreatePerson = r.CreatePerson, * CreateTime = r.CreateTime, * IsLast = r.IsLast, * state = (m_BLL.GetList(r.Id).Count > 0) ? "closed" : "open" * }; * * * return Json(json); */ }
public void ActionApply(SysModuleModel model) { if (ValidSave(model)) ApplyRedirect(model.RecordID, entity.ID); }
public async Task <FuncResult> Add(SysModuleModel model, int currentUserId) { //模块名称不能重复 if (_context.SysModules.FirstOrDefault(e => e.ModuleName == model.ModuleName) != null) { return(new FuncResult() { IsSuccess = false, Message = "模块名不能重复!" }); } int level = 1; if (!string.IsNullOrWhiteSpace(model.ParentId)) { var parent_entity = _context.SysModules.FirstOrDefault(e => e.Id == model.ParentId); if (parent_entity == null) { return(new FuncResult() { IsSuccess = false, Message = "父级ID错误" }); } level = parent_entity.Level + 1; } var entity = new SysModule() { ModuleName = model.ModuleName, Level = level, ParentId = model.ParentId, Last_Updated_By = currentUserId, Last_Update_Date = DateTime.Now, Created_By = currentUserId, Creation_Date = DateTime.Now }; await _context.SysModules.AddAsync(entity); using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction trans = _context.Database.BeginTransaction()) { try { await _context.SaveChangesAsync(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); return(new FuncResult() { IsSuccess = false, Content = ex.Message }); } } return(new FuncResult() { IsSuccess = true, Content = entity, Message = "添加成功" }); }
private bool ValidSave(SysModuleModel model) { TryUpdateModel(entity); ViewBag.Data = entity; ViewBag.Model = model; CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error; //kiem tra ten if (entity.Name.Trim() == string.Empty) CPViewPage.Message.ListMessage.Add("Nhập tên chức năng."); if (CPViewPage.Message.ListMessage.Count == 0) { try { //save SysModuleService.Instance.Save(entity); } catch (Exception ex) { Global.Error.Write(ex); CPViewPage.Message.ListMessage.Add(ex.Message); return false; } return true; } return false; }
/// <summary> /// 将当前所有API接口添加到数据 /// </summary> private void InitCurrentApiInterface() { //插入一个约定树根数据 SysModuleModel rootModel = m_BLL.GetById("ApiInterfaceAuth"); if (rootModel == null) { SysModuleModel model = new SysModuleModel() { Id = "ApiInterfaceAuth", Name = "Api接口授权", EnglishName = "ApiInterfaceAuth", ParentId = "000", Url = "", Iconic = "fa fa-television", Enable = true, Remark = "Api接口授权", Sort = 1, CreatePerson = "Admin", CreateTime = DateTime.Now, IsLast = false }; m_BLL.Create(ref errors, model); } //把控制器当成URL,把Aciton当成操作码插入到数据表做为权限设置,类似之前的权限系统 //获得API管理器 Collection <ApiDescription> apiColl = GlobalConfiguration.Configuration.Services.GetApiExplorer().ApiDescriptions; ILookup <HttpControllerDescriptor, ApiDescription> apiGroups = apiColl.ToLookup(api => api.ActionDescriptor.ControllerDescriptor); foreach (var group in apiGroups) { string controllerName = group.Key.ControllerName; //----------插入控制器 rootModel = m_BLL.GetById(controllerName); if (rootModel == null) { SysModuleModel model = new SysModuleModel() { Id = controllerName, Name = controllerName, EnglishName = "", ParentId = "ApiInterfaceAuth", Url = controllerName, Iconic = "fa fa-television", Enable = true, Remark = "Api接口授权", Sort = 1, CreatePerson = "Admin", CreateTime = DateTime.Now, IsLast = true }; m_BLL.Create(ref errors, model); } //-----------插入Action foreach (var m in group) { string actionName = m.ActionDescriptor.ActionName; SysModuleOperateModel model = operateBLL.GetById(m.ActionDescriptor.ActionName); if (model == null) { model = new SysModuleOperateModel(); model.Id = controllerName + actionName; model.Name = m.Documentation == null ? actionName : m.Documentation; model.KeyCode = actionName; model.ModuleId = controllerName; model.IsValid = true; model.Sort = 0; operateBLL.Create(ref errors, model); } } } }
public void ActionSave(SysModuleModel model) { if (ValidSave(model)) SaveRedirect(); }
private int GetMaxOrder(SysModuleModel model) { return(SysModuleService.Instance.CreateQuery() .Max(o => o.Order) .ToValue().ToInt(0) + 1); }
/// <summary> /// 校验Excel数据,这个方法一般用于重写校验逻辑 /// </summary> public virtual bool CheckImportData(string fileName, List <SysModuleModel> list, ref ValidationErrors errors) { var targetFile = new FileInfo(fileName); if (!targetFile.Exists) { errors.Add("导入的数据文件不存在"); return(false); } var excelFile = new ExcelQueryFactory(fileName); //对应列头 excelFile.AddMapping <SysModuleModel>(x => x.Name, "Name"); excelFile.AddMapping <SysModuleModel>(x => x.EnglishName, "EnglishName"); excelFile.AddMapping <SysModuleModel>(x => x.ParentId, "ParentId"); excelFile.AddMapping <SysModuleModel>(x => x.Url, "Url"); excelFile.AddMapping <SysModuleModel>(x => x.Iconic, "Iconic"); excelFile.AddMapping <SysModuleModel>(x => x.Sort, "Sort"); excelFile.AddMapping <SysModuleModel>(x => x.Remark, "Remark"); excelFile.AddMapping <SysModuleModel>(x => x.Enable, "Enable"); excelFile.AddMapping <SysModuleModel>(x => x.CreatePerson, "CreatePerson"); excelFile.AddMapping <SysModuleModel>(x => x.CreateTime, "CreateTime"); excelFile.AddMapping <SysModuleModel>(x => x.IsLast, "IsLast"); excelFile.AddMapping <SysModuleModel>(x => x.Version, "Version"); //SheetName var excelContent = excelFile.Worksheet <SysModuleModel>(0); int rowIndex = 1; //检查数据正确性 foreach (var row in excelContent) { var errorMessage = new StringBuilder(); var entity = new SysModuleModel(); entity.Id = row.Id; entity.Name = row.Name; entity.EnglishName = row.EnglishName; entity.ParentId = row.ParentId; entity.Url = row.Url; entity.Iconic = row.Iconic; entity.Sort = row.Sort; entity.Remark = row.Remark; entity.Enable = row.Enable; entity.CreatePerson = row.CreatePerson; entity.CreateTime = row.CreateTime; entity.IsLast = row.IsLast; entity.Version = row.Version; //============================================================================= if (errorMessage.Length > 0) { errors.Add(string.Format( "第 {0} 列发现错误:{1}{2}", rowIndex, errorMessage, "<br/>")); } list.Add(entity); rowIndex += 1; } if (errors.Count > 0) { return(false); } return(true); }
public async Task <FuncResult> Update(string id, [FromBody] SysModuleModel model) { FuncResult data = await sysmoduleService.Update(id, model, CurrentUser.Get().Id); return(data); }
public ActionResult Edit(string id) { SysModuleModel entity = m_BLL.GetById(id); return(View(entity)); }
/// <summary> /// 插入信息 /// </summary> public int InsertInfo(SqlTransaction trans, SysModuleModel sysModel) { return(sysDAL.InsertInfo(trans, sysModel)); }
public string returnjson(SysModuleModel model) { var jsondata = js.Serialize(model); return(jsondata); }
public void ActionSaveNew(SysModuleModel model) { if (ValidSave(model)) SaveNewRedirect(model.RecordID, entity.ID); }
private int GetMaxOrder(SysModuleModel model) { return SysModuleService.Instance.CreateQuery() .Max(o => o.Order) .ToValue().ToInt(0) + 1; }