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.

130 lines
4.0 KiB

  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using SqlSugar;
  4. using SqlSugar.Base;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace EasyBL.WEBAPP.SYS
  8. {
  9. public class ExhibStatMaintain_QryService : ServiceBase
  10. {
  11. #region 展覽統計管理(List 查詢展覽統計)
  12. /// <summary>
  13. /// 展覽統計管理(List 查詢展覽統計)
  14. /// </summary>
  15. /// <param name="i_crm"></param>
  16. /// <returns></returns>
  17. ///
  18. public ResponseMessage QueryStatisticsList(RequestMessage i_crm)
  19. {
  20. ResponseMessage rm = null;
  21. string sMsg = null;
  22. var db = SugarBase.GetIntance();
  23. List<SETB_CMS_Exhibition_Statistics> saStats = new List<SETB_CMS_Exhibition_Statistics>();
  24. try
  25. {
  26. do
  27. {
  28. var sExhibitionID = _fetchString(i_crm, @"ExhibitionID");
  29. saStats = db.Queryable<SETB_CMS_Exhibition_Statistics>()
  30. .Where(t1 => t1.OrgID == i_crm.ORIGID && t1.Effective == "Y" && t1.DelStatus == "N")
  31. .Where(t1 => t1.ExhibitionID == sExhibitionID)
  32. .Select((t1) => new SETB_CMS_Exhibition_Statistics
  33. {
  34. StatisticsID = SqlFunc.GetSelfAndAutoFill(t1.StatisticsID)
  35. })
  36. .OrderBy(t1 => t1.Year, OrderByType.Desc)
  37. .ToList();
  38. rm = new SuccessResponseMessage(null, i_crm);
  39. rm.DATA.Add(BLWording.REL, saStats);
  40. } while (false);
  41. }
  42. catch (Exception ex)
  43. {
  44. sMsg = Util.GetLastExceptionMsg(ex);
  45. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ExhibStatMaintain_QryService), "", "QueryStatisticsList 展覽統計(List 查詢展覽統計)", "", "", "");
  46. }
  47. finally
  48. {
  49. if (null != sMsg)
  50. {
  51. rm = new ErrorResponseMessage(sMsg, i_crm);
  52. }
  53. }
  54. return rm;
  55. }
  56. #endregion 展覽統計管理(List 查詢展覽統計)
  57. #region 展覽統計管理(Boolean 檢查是否存在)
  58. /// <summary>
  59. /// 展覽統計管理(Boolean 檢查是否存在)
  60. /// </summary>
  61. /// <param name="i_crm"></param>
  62. /// <returns></returns>
  63. ///
  64. public Boolean Exists(RequestMessage i_crm, string sExhibitionID, string sYear)
  65. {
  66. Boolean found = false;
  67. ResponseMessage rm = null;
  68. string sMsg = null;
  69. var db = SugarBase.GetIntance();
  70. int count = 0;
  71. try
  72. {
  73. do
  74. {
  75. count = db.Queryable<SETB_CMS_Exhibition_Statistics>()
  76. .Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
  77. .Where(t1 => t1.ExhibitionID == sExhibitionID)
  78. .Where(t1 => t1.Year == sYear)
  79. .Count();
  80. rm = new SuccessResponseMessage(null, i_crm);
  81. rm.DATA.Add(BLWording.REL, count);
  82. } while (false);
  83. }
  84. catch (Exception ex)
  85. {
  86. sMsg = Util.GetLastExceptionMsg(ex);
  87. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ExhibStatMaintain_QryService), "", "Exists 展覽統計管理(Boolean 檢查是否存在)", "", "", "");
  88. }
  89. finally
  90. {
  91. if (null != sMsg)
  92. {
  93. rm = new ErrorResponseMessage(sMsg, i_crm);
  94. }
  95. }
  96. if (count > 0)
  97. {
  98. found = true;
  99. }
  100. return found;
  101. }
  102. #endregion 展覽統計管理(Boolean 檢查是否存在)
  103. }
  104. }