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.

149 lines
5.6 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.EIP
  7. {
  8. public class EipComService : ServiceBase
  9. {
  10. #region 通過帳單號碼抓去專案代號
  11. /// <summary>
  12. /// 通過帳單號碼抓去專案代號
  13. /// </summary>
  14. /// <param name="i_crm"></param>
  15. /// <returns></returns>
  16. public ResponseMessage GetPrjCodeByBillNO(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 sBillNO = _fetchString(i_crm, @"BillNO");
  26. var oBillInfo = db.Queryable<OTB_OPM_BillInfo, OTB_OPM_Exhibition>((t1, t2) => t1.OrgID == t2.OrgID && t1.ExhibitionNO == t2.SN.ToString())
  27. .Where((t1, t2) => t1.OrgID == i_crm.ORIGID && t1.BillNO == sBillNO)
  28. .Select((t1, t2) => new { t1.BillNO, PrjCode = t2.ExhibitionCode }).Single();
  29. rm = new SuccessResponseMessage(null, i_crm);
  30. rm.DATA.Add(BLWording.REL, oBillInfo);
  31. } while (false);
  32. }
  33. catch (Exception ex)
  34. {
  35. sMsg = Util.GetLastExceptionMsg(ex);
  36. LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(EipComService), @"EIPCOMMON", @"GetPrjCodeByBillNO(通過帳單號碼抓去專案代號)", @"", @"", @"");
  37. }
  38. finally
  39. {
  40. if (null != sMsg)
  41. {
  42. rm = new ErrorResponseMessage(sMsg, i_crm);
  43. }
  44. }
  45. return rm;
  46. }
  47. #endregion 通過帳單號碼抓去專案代號
  48. #region 抓去個人主頁請假資訊
  49. /// <summary>
  50. /// 抓去個人主頁請假資訊
  51. /// </summary>
  52. /// <param name="i_crm"></param>
  53. /// <returns></returns>
  54. public ResponseMessage GetLeavelist(RequestMessage i_crm)
  55. {
  56. ResponseMessage rm = null;
  57. string sMsg = null;
  58. var db = SugarBase.DB;
  59. try
  60. {
  61. do
  62. {
  63. var rTomorrow = DateTime.Now.AddDays(2);
  64. var saLeave = db.Queryable<OTB_EIP_Leave, OTB_SYS_Members>((a, b) =>
  65. new object[] {
  66. JoinType.Inner,a.OrgID==b.OrgID && a.AskTheDummy==b.MemberID
  67. }).OrderBy(a => a.StartDate)
  68. .Where((a, b) => a.OrgID == i_crm.ORIGID && a.EndDate.Value >= DateTime.Now.Date && a.StartDate.Value <= rTomorrow.Date)
  69. .Where((a, b) => @"B,H-O,E".Contains(a.Status))
  70. .Select((a, b) => new { Info = a, AskTheDummyName = b.MemberName, b.MemberPic, b.OrgID }).ToList();
  71. rm = new SuccessResponseMessage(null, i_crm);
  72. rm.DATA.Add(BLWording.REL, saLeave);
  73. } while (false);
  74. }
  75. catch (Exception ex)
  76. {
  77. sMsg = Util.GetLastExceptionMsg(ex);
  78. LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(EipComService), @"EIPCOMMON", @"GetLeavelist(抓去個人主頁請假資訊)", @"", @"", @"");
  79. }
  80. finally
  81. {
  82. if (null != sMsg)
  83. {
  84. rm = new ErrorResponseMessage(sMsg, i_crm);
  85. }
  86. }
  87. return rm;
  88. }
  89. #endregion 抓去個人主頁請假資訊
  90. #region 獲取簽核流程
  91. /// <summary>
  92. /// 獲取簽核流程
  93. /// </summary>
  94. /// <param name="i_crm">todo: describe i_crm parameter on GetFlows</param>
  95. /// <returns></returns>
  96. public ResponseMessage GetFlows(RequestMessage i_crm)
  97. {
  98. ResponseMessage rm = null;
  99. string sMsg = null;
  100. var db = SugarBase.GetIntance();
  101. try
  102. {
  103. do
  104. {
  105. var sFlow_Type = _fetchString(i_crm, @"Flow_Type");
  106. var sShareTo = _fetchString(i_crm, @"ShareTo");
  107. var saCheckFlow = db.Queryable<OTB_EIP_CheckFlow>()
  108. .OrderBy(x => x.ModifyDate)
  109. .Where(x => x.OrgID == i_crm.ORIGID)
  110. .WhereIF(!string.IsNullOrEmpty(sFlow_Type), x => x.Flow_Type == sFlow_Type)
  111. .WhereIF(!string.IsNullOrEmpty(sShareTo), x => x.ShareTo.Contains(sShareTo))
  112. .Select(x => new
  113. {
  114. x.Guid,
  115. x.Flow_Name,
  116. x.Flows
  117. })
  118. .ToList();
  119. rm = new SuccessResponseMessage(null, i_crm);
  120. rm.DATA.Add(BLWording.REL, saCheckFlow);
  121. } while (false);
  122. }
  123. catch (Exception ex)
  124. {
  125. sMsg = Util.GetLastExceptionMsg(ex);
  126. LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(EipComService), @"EIPCOMMON", @"GetFlows(獲取簽核流程)", @"", @"", @"");
  127. }
  128. finally
  129. {
  130. if (null != sMsg)
  131. {
  132. rm = new ErrorResponseMessage(sMsg, i_crm);
  133. }
  134. }
  135. return rm;
  136. }
  137. #endregion 獲取簽核流程
  138. }
  139. }