You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.5 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using SqlSugar;
  4. using SqlSugar.Base;
  5. using System;
  6. namespace EasyBL.WEBAPP.SYS
  7. {
  8. public class Announcement_QryService : ServiceBase
  9. {
  10. #region 公告管理(分頁資料)
  11. /// <summary>
  12. /// 公告管理(分頁資料)
  13. /// </summary>
  14. /// <param name="i_crm">todo: describe i_crm parameter on QueryPage</param>
  15. /// <returns></returns>
  16. public ResponseMessage QueryPage(RequestMessage i_crm)
  17. {
  18. ResponseMessage rm = null;
  19. string sMsg = null;
  20. var db = SugarBase.DB;
  21. try
  22. {
  23. do
  24. {
  25. var pml = new PageModel
  26. {
  27. PageIndex = _fetchInt(i_crm, @"pageIndex"),
  28. PageSize = _fetchInt(i_crm, @"pageSize")
  29. };
  30. var iPageCount = 0;
  31. var sSortField = _fetchString(i_crm, @"sortField");
  32. var sSortOrder = _fetchString(i_crm, @"sortOrder");
  33. var sAnn_Type = _fetchString(i_crm, @"Ann_Type");
  34. var sTitle = _fetchString(i_crm, @"Title");
  35. var sStartDateTime = _fetchString(i_crm, @"StartDateTime");
  36. var sEndDateTime = _fetchString(i_crm, @"EndDateTime");
  37. var bExcel = _fetchBool(i_crm, @"Excel");
  38. var rStartDateTime = new DateTime();
  39. var rEndDateTime = new DateTime();
  40. if (!string.IsNullOrEmpty(sStartDateTime))
  41. {
  42. rStartDateTime = SqlFunc.ToDate(sStartDateTime);
  43. }
  44. if (!string.IsNullOrEmpty(sEndDateTime))
  45. {
  46. rEndDateTime = SqlFunc.ToDate(sEndDateTime).AddDays(1);
  47. }
  48. pml.DataList = db.Queryable<OTB_SYS_Announcement>()
  49. .Where(x => x.OrgID == i_crm.ORIGID && x.Title.Contains(sTitle))
  50. .WhereIF(!string.IsNullOrEmpty(sAnn_Type), x => x.Ann_Type == sAnn_Type)
  51. .WhereIF(!string.IsNullOrEmpty(sStartDateTime), x => x.StartDateTime >= rStartDateTime.Date)
  52. .WhereIF(!string.IsNullOrEmpty(sEndDateTime), x => x.EndDateTime <= rEndDateTime.Date)
  53. .OrderBy(sSortField, sSortOrder)
  54. .ToPageList(pml.PageIndex, bExcel ? 100000 : pml.PageSize, ref iPageCount);
  55. pml.Total = iPageCount;
  56. rm = new SuccessResponseMessage(null, i_crm);
  57. if (bExcel)
  58. {
  59. }
  60. else
  61. {
  62. rm.DATA.Add(BLWording.REL, pml);
  63. }
  64. } while (false);
  65. }
  66. catch (Exception ex)
  67. {
  68. sMsg = Util.GetLastExceptionMsg(ex);
  69. LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(Announcement_QryService), @"公告管理", @"QueryPage(公告管理(分頁資料))", @"", @"", @"");
  70. }
  71. finally
  72. {
  73. if (null != sMsg)
  74. {
  75. rm = new ErrorResponseMessage(sMsg, i_crm);
  76. }
  77. }
  78. return rm;
  79. }
  80. #endregion 公告管理(分頁資料)
  81. }
  82. }