/// <summary> /// Initializes a new instance of the <see cref="CustomRouterManager"/> class. /// The custom router manager. /// </summary> /// <param name="absoluteSiteUrl">The absolute site URL.</param> /// <param name="rd">The rd.</param> public CustomRouterManager(string absoluteSiteUrl, RecordDocument rd) { if (String.IsNullOrEmpty(absoluteSiteUrl)) { throw new ArgumentNullException("absoluteSiteUrl"); } if (rd == null) { throw new ArgumentNullException("rd"); } UnifiedLoggingServer.LogMedium("--- " + this.GetType().Name + " 2@ ---"); UnifiedLoggingServer.LogMedium("-@1:" + absoluteSiteUrl); UnifiedLoggingServer.LogMedium("-@2:" + rd.File.Name); this.AbsoluteSiteUrl = absoluteSiteUrl; this.ContentTypeName = rd.ContentType.Name; this.RouterName = rd.ContentType.Name + "CustomRouter"; this.RecordsRepositoryProperties = this.FetchProperties(rd.FieldCollection, rd.ListItem); this.RouterRule = this.FetchRule(rd); this.RouterPath = this.RouterRule.Web.Url + "/"; this.RouterLibrary = this.FetchLibrary(rd); this.HasRouter = this.CanFindRouter(rd); this.HasTargetFolder = this.RouterRule["Target Folder"] != null; this.RouterFolder = this.FetchFolder(); this.RouterPath = this.FetchPath(this.RouterPath); this.CustomRouter = new CustomRouter(); this.CustomRouter.Initialize(absoluteSiteUrl, rd.File, rd.ContentType.Name); this.AssemblyName = this.CustomRouter.AssemblyName; this.ClassName = this.GetType().Namespace + "." + this.CustomRouter.Name; }
/// <summary> /// The fetch rule. /// </summary> /// <param name="rd">The rd.</param> /// <returns> /// The Microsoft.SharePoint.SPListItem. /// </returns> private SPListItem FetchRule(RecordDocument rd) { // starts orphan SPListItem rule = null; // check if in the family rule = rd.HasLibrary ? rd.RoutingRule : rd.ParentRoutingRule; return(rule); }
/// <summary> /// Determines whether this instance [can find router] the specified rd. /// </summary> /// <param name="rd">The rd.</param> /// <returns> /// <c>true</c> if this instance [can find router] the specified rd; otherwise, <c>false</c>. /// </returns> private bool CanFindRouter(RecordDocument rd) { // starts orphan bool boo = false; // check if in the family boo = rd.HasRoutingRule ? rd.HasRoutingRule : rd.HasParentRoutingRule; return(boo); }
/// <summary> /// Fetches the library. /// </summary> /// <param name="rd">The rd.</param> /// <returns> /// The Microsoft.SharePoint.SPList. /// </returns> private SPList FetchLibrary(RecordDocument rd) { // starts orphan SPList lib = null; // check if in the family lib = rd.HasLibrary ? rd.CandidateLibrary : rd.ParentCandidateLibrary; return(lib); }
/// <summary> /// Gets the content type boolean. /// </summary> /// <param name="recordDocument">The record document.</param> /// <returns> /// <c>true</c> if [has content type] [the specified record document]; otherwise, <c>false</c>. /// </returns> private bool GetContentTypeBoolean(RecordDocument recordDocument) { foreach (SPList enabledLibrary in this.EnabledLibraries) { if (enabledLibrary.ContentTypesEnabled && enabledLibrary.ContentTypes[recordDocument.ContentType.Name] != null) { return(true); } } return(false); }
/// <summary> /// Gets the content type boolean. /// </summary> /// <param name="recordDocument">The record document.</param> /// <returns> /// The System.Boolean. /// </returns> private bool GetContentTypeBoolean(RecordDocument recordDocument) { const string SubContentType = "Submission Content Type"; foreach (SPListItem routingRule in this.RoutingRules) { SPField spField = routingRule.Fields[SubContentType]; if (routingRule[spField.Id].Equals(recordDocument.ContentType.Name.Trim())) { return(true); } } return(false); }
/// <summary> /// Gets the content type indices. /// </summary> /// <param name="recordDocument">The record document.</param> /// <returns> /// The System.Collections.Generic.List`1[T -> System.Int32]. /// </returns> private List <int> GetContentTypeIndices(RecordDocument recordDocument) { List <int> intList = new List <int>(); for (int i = 0; i < this.EnabledLibraries.Count; i++) { SPList enabledLibrary = this.EnabledLibraries[i]; if (enabledLibrary.ContentTypesEnabled && enabledLibrary.ContentTypes[recordDocument.ContentType.Name] != null) { intList.Add(i); } } return(intList); }
/// <summary> /// Gets the content type indices. /// </summary> /// <param name="recordDocument"> /// The record document. /// </param> /// <returns> /// The System.Collections.Generic.List`1[T -> System.Int32]. /// </returns> private List <int> GetContentTypeIndices(RecordDocument recordDocument) { List <int> intList = new List <int>(); const string SubContentType = "Submission Content Type"; for (int i = 0; i < this.RoutingRules.Count; i++) { SPListItem routingRule = this.RoutingRules[i]; SPField spField = routingRule.Fields[SubContentType]; if (routingRule[spField.Id].Equals(recordDocument.ContentType.Name.Trim())) { intList.Add(i); } } return(intList); }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="isDisposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool isDisposing) { // Check if Dispose has been called if (!this.isDisposed) { // dispose managed and unmanaged resources if (isDisposing) { // managed resources clean this.RecordDocument = null; } // unmanaged resources clean // confirm cleaning this.isDisposed = true; } }
/// <summary>Releases unmanaged and - optionally - managed resources.</summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// true to release both managed and unmanaged resources; false to release only unmanaged resources. /// <param name="isDisposing">The is disposing.</param> private void Dispose(bool isDisposing) { // Check if Dispose has been called if (!this.isDisposed) { // dispose managed and unmanaged resources if (isDisposing) { // managed resources clean this.DropOffLibrary = null; this.EnabledLibraries = null; this.RoutingRules = null; this.DropOffRecordDocument = null; } // unmanaged resources clean // confirm cleaning this.isDisposed = true; } }
/// <summary> /// Gets the content type boolean. /// </summary> /// <param name="recordDocument"> /// The record document. /// </param> /// <param name="checkParent"> /// The check parent. /// </param> /// <returns> /// The System.Boolean. /// </returns> public bool GetContentTypeBoolean(RecordDocument recordDocument, bool checkParent) { if (!checkParent) { return(this.GetContentTypeBoolean(recordDocument)); } else { bool boo = false; foreach (SPList enabledLibrary in this.EnabledLibraries) { if (enabledLibrary.ContentTypesEnabled && enabledLibrary.ContentTypes[recordDocument.ParentContentType.Name] != null) { boo = true; } } return(this.GetContentTypeBoolean(recordDocument) || boo); } }
/// <summary> /// Gets the content type boolean. /// </summary> /// <param name="recordDocument"> /// The record document. /// </param> /// <param name="checkParent"> /// if set to <c>true</c> [check parent]. /// </param> /// <returns> /// The System.Boolean. /// </returns> public bool GetContentTypeBoolean(RecordDocument recordDocument, bool checkParent) { if (!checkParent) { return(this.GetContentTypeBoolean(recordDocument)); } else { bool boo = false; const string SubContentType = "Submission Content Type"; foreach (SPListItem routingRule in this.RoutingRules) { SPField spField = routingRule.Fields[SubContentType]; if (routingRule[spField.Id].Equals(recordDocument.ParentContentType.Name.Trim())) { boo = true; } } return(boo || this.GetContentTypeBoolean(recordDocument)); } }
/// <summary> /// Gets the content type indices. /// </summary> /// <param name="recordDocument"> /// The record document. /// </param> /// <param name="checkParent"> /// if set to <c>true</c> [check parent]. /// </param> /// <returns> /// The System.Collections.Generic.List`1[T -> System.Int32]. /// </returns> public List <int> GetContentTypeIndices(RecordDocument recordDocument, bool checkParent) { if (!checkParent) { return(this.GetContentTypeIndices(recordDocument)); } else { List <int> intList = new List <int>(); for (int i = 0; i < this.EnabledLibraries.Count; i++) { SPList enabledLibrary = this.EnabledLibraries[i]; if (enabledLibrary.ContentTypesEnabled && enabledLibrary.ContentTypes[recordDocument.ParentContentType.Name] != null) { intList.Add(i); } } return(intList); } }