Пример #1
0
        /// <summary>
        /// Check if the Modeler has deposited the OverallResult entry in the job data.xml file
        /// </summary>
        /// <param name="dataXmlFileName"></param>
        /// <returns></returns>
        public bool OverallResultEntryCheck(string dataXmlFileName)
        {
            int numOfRetries = 0;

            do
            {
                // Check for data.xml file to be ready
                if (StaticClass.CheckFileReady(dataXmlFileName))
                {
                    // Check if the OverallResult node exists
                    XmlDocument dataXmlDoc = new XmlDocument();
                    dataXmlDoc.Load(dataXmlFileName);
                    XmlNode OverallResult = dataXmlDoc.DocumentElement.SelectSingleNode("/Data/OverallResult/result");
                    if (OverallResult != null)
                    {
                        return(true);
                    }

                    // Check for shutdown or pause
                    if (StaticClass.ShutDownPauseCheck("Overall Result Entry Check") == true)
                    {
                        return(false);
                    }

                    Thread.Sleep(StaticClass.FILE_WAIT_DELAY);
                }
            }while (numOfRetries++ < StaticClass.NUM_RESULTS_ENTRY_RETRIES);

            StaticClass.Log(string.Format("File {0} did not have Overall Result entry even after {1} retries at {2:HH:mm:ss.fff}",
                                          dataXmlFileName, StaticClass.NUM_RESULTS_ENTRY_RETRIES, DateTime.Now));
            return(false);
        }
        /// <summary>
        /// The Add or Change of files callback
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void OnCreated(object source, FileSystemEventArgs e)
        {
            string fullDirectory = e.FullPath;
            string jobDirectory  = fullDirectory.Replace(StaticClass.IniData.InputDir, "").Remove(0, 1);
            string jobFile       = jobDirectory.Substring(jobDirectory.LastIndexOf('\\') + 1);
            string job           = jobDirectory.Substring(0, jobDirectory.LastIndexOf('\\'));

            // If Number of files is not complete
            if (StaticClass.NumberOfInputFilesFound[job] < StaticClass.NumberOfInputFilesNeeded[job])
            {
                // Wait some for the file creation to complete
                Thread.Sleep(StaticClass.FILE_RECEIVE_WAIT);

                if (StaticClass.CheckFileReady(fullDirectory) == true)
                {
                    // Increment the number of Input Buffer Job files found
                    StaticClass.NumberOfInputFilesFound[job]++;

                    StaticClass.Log(string.Format("Input File Watcher detected {0} for Job {1} file {2} of {3} at {4:HH:mm:ss.fff}",
                                                  jobFile, job, StaticClass.NumberOfInputFilesFound[job], StaticClass.NumberOfInputFilesNeeded[job], DateTime.Now));

                    // If Number of Input files is complete
                    if (StaticClass.NumberOfInputFilesFound[job] == StaticClass.NumberOfInputFilesNeeded[job])
                    {
                        StaticClass.Log(string.Format("\nInput File Watcher detected Job {0} complete set of {1} files at {2:HH:mm:ss.fff}",
                                                      job, StaticClass.NumberOfInputFilesNeeded[job], DateTime.Now));

                        // Signal the Run thread that the Input Buffer files were found
                        StaticClass.InputFileScanComplete[job] = true;
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Get the data from the Job xml file
        /// </summary>
        /// <param name="jobXmlData"></param>
        /// <param name="monitorData"></param>
        /// <returns></returns>
        public StatusMonitorData GetJobXmlData(JobXmlData jobXmlData, StatusMonitorData monitorData)
        {
            // Wait for Job xml file to be ready
            string jobXmlFileName = jobXmlData.JobDirectory + @"\" + jobXmlData.XmlFileName;

            if (StaticClass.CheckFileReady(jobXmlFileName))
            {
                // Read Job xml file and get the top node
                XmlDocument jobXmlDoc = new XmlDocument();
                jobXmlDoc.Load(jobXmlFileName);

                XmlElement root    = jobXmlDoc.DocumentElement;
                string     TopNode = root.LocalName;

                // Get nodes for the number of files and names of files to transfer from Job .xml file
                XmlNode UnitNumberdNode = jobXmlDoc.DocumentElement.SelectSingleNode("/" + TopNode + "/listitem/value");
                XmlNode ConsumedNode    = jobXmlDoc.DocumentElement.SelectSingleNode("/" + TopNode + "/FileConfiguration/Consumed");
                XmlNode ProducedNode    = jobXmlDoc.DocumentElement.SelectSingleNode("/" + TopNode + "/FileConfiguration/Produced");
                XmlNode TransferedNode  = jobXmlDoc.DocumentElement.SelectSingleNode("/" + TopNode + "/FileConfiguration/Transfered");
                XmlNode ModelerNode     = jobXmlDoc.DocumentElement.SelectSingleNode("/" + TopNode + "/FileConfiguration/Modeler");

                // Assign then increment port number for this Job
                monitorData.JobPortNumber = StaticClass.IniData.StartPort + StaticClass.JobPortIndex++;

                // Get the modeler and number of files to transfer
                int NumFilesToTransfer = 0;
                monitorData.UnitNumber       = UnitNumberdNode.InnerText;
                monitorData.Modeler          = ModelerNode.InnerText;
                monitorData.NumFilesConsumed = Convert.ToInt32(ConsumedNode.InnerText);
                monitorData.NumFilesProduced = Convert.ToInt32(ProducedNode.InnerText);
                if (TransferedNode != null)
                {
                    NumFilesToTransfer = Convert.ToInt32(TransferedNode.InnerText);
                }
                monitorData.NumFilesToTransfer = NumFilesToTransfer;

                // Get the modeler and number of files to transfer
                StaticClass.Log($"Unit Number                    : {monitorData.UnitNumber}");
                StaticClass.Log($"Modeler                        : {monitorData.Modeler}");
                StaticClass.Log($"Num Files Consumed             : {monitorData.NumFilesConsumed}");
                StaticClass.Log($"Num Files Produced             : {monitorData.NumFilesProduced}");
                StaticClass.Log($"Num Files To Transfer          : {monitorData.NumFilesToTransfer}");
                StaticClass.Log($"Job Port Number                : {monitorData.JobPortNumber}");

                // Create the Transfered file list from the Xml file entries
                monitorData.TransferedFileList = new List <string>(NumFilesToTransfer);
                for (int i = 1; i < NumFilesToTransfer + 1; i++)
                {
                    string  transferFileNodeName = ("/" + TopNode + "/FileConfiguration/Transfered" + i.ToString());
                    XmlNode TransferedFileXml    = jobXmlDoc.DocumentElement.SelectSingleNode(transferFileNodeName);
                    monitorData.TransferedFileList.Add(TransferedFileXml.InnerText);
                    StaticClass.Log(string.Format("Transfer File{0}                 : {1}", i, TransferedFileXml.InnerText));
                }
            }
            else
            {
                StaticClass.Logger.LogError("File {0} is not available at {1:HH:mm:ss.fff}\n", jobXmlFileName, DateTime.Now);
            }

            return(monitorData);
        }