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.

260 lines
12 KiB

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