/// <summary> /// /// </summary> /// <param name="propertie"></param> /// <param name="name"></param> /// <returns></returns> public static WebSiteControllerRule GetRule(string propertie, string name) { WebSiteControllerRule _rule = null; int code = 100; bool NaN = int.TryParse(name, out code); if (!NaN || code > 299) { WebSiteControllerRulesCollection rules = GetFromConfigDB().rules; foreach (WebSiteControllerRule rule in rules) { try { if (rule.Properties.ContainsValue(name)) { if (rule.Properties[propertie].Equals(name)) { _rule = rule; break; } } } catch (Exception ex) { ex.ToString(); } } } return(_rule); //return GetFromConfigDB().rules[name]; }
/* * /// <summary> * /// Initializes a new instance of the <see cref="WebSiteControllerConfig"/> class. * /// </summary> * /// <param name="persisted"></param> * public WebSiteControllerConfig(SPWebApplication webApp)// * : base(OBJECTNAME, webApp, ID) * { * try * { * this.rules = new WebSiteControllerRulesCollection(this); * this.modules = new WebSiteControllerModulesCollection(this); * } * catch (Exception ex) * { * ex.ToString(); * } * } */ public WebSiteControllerConfig(SPPersistedObject persisted, Guid guid) : base(OBJECTNAME, persisted, guid) { try { this.rules = new WebSiteControllerRulesCollection(this); this.modules = new WebSiteControllerModulesCollection(this); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } }
public static List <WebSiteControllerRule> GetRulesForPage(SPWebApplication Webapp, Uri url, string ruleType, SPUser user) { WebApp = Webapp; List <WebSiteControllerRule> list = new List <WebSiteControllerRule>(); if (url == null) { return(list); } WebSiteControllerModulesCollection modules = GetFromConfigDB().modules; foreach (PersistedWebSiteControllerModule module in modules) { IWebSiteControllerModule imodule = GetModule(Webapp, module.Id); if (imodule.AlwaysRun) { try { WebSiteControllerRule _rule = GetRule(imodule.RuleType); if (_rule == null) { _rule = new WebSiteControllerRule(); } //WebSiteControllerRule temp = new WebSiteControllerRule(SPContext.Current.Site.Url, url.ToString(), ruleType, String.Empty, WebSiteControllerPrincipalType.None, false, true, 0, _rule.Parent); list.Add(_rule); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } } } WebSiteControllerRulesCollection rules = GetFromConfigDB().rules; foreach (WebSiteControllerRule rule in rules) { if (IsSinglePageControlled(rule, url, ruleType, user)) { list.Add(rule); } } list.Sort(WebSiteControllerRule.CompareBySequence); return(list); }
/// <summary> /// Determines whether the specified page has associated Page Control rules of the given type. /// </summary> /// <param name="url">The url to the page</param> /// <param name="ruleType">Type of the rule.</param> /// <param name="user">The current user.</param> /// <returns> /// <c>true</c> if the page specified by the url has rules otherwise, <c>false</c>. /// </returns> public static bool IsPageControlled(Uri url, string ruleType, SPUser user) { bool found = false; WebSiteControllerRulesCollection rules = GetFromConfigDB().rules; foreach (WebSiteControllerRule rule in rules) { if (IsSinglePageControlled(rule, url, ruleType, user)) { found = true; break; } } return(found); }
public static List <WebSiteControllerRule> GetRulesForSiteCollection(Uri url, string ruleType) { WebSiteControllerRulesCollection rules = GetFromConfigDB().rules; List <WebSiteControllerRule> list = new List <WebSiteControllerRule>(); foreach (WebSiteControllerRule rule in rules) { if (rule.SiteCollection.Equals(url.ToString(), StringComparison.OrdinalIgnoreCase) && (String.IsNullOrEmpty(ruleType) || rule.RuleType.Equals(ruleType, StringComparison.OrdinalIgnoreCase))) { list.Add(rule); } } list.Sort(WebSiteControllerRule.CompareBySequence); return(list); }
/// <summary> /// /// </summary> /// <param name="Webapp"></param> /// <param name="url"></param> /// <param name="ruleType"></param> /// <returns></returns> public static bool HasRule(SPWebApplication Webapp, Uri url, string ruleType) { WebSiteControllerRulesCollection rules = GetFromConfigDB().rules; foreach (WebSiteControllerRule rule in rules) { try { if (rule.RuleType == ruleType && rule.Url == url.ToString()) { return(true); } } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } } return(false); //return GetFromConfigDB().rules[name]; }