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.

275 lines
12 KiB

  1. using Swift.web.Library;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Web;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. namespace Swift.web.DashboardV2
  12. {
  13. public partial class Dashboard : Page
  14. {
  15. private SwiftLibrary sl = new SwiftLibrary();
  16. private RemittanceLibrary _remit = new RemittanceLibrary();
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. sl.CheckSession();
  20. if (!IsPostBack)
  21. {
  22. PopulateMenu();
  23. PopulateNotification();
  24. // Task.WaitAll(Task.Run(() => PopulateNotification()));
  25. GetStatic.PrintMessage(Page);
  26. }
  27. }
  28. public async Task PopulateNotificationAsync()
  29. {
  30. await Task.Run(() => PopulateNotification());
  31. }
  32. protected string getUser()
  33. {
  34. return GetStatic.GetUser();
  35. }
  36. protected void PopulateNotification()
  37. {
  38. string sql = "EXEC proc_notification @user = '" + getUser() + "'";
  39. DataTable dt = _remit.ExecuteDataTable(sql);
  40. if (null == dt)
  41. {
  42. return;
  43. }
  44. if (dt.Rows.Count == 0)
  45. {
  46. return;
  47. }
  48. StringBuilder sb = new StringBuilder();
  49. int counter = 0;
  50. foreach (DataRow item in dt.Rows)
  51. {
  52. counter += Convert.ToInt16(item["count"].ToString());
  53. sb.AppendLine("<li class=\"clearfix\">");
  54. sb.AppendLine("<a href=\"" + item["link"].ToString() + "\" target=\"mainFrame\">");
  55. sb.AppendLine("<span class=\"pull-left\">");
  56. sb.AppendLine("<i class=\"fa fa-bell\" style='color:#0e96ec'></i>");
  57. sb.AppendLine("</span>");
  58. sb.AppendLine("<span class=\"media-body\">");
  59. sb.AppendLine(item["msg"].ToString());
  60. sb.AppendLine("<em>" + item["msg1"].ToString() + "</em>");
  61. sb.AppendLine("</span>");
  62. sb.AppendLine("</a></li>");
  63. }
  64. count.Text = counter.ToString();
  65. notification.InnerHtml = "<li class=\"notify-title\">" + counter.ToString() + " New Notifications</li>" + sb.ToString();
  66. }
  67. protected void PopulateMenu()
  68. {
  69. StringBuilder sb = new StringBuilder();
  70. sb = (StringBuilder)Session[getUser() + "Menu"];
  71. if (string.IsNullOrEmpty(sb.ToString()) || string.IsNullOrWhiteSpace(sb.ToString()))
  72. {
  73. sb = new StringBuilder();
  74. string sql = "exec menu_proc @flag = 'admin', @user = '" + getUser() + "'";
  75. DataSet ds = _remit.ExecuteDataset(sql);
  76. DataTable menuGroup = ds.Tables[0];
  77. sb.AppendLine("<div id=\"navbar-main\" class=\"navbar-collapse collapse\">");
  78. sb.AppendLine("<ul class=\"nav navbar-nav\">");
  79. sb.AppendLine("<li class=\"active\"><a href=\"/DashboardV2/Dashboard.aspx\">Dashboard</a></li>");
  80. if (ds.Tables[0].Rows.Count == 0 || ds.Tables[1].Rows.Count == 0)
  81. {
  82. sb.AppendLine("</li></ul>");
  83. sb.AppendLine("</div>");
  84. menu.InnerHtml = sb.ToString();
  85. return;
  86. }
  87. for (int i = 0; i <= menuGroup.Rows.Count; i++)
  88. {
  89. if (menuGroup.Rows.Count != 0)
  90. {
  91. string menuGroupName = menuGroup.Rows[0]["menuGroup"].ToString();
  92. DataRow[] rows = ds.Tables[1].Select("menuGroup IN (" + GetMenuGroup(GetMainMenuGroup(menuGroupName)) + ")");
  93. sb.AppendLine(GetMenuContents(menuGroupName, rows));
  94. DataRow[] rowsToRemove = menuGroup.Select("menuGroup IN (" + GetMenuGroup(GetMainMenuGroup(menuGroupName)) + ")");
  95. foreach (DataRow row in rowsToRemove)
  96. {
  97. menuGroup.Rows.Remove(row);
  98. }
  99. }
  100. i = 0;
  101. }
  102. sb.AppendLine("</li></ul>");
  103. sb.AppendLine("</div>");
  104. Session[getUser() + "Menu"] = sb;
  105. }
  106. menu.InnerHtml = sb.ToString();
  107. }
  108. private string GetMenuContents(string menuGroup, DataRow[] dr)
  109. {
  110. StringBuilder sb = new StringBuilder("");
  111. DataTable dt = CreateDataTable();
  112. foreach (DataRow row in dr)
  113. {
  114. dt.ImportRow(row);
  115. }
  116. sb.AppendLine("<li class=\"dropdown\">");
  117. sb.AppendLine("<a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-haspopup=\"true\" aria-expanded=\"false\">" + GetMainMenuGroup(menuGroup) + "<span class=\"caret\"></span></a>");
  118. sb.AppendLine("<ul class=\"dropdown-menu\">");
  119. for (int i = 0; i <= dt.Rows.Count; i++)
  120. {
  121. if (dt.Rows.Count != 0)
  122. {
  123. DataRow[] menuList = dt.Select("menuGroup = ('" + dt.Rows[0]["menuGroup"].ToString() + "')");
  124. string subMainMenu = menuList[0]["menuGroup"].ToString();
  125. if (menuGroup == "Notifications" || subMainMenu == "User Management" || subMainMenu == "Other Services" || subMainMenu == "Transaction" || menuGroup == "Rule Setup")
  126. {
  127. foreach (DataRow row in menuList)
  128. {
  129. sb.AppendLine("<li><a tabindex=\"-1\" href=\"" + row["linkPage"].ToString() + "\" target=\"mainFrame\">" + row["menuName"].ToString() + "</a></li>");
  130. }
  131. //sb.AppendLine("</ul></li>");
  132. }
  133. else
  134. {
  135. sb.AppendLine("<li class=\"dropdown-submenu\"><a tabindex=\"-1\" href=\"#\">" + subMainMenu + "</a>");
  136. sb.AppendLine("<ul class=\"dropdown-menu\">");
  137. foreach (DataRow row in menuList)
  138. {
  139. sb.AppendLine("<li class=\"submenu\"><a tabindex=\"-1\" href=\"" + row["linkPage"].ToString() + "\" target=\"mainFrame\">" + row["menuName"].ToString() + "</a></li>");
  140. }
  141. sb.AppendLine("</ul></li>");
  142. }
  143. DataRow[] rows = dt.Select("menuGroup = ('" + dt.Rows[0]["menuGroup"].ToString() + "')");
  144. foreach (DataRow row in rows)
  145. {
  146. dt.Rows.Remove(row);
  147. }
  148. }
  149. i = 0;
  150. }
  151. sb.AppendLine("</ul></li>");
  152. return sb.ToString();
  153. }
  154. private DataTable CreateDataTable()
  155. {
  156. DataTable dt = new DataTable();
  157. DataColumn linkPage = new DataColumn("linkPage", Type.GetType("System.String"));
  158. DataColumn menuName = new DataColumn("menuName", Type.GetType("System.String"));
  159. DataColumn menuGroup = new DataColumn("menuGroup", Type.GetType("System.String"));
  160. dt.Columns.Add(linkPage);
  161. dt.Columns.Add(menuName);
  162. dt.Columns.Add(menuGroup);
  163. return dt;
  164. }
  165. private string GetMenuGroup(string mainMenuGroup)
  166. {
  167. string menuGroups = "";
  168. if (mainMenuGroup == "Administration")
  169. {
  170. menuGroups = "'User Management', 'Mobile Menu', 'Application Settings', 'Application Log', 'Administration', 'Customer Management' ,'Online Customer','Deposit API','Registration' ";
  171. }
  172. else if (mainMenuGroup == "System Security")
  173. {
  174. menuGroups = "'Notifications'";
  175. }
  176. else if (mainMenuGroup == "Transaction")
  177. {
  178. menuGroups = "'Transaction'";
  179. }
  180. else if (mainMenuGroup == "Remittance")
  181. {
  182. //menuGroups = "'Credit Risk Management', 'Reports-Master','Reports','Service Charge & Commission', 'Customer Reports' ,'Utilities', 'Remittance', 'Compliance','Watchlist Management' , 'Risk Based Assessement'";
  183. menuGroups = "'Credit Risk Management', 'Reports-Master','Reports','Service Charge & Commission', 'Customer Reports' ,'Utilities', 'Remittance', 'Risk Based Assessement'";
  184. }
  185. else if (mainMenuGroup == "Compliance")
  186. {
  187. menuGroups = "'Compliance', 'Watchlist Management', 'Report'"; //
  188. }
  189. else if (mainMenuGroup == "Account")
  190. {
  191. menuGroups = "'BILL & VOUCHER', 'Remittance Reports', 'ACCOUNT SETTING', 'ACCOUNT REPORT', 'Accounts', 'Cash Report' , 'ACCOUNT REPORT - OLD'";
  192. }
  193. else if (mainMenuGroup == "EXCHANGE SETUP")
  194. {
  195. menuGroups = "'Credit Risk', 'Service Charge/Commission','EXCHANGE SETUP','Exchange Rate', 'Cash And Vault','ThirdParty Setups'";
  196. }
  197. else if (mainMenuGroup == "MOBILE")
  198. {
  199. menuGroups = "'Mobile Setup', 'Mobile Reports','Mobile Notification','Mobile Operations'";
  200. }
  201. else
  202. {
  203. menuGroups = "'" + mainMenuGroup + "'";
  204. }
  205. return menuGroups;
  206. }
  207. protected string GetMainMenuGroup(string menuGroupName)
  208. {
  209. string mainMenuGroupName = "";
  210. if (menuGroupName == "User Management" || menuGroupName == "Application Settings" || menuGroupName == "Application Log" || menuGroupName == "Administration" || menuGroupName == "Customer Management" || menuGroupName == " Online Customer" || menuGroupName == "Registration" || menuGroupName == "Mobile Menu")
  211. {
  212. mainMenuGroupName = "Administration";
  213. }
  214. else if (menuGroupName == "Notifications")
  215. {
  216. mainMenuGroupName = "System Security";
  217. }
  218. else if (menuGroupName == "Credit Risk Management" || menuGroupName == "Customer Reports" || menuGroupName == "Reports-Master" || menuGroupName == "Reports" || menuGroupName == "Service Charge & Commission" || menuGroupName == "Utilities" || menuGroupName == "Remittance" || menuGroupName == "Risk Based Assessement")
  219. {
  220. mainMenuGroupName = "Remittance";
  221. }
  222. else if (menuGroupName == "BILL & VOUCHER" || menuGroupName == "Remittance Reports" || menuGroupName == "ACCOUNT SETTING" || menuGroupName == "ACCOUNT REPORT" || menuGroupName == "Accounts" || menuGroupName == "OFAC Management" || menuGroupName == "Cash Report" || menuGroupName == "Account Report - OLD")
  223. {
  224. mainMenuGroupName = "Account";
  225. }
  226. else if (menuGroupName == "Credit Risk" || menuGroupName == "Service Charge/Commission" || menuGroupName == "Exchange Rate" || menuGroupName == "Cash And Vault" || menuGroupName == "ThirdParty Setups")
  227. {
  228. mainMenuGroupName = "EXCHANGE SETUP";
  229. }
  230. else if (menuGroupName == "Compliance" || menuGroupName == "Watchlist Management" || menuGroupName == "Report") //
  231. {
  232. mainMenuGroupName = "Compliance";
  233. }
  234. //else if (menuGroupName == "ThirdParty Setups")
  235. //{
  236. // mainMenuGroupName = "Exchange Rate";
  237. //}
  238. else if (menuGroupName == "Transaction")
  239. {
  240. mainMenuGroupName = "Transaction";
  241. }
  242. else if (menuGroupName == "Mobile Notification" || menuGroupName == "Mobile Setup" || menuGroupName == "Mobile Reports" || menuGroupName == "Mobile Operations")
  243. {
  244. mainMenuGroupName = "MOBILE";
  245. }
  246. else
  247. {
  248. mainMenuGroupName = menuGroupName;
  249. }
  250. return mainMenuGroupName;
  251. }
  252. }
  253. }