Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public ActionResult Details(string id)
        {
            ViewBag.Perm = GetPermission();
            MIS_ArticleModel entity = m_BLL.GetById(id);

            return(View(entity));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
 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);
     }
 }
Exemplo n.º 7
0
 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));
     }
 }
Exemplo n.º 8
0
        public ActionResult Details(string id)
        {
            ViewBag.perm = GetPermission();
            MIS_ArticleModel model = m_BLL.GetById(id);

            return(View(model));
        }
Exemplo n.º 9
0
        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, "审核未通过")));
            }
        }
Exemplo n.º 10
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)));
     }
 }
Exemplo n.º 11
0
 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));
     }
 }
Exemplo n.º 12
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);
 }
Exemplo n.º 13
0
        public ActionResult Edit(string id)
        {
            ViewBag.Perm = GetPermission();
            MIS_ArticleModel entity = articleBll.GetById(id);

            return(View(entity));
        }
Exemplo n.º 14
0
 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));
     }
 }
Exemplo n.º 15
0
 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)));
 }
Exemplo n.º 16
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));
            }
        }
Exemplo n.º 17
0
 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)));
 }
Exemplo n.º 18
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);
            }
        }
Exemplo n.º 19
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);
            }
        }
Exemplo n.º 20
0
 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));
     }
 }
Exemplo n.º 21
0
 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)));
     }
 }
Exemplo n.º 22
0
 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)));
     }
 }
Exemplo n.º 23
0
        /// <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);
        }
Exemplo n.º 24
0
        public ActionResult Details(string id)
        {
            MIS_ArticleModel entity = m_BLL.GetById(id);

            return(View(entity));
        }