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.

326 lines
10 KiB

  1. using Swift.DAL.BL.System.GeneralSettings;
  2. using Swift.web.Library;
  3. using System;
  4. using System.Data;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Web;
  8. using System.Web.Script.Serialization;
  9. namespace Swift.web
  10. {
  11. public partial class Font : System.Web.UI.Page
  12. {
  13. private SwiftLibrary sl = new SwiftLibrary();
  14. protected string HighChart = "";
  15. protected string HighChart2 = "";
  16. protected string HighChart3 = "";
  17. protected string HighChart4 = "";
  18. protected string HighChart5 = "";
  19. protected string countryName = "";
  20. protected string countryName2 = "";
  21. protected string countryName3 = "";
  22. protected string countryName4 = "";
  23. protected string countryName5 = "";
  24. private int oldValue = 0;
  25. protected void Page_Load(object sender, EventArgs e)
  26. {
  27. Response.Redirect("/DashboardV2/Dashboard.aspx",true);
  28. var MethodName = Request.Form["MethodName"];
  29. switch (MethodName)
  30. {
  31. case "Messages":
  32. PopulateMessageDetail();
  33. break;
  34. default:
  35. break;
  36. }
  37. sl.CheckSession();
  38. if (!IsPostBack)
  39. {
  40. Load_TransactionCount();
  41. PopulateMessages();
  42. LoadExrate();
  43. }
  44. PopulateChart();
  45. }
  46. private void LoadExrate()
  47. {
  48. var obj = new MessageSettingDao();
  49. var dt = obj.GetExRate(GetStatic.GetUser());
  50. if (dt.Rows.Count == 0 || dt == null)
  51. {
  52. return;
  53. }
  54. StringBuilder sb = new StringBuilder();
  55. sb.AppendLine("<table class=\"table table-responsive table-bordered\"><thead><tr>");
  56. for (int i = 0; i < dt.Columns.Count; i++)
  57. {
  58. sb.AppendLine("<th>" + dt.Columns[i] + "</th>");
  59. }
  60. sb.AppendLine("</tr></thead>");
  61. sb.AppendLine("<tbody>");
  62. for (int i = 0; i < dt.Rows.Count; i++)
  63. {
  64. sb.AppendLine("<tr>");
  65. for (int j = 0; j < dt.Columns.Count; j++)
  66. {
  67. sb.AppendLine("<td style='text-align:center;'>" + (string.IsNullOrEmpty(Convert.ToString(dt.Rows[i][j]))?"-": dt.Rows[i][j]) + "</td>");
  68. }
  69. sb.AppendLine("</tr>");
  70. }
  71. sb.AppendLine("</tbody></table>");
  72. tblExRate.InnerHtml = sb.ToString();
  73. }
  74. private void PopulateChart()
  75. {
  76. barDiv.Visible = false;
  77. var obj = new MessageSettingDao();
  78. DataSet ds = obj.GetHighChartData(GetStatic.GetUser());
  79. if (null == ds)
  80. {
  81. return;
  82. }
  83. if (ds.Tables.Count == 0)
  84. {
  85. return;
  86. }
  87. barDiv.Visible = true;
  88. if (ds.Tables.Count >= 2)
  89. {
  90. countryName = ds.Tables[0].Rows[0][0].ToString();
  91. HighChart = GetHighChartData(ds.Tables[1]);
  92. }
  93. if (ds.Tables.Count >= 4)
  94. {
  95. countryName2 = ds.Tables[2].Rows[0][0].ToString();
  96. HighChart2 = GetHighChartData(ds.Tables[3]);
  97. }
  98. if (ds.Tables.Count >= 6)
  99. {
  100. countryName3 = ds.Tables[4].Rows[0][0].ToString();
  101. HighChart3 = GetHighChartData(ds.Tables[5]);
  102. }
  103. if (ds.Tables.Count >= 8)
  104. {
  105. countryName4 = ds.Tables[6].Rows[0][0].ToString();
  106. HighChart4 = GetHighChartData(ds.Tables[7]);
  107. }
  108. if (ds.Tables.Count >= 10)
  109. {
  110. countryName5 = ds.Tables[8].Rows[0][0].ToString();
  111. HighChart5 = GetHighChartData(ds.Tables[9]);
  112. }
  113. }
  114. protected string GetHighChartData(DataTable dt)
  115. {
  116. string retData = "";
  117. int j = 0;
  118. int count = 0;
  119. int rowCount = 0;
  120. for (int i = 0; i < dt.Columns.Count - 1; i++)
  121. {
  122. int rowCounts = 0;
  123. oldValue = 0;
  124. string oldValues = "0";
  125. foreach (DataRow item in dt.Rows)
  126. {
  127. if (j == 0)
  128. {
  129. retData += "{name: '" + dt.Columns[i + 1].ColumnName + "',";
  130. retData += "data: [";
  131. }
  132. if (DataExists(dt, rowCounts, i + 1))
  133. {
  134. retData += GetValue(oldValues, item[dt.Columns[i + 1].ColumnName].ToString()) + ",";
  135. }
  136. if (item[dt.Columns[i + 1].ColumnName].ToString() != "0")
  137. {
  138. oldValues = item[dt.Columns[i + 1].ColumnName].ToString();
  139. }
  140. j++;
  141. rowCounts++;
  142. rowCount++;
  143. }
  144. if (count == 11)
  145. {
  146. retData += "]}";
  147. }
  148. else
  149. {
  150. retData += "]},";
  151. }
  152. j = 0;
  153. rowCount = 0;
  154. count++;
  155. }
  156. return retData;
  157. }
  158. private bool DataExists(DataTable dataTable, int rowIndex, int colCount)
  159. {
  160. bool retVal = false;
  161. rowIndex = (rowIndex.Equals(0)) ? 1 : rowIndex;
  162. for (int i = rowIndex; i < dataTable.Rows.Count; i++)
  163. {
  164. if (dataTable.Rows[i][colCount].ToString() != "0")
  165. {
  166. retVal = true;
  167. }
  168. }
  169. return retVal;
  170. }
  171. private string GetValue(string oldVal, string newVal)
  172. {
  173. if (newVal == "0")
  174. {
  175. if (oldVal != "0")
  176. {
  177. oldValue = Convert.ToInt16(oldVal);
  178. }
  179. return oldValue.ToString();
  180. }
  181. else
  182. {
  183. return newVal;
  184. }
  185. }
  186. private void PopulateMessageDetail()
  187. {
  188. string msgId = Request.Form["MessageId"];
  189. var obj = new MessageSettingDao();
  190. DataRow dr = obj.GetNewsFeederMessage(msgId);
  191. if (dr == null)
  192. {
  193. return;
  194. }
  195. MessageData _data = new MessageData();
  196. _data.CreatedBy = dr["createdBy"].ToString();
  197. _data.CreatedDate = dr["createdDate"].ToString();
  198. _data.Message = dr["newsFeederMsg"].ToString();
  199. var json = new JavaScriptSerializer().Serialize(_data);
  200. JsonSerialize(json);
  201. }
  202. private void JsonSerialize<T>(T obk)
  203. {
  204. JavaScriptSerializer jsonData = new JavaScriptSerializer();
  205. string jsonString = jsonData.Serialize(obk);
  206. HttpContext.Current.Response.ContentType = "application/json";
  207. HttpContext.Current.Response.Write(jsonString);
  208. HttpContext.Current.Response.End();
  209. }
  210. public class MessageData
  211. {
  212. public string CreatedBy { get; set; }
  213. public string CreatedDate { get; set; }
  214. public string Message { get; set; }
  215. }
  216. protected String GetDate()
  217. {
  218. return DateTime.Now.ToString("yyyy-MM-dd");
  219. }
  220. protected void Load_TransactionCount()
  221. {
  222. var obj = new MessageSettingDao();
  223. var ds = obj.Get_TransactionCount(GetStatic.GetUser());
  224. divPopulateTxnCount.Visible = false;
  225. TxnWiseStatus.Visible = false;
  226. if (null == ds)
  227. {
  228. return;
  229. }
  230. if (ds.Tables.Count == 0)
  231. {
  232. return;
  233. }
  234. var dr = ds.Tables[0].Rows[0];
  235. iCancel.Text = dr["iCancel"].ToString();
  236. iSend.Text = dr["iSend"].ToString();
  237. iPaid.Text = dr["intPaidCount"].ToString();
  238. divPopulateTxnCount.Visible = true;
  239. TxnWiseStatus.Visible = true;
  240. var dt = ds.Tables[1];
  241. int sn = 0;
  242. var sb = "";
  243. sb += "<table class='table table-responsive table-bordered'>";
  244. sb += "<tr>";
  245. sb += "<th>S.N</th>";
  246. sb += "<th>NO OF TXN</th>";
  247. sb += "<th>STATUS</th>";
  248. sb += "</tr>";
  249. foreach (DataRow item in dt.Rows)
  250. {
  251. sn++;
  252. sb += "<tr>";
  253. sb += "<td>" + sn + "</td>";
  254. sb += "<td><a onclick=\"ShowReport('" + item["tranStatus"] + "')\">" + item["TxnNo"] + "</a></td>";
  255. sb += "<td>" + item["tranStatus"] + "</td>";
  256. sb += "</tr>";
  257. }
  258. sb += "</table>";
  259. if (dt.Rows.Count > 0)
  260. {
  261. TxnWiseStatus.InnerHtml = sb;
  262. }
  263. }
  264. protected void PopulateMessages()
  265. {
  266. var obj = new MessageSettingDao();
  267. var dt = obj.GetNewsFeeder(GetStatic.GetUser(), GetStatic.GetUserType(), GetStatic.GetCountryId(), GetStatic.GetAgent(), GetStatic.GetBranch());
  268. if (dt.Rows.Count == 0 || dt == null)
  269. {
  270. return;
  271. }
  272. StringBuilder sb = new StringBuilder();
  273. foreach (DataRow item in dt.Rows)
  274. {
  275. string msgId = item["msgId"].ToString();
  276. sb.AppendLine("<li class=\"list-group-item\">");
  277. sb.AppendLine("<a href=\"javascript:void(0);\" onclick=\"ShowMessage('" + msgId + "')\" data-toggle=\"modal\">" + GetMessageToShow(item["newsFeederMsg"].ToString()) + "</a>");
  278. sb.AppendLine("<small><i class=\"fa fa-clock-o\"></i>&nbsp;" + item["msgDate"].ToString() + "</small>");
  279. sb.AppendLine("</li>");
  280. }
  281. //messages.InnerHtml = sb.ToString();
  282. }
  283. private string GetMessageToShow(string message)
  284. {
  285. string pureString = Regex.Replace(message, "<.*?>", String.Empty);
  286. return pureString.Substring(0, Math.Min(pureString.Length, 40));
  287. }
  288. }
  289. }