SobekCM.Builder_Library.Actionable_Builder_Source_Folder.Move_From_Inbound_To_Processing C# (CSharp) 메소드

Move_From_Inbound_To_Processing() 공개 메소드

Moves all packages from the inbound folder into the processing folder to queue them for loading into the library
public Move_From_Inbound_To_Processing ( string &Message ) : bool
Message string Message to be passed out if something occurred during this attempted move
리턴 bool
        public bool Move_From_Inbound_To_Processing(out string Message)
        {
            Message = String.Empty;

            // Get the directories
            string inboundFolder = Inbound_Folder;

            // Make sure the inbound directory exists
            if (!Directory.Exists(inboundFolder))
            {
                try
                {
                    Directory.CreateDirectory(inboundFolder);
                }
                catch
                {

                    Message = "Unable to create the non-existent inbound folder " + inboundFolder;
                    return false;
                }
            }

            // Make sure the processing directory exists
            if (!Directory.Exists(Processing_Folder))
            {
                try
                {
                    Directory.CreateDirectory(Processing_Folder);
                }
                catch
                {
                    Message = "Unable to create the non-existent processing folder " + Processing_Folder;
                    return false;
                }
            }

            // Make sure the failures directory exists
            if (!Directory.Exists(Failures_Folder))
            {
                try
                {
                    Directory.CreateDirectory(Failures_Folder);
                }
                catch
                {
                    Message = "Unable to create the non-existent failures folder " + Failures_Folder;
                    return false;
                }
            }

            // If there are loose METS here, move them into flat folders of the same name
            try
            {
                string[] looseMets = SobekCM_File_Utilities.GetFiles(inboundFolder, "*.mets*|*.xml");
                foreach (string thisLooseMetsXml in looseMets)
                {
                    string filename = Path.GetFileName(thisLooseMetsXml);
                    string filenameSplitter = Path.GetFileNameWithoutExtension(thisLooseMetsXml);
                    if (!Directory.Exists(inboundFolder + "\\" + filenameSplitter))
                        Directory.CreateDirectory(inboundFolder + "\\" + filenameSplitter);
                    if (File.Exists(inboundFolder + "\\" + filenameSplitter + "\\" + filename))
                        File.Delete(thisLooseMetsXml);
                    else
                        File.Move(thisLooseMetsXml, inboundFolder + "\\" + filenameSplitter + "\\" + filename);
                }
            }
            catch (Exception ee)
            {
                Message = "Error moving the package from " + inboundFolder + " to " + Processing_Folder + ":" + ee.Message;
                return false;
            }

            // Get the list of all terminal directories
            IEnumerable<string> terminalDirectories = Get_Terminal_SubDirectories(inboundFolder);

            // Create a digital resource object for each directory
            List<Incoming_Digital_Resource> inboundResources = terminalDirectories.Select(ThisDirectory => new Incoming_Digital_Resource(ThisDirectory, this)).ToList();

            // Step through each resource which came in
            bool returnVal = true;
            foreach (Incoming_Digital_Resource resource in inboundResources)
            {
                // Is this resource a candidate to move for continued processing?
                long resource_age = resource.AgeInTicks;
                if ((resource_age > Engine_ApplicationCache_Gateway.Settings.Builder.Complete_Package_Required_Aging) || ((resource_age > Engine_ApplicationCache_Gateway.Settings.Builder.METS_Only_Package_Required_Aging) && (resource.METS_Only_Package)))
                {
                    if (!resource.Move(Processing_Folder))
                    {
                        returnVal = false;
                    }
                }
                else
                {
                    Message = "Resource ( " + resource.Resource_Folder + " ) needs to age more before it will be processed";
                }
            }

            return returnVal;
        }