using Learun.DataBase.Repository; using Learun.Util; using System; using System.Collections.Generic; using System.Text; namespace Learun.Application.OA.Email.EmailReceive { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2017 /// 创建人:陈彬彬 /// 日 期:2018.06.04 /// 描 述:邮件接收管理 /// public class EmailReceiveService : RepositoryFactory { #region 获取数据 /// /// 获取收取邮件数据 /// /// 分页参数 /// 关键词 /// public IEnumerable GetReceiveList(Pagination pagination,string queryJson) { try { UserInfo userInfo = LoginUserInfo.Get(); var strSql = new StringBuilder(); strSql.Append("SELECT * FROM LR_EmailReceive t WHERE t.F_DeleteMark = 0 AND t.F_EnabledMark = 0 AND F_CreatorUserId=@userId"); var queryParam = queryJson.ToJObject(); DateTime startTime = new DateTime(), endTime = new DateTime(); // 日期 if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) { startTime = queryParam["StartTime"].ToDate(); endTime = queryParam["EndTime"].ToDate().AddDays(1); strSql.Append(" AND ( t.F_Date >= @startTime AND t.F_Date <= @endTime ) "); } // 关键字 string keyword = ""; if (!queryParam["keyword"].IsEmpty()) { keyword = queryParam["keyword"].ToString(); strSql.Append(" AND (t.F_Subject like @keyword OR t.F_Sender like @keyword )"); } return this.BaseRepository().FindList(strSql.ToString(), new { userId=userInfo.userId, startTime = startTime, endTime = endTime, keyword = "%" + keyword + "%" }, pagination); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取邮件接收实体 /// /// 主键 /// public EmailReceiveEntity GetReceiveEntity(string keyValue) { try { return this.BaseRepository().FindEntity(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 获取邮件接收个数 /// /// public int GetCount() { try { string sql = "SELECT F_Id FROM LR_EmailReceive"; var list = this.BaseRepository().FindTable(sql); return list.Rows.Count; } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion #region 提交数据 /// /// 删除 /// /// 主键 public void DeleteEntity(string keyValue) { try { this.BaseRepository().Delete(t => t.F_Id == keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } /// /// 保存(新增、修改) /// /// 主键值 /// 邮件接收实体 /// public void SaveReceiveEntity(string keyValue, EmailReceiveEntity receiveEntity) { try { if (!string.IsNullOrEmpty(keyValue)) { receiveEntity.Modify(keyValue); this.BaseRepository().Update(receiveEntity); } else { receiveEntity.Create(); this.BaseRepository().Insert(receiveEntity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } #endregion } }