using Learun.DataBase.Repository; using Learun.Util; using System; using System.Collections.Generic; using System.Text; using Spire.Pdf.General.Render.Decode.Jpeg2000.Icc; namespace Learun.Application.OA { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创建人:陈彬彬 /// 日 期:2017.04.17 /// 描 述:新闻管理 /// public class NewsService : RepositoryFactory { #region 获取数据 /// /// 新闻列表 /// /// 分页参数 /// 类型 /// 关键词 /// public IEnumerable GetPageList(Pagination pagination, string keyword) { try { var strSql = new StringBuilder(); strSql.Append("SELECT * FROM LR_OA_News t WHERE t.F_TypeId = 1 "); if (!string.IsNullOrEmpty(keyword)) { strSql.Append(" AND F_FullHead like @keyword"); } return this.BaseRepository().FindList(strSql.ToString(), new { keyword = "%" + keyword + "%" }, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } public IEnumerable GetAboutSchool() { try { return this.BaseRepository().FindList(a => a.F_Category == "关于学院"); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } public IEnumerable GetNews() { try { return this.BaseRepository().FindList(a => a.F_Category == "新闻公告"); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 新闻公告实体 /// /// 主键值 /// public NewsEntity GetEntity(string keyValue) { try { return this.BaseRepository().FindEntity(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion #region 提交数据 /// /// 删除 /// /// 主键 public void DeleteEntity(string keyValue) { try { NewsEntity entity = new NewsEntity() { F_NewsId = keyValue, }; this.BaseRepository().Delete(entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 保存(新增、修改) /// /// 主键值 /// 新闻公告实体 /// public void SaveEntity(string keyValue, NewsEntity newsEntity) { try { newsEntity.F_TypeId = 1; if (!string.IsNullOrEmpty(keyValue)) { newsEntity.Modify(keyValue); this.BaseRepository().Update(newsEntity); } else { newsEntity.Create(); this.BaseRepository().Insert(newsEntity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion public void ChangeStatusByProcessId(string parameterProcessId, int status) { if (status == 2|| status == 0) { try { var newEntity = this.BaseRepository() .FindEntity(a => a.F_ProgressId == parameterProcessId); if (null != newEntity) { newEntity.F_Status = status.ToString(); if (status==2) { newEntity.F_EnabledMark = 1; } } this.BaseRepository().Update(newEntity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } } } }