public static bool CheckApp(out string msg, string appid = "") { msg = ""; Guid userID = RoadFlow.Platform.Users.CurrentUserID; if (userID.IsEmptyGuid()) { msg = "<script>top.login();</script>"; return(false); } appid = (appid.IsNullOrEmpty() ? HttpContext.Current.Request["appid"] : appid); Guid appGuid; if (!appid.IsGuid(out appGuid)) { return(false); } List <RoadFlow.Data.Model.MenuUser> all = new RoadFlow.Platform.MenuUser().GetAll(); string source; string @params; bool flag = new RoadFlow.Platform.Menu().HasUse(appGuid, userID, all, out source, out @params); if (!flag) { return(false); } string url = HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"].ToString(); if (!url.IsNullOrEmpty()) { url = url.TrimStart('/'); if (!url.IsNullOrEmpty()) { List <RoadFlow.Data.Model.AppLibrarySubPages> list = new RoadFlow.Platform.AppLibrarySubPages().GetAll().FindAll((RoadFlow.Data.Model.AppLibrarySubPages p) => p.Address.Contains(url, StringComparison.CurrentCultureIgnoreCase)); if (list.Count > 0) { foreach (RoadFlow.Data.Model.AppLibrarySubPages item in list) { if (all.Find(delegate(RoadFlow.Data.Model.MenuUser p) { if (p.MenuID == appGuid && p.SubPageID == item.ID) { return(p.Users.Contains(userID.ToString(), StringComparison.CurrentCultureIgnoreCase)); } return(false); }) != null) { return(true); } } return(false); } } } return(flag); }
public RedirectResult SubPageDelete() { string text = base.Request.Form["subpagesbox"] ?? ""; RoadFlow.Platform.AppLibrarySubPages appLibrarySubPages = new RoadFlow.Platform.AppLibrarySubPages(); RoadFlow.Platform.AppLibraryButtons1 appLibraryButtons = new RoadFlow.Platform.AppLibraryButtons1(); using (TransactionScope transactionScope = new TransactionScope()) { string[] array = text.Split(','); foreach (string str in array) { if (str.IsGuid()) { appLibrarySubPages.Delete(str.ToGuid()); appLibraryButtons.DeleteByAppID(str.ToGuid()); } } RoadFlow.Platform.Log.Add("删除了子页面", text, RoadFlow.Platform.Log.Types.菜单权限); transactionScope.Complete(); } appLibrarySubPages.ClearCache(); appLibraryButtons.ClearCache(); return(Redirect("SubPages" + base.Request.Url.Query)); }
public ActionResult SubPageEdit(FormCollection collection) { RoadFlow.Platform.AppLibrarySubPages appLibrarySubPages = new RoadFlow.Platform.AppLibrarySubPages(); RoadFlow.Data.Model.AppLibrarySubPages appLibrarySubPages2 = null; string str = base.Request.QueryString["subid"]; if (str.IsGuid()) { appLibrarySubPages2 = appLibrarySubPages.Get(str.ToGuid()); } if (collection != null) { string str2 = base.Request.Form["Title"]; string str3 = base.Request.Form["Address"]; bool flag = false; if (appLibrarySubPages2 == null) { appLibrarySubPages2 = new RoadFlow.Data.Model.AppLibrarySubPages(); flag = true; appLibrarySubPages2.ID = Guid.NewGuid(); appLibrarySubPages2.AppLibraryID = base.Request.QueryString["id"].ToGuid(); } appLibrarySubPages2.Name = str2.Trim1(); appLibrarySubPages2.Address = str3.Trim1(); using (TransactionScope transactionScope = new TransactionScope()) { if (flag) { appLibrarySubPages.Add(appLibrarySubPages2); RoadFlow.Platform.Log.Add("添加了子页面", appLibrarySubPages2.Serialize(), RoadFlow.Platform.Log.Types.菜单权限); base.ViewBag.Script = "alert('添加成功!');window.location='SubPages" + base.Request.Url.Query + "';"; } else { appLibrarySubPages.Update(appLibrarySubPages2); RoadFlow.Platform.Log.Add("修改了子页面", appLibrarySubPages2.Serialize(), RoadFlow.Platform.Log.Types.菜单权限); base.ViewBag.Script = "alert('保存成功!');window.location='SubPages" + base.Request.Url.Query + "';"; } RoadFlow.Platform.AppLibraryButtons1 appLibraryButtons = new RoadFlow.Platform.AppLibraryButtons1(); string obj = base.Request.Form["buttonindex"] ?? ""; List <RoadFlow.Data.Model.AppLibraryButtons1> allByAppID = appLibraryButtons.GetAllByAppID(appLibrarySubPages2.ID); List <RoadFlow.Data.Model.AppLibraryButtons1> list = new List <RoadFlow.Data.Model.AppLibraryButtons1>(); string[] array = obj.Split(','); foreach (string index in array) { string str4 = base.Request.Form["button_" + index]; string str5 = base.Request.Form["buttonname_" + index]; string text = base.Request.Form["buttonevents_" + index]; string ico = base.Request.Form["buttonico_" + index]; string str6 = base.Request.Form["showtype_" + index]; string str7 = base.Request.Form["buttonsort_" + index]; if (!str5.IsNullOrEmpty() && !text.IsNullOrEmpty()) { RoadFlow.Data.Model.AppLibraryButtons1 appLibraryButtons2 = allByAppID.Find((RoadFlow.Data.Model.AppLibraryButtons1 p) => p.ID == index.ToGuid()); bool flag2 = false; if (appLibraryButtons2 == null) { flag2 = true; appLibraryButtons2 = new RoadFlow.Data.Model.AppLibraryButtons1(); appLibraryButtons2.ID = Guid.NewGuid(); } else { list.Add(appLibraryButtons2); } appLibraryButtons2.AppLibraryID = appLibrarySubPages2.ID; if (str4.IsGuid()) { appLibraryButtons2.ButtonID = str4.ToGuid(); } appLibraryButtons2.Events = text; appLibraryButtons2.Ico = ico; appLibraryButtons2.Name = str5.Trim1(); appLibraryButtons2.Sort = str7.ToInt(0); appLibraryButtons2.ShowType = str6.ToInt(0); appLibraryButtons2.Type = 0; if (flag2) { appLibraryButtons.Add(appLibraryButtons2); } else { appLibraryButtons.Update(appLibraryButtons2); } } } foreach (RoadFlow.Data.Model.AppLibraryButtons1 item in allByAppID) { if (list.Find((RoadFlow.Data.Model.AppLibraryButtons1 p) => p.ID == item.ID) == null) { appLibraryButtons.Delete(item.ID); } } transactionScope.Complete(); appLibraryButtons.ClearCache(); appLibrarySubPages.ClearCache(); } } if (appLibrarySubPages2 == null) { appLibrarySubPages2 = new RoadFlow.Data.Model.AppLibrarySubPages(); appLibrarySubPages2.ID = Guid.Empty; appLibrarySubPages2.AppLibraryID = base.Request.QueryString["id"].ToGuid(); } return(View(appLibrarySubPages2)); }