private iSubmissionPackageModule Get_Submission_Module(Builder_Module_Setting itemSetting, out string ErrorMessage) { ErrorMessage = String.Empty; // Look for the standard if (String.IsNullOrEmpty(itemSetting.Assembly)) { iSubmissionPackageModule thisModule = null; switch (itemSetting.Class) { case "SobekCM.Builder_Library.Modules.Items.ConvertOfficeFilesToPdfModule": thisModule = new ConvertOfficeFilesToPdfModule(); break; case "SobekCM.Builder_Library.Modules.Items.ExtractTextFromPdfModule": thisModule = new ExtractTextFromPdfModule(); break; case "SobekCM.Builder_Library.Modules.Items.CreatePdfThumbnailModule": thisModule = new CreatePdfThumbnailModule(); break; case "SobekCM.Builder_Library.Modules.Items.ExtractTextFromHtmlModule": thisModule = new ExtractTextFromHtmlModule(); break; case "SobekCM.Builder_Library.Modules.Items.ExtractTextFromXmlModule": thisModule = new ExtractTextFromXmlModule(); break; case "SobekCM.Builder_Library.Modules.Items.OcrTiffsModule": thisModule = new OcrTiffsModule(); break; case "SobekCM.Builder_Library.Modules.Items.CleanDirtyOcrModule": thisModule = new CleanDirtyOcrModule(); break; case "SobekCM.Builder_Library.Modules.Items.CheckForSsnModule": thisModule = new CheckForSsnModule(); break; case "SobekCM.Builder_Library.Modules.Items.CreateImageDerivativesModule": thisModule = new CreateImageDerivativesModule(); break; case "SobekCM.Builder_Library.Modules.Items.CopyToArchiveFolderModule": thisModule = new CopyToArchiveFolderModule(); break; case "SobekCM.Builder_Library.Modules.Items.MoveFilesToImageServerModule": thisModule = new MoveFilesToImageServerModule(); break; case "SobekCM.Builder_Library.Modules.Items.ReloadMetsAndBasicDbInfoModule": thisModule = new ReloadMetsAndBasicDbInfoModule(); break; case "SobekCM.Builder_Library.Modules.Items.UpdateJpegAttributesModule": thisModule = new UpdateJpegAttributesModule(); break; case "SobekCM.Builder_Library.Modules.Items.AttachAllNonImageFilesModule": thisModule = new AttachAllNonImageFilesModule(); break; case "SobekCM.Builder_Library.Modules.Items.AddNewImagesAndViewsModule": thisModule = new AddNewImagesAndViewsModule(); break; case "SobekCM.Builder_Library.Modules.Items.AttachImagesAllModule": thisModule = new AttachImagesAllModule(); break; case "SobekCM.Builder_Library.Modules.Items.EnsureMainThumbnailModule": thisModule = new EnsureMainThumbnailModule(); break; case "SobekCM.Builder_Library.Modules.Items.GetPageCountFromPdfModule": thisModule = new GetPageCountFromPdfModule(); break; case "SobekCM.Builder_Library.Modules.Items.UpdateWebConfigModule": thisModule = new UpdateWebConfigModule(); break; case "SobekCM.Builder_Library.Modules.Items.SaveServiceMetsModule": thisModule = new SaveServiceMetsModule(); break; case "SobekCM.Builder_Library.Modules.Items.SaveMarcXmlModule": thisModule = new SaveMarcXmlModule(); break; case "SobekCM.Builder_Library.Modules.Items.SaveToDatabaseModule": thisModule = new SaveToDatabaseModule(); break; case "SobekCM.Builder_Library.Modules.Items.SaveToSolrLuceneModule": thisModule = new SaveToSolrLuceneModule(); break; case "SobekCM.Builder_Library.Modules.Items.CleanWebResourceFolderModule": thisModule = new CleanWebResourceFolderModule(); break; case "SobekCM.Builder_Library.Modules.Items.CreateStaticVersionModule": thisModule = new CreateStaticVersionModule(); break; case "SobekCM.Builder_Library.Modules.Items.AddTrackingWorkflowModule": thisModule = new AddTrackingWorkflowModule(); break; case "SobekCM.Builder_Library.Modules.Items.DeleteItemModule": thisModule = new DeleteItemModule(); break; } if (thisModule != null) { if ((!String.IsNullOrEmpty(itemSetting.Argument1)) || (!String.IsNullOrEmpty(itemSetting.Argument2)) || (!String.IsNullOrEmpty(itemSetting.Argument3))) { if (thisModule.Arguments == null) thisModule.Arguments = new List<string>(); thisModule.Arguments.Add(String.IsNullOrEmpty(itemSetting.Argument1) ? String.Empty : itemSetting.Argument1); thisModule.Arguments.Add(String.IsNullOrEmpty(itemSetting.Argument2) ? String.Empty : itemSetting.Argument2); thisModule.Arguments.Add(String.IsNullOrEmpty(itemSetting.Argument3) ? String.Empty : itemSetting.Argument3); } return thisModule; } } object itemAsObj = Get_Module(itemSetting, out ErrorMessage); if ((itemAsObj == null) && (ErrorMessage.Length > 0)) { return null; } iSubmissionPackageModule itemAsItem = itemAsObj as iSubmissionPackageModule; if (itemAsItem == null) { ErrorMessage = itemSetting.Class + " loaded from assembly but does not implement the ISubmissionPackageModules interface!"; return null; } if ((!String.IsNullOrEmpty(itemSetting.Argument1)) || (!String.IsNullOrEmpty(itemSetting.Argument2)) || (!String.IsNullOrEmpty(itemSetting.Argument3))) { if (itemAsItem.Arguments == null) itemAsItem.Arguments = new List<string>(); itemAsItem.Arguments.Add(String.IsNullOrEmpty(itemSetting.Argument1) ? String.Empty : itemSetting.Argument1); itemAsItem.Arguments.Add(String.IsNullOrEmpty(itemSetting.Argument2) ? String.Empty : itemSetting.Argument2); itemAsItem.Arguments.Add(String.IsNullOrEmpty(itemSetting.Argument3) ? String.Empty : itemSetting.Argument3); } return itemAsItem; }
private static void Set_NonScheduled_Modules(Builder_Settings SettingsObject, DataTable BuilderFoldersTable, Dictionary<int, List<Builder_Module_Setting>> SetidToModules, bool IncludeModuleDescriptions ) { //DataColumn moduleIdColumn = BuilderFoldersTable.Columns["ModuleID"]; DataColumn assemblyColumn = BuilderFoldersTable.Columns["Assembly"]; DataColumn classColumn = BuilderFoldersTable.Columns["Class"]; DataColumn descColumn = BuilderFoldersTable.Columns["ModuleDesc"]; DataColumn args1Column = BuilderFoldersTable.Columns["Argument1"]; DataColumn args2Column = BuilderFoldersTable.Columns["Argument2"]; DataColumn args3Column = BuilderFoldersTable.Columns["Argument3"]; // DataColumn enabledColumn = BuilderFoldersTable.Columns["Enabled"]; DataColumn setIdColumn = BuilderFoldersTable.Columns["ModuleSetID"]; // DataColumn setNameColumn = BuilderFoldersTable.Columns["SetName"]; // DataColumn setEnabledColumn = BuilderFoldersTable.Columns["SetEnabled"]; DataColumn typeAbbrevColumn = BuilderFoldersTable.Columns["TypeAbbrev"]; // DataColumn typeDescColumn = BuilderFoldersTable.Columns["TypeDescription"]; int prevSetid = -1; List<Builder_Module_Setting> folderSettings = new List<Builder_Module_Setting>(); foreach (DataRow thisRow in BuilderFoldersTable.Rows) { string type = thisRow[typeAbbrevColumn].ToString().ToUpper(); Builder_Module_Setting newSetting = new Builder_Module_Setting { Class = thisRow[classColumn].ToString() }; if (thisRow[assemblyColumn] != DBNull.Value) newSetting.Assembly = thisRow[assemblyColumn].ToString(); if (thisRow[args1Column] != DBNull.Value) newSetting.Argument1 = thisRow[args1Column].ToString(); if (thisRow[args2Column] != DBNull.Value) newSetting.Argument2 = thisRow[args2Column].ToString(); if (thisRow[args3Column] != DBNull.Value) newSetting.Argument3 = thisRow[args3Column].ToString(); if (IncludeModuleDescriptions) { if (thisRow[descColumn] != DBNull.Value) newSetting.Description = thisRow[descColumn].ToString(); } switch (type) { case "PRE": SettingsObject.PreProcessModulesSettings.Add(newSetting); break; case "POST": SettingsObject.PostProcessModulesSettings.Add(newSetting); break; case "NEW": SettingsObject.ItemProcessModulesSettings.Add(newSetting); break; case "DELT": SettingsObject.ItemDeleteModulesSettings.Add(newSetting); break; case "FOLD": int setId = Int32.Parse(thisRow[setIdColumn].ToString()); if (prevSetid != setId) { if (folderSettings.Count > 0) { SetidToModules[prevSetid] = folderSettings; folderSettings = new List<Builder_Module_Setting>(); } prevSetid = setId; folderSettings.Add(newSetting); } else { folderSettings.Add(newSetting); } break; } } if (folderSettings.Count > 0) { SetidToModules[prevSetid] = folderSettings; } }
private object Get_Module(Builder_Module_Setting Settings, out string ErrorMessage ) { ErrorMessage = String.Empty; try { // Using reflection, create an object from the class namespace/name Assembly dllAssembly = Assembly.GetExecutingAssembly(); if (!String.IsNullOrEmpty(Settings.Assembly)) { dllAssembly = Assembly.LoadFrom(Settings.Assembly); } Type readerWriterType = dllAssembly.GetType(Settings.Class); return Activator.CreateInstance(readerWriterType); } catch (Exception ee) { ErrorMessage = "Unable to load class from assembly. ( " + Settings.Class + " ) : " + ee.Message; return null; } }