예제 #1
0
 /// <summary>
 /// Check the Input Buffer for directories that are older than the time limit
 /// </summary>
 public static void CheckForInputBufferTimeLimits()
 {
     string[] directories = Directory.GetDirectories(IniData.InputDir);
     foreach (string dir in directories)
     {
         // Get the current directory list and delete the ones beyond the time limit
         DirectoryInfo dirInfo = new DirectoryInfo(dir);
         if (dirInfo.LastWriteTime < DateTime.Now.AddDays(-IniData.InputBufferTimeLimit))
         {
             FileHandling.DeleteDirectory(dir);
         }
     }
 }
예제 #2
0
        public void RunInputBufferScan(string directory, string job, StatusMonitorData monitorData)
        {
            // Add initial entry to status list
            StaticClass.StatusDataEntry(job, JobStatus.MONITORING_INPUT, JobType.TIME_START);

            // Monitor the Input Buffer job directory until it has the total number of consumed files
            string inputBufferJobDir   = StaticClass.IniData.InputDir;
            int    numberOfFilesNeeded = monitorData.NumFilesConsumed;

            if (Directory.Exists(inputBufferJobDir))
            {
                string inputJobFileDir = inputBufferJobDir + @"\" + job;

                // Register with the File Watcher class event and start its thread
                InputFileWatcherThread inputFileWatch = new InputFileWatcherThread(inputJobFileDir, numberOfFilesNeeded);
                if (inputFileWatch == null)
                {
                    StaticClass.Logger.LogError("Job Run Thread inputFileWatch failed to instantiate");
                }
                inputFileWatch.ThreadProc();

                // Wait for Input file scan to complete
                do
                {
                    if (StaticClass.ShutDownPauseCheck("Run Job") == true)
                    {
                        return;
                    }

                    Thread.Yield();
                }while (StaticClass.InputFileScanComplete[job] == false);

                StaticClass.Log(string.Format("Finished Input file scan for Job {0} at {1:HH:mm:ss.fff}",
                                              inputJobFileDir, DateTime.Now));

                // Add copying entry to status list
                StaticClass.StatusDataEntry(job, JobStatus.COPYING_TO_PROCESSING, JobType.TIME_START);

                // Move files from Input directory to the Processing directory, creating it first if needed
                FileHandling.CopyFolderContents(inputJobFileDir, directory, true, true);
            }
            else
            {
                StaticClass.Logger.LogError("Could not find Input Buffer Directory");
                throw new InvalidOperationException("Could not find Input Buffer Directory");
            }
        }
예제 #3
0
        /// <summary>
        /// Run the Job Completion file and directory handling
        /// </summary>
        /// <param name="job"></param>
        /// <param name="monitorData"></param>
        public void RunJobFileProcessing(string job, StatusMonitorData monitorData)
        {
            string repositoryDirectory    = StaticClass.IniData.RepositoryDir;
            string finishedDirectory      = StaticClass.IniData.FinishedDir;
            string errorDirectory         = StaticClass.IniData.ErrorDir;
            string processingBufferJobDir = StaticClass.IniData.ProcessingDir + @"\" + job;
            string dataXmlFileName        = StaticClass.IniData.ProcessingDir + @"\" + job + @"\" + "data.xml";

            StaticClass.StatusDataEntry(job, JobStatus.COPYING_TO_ARCHIVE, JobType.TIME_START);

            // Get the pass or fail data from the data.xml OverallResult result node
            XmlDocument dataXmlDoc = new XmlDocument();

            dataXmlDoc.Load(dataXmlFileName);
            XmlNode OverallResult = dataXmlDoc.DocumentElement.SelectSingleNode("/Data/OverallResult/result");
            string  passFail      = "Fail";

            if (OverallResult != null)
            {
                passFail = OverallResult.InnerText;
            }

            string repositoryJobDirectoryName = repositoryDirectory + @"\" + job;

            if ((OverallResult != null) && (passFail == "Pass"))
            {
                // If the Finished directory does not exist, create it
                string finishedJobDirectoryName = finishedDirectory + @"\" + monitorData.JobSerialNumber;
                if (!Directory.Exists(finishedJobDirectoryName))
                {
                    Directory.CreateDirectory(finishedJobDirectoryName);
                }

                // Copy the Transfered files to the Finished directory
                foreach (string file in monitorData.TransferedFileList)
                {
                    FileHandling.CopyFile(processingBufferJobDir + @"\" + file,
                                          finishedJobDirectoryName + @"\" + file);
                }

                // Move Processing Buffer Files to the Repository directory when passed
                FileHandling.CopyFolderContents(processingBufferJobDir, repositoryJobDirectoryName, true, true);
            }
            else // Send files to the Error Buffer and repository
            {
                // If the Error directory does not exist, create it
                string errorJobDirectoryName = errorDirectory + @"\" + monitorData.JobSerialNumber;
                if (!Directory.Exists(errorJobDirectoryName))
                {
                    Directory.CreateDirectory(errorJobDirectoryName);
                }

                // Copy the Transfered files to the Error directory
                foreach (string file in monitorData.TransferedFileList)
                {
                    if (File.Exists(processingBufferJobDir + @"\" + file))
                    {
                        FileHandling.CopyFile(processingBufferJobDir + @"\" + file,
                                              errorJobDirectoryName + @"\" + file);
                    }
                }

                // Move Processing Buffer Files to the Repository directory when failed
                FileHandling.CopyFolderContents(processingBufferJobDir, repositoryJobDirectoryName, true, true);
            }
        }