protected void SaveButton_Click(object sender, EventArgs e) { int typeID = OwnerType == "role" ? Constants.OwnerRole : Constants.OwnerAccount; string[] adds = null; //判断AddsTextBox.Text是否为空,其主要是由于前台JS所产生,为空则消除空; if (AddsTextBox.Text != "null" && AddsTextBox.Text != null && AddsTextBox.Text != string.Empty) { adds = AddsTextBox.Text.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); } if (adds != null && adds.Length > 0) { for (int i = 0; i < adds.Length; i++) { adds[i] = We7Helper.FormatToGUID(adds[i]); } } AccountHelper.DeletePermission(typeID, OwnerID, ObjectID); AccountHelper.AddPermission(typeID, OwnerID, ObjectID, adds); if (ApplyPermissionToSubChannelsCheckBox.Checked == true && ApplyPermissionToSubChannelsCheckBox.Visible) { List <Channel> subChannels = ChannelHelper.GetSubChannelList(ObjectID, true); foreach (Channel ch in subChannels) { AccountHelper.DeletePermission(typeID, OwnerID, ch.ID); AccountHelper.AddPermission(typeID, OwnerID, ch.ID, adds); } } if (OwnerType != "role") { Account act = AccountHelper.GetAccount(OwnerID, new string[] { "LoginName", "Email" }); if (act != null) { string userName = String.Format("{0}({1})", act.LoginName, act.Email); string content = string.Format("给用户“{0}设置权限”", userName); AddLog("权限设置", content); } } else { Role role = AccountHelper.GetRole(OwnerID); if (role != null) { string content = string.Format("给角色“{0}设置权限”", role.Name); AddLog("权限设置", content); } } Messages.ShowMessage("权限设置成功!"); Initialize(); }
private string GetChannelID(HttpContext context) { if (context.Request["node"] != null && context.Request["node"].ToString() != "root") { return(We7Helper.FormatToGUID(context.Request["node"])); } else { return(string.Empty); } }
/// <summary> /// 从Url中取得ID号 /// </summary> /// <returns></returns> public static string GetIDFromUrl() { string path = HttpContext.Current.Request.RawUrl; //取得Url的原始地址 GeneralConfigInfo si = GeneralConfigs.GetConfig(); if (si == null) { return(""); } string ext = si.UrlFormat; if (ext == null || ext.Length == 0) { ext = "html"; } if (path.LastIndexOf("?") > -1) { if (path.ToLower().IndexOf("article=") > -1) { path = path.Substring(path.ToLower().IndexOf("article=") + 8); } else { path = path.Remove(path.LastIndexOf("?")); } } string mathstr = @"/(\w|\s|(-)|(_))+\." + ext + "$"; if (path.ToLower().EndsWith("default." + ext)) { path = path.Remove(path.Length - 12); } if (path.ToLower().EndsWith("index." + ext)) { path = path.Remove(path.Length - 10); } if (Regex.IsMatch(path, mathstr)) { int lastSlash = path.LastIndexOf("/"); if (lastSlash > -1) { path = path.Remove(0, lastSlash + 1); } int lastDot = path.LastIndexOf("."); if (lastDot > -1) { path = path.Remove(lastDot, path.Length - lastDot); } if (We7Helper.IsGUID(We7Helper.FormatToGUID(path))) { path = We7Helper.FormatToGUID(path); } else { int lastSub = path.LastIndexOf("-"); if (lastSub > -1) { path = path.Remove(0, lastSub + 1); } if (!We7Helper.IsNumber(path)) { path = ""; } else { path = HelperFactory.Instance.GetHelper <ArticleHelper>().GetArticleIDBySN(path); } } return(path); } else { return(string.Empty); } }