Exemple #1
0
        /// <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;
                    }
                }
            }
        }