コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: MIS_ArticleBLL.cs プロジェクト: like-stop/1
 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);
     }
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 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);
 }
コード例 #7
0
        /// <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;
            }
        }
コード例 #8
0
        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));
        }
コード例 #9
0
 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));
     }
 }
コード例 #10
0
 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));
     }
 }
コード例 #11
0
        /// <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);
            }
        }
コード例 #12
0
 public int Create(MIS_Article entity)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         db.MIS_Article.Add(entity);
         return(db.SaveChanges());
     }
 }
コード例 #13
0
 public int Create(MIS_Article entity)
 {
     using (AppDBContainer db = new AppDBContainer())
     {
         db.MIS_Article.Add(entity);
         return(db.SaveChanges());
     }
 }
コード例 #14
0
 public int Edit(MIS_Article entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         return(db.SaveChanges());
     }
 }
コード例 #15
0
 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());
     }
 }
コード例 #16
0
 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());
     }
 }
コード例 #17
0
 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());
     }
 }
コード例 #18
0
 public bool IsExist(string id)
 {
     using (AppDBContainer db = new AppDBContainer())
     {
         MIS_Article entity = GetById(id);
         if (entity != null)
         {
             return(true);
         }
         return(false);
     }
 }
コード例 #19
0
 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());
     }
 }
コード例 #20
0
 public bool IsExist(string id)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         MIS_Article entity = GetById(id);
         if (entity != null)
         {
             return(true);
         }
         return(false);
     }
 }
コード例 #21
0
        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));
            }
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
        /// <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());
        }
コード例 #24
0
        /// <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);
            }
        }
コード例 #25
0
 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));
     }
 }
コード例 #26
0
        public ActionResult Details(string id)
        {
            MIS_Article entity = m_BLL.m_Rep.Find(Convert.ToInt32(id));

            return(View(entity));
        }