/// <summary> /// 审核 /// </summary> /// <param name="errors">持久的错误信息</param> /// <param name="id">主键</param> /// <param name="checkFlag">1审核0反审核</param> /// <param name="checker">审核人</param> /// <returns>是否成功</returns> public bool Check(ref ValidationErrors errors, string id, string checkFlag, string checker) { try { MIS_Article entity = m_Rep.GetById(id); if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.CheckFlag = checkFlag; entity.Checker = checker; entity.CheckDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (m_Rep.Update(entity)) { return(true); } else { errors.Add(Resource.CheckFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
/// <summary> /// 审核 /// </summary> /// <param name="errors"></param> /// <param name="id"></param> /// <param name="currUserId"></param> /// <returns></returns> public bool Audit(ref ValidationErrors errors, string id, string currUserId) { try { MIS_Article entity = articleRep.GetById(id); entity.CheckFlag = 1; entity.CheckDateTime = DateTime.Now; entity.Checker = currUserId; if (articleRep.Edit(entity) == 1) { return(true); } else { errors.Add(Suggestion.EditFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public string RunJob(ref JobDataMap dataMap, string jobName, string id, string taskName) { MIS_ArticleBLL discussArticleBLL = new MIS_ArticleBLL(); MIS_Article model = discussArticleBLL.m_Rep.Find(Convert.ToInt32(id)); string retResult = ""; if (model == null) { retResult = "文章不存在"; return(retResult); } model.CheckFlag = "0"; ValidationErrors validationErrors = new ValidationErrors(); discussArticleBLL.m_Rep.Update(model); if (validationErrors.Count > 0) { return(validationErrors.Error); } retResult = "修改成功"; return(retResult); }
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 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 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); }
/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <MIS_ArticleModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { MIS_Article entity = new MIS_Article(); entity.Id = ResultHelper.NewId; 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 = ResultHelper.NowTime; entity.CustomLink = model.CustomLink; entity.IsType = model.IsType; db.MIS_Article.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }
public ActionResult Edit(string id) { MIS_Article entity = m_BLL.m_Rep.Find(Convert.ToInt32(id)); ViewBag.Category = new SelectList(categoryBLL.m_Rep.FindList(a => a.ParentId == "0"), "Id", "Name", entity.CategoryIdParent); return(View(entity)); }
public JsonResult Create(MIS_Article model) { if (model != null && ModelState.IsValid) { model.ChannelId = "0"; model.Creater = GetUserId(); model.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); model.CheckFlag = "0"; if (m_BLL.m_Rep.Create(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 JsonResult Create(MIS_Article model) { if (model != null && ModelState.IsValid) { model.ChannelId = "0"; model.Creater = GetUserId(); model.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); model.CheckFlag = "0"; if (m_BLL.m_Rep.Create(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)); } }
/// <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 int Create(MIS_Article entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.MIS_Article.Add(entity); return(db.SaveChanges()); } }
public int Create(MIS_Article entity) { using (AppDBContainer db = new AppDBContainer()) { db.MIS_Article.Add(entity); return(db.SaveChanges()); } }
public int Edit(MIS_Article entity) { using (DBContainer db = new DBContainer()) { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
public int Edit(MIS_Article entity) { using (AppDBContainer db = new AppDBContainer()) { db.MIS_Article.Attach(entity); db.Entry(entity).State = EntityState.Modified; return(db.SaveChanges()); } }
public int Edit(MIS_Article entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.MIS_Article.Attach(entity); //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); db.Entry <MIS_Article>(entity).State = EntityState.Modified; return(db.SaveChanges()); } }
public int Edit(MIS_Article entity) { using (DBContainer db = new DBContainer()) { //db.MIS_Article.Attach(entity); //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); db.Set <MIS_Article>().Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
public bool IsExist(string id) { using (AppDBContainer db = new AppDBContainer()) { MIS_Article entity = GetById(id); if (entity != null) { return(true); } return(false); } }
public int Delete(string id) { using (AppDBContainer db = new AppDBContainer()) { MIS_Article entity = db.MIS_Article.SingleOrDefault(a => a.Id == id); if (entity != null) { db.MIS_Article.Remove(entity); } return(db.SaveChanges()); } }
public bool IsExist(string id) { using (AppsDBEntities db = new AppsDBEntities()) { MIS_Article entity = GetById(id); if (entity != null) { return(true); } return(false); } }
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 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="db">数据库上下文</param> /// <param name="entity">主键ID</param> public int Delete(string id, string userId) { MIS_Article entity = new MIS_Article(); if (string.IsNullOrEmpty(userId)) { entity = Context.MIS_Article.SingleOrDefault(a => a.Id == id); } else { entity = Context.MIS_Article.SingleOrDefault(a => a.Id == id && a.Creater == userId); } if (entity != null) { Context.MIS_Article.Remove(entity); } return(this.SaveChanges()); }
/// <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_Article model) { if (model != null && ModelState.IsValid) { if (m_BLL.m_Rep.Update(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 ActionResult Details(string id) { MIS_Article entity = m_BLL.m_Rep.Find(Convert.ToInt32(id)); return(View(entity)); }