|
|
using Swift.web.Library; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
namespace Swift.web.DashboardV2 {
public partial class Dashboard : Page { private SwiftLibrary sl = new SwiftLibrary(); private RemittanceLibrary _remit = new RemittanceLibrary();
protected void Page_Load(object sender, EventArgs e) { sl.CheckSession(); if (!IsPostBack) { PopulateMenu(); PopulateNotification();
// Task.WaitAll(Task.Run(() => PopulateNotification()));
GetStatic.PrintMessage(Page);
} }
public async Task PopulateNotificationAsync() { await Task.Run(() => PopulateNotification()); }
protected string getUser() { return GetStatic.GetUser(); }
protected void PopulateNotification() { string sql = "EXEC proc_notification @user = '" + getUser() + "'"; DataTable dt = _remit.ExecuteDataTable(sql); if (null == dt) { return; } if (dt.Rows.Count == 0) { return; } StringBuilder sb = new StringBuilder(); int counter = 0;
foreach (DataRow item in dt.Rows) { counter += Convert.ToInt16(item["count"].ToString()); sb.AppendLine("<li class=\"clearfix\">"); sb.AppendLine("<a href=\"" + item["link"].ToString() + "\" target=\"mainFrame\">"); sb.AppendLine("<span class=\"pull-left\">"); sb.AppendLine("<i class=\"fa fa-bell\" style='color:#0e96ec'></i>"); sb.AppendLine("</span>"); sb.AppendLine("<span class=\"media-body\">"); sb.AppendLine(item["msg"].ToString()); sb.AppendLine("<em>" + item["msg1"].ToString() + "</em>"); sb.AppendLine("</span>"); sb.AppendLine("</a></li>"); } count.Text = counter.ToString(); notification.InnerHtml = "<li class=\"notify-title\">" + counter.ToString() + " New Notifications</li>" + sb.ToString(); }
protected void PopulateMenu() { StringBuilder sb = new StringBuilder(); sb = (StringBuilder)Session[getUser() + "Menu"]; if (string.IsNullOrEmpty(sb.ToString()) || string.IsNullOrWhiteSpace(sb.ToString())) { sb = new StringBuilder(); string sql = "exec menu_proc @flag = 'admin', @user = '" + getUser() + "'"; DataSet ds = _remit.ExecuteDataset(sql); DataTable menuGroup = ds.Tables[0];
sb.AppendLine("<div id=\"navbar-main\" class=\"navbar-collapse collapse\">"); sb.AppendLine("<ul class=\"nav navbar-nav\">"); sb.AppendLine("<li class=\"active\"><a href=\"/DashboardV2/Dashboard.aspx\">Dashboard</a></li>"); if (ds.Tables[0].Rows.Count == 0 || ds.Tables[1].Rows.Count == 0) { sb.AppendLine("</li></ul>"); sb.AppendLine("</div>"); menu.InnerHtml = sb.ToString(); return; }
for (int i = 0; i <= menuGroup.Rows.Count; i++) { if (menuGroup.Rows.Count != 0) { string menuGroupName = menuGroup.Rows[0]["menuGroup"].ToString(); DataRow[] rows = ds.Tables[1].Select("menuGroup IN (" + GetMenuGroup(GetMainMenuGroup(menuGroupName)) + ")");
sb.AppendLine(GetMenuContents(menuGroupName, rows)); DataRow[] rowsToRemove = menuGroup.Select("menuGroup IN (" + GetMenuGroup(GetMainMenuGroup(menuGroupName)) + ")"); foreach (DataRow row in rowsToRemove) { menuGroup.Rows.Remove(row); } } i = 0; } sb.AppendLine("</li></ul>"); sb.AppendLine("</div>"); Session[getUser() + "Menu"] = sb; } menu.InnerHtml = sb.ToString(); }
private string GetMenuContents(string menuGroup, DataRow[] dr) { StringBuilder sb = new StringBuilder(""); DataTable dt = CreateDataTable();
foreach (DataRow row in dr) { dt.ImportRow(row); } sb.AppendLine("<li class=\"dropdown\">"); 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>"); sb.AppendLine("<ul class=\"dropdown-menu\">"); for (int i = 0; i <= dt.Rows.Count; i++) { if (dt.Rows.Count != 0) { DataRow[] menuList = dt.Select("menuGroup = ('" + dt.Rows[0]["menuGroup"].ToString() + "')"); string subMainMenu = menuList[0]["menuGroup"].ToString();
if (menuGroup == "Notifications" || subMainMenu == "User Management" || subMainMenu == "Other Services" || subMainMenu == "Transaction" || menuGroup == "Rule Setup") { foreach (DataRow row in menuList) { sb.AppendLine("<li><a tabindex=\"-1\" href=\"" + row["linkPage"].ToString() + "\" target=\"mainFrame\">" + row["menuName"].ToString() + "</a></li>"); } //sb.AppendLine("</ul></li>");
} else { sb.AppendLine("<li class=\"dropdown-submenu\"><a tabindex=\"-1\" href=\"#\">" + subMainMenu + "</a>"); sb.AppendLine("<ul class=\"dropdown-menu\">"); foreach (DataRow row in menuList) { sb.AppendLine("<li class=\"submenu\"><a tabindex=\"-1\" href=\"" + row["linkPage"].ToString() + "\" target=\"mainFrame\">" + row["menuName"].ToString() + "</a></li>"); } sb.AppendLine("</ul></li>"); }
DataRow[] rows = dt.Select("menuGroup = ('" + dt.Rows[0]["menuGroup"].ToString() + "')"); foreach (DataRow row in rows) { dt.Rows.Remove(row); } } i = 0; } sb.AppendLine("</ul></li>"); return sb.ToString(); }
private DataTable CreateDataTable() { DataTable dt = new DataTable(); DataColumn linkPage = new DataColumn("linkPage", Type.GetType("System.String")); DataColumn menuName = new DataColumn("menuName", Type.GetType("System.String")); DataColumn menuGroup = new DataColumn("menuGroup", Type.GetType("System.String")); dt.Columns.Add(linkPage); dt.Columns.Add(menuName); dt.Columns.Add(menuGroup);
return dt; }
private string GetMenuGroup(string mainMenuGroup) { string menuGroups = ""; if (mainMenuGroup == "Administration") { menuGroups = "'User Management', 'Mobile Menu', 'Application Settings', 'Application Log', 'Administration', 'Customer Management' ,'Online Customer','Deposit API','Registration' "; } else if (mainMenuGroup == "System Security") { menuGroups = "'Notifications'"; } else if (mainMenuGroup == "Transaction") { menuGroups = "'Transaction'"; } else if (mainMenuGroup == "Remittance") { //menuGroups = "'Credit Risk Management', 'Reports-Master','Reports','Service Charge & Commission', 'Customer Reports' ,'Utilities', 'Remittance', 'Compliance','Watchlist Management' , 'Risk Based Assessement'";
menuGroups = "'Credit Risk Management', 'Reports-Master','Reports','Service Charge & Commission', 'Customer Reports' ,'Utilities', 'Remittance', 'Risk Based Assessement'"; } else if (mainMenuGroup == "Compliance") { menuGroups = "'Compliance', 'Watchlist Management', 'Report'"; //
} else if (mainMenuGroup == "Account") { menuGroups = "'BILL & VOUCHER', 'Remittance Reports', 'ACCOUNT SETTING', 'ACCOUNT REPORT', 'Accounts', 'Cash Report' , 'ACCOUNT REPORT - OLD'"; } else if (mainMenuGroup == "EXCHANGE SETUP") { menuGroups = "'Credit Risk', 'Service Charge/Commission','EXCHANGE SETUP','Exchange Rate', 'Cash And Vault','ThirdParty Setups'"; } else if (mainMenuGroup == "MOBILE") { menuGroups = "'Mobile Setup', 'Mobile Reports','Mobile Notification','Mobile Operations'"; } else { menuGroups = "'" + mainMenuGroup + "'"; } return menuGroups; }
protected string GetMainMenuGroup(string menuGroupName) { string mainMenuGroupName = ""; if (menuGroupName == "User Management" || menuGroupName == "Application Settings" || menuGroupName == "Application Log" || menuGroupName == "Administration" || menuGroupName == "Customer Management" || menuGroupName == " Online Customer" || menuGroupName == "Registration" || menuGroupName == "Mobile Menu") { mainMenuGroupName = "Administration"; } else if (menuGroupName == "Notifications") { mainMenuGroupName = "System Security"; } 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") { mainMenuGroupName = "Remittance"; } 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") { mainMenuGroupName = "Account"; } else if (menuGroupName == "Credit Risk" || menuGroupName == "Service Charge/Commission" || menuGroupName == "Exchange Rate" || menuGroupName == "Cash And Vault" || menuGroupName == "ThirdParty Setups") { mainMenuGroupName = "EXCHANGE SETUP"; } else if (menuGroupName == "Compliance" || menuGroupName == "Watchlist Management" || menuGroupName == "Report") //
{ mainMenuGroupName = "Compliance"; } //else if (menuGroupName == "ThirdParty Setups")
//{
// mainMenuGroupName = "Exchange Rate";
//}
else if (menuGroupName == "Transaction") { mainMenuGroupName = "Transaction"; } else if (menuGroupName == "Mobile Notification" || menuGroupName == "Mobile Setup" || menuGroupName == "Mobile Reports" || menuGroupName == "Mobile Operations") { mainMenuGroupName = "MOBILE"; } else { mainMenuGroupName = menuGroupName; } return mainMenuGroupName; } } }
|