/// <summary> /// Creates the router. /// </summary> /// <param name="author">The author.</param> /// <param name="openBinaryStream">The open binary stream.</param> public void CreateRouter(string author, Stream openBinaryStream) { using (SPSite spSite = new SPSite(this.AbsoluteSiteUrl)) using (SPWeb spWeb = spSite.OpenWeb()) { EcmDocumentRoutingWeb ecmDocumentRoutingWeb = new EcmDocumentRoutingWeb(spWeb); try { ecmDocumentRoutingWeb.RemoveCustomRouter(this.RouterName); } catch (Exception e) { UnifiedLoggingServer.LogHigh("EcmDocumentRoutingWeb<" + this.RouterName + "> DEL_ERR:" + e.Message); } UnifiedLoggingServer.LogMedium("---- CRM:ADD_ROUTER"); ecmDocumentRoutingWeb.AddCustomRouter(this.RouterName, this.AssemblyName, this.ClassName); // fetch corresponding folder into corresponding library UnifiedLoggingServer.LogMedium("---- CRM_DestPath=" + this.RouterPath); if (this.HasRouter) { string log = "---- CRM.OnSubmiting\n"; UnifiedLoggingServer.LogMedium("---- CRM.OnSubmiting_DestPath=" + this.RouterPath); this.CustomRouter.OnSubmitFile( ecmDocumentRoutingWeb, this.ContentTypeName, author, openBinaryStream, this.RecordsRepositoryProperties, this.RouterFolder, ref log); UnifiedLoggingServer.LogMedium("---- CRM.OnSubmitted_DestPath=" + this.RouterPath); UnifiedLoggingServer.LogMedium(log); } UnifiedLoggingServer.LogMedium("---- CRM_END_DestPath=" + this.RouterPath); } }
// CustomRouterResult ICustomRouter.OnSubmitFile( // public CustomRouterResult OnSubmitFile( /// <summary> /// The on submit file. /// </summary> /// <param name="contentOrganizerWeb">The content organizer web.</param> /// <param name="recordSeries">The record series.</param> /// <param name="userName">The user name.</param> /// <param name="fileContent">The file content.</param> /// <param name="properties">The properties.</param> /// <param name="finalFolder">The final folder.</param> /// <param name="resultDetails">The result details.</param> /// <returns> /// The Microsoft.Office.RecordsManagement.RecordsRepository.CustomRouterResult. /// </returns> public CustomRouterResult OnSubmitFile( EcmDocumentRoutingWeb contentOrganizerWeb, string recordSeries, string userName, Stream fileContent, RecordsRepositoryProperty[] properties, SPFolder finalFolder, ref string resultDetails) { if (contentOrganizerWeb == null) { throw new ArgumentNullException("contentOrganizerWeb"); } // We should have a Content Organizer enabled web if (!contentOrganizerWeb.IsRoutingEnabled) { throw new ArgumentException("Invalid content organizer."); } if (String.IsNullOrEmpty(recordSeries)) { throw new ArgumentNullException("recordSeries"); } if (String.IsNullOrEmpty(userName)) { throw new ArgumentNullException("userName"); } if (fileContent.Length == 0) { throw new ArgumentNullException("fileContent"); } if (properties == null) { throw new ArgumentNullException("properties"); } if (!finalFolder.Exists) { throw new ArgumentNullException("finalFolder"); } UnifiedLoggingServer.LogMedium("---- CR.OnSubmitFile() 7@"); UnifiedLoggingServer.LogMedium("-@1:" + contentOrganizerWeb.GetType()); UnifiedLoggingServer.LogMedium("-@2:" + recordSeries); UnifiedLoggingServer.LogMedium("-@3:" + userName); UnifiedLoggingServer.LogMedium("-@4:" + fileContent.Length); UnifiedLoggingServer.LogMedium("-@5:" + properties.Length); UnifiedLoggingServer.LogMedium("-@6:" + finalFolder.Name); UnifiedLoggingServer.LogMedium("-@7:" + resultDetails); try { foreach (RecordsRepositoryProperty recordsRepositoryProperty in properties) { string s = "---- CR.Props [" + recordsRepositoryProperty.Name + "|" + recordsRepositoryProperty.Value + "]"; this.log += s + "\n"; UnifiedLoggingServer.LogMedium(s); } // Create a Hashtable of properties which forms the metadata for the file Hashtable fileProperties = EcmDocumentRouter.GetHashtableForRecordsRepositoryProperties(properties, recordSeries); UnifiedLoggingServer.LogMedium("---- CR.OnSubmitFile().GetHashtableForRecordsRepositoryProperties:" + fileProperties.Count); resultDetails += this.log; UnifiedLoggingServer.LogMedium("-@FilNm_:" + this.FileName); UnifiedLoggingServer.LogMedium("-@FilPt_:" + this.FilePath); UnifiedLoggingServer.LogMedium("-@SPusr_:" + this.SpUser); // Save it to disk EcmDocumentRouter.SaveFileToFinalLocation( contentOrganizerWeb, finalFolder, fileContent, this.FileName, this.FilePath, fileProperties, this.SpUser, true, "CustomRouter CheckInComment"); } catch (Exception e) { UnifiedLoggingServer.LogHigh("---- CR:TryCatch savefiletofinallocation" + e.Message); return(CustomRouterResult.SuccessCancelFurtherProcessing); } return(CustomRouterResult.SuccessContinueProcessing); }