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.

154 lines
6.3 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. using System.Web.UI;
  14. namespace Swift.web.AgentNew.SMSLog
  15. {
  16. public partial class SMSLog : Page
  17. {
  18. private readonly ReceiptDao obj = new ReceiptDao();
  19. private readonly SwiftLibrary sl = new SwiftLibrary();
  20. private readonly SwiftGrid _grid = new SwiftGrid();
  21. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  22. private SendTranIRHDao st = new SendTranIRHDao();
  23. private const string GridName = "SMSLogGrid";
  24. private const string ViewFunctionId = "20308000";
  25. private const string ReSendFunctionId = "20318010";
  26. private const string SyncFunctionId = "20308000";
  27. protected void Page_Load(object sender, EventArgs e)
  28. {
  29. Authenticate();
  30. var methodName = Request.Form["MethodName"];
  31. if (methodName == "SyncStatus")
  32. SyncStatus();
  33. if (methodName == "SendSMS")
  34. SendSMS();
  35. if (!IsPostBack)
  36. {
  37. }
  38. LoadGrid();
  39. }
  40. private void SendSMS()
  41. {
  42. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":resendSms";
  43. SendSMSApiService _sendAPI = new SendSMSApiService();
  44. DataRow dr = obj.GetTxnDataForSMS(GetStatic.GetUser(), Request.Form["controlno"]);
  45. string msgBody = GetStatic.GetSMSTextForTxn(dr);
  46. SMSRequestModel _req = new SMSRequestModel
  47. {
  48. ProviderId = "onewaysms",
  49. MobileNumber = Request.Form["mobileNumber"].Trim().Replace("+", ""),
  50. SMSBody = msgBody,
  51. ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40),
  52. RequestedBy = GetStatic.GetUser(),
  53. UserName = GetStatic.GetUser(),
  54. method = "send",
  55. ControlNo = Request.Form["controlno"]
  56. };
  57. JsonResponse _resp = _sendAPI.SMSTPApi(_req);
  58. string isSuccess = (_resp.ResponseCode == "0") ? "1" : "0";
  59. obj.LogSMS(Request.Form["controlno"], GetStatic.GetUser(), msgBody, Request.Form["mobileNumber"].Trim().Replace("+", ""),
  60. ProcessId, _resp.Extra, isSuccess);
  61. GetStatic.JsonResponse(_resp, this);
  62. }
  63. private void SyncStatus()
  64. {
  65. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":syncStatusSms";
  66. SendSMSApiService _sendAPI = new SendSMSApiService();
  67. //GetSMSTextForTxn
  68. SMSRequestModel _req = new SMSRequestModel
  69. {
  70. ProviderId = "onewaysms",
  71. ProcessId = Request.Form["processId"],
  72. RequestedBy = GetStatic.GetUser(),
  73. UserName = GetStatic.GetUser(),
  74. method = "status",
  75. MTID = Request.Form["mtId"]
  76. };
  77. JsonResponse _resp = _sendAPI.SMSTPApi(_req);
  78. string status = (_resp.ResponseCode == "0" || _resp.ResponseCode == "100") ? "Success" : "Fail";
  79. obj.LogSMSSyncStatus(GetStatic.GetUser(), Request.Form["rowId"], status, _resp.Msg);
  80. GetStatic.JsonResponse(_resp, this);
  81. }
  82. private void LoadGrid()
  83. {
  84. _grid.FilterList = new List<GridFilter>
  85. {
  86. new GridFilter("CONTROL_NO", "JME No", "T"),
  87. new GridFilter("MOBILE_NUMBER", "Mobile No", "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_DATE", "Sent Date", "", "D"),
  97. new GridColumn("STATUS", "Status", "", "T"),
  98. new GridColumn("STATUS_DETAIL", "Status Detail", "", "T")
  99. };
  100. _grid.GridType = 1;
  101. _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  102. _grid.GridName = GridName;
  103. _grid.LoadGridOnFilterOnly = true;
  104. _grid.ShowPagingBar = true;
  105. _grid.AlwaysShowFilterForm = true;
  106. _grid.ShowFilterForm = true;
  107. _grid.AllowDelete = false;
  108. _grid.RowIdField = "ROW_ID";
  109. _grid.ThisPage = "SMSLog.aspx"; ;
  110. _grid.InputPerRow = 4;
  111. _grid.EnablePdfDownload = true;
  112. _grid.GridMinWidth = 700;
  113. _grid.GridWidth = 100;
  114. _grid.ShowCheckBox = false;
  115. _grid.IsGridWidthInPercent = true;
  116. _grid.AllowCustomLink = true;
  117. _grid.CustomLinkVariables = "ROW_ID,MT_ID,PROCESS_ID,MOBILE_NUMBER,CONTROL_NO";
  118. var customLinkText = new StringBuilder();
  119. if (_sdd.CheckAuthentication(SyncFunctionId))
  120. 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>");
  121. if (_sdd.CheckAuthentication(ReSendFunctionId))
  122. 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>");
  123. _grid.CustomLinkText = customLinkText.ToString();
  124. string sql = "[PROC_SMS_LOG] @flag='s'";
  125. _grid.SetComma();
  126. rpt_grid.InnerHtml = _grid.CreateGrid(sql);
  127. }
  128. public void Authenticate()
  129. {
  130. _sdd.CheckAuthentication(ViewFunctionId);
  131. }
  132. }
  133. }