private iSubmissionPackageModule Get_Submission_Module(Builder_Module_Setting ItemSetting, string InstanceName, 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.CreateImageDerivativesLegacyModule": thisModule = new CreateImageDerivativesLegacyModule(); 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, InstanceName, 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 object Get_Module(Builder_Module_Setting Settings, string InstanceName, 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)) { string base_dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace("file:///", ""); string assembly_network = Path.Combine(base_dir, "plugins", InstanceName, Settings.Assembly); if ((assembly_network.IndexOf(".dll", StringComparison.InvariantCultureIgnoreCase) < 0) && ( File.Exists(assembly_network + ".dl;l"))) assembly_network = assembly_network + ".dll"; // Is this file present? if (File.Exists(assembly_network)) dllAssembly = Assembly.LoadFrom(assembly_network); else if ( Directory.Exists(Path.Combine(base_dir, "plugins", InstanceName))) { // Did the assembly include a .dll? string assembly_name = Settings.Assembly; if (assembly_name.IndexOf(".dll", StringComparison.InvariantCultureIgnoreCase) < 0) assembly_name = assembly_name + ".dll"; // File was not present, so look around a bit string found_assembly = null; string[] subdirs = Directory.GetDirectories(Path.Combine(base_dir, "plugins", InstanceName)); foreach (string thisSubDir in subdirs) { // Look for the assembly here string possible_assembly = Path.Combine(thisSubDir, assembly_name); if (File.Exists(possible_assembly)) { found_assembly = possible_assembly; break; } // Look a little bit deeper string[] subsubdirs = Directory.GetDirectories(thisSubDir); foreach (string thisSubSubDir in subsubdirs) { // Look for the assembly here possible_assembly = Path.Combine(thisSubSubDir, assembly_name); if (File.Exists(possible_assembly)) { found_assembly = possible_assembly; break; } } // If found, break if (!String.IsNullOrEmpty(found_assembly)) break; } // Was the assembly found? if (!String.IsNullOrEmpty(found_assembly)) { dllAssembly = Assembly.LoadFrom(found_assembly); } else { ErrorMessage = "Unable to find the assembly referenced in a builder setting ( " + Settings.Assembly + " )."; return null; } } } 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; } }
private object Get_Module(Builder_Module_Setting Settings, string InstanceName, 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)) { string base_dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace("file:///", ""); string assembly_network = Path.Combine(base_dir, "plugins", InstanceName, Settings.Assembly); if ((assembly_network.IndexOf(".dll", StringComparison.InvariantCultureIgnoreCase) < 0) && (File.Exists(assembly_network + ".dl;l"))) { assembly_network = assembly_network + ".dll"; } // Is this file present? if (File.Exists(assembly_network)) { dllAssembly = Assembly.LoadFrom(assembly_network); } else if (Directory.Exists(Path.Combine(base_dir, "plugins", InstanceName))) { // Did the assembly include a .dll? string assembly_name = Settings.Assembly; if (assembly_name.IndexOf(".dll", StringComparison.InvariantCultureIgnoreCase) < 0) { assembly_name = assembly_name + ".dll"; } // File was not present, so look around a bit string found_assembly = null; string[] subdirs = Directory.GetDirectories(Path.Combine(base_dir, "plugins", InstanceName)); foreach (string thisSubDir in subdirs) { // Look for the assembly here string possible_assembly = Path.Combine(thisSubDir, assembly_name); if (File.Exists(possible_assembly)) { found_assembly = possible_assembly; break; } // Look a little bit deeper string[] subsubdirs = Directory.GetDirectories(thisSubDir); foreach (string thisSubSubDir in subsubdirs) { // Look for the assembly here possible_assembly = Path.Combine(thisSubSubDir, assembly_name); if (File.Exists(possible_assembly)) { found_assembly = possible_assembly; break; } } // If found, break if (!String.IsNullOrEmpty(found_assembly)) { break; } } // Was the assembly found? if (!String.IsNullOrEmpty(found_assembly)) { dllAssembly = Assembly.LoadFrom(found_assembly); } else { ErrorMessage = "Unable to find the assembly referenced in a builder setting ( " + Settings.Assembly + " )."; return(null); } } } 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); } }
private iSubmissionPackageModule Get_Submission_Module(Builder_Module_Setting ItemSetting, string InstanceName, 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.CreateImageDerivativesLegacyModule": thisModule = new CreateImageDerivativesLegacyModule(); 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, InstanceName, 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; Dictionary <int, List <Builder_Module_Setting> > folderSettings = new Dictionary <int, 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 (SetidToModules.ContainsKey(setId)) { SetidToModules[setId].Add(newSetting); } else { SetidToModules[setId] = new List <Builder_Module_Setting> { newSetting }; } break; } } }
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; Dictionary<int,List<Builder_Module_Setting>> folderSettings = new Dictionary<int, 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 (SetidToModules.ContainsKey(setId)) { SetidToModules[setId].Add(newSetting); } else { SetidToModules[setId] = new List<Builder_Module_Setting> {newSetting}; } break; } } }