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.

155 lines
6.5 KiB

  1. using Swift.API.Common;
  2. using Swift.API.Common.SMS;
  3. using Swift.API.ThirdPartyApiServices;
  4. using Swift.DAL.BL.AgentPanel.Send;
  5. using Swift.DAL.BL.Remit.Transaction;
  6. using Swift.web.Component.Grid;
  7. using Swift.web.Component.Grid.gridHelper;
  8. using Swift.web.Library;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Text;
  13. namespace Swift.web.SwiftSystem.SMSLog
  14. {
  15. public partial class SMSLog : System.Web.UI.Page
  16. {
  17. private readonly ReceiptDao obj = new ReceiptDao();
  18. private readonly SwiftLibrary sl = new SwiftLibrary();
  19. private readonly SwiftGrid _grid = new SwiftGrid();
  20. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  21. private SendTranIRHDao st = new SendTranIRHDao();
  22. private const string GridName = "SMSLogGridAdm";
  23. private const string ViewFunctionId = "20319000";
  24. private const string ReSendFunctionId = "20319010";
  25. private const string SyncFunctionId = "20319020";
  26. protected void Page_Load(object sender, EventArgs e)
  27. {
  28. Authenticate();
  29. var methodName = Request.Form["MethodName"];
  30. if (methodName == "SyncStatus")
  31. SyncStatus();
  32. if (methodName == "SendSMS")
  33. SendSMS();
  34. if (!IsPostBack)
  35. {
  36. }
  37. LoadGrid();
  38. }
  39. private void SendSMS()
  40. {
  41. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":resendSms";
  42. SendSMSApiService _sendAPI = new SendSMSApiService();
  43. DataRow dr = obj.GetTxnDataForSMS(GetStatic.GetUser(), Request.Form["controlno"]);
  44. string msgBody = GetStatic.GetSMSTextForTxn(dr);
  45. SMSRequestModel _req = new SMSRequestModel
  46. {
  47. ProviderId = "onewaysms",
  48. MobileNumber = Request.Form["mobileNumber"].Trim().Replace("+", ""),
  49. SMSBody = msgBody,
  50. ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40),
  51. RequestedBy = GetStatic.GetUser(),
  52. UserName = GetStatic.GetUser(),
  53. method = "send",
  54. ControlNo = Request.Form["controlno"]
  55. };
  56. JsonResponse _resp = _sendAPI.SMSTPApi(_req);
  57. string isSuccess = (_resp.ResponseCode == "0") ? "1" : "0";
  58. obj.LogSMS(Request.Form["controlno"], GetStatic.GetUser(), msgBody, Request.Form["mobileNumber"].Trim().Replace("+", ""),
  59. ProcessId, _resp.Extra, isSuccess);
  60. GetStatic.JsonResponse(_resp, this);
  61. }
  62. private void SyncStatus()
  63. {
  64. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":syncStatusSms";
  65. SendSMSApiService _sendAPI = new SendSMSApiService();
  66. //GetSMSTextForTxn
  67. SMSRequestModel _req = new SMSRequestModel
  68. {
  69. ProviderId = "onewaysms",
  70. ProcessId = Request.Form["processId"],
  71. RequestedBy = GetStatic.GetUser(),
  72. UserName = GetStatic.GetUser(),
  73. method = "status",
  74. MTID = Request.Form["mtId"]
  75. };
  76. JsonResponse _resp = _sendAPI.SMSTPApi(_req);
  77. string status = (_resp.ResponseCode == "0" || _resp.ResponseCode == "100") ? "Success" : "Fail";
  78. obj.LogSMSSyncStatus(GetStatic.GetUser(), Request.Form["rowId"], status, _resp.Msg);
  79. GetStatic.JsonResponse(_resp, this);
  80. }
  81. private void LoadGrid()
  82. {
  83. _grid.FilterList = new List<GridFilter>
  84. {
  85. new GridFilter("CONTROL_NO", "JME No", "T"),
  86. new GridFilter("MOBILE_NUMBER", "Mobile No", "T"),
  87. new GridFilter("CREATED_BY", "Sent By", "T")
  88. };
  89. _grid.ColumnList = new List<GridColumn>
  90. {
  91. new GridColumn("CONTROL_NO", "JME No", "", "T"),
  92. new GridColumn("MOBILE_NUMBER", "Mobile No", "", "T"),
  93. new GridColumn("PROCESS_ID", "Process ID", "", "T"),
  94. new GridColumn("IS_SEND_SUCCESS", "Is Send Success", "", "T"),
  95. new GridColumn("MSG_BODY", "Message", "", "T"),
  96. new GridColumn("CREATED_BY", "Sent By", "", "T"),
  97. new GridColumn("CREATED_DATE", "Sent Date", "", "D"),
  98. new GridColumn("STATUS", "Status", "", "T"),
  99. new GridColumn("STATUS_DETAIL", "Status Detail", "", "T")
  100. };
  101. _grid.GridType = 1;
  102. _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  103. _grid.GridName = GridName;
  104. _grid.LoadGridOnFilterOnly = false;
  105. _grid.ShowPagingBar = true;
  106. _grid.AlwaysShowFilterForm = true;
  107. _grid.ShowFilterForm = true;
  108. _grid.AllowDelete = false;
  109. _grid.RowIdField = "ROW_ID";
  110. _grid.ThisPage = "SMSLog.aspx";
  111. _grid.InputPerRow = 4;
  112. _grid.EnablePdfDownload = true;
  113. _grid.GridMinWidth = 700;
  114. _grid.GridWidth = 100;
  115. _grid.ShowCheckBox = false;
  116. _grid.IsGridWidthInPercent = true;
  117. _grid.AllowCustomLink = true;
  118. _grid.CustomLinkVariables = "ROW_ID,MT_ID,PROCESS_ID,MOBILE_NUMBER,CONTROL_NO";
  119. var customLinkText = new StringBuilder();
  120. if (_sdd.CheckAuthentication(SyncFunctionId))
  121. customLinkText.Append("<a href=\"javascript:void(0);\" onclick=\"SynccStatus('@ROW_ID','@MT_ID','@PROCESS_ID')\" title='Sync Status'><span class=\"action-icon btn btn-xs btn-primary\"><i class=\"fa fa-recycle\"></i><span></a>");
  122. if (_sdd.CheckAuthentication(ReSendFunctionId))
  123. customLinkText.Append("&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"ResendSMS('@ROW_ID', '@MOBILE_NUMBER', '@CONTROL_NO')\" title='Re-Send SMS'><span class=\"action-icon btn btn-xs btn-primary\"><i class=\"fa fa-send\"></i><span></a>");
  124. _grid.CustomLinkText = customLinkText.ToString();
  125. string sql = "[PROC_SMS_LOG] @flag='s'";
  126. _grid.SetComma();
  127. rpt_grid.InnerHtml = _grid.CreateGrid(sql);
  128. }
  129. public void Authenticate()
  130. {
  131. _sdd.CheckAuthentication(ViewFunctionId);
  132. }
  133. }
  134. }