public virtual async Task <MIS_ArticleModel> GetByIdAsync(object id) { if (IsExists(id)) { MIS_Article entity = await m_Rep.GetByIdAsync(id); MIS_ArticleModel model = new MIS_ArticleModel(); model.Id = entity.Id; model.ChannelId = entity.ChannelId; model.CategoryId = entity.CategoryId; model.Title = entity.Title; model.ImgUrl = entity.ImgUrl; model.BodyContent = entity.BodyContent; model.Sort = entity.Sort; model.Click = entity.Click; model.CheckFlag = entity.CheckFlag; model.Checker = entity.Checker; model.CheckDateTime = entity.CheckDateTime; model.Creater = entity.Creater; model.CreateTime = entity.CreateTime; model.CustomLink = entity.CustomLink; model.IsType = entity.IsType; return(model); } else { return(null); } }
public ActionResult Details(string id) { ViewBag.Perm = GetPermission(); MIS_ArticleModel entity = m_BLL.GetById(id); return(View(entity)); }
public string RunJob(ref JobDataMap dataMap, string jobName, string id, string taskName) { IMIS_ArticleBLL discussArticleBLL = new MIS_ArticleBLL() { m_Rep = new MIS_ArticleRepository(new DBContainer()) }; MIS_ArticleModel model = discussArticleBLL.GetById(id); string retResult = ""; if (model == null) { retResult = "文章不存在"; return(retResult); } model.CheckFlag = 0; ValidationErrors validationErrors = new ValidationErrors(); discussArticleBLL.Edit(ref validationErrors, model); if (validationErrors.Count > 0) { return(validationErrors.Error); } retResult = "修改成功"; return(retResult); }
public ActionResult Edit(string id) { MIS_ArticleModel entity = m_BLL.GetById(id); ViewBag.Category = new SelectList(categoryBLL.GetList("0"), "Id", "Name", entity.CategoryIdParent); return(View(entity)); }
/// <summary> /// 根据ID获得一个实体 /// </summary> /// <param name="id">id</param> /// <returns>实体</returns> public virtual MIS_ArticleModel GetById(string id) { if (IsExist(id)) { MIS_Article entity = m_Rep.GetById(id); MIS_ArticleModel model = new MIS_ArticleModel(); model.Id = entity.Id; model.ChannelId = entity.ChannelId; model.CategoryId = entity.CategoryId; model.Title = entity.Title; model.ImgUrl = entity.ImgUrl; model.BodyContent = entity.BodyContent; model.Sort = entity.Sort; model.Click = entity.Click; model.CheckFlag = entity.CheckFlag; model.Checker = entity.Checker; model.CheckDateTime = entity.CheckDateTime; model.Creater = entity.Creater; model.CreateTime = entity.CreateTime; return(model); } else { return(null); } }
public override MIS_ArticleModel GetById(object id) { if (IsExists(id)) { MIS_Article entity = m_Rep.GetById(id); MIS_ArticleModel model = new MIS_ArticleModel(); model.Id = entity.Id; model.ChannelId = entity.ChannelId; model.CategoryId = entity.CategoryId; model.Title = entity.Title; model.CreaterName = entity.SysUser.TrueName; model.ImgUrl = entity.ImgUrl; model.BodyContent = entity.BodyContent; model.Sort = entity.Sort; model.Click = entity.Click; model.CheckFlag = entity.CheckFlag; model.Checker = entity.Checker; model.CheckDateTime = entity.CheckDateTime; model.Creater = entity.Creater; model.CreateTime = entity.CreateTime; model.CustomLink = entity.CustomLink; model.IsType = entity.IsType; model.CategoryIdParent = entity.MIS_Article_Category.ParentId; return(model); } else { return(null); } }
public JsonResult Create(MIS_ArticleModel model) { if (model != null && ModelState.IsValid) { model.Id = ResultHelper.NewId; model.ChannelId = 0; model.Creater = GetUserId(); model.CreateTime = ResultHelper.NowTime; model.CheckFlag = 0; if (m_BLL.Create(ref errors, model)) { if (string.IsNullOrEmpty(model.Task)) { //简单任务 JobsTools.CreateTaskJob(ref errors, model.Task, "Apps.Jobs.MIS.DiscussPostNewTopicsJob", model.Id, model.Title);//带命名空间的任务处理类名称 } LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Title:" + model.Title, "成功", "创建", "信息中心"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Title:" + model.Title + "," + ErrorCol, "失败", "创建", "信息中心"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet)); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail), JsonRequestBehavior.AllowGet)); } }
public ActionResult Details(string id) { ViewBag.perm = GetPermission(); MIS_ArticleModel model = m_BLL.GetById(id); return(View(model)); }
public JsonResult Edit(MIS_ArticleModel model) { if (model.CheckFlag) { model.Checker = GetUserId(); model.CheckDateTime = DateTime.Now; if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id, "成功", "修改", "MIS_Article"); return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + "," + ErrorCol, "失败", "修改", "MIS_Article"); return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail))); } } else { return(Json(JsonHandler.CreateMessage(0, "审核未通过"))); } }
public JsonResult Create(MIS_ArticleModel model) { model.Creater = GetUserId(); model.Checker = GetUserId(); model.CreateTime = DateTime.Now; model.CheckDateTime = DateTime.Now; model.CheckFlag = true; model.Sort = 0; model.Click = 0; model.Id = System.Guid.NewGuid().ToString("N"); if (model != null && ModelState.IsValid) { if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id, "成功", "创建", "MIS_Article"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + "," + ErrorCol, "失败", "创建", "MIS_Article"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail))); } }
public JsonResult Create(MIS_ArticleModel model) { if (model != null && ModelState.IsValid) { model.Id = ResultHelper.NewId; model.ChannelId = 0; model.Creater = GetUserId(); model.CreateTime = ResultHelper.NowTime; model.CheckFlag = 0; if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Title:" + model.Title, "成功", "创建", "信息中心"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Title:" + model.Title + "," + ErrorCol, "失败", "创建", "信息中心"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet)); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail), JsonRequestBehavior.AllowGet)); } }
public MIS_ArticleModel GetById(string id) { if (IsExist(id)) { MIS_Article entity = m_Rep.GetById(id); MIS_ArticleModel model = new MIS_ArticleModel { BodyContent = entity.BodyContent, CategoryId = entity.CategoryId, ChannelId = entity.ChannelId, CheckDateTime = entity.CheckDateTime ?? DateTime.Now, Checker = entity.Checker, CheckFlag = entity.CheckFlag, Click = entity.Click ?? 0, Creater = entity.Creater, CreateTime = entity.CreateTime ?? DateTime.Now, Id = entity.Id, ImgUrl = entity.ImgUrl, Sort = entity.Sort ?? 0, Title = entity.Title }; return(model); } return(null); }
public ActionResult Edit(string id) { ViewBag.Perm = GetPermission(); MIS_ArticleModel entity = articleBll.GetById(id); return(View(entity)); }
public ActionResult Details(string id) { ViewBag.perm = GetPermission(); if (!string.IsNullOrEmpty(id)) { MIS_ArticleModel model = m_BLL.GetById(id); return(View(model)); } else { MIS_ArticleModel model = new MIS_ArticleModel(); return(View(model)); } }
public JsonResult Edit(MIS_ArticleModel model) { if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Title, "成功", "修改", "MIS_Article"); return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed))); } string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Title + "," + ErrorCol, "失败", "修改", "MIS_Article"); return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol))); } return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail))); }
public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(MIS_ArticleModel model) { ValidationErrors errors = new ValidationErrors(); try { MIS_Article entity = await m_Rep.GetByIdAsync(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new MIS_Article(); entity.Id = model.Id; entity.ChannelId = model.ChannelId; entity.CategoryId = model.CategoryId; entity.Title = model.Title; entity.ImgUrl = model.ImgUrl; entity.BodyContent = model.BodyContent; entity.Sort = model.Sort; entity.Click = model.Click; entity.CheckFlag = model.CheckFlag; entity.Checker = model.Checker; entity.CheckDateTime = model.CheckDateTime; entity.Creater = model.Creater; entity.CreateTime = model.CreateTime; entity.CustomLink = model.CustomLink; entity.IsType = model.IsType; 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 JsonResult Create(MIS_ArticleModel model) { model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; if (ModelState.IsValid) { if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Title, "成功", "创建", "MIS_Article"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",ChannelId" + model.Title + "," + ErrorCol, "失败", "创建", "MIS_Article"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol))); } return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail))); }
public virtual bool Create(ref ValidationErrors errors, MIS_ArticleModel model) { try { MIS_Article entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new MIS_Article(); entity.Id = model.Id; entity.ChannelId = model.ChannelId; entity.CategoryId = model.CategoryId; entity.Title = model.Title; entity.ImgUrl = model.ImgUrl; entity.BodyContent = model.BodyContent; entity.Sort = model.Sort; entity.Click = model.Click; entity.CheckFlag = model.CheckFlag; entity.Checker = model.Checker; entity.CheckDateTime = model.CheckDateTime; entity.Creater = model.Creater; entity.CreateTime = model.CreateTime; entity.CustomLink = model.CustomLink; entity.IsType = model.IsType; 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); } }
/// <summary> /// 修改一个实体 /// </summary> /// <param name="errors">持久的错误信息</param> /// <param name="model">模型</param> /// <returns>是否成功</returns> public virtual bool Edit(ref ValidationErrors errors, MIS_ArticleModel model) { try { MIS_Article entity = m_Rep.GetById(model.Id); if (entity == null) { errors.add(Suggestion.Disable); return(false); } entity.Id = model.Id; entity.ChannelId = model.ChannelId; entity.CategoryId = model.CategoryId; entity.Title = model.Title; entity.ImgUrl = model.ImgUrl; entity.BodyContent = model.BodyContent; entity.Sort = model.Sort; entity.Click = model.Click; entity.CheckFlag = model.CheckFlag; entity.Checker = model.Checker; entity.CheckDateTime = model.CheckDateTime; entity.Creater = model.Creater; entity.CreateTime = model.CreateTime; if (m_Rep.Edit(entity)) { return(true); } else { errors.add(Suggestion.EditFail); return(false); } } catch (Exception ex) { errors.add(ex.Message); ExceptionHandler.WriteException(ex); //ExceptionHander.WriteException(ex); return(false); } }
public JsonResult Edit(MIS_ArticleModel model) { if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Title:" + model.Title, "成功", "修改", "信息中心"); return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Title:" + model.Title + "," + ErrorCol, "失败", "修改", "信息中心"); return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ":" + ErrorCol), JsonRequestBehavior.AllowGet)); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.EditFail), JsonRequestBehavior.AllowGet)); } }
public JsonResult Edit(MIS_ArticleModel model) { if (model != null && ModelState.IsValid) { if (articleBll.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetCurrentUserId(), "Id" + model.Id + ",ChannelId" + model.ChannelId, "成功", "修改", "IMIS_ArticleRepository"); return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetCurrentUserId(), "Id" + model.Id + ",ChannelId" + model.ChannelId + "," + ErrorCol, "失败", "修改", "IMIS_ArticleRepository"); return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail))); } }
public JsonResult Create(MIS_ArticleModel model) { model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; model.Creater = GetCurrentUserId(); if (model != null && ModelState.IsValid) { if (articleBll.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetCurrentUserId(), "Id" + model.Id + ",ChannelId" + model.ChannelId, "成功", "创建", "IMIS_ArticleRepository"); return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetCurrentUserId(), "Id" + model.Id + ",ChannelId" + model.ChannelId + "," + ErrorCol, "失败", "创建", "IMIS_ArticleRepository"); return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail))); } }
/// <summary> /// 校验Excel数据,这个方法一般用于重写校验逻辑 /// </summary> public virtual bool CheckImportData(string fileName, List <MIS_ArticleModel> list, ref ValidationErrors errors) { var targetFile = new FileInfo(fileName); if (!targetFile.Exists) { errors.Add("导入的数据文件不存在"); return(false); } var excelFile = new ExcelQueryFactory(fileName); //对应列头 excelFile.AddMapping <MIS_ArticleModel>(x => x.ChannelId, "所属栏目"); excelFile.AddMapping <MIS_ArticleModel>(x => x.CategoryId, "所属类别"); excelFile.AddMapping <MIS_ArticleModel>(x => x.Title, "文章标题"); excelFile.AddMapping <MIS_ArticleModel>(x => x.ImgUrl, "配图"); excelFile.AddMapping <MIS_ArticleModel>(x => x.BodyContent, "内容"); excelFile.AddMapping <MIS_ArticleModel>(x => x.Sort, "排序"); excelFile.AddMapping <MIS_ArticleModel>(x => x.Click, "点击量"); excelFile.AddMapping <MIS_ArticleModel>(x => x.CheckFlag, "审核状态"); excelFile.AddMapping <MIS_ArticleModel>(x => x.Checker, "审核人"); excelFile.AddMapping <MIS_ArticleModel>(x => x.CheckDateTime, "审核时间"); excelFile.AddMapping <MIS_ArticleModel>(x => x.Creater, "创建人"); excelFile.AddMapping <MIS_ArticleModel>(x => x.CreateTime, "创建时间"); excelFile.AddMapping <MIS_ArticleModel>(x => x.CustomLink, "自定义链接"); excelFile.AddMapping <MIS_ArticleModel>(x => x.IsType, "0,普通文章,1.幻灯片,2.首页栏目"); //SheetName var excelContent = excelFile.Worksheet <MIS_ArticleModel>(0); int rowIndex = 1; //检查数据正确性 foreach (var row in excelContent) { var errorMessage = new StringBuilder(); var entity = new MIS_ArticleModel(); entity.Id = row.Id; entity.ChannelId = row.ChannelId; entity.CategoryId = row.CategoryId; entity.Title = row.Title; entity.ImgUrl = row.ImgUrl; entity.BodyContent = row.BodyContent; entity.Sort = row.Sort; entity.Click = row.Click; entity.CheckFlag = row.CheckFlag; entity.Checker = row.Checker; entity.CheckDateTime = row.CheckDateTime; entity.Creater = row.Creater; entity.CreateTime = row.CreateTime; entity.CustomLink = row.CustomLink; entity.IsType = row.IsType; //============================================================================= 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 ActionResult Details(string id) { MIS_ArticleModel entity = m_BLL.GetById(id); return(View(entity)); }