/// <summary> /// Method to start new jobs from the Input Buffer /// </summary> /// <param name="directory"></param> public void StartInputJob(string directory) { // Get data found in Job xml file JobXmlData jobXmlData = StaticClass.GetJobXmlFileInfo(directory, DirectoryScanType.INPUT_BUFFER); if (jobXmlData == null) { StaticClass.Logger.LogError("InputJobsScanThread GetJobXmlData failed"); } // Display job xml data found StaticClass.Log("Input Job : " + jobXmlData.Job); StaticClass.Log("Input Job Directory : " + jobXmlData.JobDirectory); StaticClass.Log("Input Job Serial Number : " + jobXmlData.JobSerialNumber); StaticClass.Log("Input Job Time Stamp : " + jobXmlData.TimeStamp); StaticClass.Log("Input Job Xml File : " + jobXmlData.XmlFileName); StaticClass.Log(string.Format("Started Input Job {0} executing Slot {1} at {2:HH:mm:ss.fff}", jobXmlData.Job, StaticClass.NumberOfJobsExecuting + 1, DateTime.Now)); // Create a thread to run the job, and then start the thread JobRunThread jobRunThread = new JobRunThread(jobXmlData, DirectoryScanType.INPUT_BUFFER); if (jobRunThread == null) { StaticClass.Logger.LogError("InputJobsScanThread jobRunThread failed to instantiate"); } jobRunThread.ThreadProc(); }
/// <summary> /// Run Input Buffer Scan /// </summary> /// <param name="jobDirectory"></param> public void RunInputBufferPartialJob(string jobDirectory) { JobXmlData jobXmlData = StaticClass.GetJobXmlFileInfo(jobDirectory, DirectoryScanType.INPUT_BUFFER); if (jobXmlData.XmlFileName != string.Empty) { // Now start the new job StartInputJob(jobDirectory); } }
/// <summary> /// Start a Processing directory job /// </summary> /// <param name="directory"></param> public void StartProcessingJob(string directory) { // Delete the data.xml file in the Processing directory if found string dataXmlFile = directory + @"\" + "data.xml"; if (File.Exists(dataXmlFile)) { File.Delete(dataXmlFile); } // Get data found in job Xml file JobXmlData jobXmlData = StaticClass.GetJobXmlFileInfo(directory, DirectoryScanType.PROCESSING_BUFFER); if (jobXmlData == null) { StaticClass.Logger.LogError("ProcessingJobsScanThread GetJobXmlData failed"); } // Display job xml Data found StaticClass.Log("Processing Job : " + jobXmlData.Job); StaticClass.Log("Processing Job Directory : " + jobXmlData.JobDirectory); StaticClass.Log("Processing Job Serial Number : " + jobXmlData.JobSerialNumber); StaticClass.Log("Processing Job Time Stamp : " + jobXmlData.TimeStamp); StaticClass.Log("Processing Job Xml File : " + jobXmlData.XmlFileName); StaticClass.Log(string.Format("Starting Processing directory Job {0} Executing Slot {1} at {2:HH:mm:ss.fff}", jobXmlData.Job, StaticClass.NumberOfJobsExecuting + 1, DateTime.Now)); // Create a thread to run the job, and then start the thread JobRunThread jobRunThread = new JobRunThread(jobXmlData, DirectoryScanType.PROCESSING_BUFFER); if (jobRunThread == null) { StaticClass.Logger.LogError("ProcessingJobsScanThread jobRunThread failed to instantiate"); } jobRunThread.ThreadProc(); }
/// <summary> /// Check for new Input Buffer jobs /// </summary> public void RunInputJobsFound() { if (StaticClass.NumberOfJobsExecuting < StaticClass.IniData.ExecutionLimit) { if (StaticClass.GetTotalNumberOfJobs() > 0) { string job = StaticClass.GetJobFromList(StaticClass.CurrentJobIndex); if (job != string.Empty) { StaticClass.Log(string.Format("Input Job handler got Job {0} from list index {1} at {2:HH:mm:ss.fff}", job, StaticClass.CurrentJobIndex, DateTime.Now)); // Check for complete jobs and run them first string jobDirectory = StaticClass.IniData.InputDir + @"\" + job; if (StaticClass.CheckIfJobFilesComplete(jobDirectory) == true) { StaticClass.Log(string.Format("Starting Input Job {0} index {1} at {2:HH:mm:ss.fff}", jobDirectory, StaticClass.CurrentJobIndex, DateTime.Now)); // Start the new completely ready Job StartInputJob(jobDirectory); // Delete the job from the list and display the new list StaticClass.DeleteJobFromList(StaticClass.CurrentJobIndex); } else // Partial Job handling { // Skip Partial Job if there are more in the list int lastIndex = StaticClass.GetLastIndex(); if (StaticClass.CurrentJobIndex < lastIndex) { StaticClass.Log(string.Format("Input Job scanner skipping Job {0} index {1} as not ready at {2:HH:mm:ss.fff}", job, StaticClass.CurrentJobIndex, DateTime.Now)); StaticClass.CurrentJobIndex++; } else // Run last job in list { // Wait for the job xml file JobXmlData jobXmlData = StaticClass.GetJobXmlFileInfo(jobDirectory, DirectoryScanType.INPUT_BUFFER); if (jobXmlData.XmlFileName != string.Empty) { StaticClass.Log(string.Format("Starting Partial Input Job {0} index {1} at {2:HH:mm:ss.fff}", jobDirectory, StaticClass.CurrentJobIndex, DateTime.Now)); // Start the new partial job StartInputJob(jobDirectory); // Delete the job from the list StaticClass.DeleteJobFromList(StaticClass.CurrentJobIndex); } // If there is a skipped partial job, start it next by setting index to previous one int previousJobIndex = StaticClass.GetPreviousIndex(); if ((previousJobIndex > 0) && (StaticClass.CurrentJobIndex > previousJobIndex)) { StaticClass.CurrentJobIndex = previousJobIndex; } } } } } else { if (CurrentJobIndex != StaticClass.CurrentJobIndex) { StaticClass.Log(string.Format("Input Jobs Scanner Resetting Current Job Index from {0} to {1} at {2:HH:mm:ss.fff}", StaticClass.CurrentJobIndex, 1, DateTime.Now)); CurrentJobIndex = StaticClass.CurrentJobIndex = 1; } } } }