public static System.Collections.Generic.Dictionary <int, string> getButtonsHtml(string menuID = "", string subpageID = "", string programID = "") { Guid menuID1; if (menuID.IsNullOrEmpty() || !menuID.IsGuid(out menuID1)) { menuID1 = HttpContext.Current.Request.QueryString["appid"].ToGuid(); } Guid subpageID1; if (!subpageID.IsGuid(out subpageID1)) { subpageID1 = HttpContext.Current.Request.QueryString["subpageid"].ToGuid(); } System.Collections.Generic.Dictionary <int, string> dictionary = new System.Collections.Generic.Dictionary <int, string>(); dictionary.Add(0, ""); dictionary.Add(1, ""); dictionary.Add(2, ""); string str1 = HttpContext.Current.Request.QueryString["applibaryid"]; List <Guid> guidList = new List <Guid>(); if (str1.IsGuid()) { foreach (RoadFlow.Data.Model.AppLibraryButtons1 appLibraryButtons1 in new AppLibraryButtons1().GetAllByAppID(str1.ToGuid()).FindAll((Predicate <RoadFlow.Data.Model.AppLibraryButtons1>)(p => p.IsValidateShow == 1))) { guidList.Add(appLibraryButtons1.ID); } } else { foreach (RoadFlow.Data.Model.MenuUser menuUser in new MenuUser().GetAll(true).FindAll((Predicate <RoadFlow.Data.Model.MenuUser>)(p => { if (p.MenuID == menuID1 && p.SubPageID == subpageID1) { return(p.Users.Contains(Users.CurrentUserID.ToString(), StringComparison.CurrentCultureIgnoreCase)); } return(false); }))) { string buttons = menuUser.Buttons; char[] chArray = new char[1] { ',' }; foreach (string str2 in buttons.Split(chArray)) { Guid test; if (str2.IsGuid(out test) && !guidList.Contains(test)) { guidList.Add(test); } } } } List <RoadFlow.Data.Model.AppLibraryButtons1> source = new List <RoadFlow.Data.Model.AppLibraryButtons1>(); RoadFlow.Data.Model.AppLibrary byCode = new AppLibrary().GetByCode(programID, true); if (byCode != null) { source.AddRange((IEnumerable <RoadFlow.Data.Model.AppLibraryButtons1>) new AppLibraryButtons1().GetAllByAppID(byCode.ID).FindAll((Predicate <RoadFlow.Data.Model.AppLibraryButtons1>)(p => p.IsValidateShow == 0))); } if (guidList.Count == 0 && source.Count == 0) { return(dictionary); } StringBuilder stringBuilder1 = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); AppLibraryButtons1 appLibraryButtons1_1 = new AppLibraryButtons1(); foreach (Guid id in guidList) { RoadFlow.Data.Model.AppLibraryButtons1 appLibraryButtons1_2 = appLibraryButtons1_1.Get(id, true); if (appLibraryButtons1_2 != null && appLibraryButtons1_2.IsValidateShow != 0) { source.Add(appLibraryButtons1_2); } } foreach (RoadFlow.Data.Model.AppLibraryButtons1 appLibraryButtons1_2 in (IEnumerable <RoadFlow.Data.Model.AppLibraryButtons1>)source.OrderBy <RoadFlow.Data.Model.AppLibraryButtons1, int>((Func <RoadFlow.Data.Model.AppLibraryButtons1, int>)(p => p.Sort))) { string userID = Users.CurrentUserID.ToString(); if (appLibraryButtons1_2.ShowType == 0) { string str2 = "fun_" + Guid.NewGuid().ToString("N"); stringBuilder1.Append("<a href=\"javascript:void(0);\" onclick=\"" + str2 + "();return false;\"><span style=\"" + (appLibraryButtons1_2.Ico.IsNullOrEmpty() || appLibraryButtons1_2.Ico.IsFontIco() ? "padding-left:0px;" : "background-image:url(" + Config.BaseUrl + appLibraryButtons1_2.Ico + ");") + "\">" + (appLibraryButtons1_2.Ico.IsNullOrEmpty() || !appLibraryButtons1_2.Ico.IsFontIco() ? "" : "<i class='fa " + appLibraryButtons1_2.Ico + "' style='font-size:14px;vertical-align:middle;margin-right:3px;'></i>") + appLibraryButtons1_2.Name + "</span></a>"); stringBuilder1.Append("<script type=\"text/javascript\">function " + str2 + "(){" + appLibraryButtons1_2.Events.FilterWildcard(userID) + "}</script>"); } else if (appLibraryButtons1_2.ShowType == 1) { string str2 = "fun_" + Guid.NewGuid().ToString("N"); stringBuilder2.Append("<button type=\"button\" " + (appLibraryButtons1_2.Ico.IsNullOrEmpty() ? "style=\"margin-left:6px;\"" : "style=\"margin-left:6px;" + (appLibraryButtons1_2.Ico.IsNullOrEmpty() || appLibraryButtons1_2.Ico.IsFontIco() ? "" : "background-image:url(" + Config.BaseUrl + appLibraryButtons1_2.Ico + ");background-repeat:no-repeat;background-position-y:center;background-position-x:8px;padding-left:28px;") + "\"") + " onclick=\"" + str2 + "();return false;\" class=\"mybutton\">"); if (!appLibraryButtons1_2.Ico.IsNullOrEmpty() && appLibraryButtons1_2.Ico.IsFontIco()) { stringBuilder2.Append("<i class=\"fa " + appLibraryButtons1_2.Ico + "\" style=\"font-size:14px;vertical-align:middle;margin-right:3px;\"></i>"); } stringBuilder2.Append("<span style=\"vertical-align:middle;\">" + appLibraryButtons1_2.Name + "</span>"); stringBuilder2.Append("</button>"); stringBuilder2.Append("<script type=\"text/javascript\">function " + str2 + "(){" + appLibraryButtons1_2.Events.FilterWildcard(userID) + "}</script>"); } else if (appLibraryButtons1_2.ShowType == 2) { string str2 = "fun_" + Guid.NewGuid().ToString("N"); stringBuilder3.Append("<a href=\"javascript:void(0);\" onclick=\"" + appLibraryButtons1_2.Events + ";return false;\" " + (appLibraryButtons1_2.Ico.IsNullOrEmpty() ? "style=\"margin-left:0px;\"" : "style=\"margin-left:0px;" + (!appLibraryButtons1_2.Ico.IsFontIco() ? "padding-left:26px;background-image:url(" + Config.BaseUrl + appLibraryButtons1_2.Ico + ");background-repeat:no-repeat;background-position-y:center;background-position-x:8px;" : "") + "\"") + ">" + (appLibraryButtons1_2.Ico.IsNullOrEmpty() || !appLibraryButtons1_2.Ico.IsFontIco() ? "" : "<i class='fa " + appLibraryButtons1_2.Ico + "' style='font-size:14px;vertical-align:middle;margin-right:3px;padding-left:10px;'></i>") + appLibraryButtons1_2.Name + "</a>"); } } dictionary[0] = stringBuilder1.Length > 0 ? "<div class=\"toolbar\" style=\"margin-top:0; border-top:none 0; position:fixed; top:0; left:0; right:0; margin-left:auto; z-index:999; width:100%; margin-right:auto;\">" + stringBuilder1.ToString() + "</div>" : ""; dictionary[1] = stringBuilder2.ToString(); dictionary[2] = stringBuilder3.ToString(); return(dictionary); }
public static Dictionary <int, string> getButtonsHtml(string menuID = "", string subpageID = "", string programID = "") { Guid menuID2; if (menuID.IsNullOrEmpty() || !menuID.IsGuid(out menuID2)) { menuID2 = HttpContext.Current.Request.QueryString["appid"].ToGuid(); } Guid subpageID2; if (!subpageID.IsGuid(out subpageID2)) { subpageID2 = HttpContext.Current.Request.QueryString["subpageid"].ToGuid(); } Dictionary <int, string> dictionary = new Dictionary <int, string>(); dictionary.Add(0, ""); dictionary.Add(1, ""); dictionary.Add(2, ""); string str = HttpContext.Current.Request.QueryString["applibaryid"]; List <Guid> list = new List <Guid>(); if (str.IsGuid()) { foreach (RoadFlow.Data.Model.AppLibraryButtons1 item in new AppLibraryButtons1().GetAllByAppID(str.ToGuid()).FindAll((RoadFlow.Data.Model.AppLibraryButtons1 p) => p.IsValidateShow == 1)) { list.Add(item.ID); } } else { foreach (RoadFlow.Data.Model.MenuUser item2 in new MenuUser().GetAll().FindAll(delegate(RoadFlow.Data.Model.MenuUser p) { if (p.MenuID == menuID2 && p.SubPageID == subpageID2) { return(p.Users.Contains(Users.CurrentUserID.ToString(), StringComparison.CurrentCultureIgnoreCase)); } return(false); })) { string[] array = item2.Buttons.Split(','); for (int i = 0; i < array.Length; i++) { Guid test; if (array[i].IsGuid(out test) && !list.Contains(test)) { list.Add(test); } } } } List <RoadFlow.Data.Model.AppLibraryButtons1> list2 = new List <RoadFlow.Data.Model.AppLibraryButtons1>(); RoadFlow.Data.Model.AppLibrary byCode = new AppLibrary().GetByCode(programID); if (byCode != null) { list2.AddRange(new AppLibraryButtons1().GetAllByAppID(byCode.ID).FindAll((RoadFlow.Data.Model.AppLibraryButtons1 p) => p.IsValidateShow == 0)); } if (list.Count == 0 && list2.Count == 0) { return(dictionary); } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); AppLibraryButtons1 appLibraryButtons = new AppLibraryButtons1(); foreach (Guid item3 in list) { RoadFlow.Data.Model.AppLibraryButtons1 appLibraryButtons2 = appLibraryButtons.Get(item3, true); if (appLibraryButtons2 != null && appLibraryButtons2.IsValidateShow != 0) { list2.Add(appLibraryButtons2); } } foreach (RoadFlow.Data.Model.AppLibraryButtons1 item4 in from p in list2 orderby p.Sort select p) { string userID = Users.CurrentUserID.ToString(); if (item4.ShowType == 0) { string text = "fun_" + Guid.NewGuid().ToString("N"); stringBuilder.Append("<a href=\"javascript:void(0);\" onclick=\"" + text + "();return false;\"><span style=\"" + ((!item4.Ico.IsNullOrEmpty() && !item4.Ico.IsFontIco()) ? ("background-image:url(" + Config.BaseUrl + item4.Ico + ");") : "padding-left:0px;") + "\">" + ((!item4.Ico.IsNullOrEmpty() && item4.Ico.IsFontIco()) ? ("<i class='fa " + item4.Ico + "' style='font-size:14px;vertical-align:middle;margin-right:3px;'></i>") : "") + item4.Name + "</span></a>"); stringBuilder.Append("<script type=\"text/javascript\">function " + text + "(){" + item4.Events.FilterWildcard(userID) + "}</script>"); } else if (item4.ShowType == 1) { string text2 = "fun_" + Guid.NewGuid().ToString("N"); stringBuilder2.Append("<button type=\"button\" " + (item4.Ico.IsNullOrEmpty() ? "style=\"margin-left:6px;\"" : ("style=\"margin-left:6px;" + ((!item4.Ico.IsNullOrEmpty() && !item4.Ico.IsFontIco()) ? ("background-image:url(" + Config.BaseUrl + item4.Ico + ");background-repeat:no-repeat;background-position-y:center;background-position-x:8px;padding-left:28px;") : "") + "\"")) + " onclick=\"" + text2 + "();return false;\" class=\"mybutton\">"); if (!item4.Ico.IsNullOrEmpty() && item4.Ico.IsFontIco()) { stringBuilder2.Append("<i class=\"fa " + item4.Ico + "\" style=\"font-size:14px;vertical-align:middle;margin-right:3px;\"></i>"); } stringBuilder2.Append("<span style=\"vertical-align:middle;\">" + item4.Name + "</span>"); stringBuilder2.Append("</button>"); stringBuilder2.Append("<script type=\"text/javascript\">function " + text2 + "(){" + item4.Events.FilterWildcard(userID) + "}</script>"); } else if (item4.ShowType == 2) { string text3 = "fun_" + Guid.NewGuid().ToString("N"); stringBuilder3.Append("<a href=\"javascript:void(0);\" onclick=\"" + item4.Events + ";return false;\" " + (item4.Ico.IsNullOrEmpty() ? "style=\"margin-left:0px;\"" : ("style=\"margin-left:0px;" + ((!item4.Ico.IsFontIco()) ? ("padding-left:26px;background-image:url(" + Config.BaseUrl + item4.Ico + ");background-repeat:no-repeat;background-position-y:center;background-position-x:8px;") : "") + "\"")) + ">" + ((!item4.Ico.IsNullOrEmpty() && item4.Ico.IsFontIco()) ? ("<i class='fa " + item4.Ico + "' style='font-size:14px;vertical-align:middle;margin-right:3px;padding-left:10px;'></i>") : "") + item4.Name + "</a>"); } } dictionary[0] = ((stringBuilder.Length > 0) ? ("<div class=\"toolbar\" style=\"margin-top:0; border-top:none 0; position:fixed; top:0; left:0; right:0; margin-left:auto; z-index:999; width:100%; margin-right:auto;\">" + stringBuilder.ToString() + "</div>") : ""); dictionary[1] = stringBuilder2.ToString(); dictionary[2] = stringBuilder3.ToString(); return(dictionary); }