コード例 #1
0
        /// <summary> Reloads the basic behavior information from the database into the
        /// digital resource, such as collections and thumbnails  </summary>
        /// <param name="Resource"> Incoming digital resource object </param>
        /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns>
        public override bool DoWork(Incoming_Digital_Resource Resource)
        {
            // Load the METS file
            if (!Resource.Load_METS())
            {
                OnError("Error reading most recent METS file from " + Resource.BibID + ":" + Resource.VID, Resource.BibID + ":" + Resource.VID, String.Empty, Resource.BuilderLogId);
                return(false);
            }

            // Add thumbnail, aggregation informaiton, and dark/access information from the database
            if (!Resource.NewPackage)
            {
                Engine_Database.Add_Minimum_Builder_Information(Resource.Metadata);
            }
            else
            {
                // Check for any access/restriction/embargo date in the RightsMD section
                RightsMD_Info rightsInfo = Resource.Metadata.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;
                if ((rightsInfo != null) && (rightsInfo.hasData))
                {
                    switch (rightsInfo.Access_Code)
                    {
                    case RightsMD_Info.AccessCode_Enum.Campus:
                        // Was there an embargo date?
                        if (rightsInfo.Has_Embargo_End)
                        {
                            if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                            {
                                Resource.Metadata.Behaviors.IP_Restriction_Membership = 1;
                            }
                        }
                        else
                        {
                            Resource.Metadata.Behaviors.IP_Restriction_Membership = 1;
                        }
                        break;

                    case RightsMD_Info.AccessCode_Enum.Private:
                        // Was there an embargo date?
                        if (rightsInfo.Has_Embargo_End)
                        {
                            if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                            {
                                Resource.Metadata.Behaviors.Dark_Flag = true;
                            }
                        }
                        else
                        {
                            Resource.Metadata.Behaviors.Dark_Flag = true;
                        }
                        break;
                    }
                }
            }

            return(true);
        }
コード例 #2
0
        /// <summary> Reloads the basic behavior information from the database into the
        /// digital resource, such as collections and thumbnails  </summary>
        /// <param name="Resource"> Incoming digital resource object </param>
        /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns>
        public override bool DoWork(Incoming_Digital_Resource Resource)
        {
            // Load the METS file
            if (!Resource.Load_METS())
            {
                OnError("Error reading most recent METS file from " + Resource.BibID + ":" + Resource.VID, Resource.BibID + ":" + Resource.VID, String.Empty, Resource.BuilderLogId);
                return false;
            }

            // Add thumbnail, aggregation informaiton, and dark/access information from the database
            if (!Resource.NewPackage)
            {
                SobekCM_Database.Add_Minimum_Builder_Information(Resource.Metadata);
            }
            else
            {
                // Check for any access/restriction/embargo date in the RightsMD section
                RightsMD_Info rightsInfo = Resource.Metadata.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;
                if ((rightsInfo != null) && (rightsInfo.hasData))
                {
                    switch (rightsInfo.Access_Code)
                    {
                        case RightsMD_Info.AccessCode_Enum.Campus:
                            // Was there an embargo date?
                            if (rightsInfo.Has_Embargo_End)
                            {
                                if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                                {
                                    Resource.Metadata.Behaviors.IP_Restriction_Membership = 1;
                                }
                            }
                            else
                            {
                                Resource.Metadata.Behaviors.IP_Restriction_Membership = 1;
                            }
                            break;

                        case RightsMD_Info.AccessCode_Enum.Private:
                            // Was there an embargo date?
                            if (rightsInfo.Has_Embargo_End)
                            {
                                if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                                {
                                    Resource.Metadata.Behaviors.Dark_Flag = true;
                                }
                            }
                            else
                            {
                                Resource.Metadata.Behaviors.Dark_Flag = true;
                            }
                            break;
                    }
                }
            }

            return true;
        }
コード例 #3
0
        private void Complete_Single_Recent_Load_Requiring_Additional_Work(string Resource_Folder, Incoming_Digital_Resource AdditionalWorkResource)
        {
            AdditionalWorkResource.METS_Type_String = "Reprocess";
            AdditionalWorkResource.BuilderLogId = Add_NonError_To_Log("........Reprocessing '" + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID + "'", "Standard",  AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, -1);

            try
            {
                // Load the METS file
                if ((!AdditionalWorkResource.Load_METS()) || (AdditionalWorkResource.BibID.Length == 0))
                {
                    Add_Error_To_Log("Error reading METS file from " + AdditionalWorkResource.Folder_Name.Replace("_", ":"), AdditionalWorkResource.Folder_Name.Replace("_", ":"), "Reprocess", AdditionalWorkResource.BuilderLogId);
                    return;
                }

                AdditionalWorkResource.METS_Type_String = "Reprocess";

                // Add thumbnail and aggregation informaiton from the database
                Library.Database.SobekCM_Database.Add_Minimum_Builder_Information(AdditionalWorkResource.Metadata);

                // Do all the item processing per instance config
                foreach (iSubmissionPackageModule thisModule in BuilderSettings.ItemProcessModules)
                {
                    if (verbose)
                    {
                        Add_NonError_To_Log("Running module " + thisModule.GetType().ToString(), true, AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, String.Empty, AdditionalWorkResource.BuilderLogId);
                    }
                    if (!thisModule.DoWork(AdditionalWorkResource))
                    {
                        Add_Error_To_Log("Unable to complete additional work for " + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, String.Empty, AdditionalWorkResource.BuilderLogId);

                        return;
                    }
                }

                // Save these collections to mark them for refreshing the RSS feeds, etc..
                Add_Process_Info_To_PostProcess_Lists(AdditionalWorkResource.BibID, AdditionalWorkResource.VID, AdditionalWorkResource.Metadata.Behaviors.Aggregation_Code_List);

                // Finally, clear the memory a little bit
                AdditionalWorkResource.Clear_METS();
            }
            catch (Exception ee)
            {
                Add_Error_To_Log("Unable to complete additional work for " + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, AdditionalWorkResource.BuilderLogId, ee);
            }
        }
コード例 #4
0
        private void Complete_Single_Recent_Load_Requiring_Additional_Work(string Resource_Folder, Incoming_Digital_Resource AdditionalWorkResource)
        {
            AdditionalWorkResource.METS_Type_String = "Reprocess";
            AdditionalWorkResource.BuilderLogId = Add_NonError_To_Log("........Reprocessing '" + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID + "'", "Standard",  AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, -1);

            try
            {
                // Pre-Process any resource files
                List<string> new_image_files = new List<string>();
                PreProcess_Any_Resource_Files(AdditionalWorkResource, new_image_files);

                // Delete any pre-archive deletes
                if (SobekCM_Library_Settings.PreArchive_Files_To_Delete.Length > 0)
                {
                    // Get the list of files again
                    string[] files = Directory.GetFiles(Resource_Folder);
                    foreach (string thisFile in files)
                    {
                        FileInfo thisFileInfo = new FileInfo(thisFile);
                        if (Regex.Match(thisFileInfo.Name, SobekCM_Library_Settings.PreArchive_Files_To_Delete, RegexOptions.IgnoreCase).Success)
                        {
                            File.Delete(thisFile);
                        }
                    }
                }

                // Archive any files, per the folder instruction
                Archive_Any_Files(AdditionalWorkResource);

                // Delete any remaining post-archive deletes
                if (SobekCM_Library_Settings.PostArchive_Files_To_Delete.Length > 0)
                {
                    // Get the list of files again
                    string[] files = Directory.GetFiles(Resource_Folder);
                    foreach (string thisFile in files)
                    {
                        FileInfo thisFileInfo = new FileInfo(thisFile);
                        if (Regex.Match(thisFileInfo.Name, SobekCM_Library_Settings.PostArchive_Files_To_Delete, RegexOptions.IgnoreCase).Success)
                        {
                            File.Delete(thisFile);
                        }
                    }
                }

                // Load the METS file
                if ((!AdditionalWorkResource.Load_METS()) || ( AdditionalWorkResource.BibID.Length == 0 ))
                {
                    Add_Error_To_Log("Error reading METS file from " + AdditionalWorkResource.Folder_Name.Replace("_", ":"), AdditionalWorkResource.Folder_Name.Replace("_", ":"), "Reprocess", AdditionalWorkResource.BuilderLogId);
                    return;
                }

                AdditionalWorkResource.METS_Type_String = "Reprocess";

                // Add thumbnail and aggregation informaiton from the database
                SobekCM_Database.Add_Minimum_Builder_Information(AdditionalWorkResource.Metadata);

                // Perform any final file updates
                Resource_File_Updates(AdditionalWorkResource, new_image_files );

                // Save all the metadata files again for any possible changes which may have occurred
                Save_All_Updated_Metadata_Files(AdditionalWorkResource);

                // Determine total size on the disk
                string[] all_files_final = Directory.GetFiles(AdditionalWorkResource.Resource_Folder);
                double size = all_files_final.Sum(ThisFile => (double) (((new FileInfo(ThisFile)).Length)/1024));
                AdditionalWorkResource.DiskSpaceMb = size;

                // Save this package to the database
                if (!AdditionalWorkResource.Save_to_Database(itemTable, false))
                {
                    Add_Error_To_Log("Error saving data to SobekCM database.  The database may not reflect the most recent data in the METS.", AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, AdditionalWorkResource.BuilderLogId );
                }

                // Save this to the Solr/Lucene database
                if (SobekCM_Library_Settings.Document_Solr_Index_URL.Length > 0)
                {
                    try
                    {
                        Solr_Controller.Update_Index(SobekCM_Library_Settings.Document_Solr_Index_URL, SobekCM_Library_Settings.Page_Solr_Index_URL, AdditionalWorkResource.Metadata, true);
                    }
                    catch (Exception ee)
                    {
                        Add_Error_To_Log("Error saving data to the Solr/Lucene index.  The index may not reflect the most recent data in the METS.", AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, AdditionalWorkResource.BuilderLogId );
                        Add_Error_To_Log("Solr Error: " + ee.Message , AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, AdditionalWorkResource.BuilderLogId );

                    }
                }

                // Save the static page and then copy to all the image servers
                string static_file = AdditionalWorkResource.Save_Static_HTML(staticBuilder);
                if ((static_file.Length == 0) || (!File.Exists(static_file)))
                {
                    Add_Error_To_Log("Error creating static page for this resource", AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, AdditionalWorkResource.BuilderLogId );
                }
                else
                {
                    // Also copy to the static page location server
                    string web_server_file_version = SobekCM_Library_Settings.Static_Pages_Location + AdditionalWorkResource.File_Root + "\\" + AdditionalWorkResource.BibID + "_" + AdditionalWorkResource.VID + ".html";
                    if (!Directory.Exists(SobekCM_Library_Settings.Static_Pages_Location + AdditionalWorkResource.File_Root))
                        Directory.CreateDirectory(SobekCM_Library_Settings.Static_Pages_Location + AdditionalWorkResource.File_Root);
                    File.Copy(static_file, web_server_file_version, true);
                }

                // Save these collections to mark them for refreshing the RSS feeds, etc..
                Add_Aggregation_To_Refresh_List(AdditionalWorkResource.Metadata.Behaviors.Aggregation_Code_List);

                // Clear the flag for additional work
                SobekCM_Database.Update_Additional_Work_Needed_Flag(AdditionalWorkResource.Metadata.Web.ItemID, false, null);

                // Mark a log in the database that this was handled as well
                Resource_Object.Database.SobekCM_Database.Add_Workflow(AdditionalWorkResource.Metadata.Web.ItemID, "Post-Processed", String.Empty, "SobekCM Bulk Loader", String.Empty);

                // If the item is born digital, has files, and is currently public, close out the digitization milestones completely
                if ((!AdditionalWorkResource.Metadata.Tracking.Born_Digital_Is_Null) && (AdditionalWorkResource.Metadata.Tracking.Born_Digital) && (AdditionalWorkResource.Metadata.Behaviors.IP_Restriction_Membership >= 0) && (AdditionalWorkResource.Metadata.Divisions.Download_Tree.Has_Files))
                {
                    Resource_Object.Database.SobekCM_Database.Update_Digitization_Milestone(AdditionalWorkResource.Metadata.Web.ItemID, 4, DateTime.Now);
                }

                // Perform some final cleanup now
                Cleanup_Web_Resource_Folder(AdditionalWorkResource);

                // Finally, clear the memory a little bit
                AdditionalWorkResource.Clear_METS();
            }
            catch (Exception ee)
            {
                Add_Error_To_Log("Unable to complete additional work for " + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, AdditionalWorkResource.BuilderLogId, ee);
            }
        }
コード例 #5
0
        private void Process_Single_Incoming_Package(Incoming_Digital_Resource ResourcePackage)
        {
            ResourcePackage.BuilderLogId = Add_NonError_To_Log("........Processing '" + ResourcePackage.Folder_Name + "'", "Standard", ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.METS_Type_String, -1);

            // Clear any existing error linked to this item
            SobekCM_Database.Builder_Clear_Item_Error_Log(ResourcePackage.BibID, ResourcePackage.VID, "SobekCM Builder");

            try
            {
                // Pre-Process any resource files
                List<string> new_image_files = new List<string>();
                PreProcess_Any_Resource_Files(ResourcePackage, new_image_files);

                // Rename the received METS files
                Rename_Any_Received_METS_File(ResourcePackage);

                // Delete any pre-archive deletes
                if (SobekCM_Library_Settings.PreArchive_Files_To_Delete.Length > 0)
                {
                    // Get the list of files again
                    string[] files = Directory.GetFiles(ResourcePackage.Resource_Folder);
                    foreach (string thisFile in files)
                    {
                        FileInfo thisFileInfo = new FileInfo(thisFile);
                        if (Regex.Match(thisFileInfo.Name, SobekCM_Library_Settings.PreArchive_Files_To_Delete, RegexOptions.IgnoreCase).Success)
                        {
                            File.Delete(thisFile);
                        }
                    }
                }

                // Archive any files, per the folder instruction
                Archive_Any_Files(ResourcePackage);

                // Delete any remaining post-archive deletes
                if (SobekCM_Library_Settings.PostArchive_Files_To_Delete.Length > 0)
                {
                    // Get the list of files again
                    string[] files = Directory.GetFiles(ResourcePackage.Resource_Folder);
                    foreach (string thisFile in files)
                    {
                        FileInfo thisFileInfo = new FileInfo(thisFile);
                        if (Regex.Match(thisFileInfo.Name, SobekCM_Library_Settings.PostArchive_Files_To_Delete, RegexOptions.IgnoreCase).Success)
                        {
                            File.Delete(thisFile);
                        }
                    }
                }

                // Clear the list of new images files here, since moving the package will recalculate this
                new_image_files.Clear();

                // Move all files to the image server
                if (!Move_All_Files_To_Image_Server(ResourcePackage, new_image_files))
                {
                    Add_Error_To_Log("Error moving some files to the image server for " + ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.METS_Type_String, ResourcePackage.BuilderLogId);
                }

                // Before we save this or anything, let's see if this is truly a new resource
                bool truly_new_bib = !(itemTable.Select("BibID='" + ResourcePackage.BibID + "' and VID='" + ResourcePackage.VID + "'").Length > 0);
                ResourcePackage.Package_Time = DateTime.Now;

                // Load the METS file
                if (!ResourcePackage.Load_METS())
                {
                    Add_Error_To_Log("Error reading most recent METS file from " + ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId);
             	                return;
                }

                // Add thumbnail, aggregation informaiton, and dark/access information from the database
                if (!truly_new_bib)
                {
                    SobekCM_Database.Add_Minimum_Builder_Information(ResourcePackage.Metadata);
                }
                else
                {
                    // Check for any access/restriction/embargo date in the RightsMD section
                    RightsMD_Info rightsInfo = ResourcePackage.Metadata.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;
                    if (( rightsInfo != null ) && ( rightsInfo.hasData ))
                    {
                        switch (rightsInfo.Access_Code)
                        {
                            case RightsMD_Info.AccessCode_Enum.Campus:
                                // Was there an embargo date?
                                if (rightsInfo.Has_Embargo_End)
                                {
                                    if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                                    {
                                        ResourcePackage.Metadata.Behaviors.IP_Restriction_Membership = 1;
                                    }
                                }
                                else
                                {
                                    ResourcePackage.Metadata.Behaviors.IP_Restriction_Membership = 1;
                                }
                                break;

                            case RightsMD_Info.AccessCode_Enum.Private:
                                // Was there an embargo date?
                                if (rightsInfo.Has_Embargo_End)
                                {
                                    if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                                    {
                                        ResourcePackage.Metadata.Behaviors.Dark_Flag = true;
                                    }
                                }
                                else
                                {
                                    ResourcePackage.Metadata.Behaviors.Dark_Flag = true;
                                }
                                break;
                        }
                    }
                }

                // Perform any final file updates
                Resource_File_Updates(ResourcePackage, new_image_files);

                // Save all the metadata files again for any possible changes which may have occurred
                Save_All_Updated_Metadata_Files(ResourcePackage);

                // Determine total size on the disk
                string[] all_files_final = Directory.GetFiles(ResourcePackage.Resource_Folder);
                double size = all_files_final.Sum(ThisFile => (double) (((new FileInfo(ThisFile)).Length)/1024));
                ResourcePackage.DiskSpaceMb = size;

                // Save this package to the database
                if (!ResourcePackage.Save_to_Database(itemTable, truly_new_bib))
                {
                    Add_Error_To_Log("Error saving data to SobekCM database.  The database may not reflect the most recent data in the METS.", ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId);
                }

                // Save this to the Solr/Lucene database
                if (SobekCM_Library_Settings.Document_Solr_Index_URL.Length > 0)
                {
                    try
                    {
                        Solr_Controller.Update_Index(SobekCM_Library_Settings.Document_Solr_Index_URL, SobekCM_Library_Settings.Page_Solr_Index_URL, ResourcePackage.Metadata, true);
                    }
                    catch (Exception ee)
                    {
                        Add_Error_To_Log("Error saving data to the Solr/Lucene index.  The index may not reflect the most recent data in the METS.", ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId);
                        Add_Error_To_Log("Solr Error: " + ee.Message, ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId);
                     }
                }

                // Save the static page and then copy to all the image servers
                string static_file = ResourcePackage.Save_Static_HTML(staticBuilder);
                if ((static_file.Length == 0) || (!File.Exists(static_file)))
                {
                    Add_Error_To_Log("Warning: error encountered creating static page for this resource", ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId);
                }
                else
                {
                    // Also copy to the static page location server
                    string web_server_file_version = SobekCM_Library_Settings.Static_Pages_Location + ResourcePackage.File_Root + "\\" + ResourcePackage.BibID + "_" + ResourcePackage.VID + ".html";
                    if (!Directory.Exists(SobekCM_Library_Settings.Static_Pages_Location + ResourcePackage.File_Root))
                        Directory.CreateDirectory(SobekCM_Library_Settings.Static_Pages_Location + ResourcePackage.File_Root);
                    File.Copy(static_file, web_server_file_version, true);
                }

                // Save these collections to mark them for refreshing the RSS feeds, etc..
                Add_Aggregation_To_Refresh_List(ResourcePackage.Metadata.Behaviors.Aggregation_Code_List);

                // Mark a workflow/progress log in the database that this was handled as well
                Resource_Object.Database.SobekCM_Database.Add_Workflow(ResourcePackage.Metadata.Web.ItemID, "Bulk Loaded", ResourcePackage.METS_Type_String, "SobekCM Bulk Loader", String.Empty);

                // If the item is born digital, has files, and is currently public, close out the digitization milestones completely
                if ((!ResourcePackage.Metadata.Tracking.Born_Digital_Is_Null) && (ResourcePackage.Metadata.Tracking.Born_Digital) && (ResourcePackage.Metadata.Behaviors.IP_Restriction_Membership >= 0) && (ResourcePackage.Metadata.Divisions.Download_Tree.Has_Files))
                {
                    Resource_Object.Database.SobekCM_Database.Update_Digitization_Milestone(ResourcePackage.Metadata.Web.ItemID, 4, DateTime.Now);
                }

                // Perform some final cleanup now
                Cleanup_Web_Resource_Folder(ResourcePackage);

                // Call the post-process custom actions
                foreach (iBuilder_PostBuild_Process processor in SobekCM_Builder_Configuration_Details.PostBuild_Processes)
                {
                    processor.PostProcess(ResourcePackage.Metadata, ResourcePackage.Resource_Folder);
                }

                // Finally, clear the memory a little bit
                ResourcePackage.Clear_METS();
            }
            catch (Exception ee)
            {
                StreamWriter errorWriter = new StreamWriter(Application.StartupPath + "\\Logs\\error.log", true);
                errorWriter.WriteLine("Message: " + ee.Message);
                errorWriter.WriteLine("Stack Trace: " + ee.StackTrace);
                errorWriter.Flush();
                errorWriter.Close();

                Add_Error_To_Log("Unable to complete new/replacement for " + ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId, ee);
            }
        }
コード例 #6
0
        /// <summary> Performs a delete from the database and moves all digital resource
        /// files into the recycle bin </summary>
        /// <param name="Resource"> Incoming digital resource object </param>
        /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns>
        public override bool DoWork(Incoming_Digital_Resource Resource)
        {
            // Read the METS and load the basic information before continuing
            Resource.Load_METS();
            Engine_Database.Add_Minimum_Builder_Information(Resource.Metadata);

            Resource.BuilderLogId = OnProcess("........Processing '" + Resource.Folder_Name + "'", "Standard", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, -1);

            Engine_Database.Builder_Clear_Item_Error_Log(Resource.BibID, Resource.VID, "SobekCM Builder");

            Resource.File_Root = Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8);
            string existing_folder = Settings.Servers.Image_Server_Network + Resource.File_Root + "\\" + Resource.VID;

            // Remove from the primary collection area
            try
            {
                if (Directory.Exists(existing_folder))
                {
                    // Make sure the delete folder exists
                    if (!Directory.Exists(Settings.Servers.Image_Server_Network + "\\RECYCLE BIN"))
                    {
                        Directory.CreateDirectory(Settings.Servers.Image_Server_Network + "\\RECYCLE BIN");
                    }

                    // Create the final directory
                    string final_folder = Settings.Servers.Image_Server_Network + "\\RECYCLE BIN\\" + Resource.File_Root + "\\" + Resource.VID;
                    if (!Directory.Exists(final_folder))
                    {
                        Directory.CreateDirectory(final_folder);
                    }

                    // Move each file
                    string[] delete_files = Directory.GetFiles(existing_folder);
                    foreach (string thisDeleteFile in delete_files)
                    {
                        string destination_file = final_folder + "\\" + Path.GetFileName(thisDeleteFile);
                        if (File.Exists(destination_file))
                        {
                            File.Delete(destination_file);
                        }
                        File.Move(thisDeleteFile, destination_file);
                    }
                }
            }
            catch (Exception ee)
            {
                OnError("Unable to move resource ( " + Resource.BibID + ":" + Resource.VID + " ) to deletes", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                OnError(ee.Message, Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                return(false);
            }

            // Delete the static page
            string static_page1 = Settings.Servers.Static_Pages_Location + Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8) + "\\" + Resource.VID + "\\" + Resource.BibID + "_" + Resource.VID + ".html";

            if (File.Exists(static_page1))
            {
                File.Delete(static_page1);
            }
            string static_page2 = Settings.Servers.Static_Pages_Location + Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8) + "\\" + Resource.BibID + "_" + Resource.VID + ".html";

            if (File.Exists(static_page2))
            {
                File.Delete(static_page2);
            }

            // Delete the file from the database
            Engine_Database.Delete_SobekCM_Item(Resource.BibID, Resource.VID, true, "Deleted upon request by builder");

            // Delete from the solr/lucene indexes
            if (Settings.Servers.Document_Solr_Index_URL.Length > 0)
            {
                try
                {
                    Solr_Controller.Delete_Resource_From_Index(Settings.Servers.Document_Solr_Index_URL, Settings.Servers.Page_Solr_Index_URL, Resource.BibID, Resource.VID);
                }
                catch (Exception ee)
                {
                    OnError("Error deleting item from the Solr/Lucene index.  The index may not reflect this delete.", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                    OnError("Solr Error: " + ee.Message, Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                    return(false);
                }
            }

            // Delete the handled METS file and package
            Resource.Delete();
            return(true);
        }
コード例 #7
0
        /// <summary> Performs a delete from the database and moves all digital resource
        /// files into the recycle bin </summary>
        /// <param name="Resource"> Incoming digital resource object </param>
        /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns>
        public override bool DoWork(Incoming_Digital_Resource Resource)
        {
            // Read the METS and load the basic information before continuing
            Resource.Load_METS();
            SobekCM_Database.Add_Minimum_Builder_Information(Resource.Metadata);

            Resource.BuilderLogId = OnProcess("........Processing '" + Resource.Folder_Name + "'", "Standard", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, -1);

            SobekCM_Database.Builder_Clear_Item_Error_Log(Resource.BibID, Resource.VID, "SobekCM Builder");

            Resource.File_Root = Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8);
            string existing_folder = Settings.Servers.Image_Server_Network + Resource.File_Root + "\\" + Resource.VID;

            // Remove from the primary collection area
            try
            {
                if (Directory.Exists(existing_folder))
                {
                    // Make sure the delete folder exists
                    if (!Directory.Exists(Settings.Servers.Image_Server_Network + "\\RECYCLE BIN"))
                    {
                        Directory.CreateDirectory(Settings.Servers.Image_Server_Network + "\\RECYCLE BIN");
                    }

                    // Create the final directory
                    string final_folder = Settings.Servers.Image_Server_Network + "\\RECYCLE BIN\\" + Resource.File_Root + "\\" + Resource.VID;
                    if (!Directory.Exists(final_folder))
                    {
                        Directory.CreateDirectory(final_folder);
                    }

                    // Move each file
                    string[] delete_files = Directory.GetFiles(existing_folder);
                    foreach (string thisDeleteFile in delete_files)
                    {
                        string destination_file = final_folder + "\\" + Path.GetFileName(thisDeleteFile);
                        if (File.Exists(destination_file))
                            File.Delete(destination_file);
                        File.Move(thisDeleteFile, destination_file);
                    }
                }
            }
            catch (Exception ee)
            {
                OnError("Unable to move resource ( " + Resource.BibID + ":" + Resource.VID + " ) to deletes", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                OnError(ee.Message, Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                return false;
            }

            // Delete the static page
            string static_page1 = Settings.Servers.Static_Pages_Location + Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8) + "\\" + Resource.VID + "\\" + Resource.BibID + "_" + Resource.VID + ".html";
            if (File.Exists(static_page1))
            {
                File.Delete(static_page1);
            }
            string static_page2 = Settings.Servers.Static_Pages_Location + Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8) + "\\" + Resource.BibID + "_" + Resource.VID + ".html";
            if (File.Exists(static_page2))
            {
                File.Delete(static_page2);
            }

            // Delete the file from the database
            SobekCM_Database.Delete_SobekCM_Item(Resource.BibID, Resource.VID, true, "Deleted upon request by builder");

            // Delete from the solr/lucene indexes
            if (Settings.Servers.Document_Solr_Index_URL.Length > 0)
            {
                try
                {
                    Solr_Controller.Delete_Resource_From_Index(Settings.Servers.Document_Solr_Index_URL, Settings.Servers.Page_Solr_Index_URL, Resource.BibID, Resource.VID);
                }
                catch (Exception ee)
                {
                    OnError("Error deleting item from the Solr/Lucene index.  The index may not reflect this delete.", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                    OnError("Solr Error: " + ee.Message, Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId);
                    return false;
                }
            }

            // Delete the handled METS file and package
            Resource.Delete();
            return true;
        }