Esempio n. 1
0
        protected static void Alert(string subject, string text)
        {
            // Send email to XBot Admin.
            string contact = XTRMObject.getDictionaryEntry("AdminMail", "*****@*****.**");

            XTRMObject.Notify(contact, null, subject, text);
        }
Esempio n. 2
0
        public static bool IsDictionaryLoaded()
        {
            bool bValid = false;

            if (XTRMObject.getDictionaryEntry("LoadDisposition").Equals("1"))
            {
                bValid = true;
                Console.Write("\nConfig ID={0}.\n", getDictionaryEntry("ConfigID"));
            }
            return(bValid);
        }
Esempio n. 3
0
        //static String odbcConnectionString = XTRMObject.getDictionaryEntry("ODBCConnectString");
        static public SqlConnection connectXDB(string connectString = "")
        {
            SqlConnection thisConnection = null;

            if (connectString.Equals(""))
            {
                connectString = XTRMObject.getDictionaryEntry("TaskConnectString");
            }
            try
            {
                thisConnection = new SqlConnection(connectString);
            }
            catch (SqlException) { }
            catch (Exception) { }

            return(thisConnection);
        }
        // Make Full Pass Through Processing.
        public int Run(int pass = 0, bool logBeat = false)
        {
            int rc = 0;

            bool initiatorStatus = getDictionaryEntry("ProcessJobs", "Y").Equals("Y");

            // Validate Connection.
            if (validateConnection(MasterConnection))
            {
                switch (pass)
                {
                // Pass 1:  Evaluate current run states.
                //          Review Active Jobs.
                case 1:
                    //myLog.WriteEntry("Starting Pass 0");
                    if (CheckStatus() >= 0)
                    //Initialize();
                    //if (bInitialized)
                    {
                        // Inspect each running job.
                        //XLogger(1200, 0, string.Format("Jobs Executing={0}; Allowed={1}", runningJobs.Count, jobsAllowed));
                        foreach (XTRMJob thisJob in runningJobs)
                        {
                            //rc = thisJob.Initialize(thisJob.jobSerial);
                            //if (rc >= 0)
                            //{
                            if (thisJob.jobStatus == 1)
                            {
                                int lActiveTasks = 0;
                                // Inspect each running task (should be one at most).
                                foreach (XTRMTask thisTask in thisJob.tasks)
                                {
                                    // Refresh Task.
                                    //rc = thisTask.Initialize(thisTask.taskSerial);
                                    //if (rc >= 0)
                                    //{

                                    /*
                                     * if (thisTask.taskStatus > 9)
                                     * {
                                     *  // Done.
                                     *  // Start next one if no other active tasks.
                                     *  //thisJob.tasks.Remove(thisTask);
                                     * }
                                     */
                                    if (thisTask.taskStatus == 1)
                                    {
                                        lActiveTasks++;
                                        if (false)
                                        {
                                            // If not original task object, then let's check closer.
                                            // This can happen if XExecutive gets re-initialized with running jobs.
                                            if (!thisTask.taskOriginator)
                                            {
                                                if (thisTask.taskPID != -1)
                                                {
                                                    // Future, Check the [time]-limit?
                                                    // Check the PID; If exists, then wait.
                                                    try
                                                    {
                                                        Process thisProcess = Process.GetProcessById(thisTask.taskPID);
                                                        if (thisProcess.HasExited)
                                                        {
                                                            thisTask.taskStatus = 95;       // Complete; disposition unknown.
                                                            rc = thisTask.Save();
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        // Mark the task as complete.
                                                        thisTask.taskStatus = 91;       // Complete; disposition unknown.
                                                        rc = thisTask.Save();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        // Other status values ignored (for now) - should not be pending!
                                        //XLogger(1201, 0, string.Format("Unexpected TaskStatus Value={0}", thisTask.taskStatus));
                                        // If result < 0, then mark job for termination!
                                        if (thisTask.taskResult < 0)
                                        {
                                            XLogger(1201, 0, string.Format("Job #{0} Terminated Due to Task #{1} Result={2}.", thisJob.jobSerial, thisTask.taskSerial, thisTask.taskResult));
                                            thisJob.jobStatus = 98;     // Terminated.
                                            thisJob.jobStop   = DateTime.Now.ToString();
                                            lActiveTasks      = 1;
                                            rc = thisJob.Save();
                                            if (rc < 0)
                                            {
                                                XLogger(1227, 0, string.Format("thisJob.Save() Failed; rc={0}", rc));
                                            }
                                            // Send email to XBot Admin.
                                            string contact = XTRMObject.getDictionaryEntry("AdminMail", "*****@*****.**");
                                            Notify(contact, null, string.Format("Job #{0}/{1} Failed {2}", thisJob.jobSerial, thisTask.taskSerial, thisJob.jobName), string.Format("Exec={0}; Path={1}; Result={2}.", thisTask.taskExecutable, thisTask.taskPath, thisTask.taskResult));
                                        }
                                    }
                                    //}
                                    //else
                                    //{
                                    // Error on Initialize() of XTask.
                                    //    XLogger(1202, 0, string.Format("XTask.Initialize() Failure; rc={0}", rc));
                                    //}
                                }
                                //if (thisJob.tasks.Count == 0)
                                if (lActiveTasks == 0)
                                {
                                    // Look for next task (within this job).
                                    List <int> pendingTaskSerials = InventoryPendingTasks(thisJob);
                                    if (pendingTaskSerials.Count <= 0)
                                    {
                                        // Job Complete
                                        thisJob.jobStatus = 99;
                                        thisJob.jobStop   = DateTime.Now.ToString();
                                        rc = thisJob.Save();
                                        if (rc < 0)
                                        {
                                            XLogger(1203, 0, string.Format("thisJob.Save() Failed; rc={0}", rc));
                                        }
                                        //runningJobs.Remove(thisJob);
                                    }
                                    else
                                    {
                                        XTRMTask pendingTask = new XTRMTask(false);
                                        if (pendingTaskSerials[0] < 1)
                                        {
                                            // Error
                                            XLogger(1204, 0, "No Pending TaskSerials");
                                        }
                                        rc = pendingTask.Initialize(pendingTaskSerials[0]);
                                        if (rc >= 0)
                                        {
                                            //thisJob.tasks.Add(pendingTask);
                                            //runningTasks.Add(pendingTask);

                                            rc = pendingTask.Start();
                                            if (rc < 0)
                                            {
                                                XLogger(1205, 0, string.Format("pendingTask.Start() Failed; Serial={0}; rc={1}", pendingTask.taskSerial, rc));
                                                // Send email to XBot Admin.
                                                string contact = XTRMObject.getDictionaryEntry("AdminMail", "*****@*****.**");
                                                Notify(contact, null, string.Format("Job Task #{0}/{1} {2} Could Not Start", thisJob.jobSerial, pendingTask.taskSerial, pendingTask.taskName), string.Format("Exec={0}; Path={1}.", pendingTask.taskExecutable, pendingTask.taskPath));
                                            }
                                            else
                                            {
                                                XLogger(1206, 0, string.Format("Task #{0} Started", pendingTask.taskSerial));
                                            }
                                            //thisJob.tasks.Add(pendingTask);
                                        }
                                        else
                                        {
                                            // Error
                                            XLogger(1207, 0, string.Format("XTask.Initialize() Failure for Pending Task; rc={0}", rc));
                                        }
                                    }
                                }
                                else
                                {
                                    // Wait for other pending task(s) - should not happen!
                                    //XLogger(1208, 0, "Waiting for Job Task(s) to Complete.");
                                }
                                //}
                                //else
                                //{
                                // Error on Initialize() of XJob.
                                //    XLogger(1209, 0, string.Format("XJob.Initialize() Failure; rc={0}", rc));
                                //}
                            }
                        }
                        // Purge Jobs that have completed! jobStatus >= 9
                        bool purgeFlag = true;
                        while (purgeFlag)
                        {
                            purgeFlag = false;
                            foreach (XTRMJob thisJob in runningJobs)
                            {
                                if (thisJob.jobStatus >= 9)
                                {
                                    runningJobs.Remove(thisJob);
                                    purgeFlag = true;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        // Error!
                        XLogger(1210, 0, "Executive Not Initialized in Pass 0");
                    }
                    break;

                // Pass 0:  Start New Jobs.
                //          Review Pending Jobs.
                //          Spawn Candidate Jobs.
                case 0:
                    if (initiatorStatus)
                    {
                        //myLog.WriteEntry("Starting Pass 1");
                        // If we are under the MPR, then start a new job.
                        if (runningJobs.Count < jobsAllowed)
                        {
                            rc = LoadCandidateJobs();
                            if (rc >= 0)
                            {
                                foreach (int thisJobSerial in candidateJobs)
                                {
                                    // Mark the Job as Started.
                                    XTRMJob newJob = new XTRMJob(false);
                                    if (runningJobs.Count < jobsAllowed)
                                    {
                                        rc = newJob.Initialize(thisJobSerial);
                                        if (rc >= 0)
                                        {
                                            newJob.jobStatus = 1;
                                            newJob.jobStart  = DateTime.Now.ToString();
                                            //newJob.jobStop = DBNull.Value.ToString();
                                            rc = newJob.Save();
                                            if (rc >= 0)
                                            {
                                                // Job Started; first task will start in next call to case 0:
                                                runningJobs.Add(newJob);
                                                XLogger(1222, 0, string.Format("Job #{0} Started; Executing={1}; Allowed={2}", newJob.jobSerial, runningJobs.Count, jobsAllowed));
                                            }
                                            else
                                            {
                                                // Error
                                                XLogger(1211, 0, string.Format("newJob.Save() Failure; rc={0}", rc));
                                            }
                                        }
                                        else
                                        {
                                            // Initialize Error (XJob).
                                            XLogger(1212, 0, string.Format("newJob.Initialize() Failure; rc = {0}", rc));
                                        }
                                    }
                                    else
                                    {
                                        XLogger(1213, 0, "Waiting for Runnng Jobs To Complete");
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                // Error
                                XLogger(1214, 0, string.Format("Failure in LoadCandidateJobs(); rc={0}", rc));
                            }
                        }
                        else
                        {
                            //XLogger(1215, 0, "Waiting for Capacity");
                            // Wait for capacity.
                        }
                    }
                    break;
                }
            }
            else
            {
                myLog.WriteEntry("Master XDB Connection Failure");
            }
            return(rc);
        }
Esempio n. 5
0
 public static string GetConfigID()
 {
     return(XTRMObject.getDictionaryEntry("ConfigID"));
 }
Esempio n. 6
0
        public int IncludeConfig(string inFile, Dictionary <String, String> myConfig, int lVariant = 0, bool bDeep = false)
        {
            //
            // Consume XML to create the XLator object.
            // if bDeep is false, then ONLY do this object.
            // if bDeep is true, then also do recursive objects.
            int                         rc            = -1;
            XmlTextReader               reader        = null;
            string                      connectString = XTRMObject.getDictionaryEntry("TaskConnectString");
            string                      outerXML;
            int                         lElementType       = 0;
            XDictionaryLoader           myDictionaryLoader = new XDictionaryLoader();
            Dictionary <String, String> elementAttributes;

            try
            {
                // Load the reader with the data file and ignore all white space nodes.
                reader = new XmlTextReader(inFile);
                reader.WhitespaceHandling = WhitespaceHandling.None;
                // Parse the file and display each of the nodes.
                bool bResult = reader.Read();
                while (bResult)
                {
                    bool bProcessed = false;
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        string elementName = reader.Name;
                        switch (elementName.ToUpper())
                        {
                        case "BASECONFIG":
                            outerXML           = reader.ReadOuterXml();
                            myDictionaryLoader = new XDictionaryLoader();
                            myConfig           = myDictionaryLoader.Augment(myConfig, outerXML);
                            bProcessed         = true;
                            break;

                        case "WITHCONFIG":
                            outerXML = reader.ReadOuterXml();
                            myDictionaryLoader.Augment(myConfig, outerXML);
                            bProcessed = true;
                            break;

                        case "EVENTFILTER":
                            outerXML = reader.ReadOuterXml();
                            XTRMEvent thisFilter = (XTRMEvent)XTRMEvent.consumeXML(myConfig, outerXML, 2, true);
                            eventFilters.Add(thisFilter);
                            bProcessed = true;
                            break;

                        case "XTRMEVENT":
                            outerXML = reader.ReadOuterXml();
                            XTRMEvent thisEvent = (XTRMEvent)XTRMEvent.consumeXML(myConfig, outerXML, 1, true);
                            events.Add(thisEvent);
                            bProcessed = true;
                            break;

                        case "XTRMWORKFLOW":
                            outerXML = reader.ReadOuterXml();
                            XTRMWorkFlow thisFlow = (XTRMWorkFlow)XTRMWorkFlow.consumeXML(myConfig, outerXML, 1, true);
                            workflows.Add(thisFlow);
                            bProcessed = true;
                            break;
                        }
                        if (!bProcessed)
                        {
                            // May wish to get all the  attributes here for new elements!
                            elementAttributes = new Dictionary <String, String>();
                            if (reader.HasAttributes)
                            {
                                reader.MoveToFirstAttribute();
                                for (int i = 0; i < reader.AttributeCount; i++)
                                {
                                    elementAttributes.Add(reader.Name, reader.Value);
                                    reader.MoveToNextAttribute();
                                }
                                if (elementAttributes.ContainsKey("Name"))
                                {
                                    // Try to instantiate the XEvent Object!
                                    name = elementAttributes["Name"];
                                }
                                reader.MoveToElement();
                            }
                            // Need to see if we are interested in this element!
                            //string elementName = reader.Name;
                            switch (elementName.ToUpper())
                            //switch (reader.Name)
                            {
                            case "EVENTFOLDER":
                                lElementType = 1;
                                bResult      = reader.Read();
                                break;

                            case "XTRM":
                                // Advance into Elements!
                                reader.MoveToContent();
                                bResult = reader.Read();
                                break;

                            default:
                                bResult = reader.Read();
                                break;
                            }
                        }
                        break;

                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.ProcessingInstruction:
                        bResult = reader.Read();
                        break;

                    case XmlNodeType.Comment:
                        bResult = reader.Read();
                        break;

                    case XmlNodeType.EndElement:
                        bResult = reader.Read();
                        break;

                    case XmlNodeType.Text:
                        switch (lElementType)
                        {
                        case 1:             // EventFolder
                            eventFolders.Add(ResolveText(reader.Value, XDictionary));
                            break;

                        default:
                            break;
                        }
                        bResult = reader.Read();
                        break;

                    default:
                        bResult = reader.Read();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                exCount_XML++;
                XLogger(2402, -1, string.Format("XLator::IncludeConfig(); ConfigFile={0}; Message={1}", configFile, ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }


            return(rc);
        }
Esempio n. 7
0
        // Make Full Pass Through Processing.
        public int Run(int pass = 0, bool logBeat = false)
        {
            int rc = 0;

            // Determine what we are currently processing!
            eventStatus      = getDictionaryEntry("ProcessEvents", "Y").Equals("Y");
            commandStatus    = getDictionaryEntry("ProcessCommands", "Y").Equals("Y");
            dataStatus       = getDictionaryEntry("ProcessData", "Y").Equals("Y");
            maxEventFileSize = Convert.ToInt32(getDictionaryEntry("MaxEventFileSize", "1024000"));

            // Validate Connection.
            if (validateConnection(MasterConnection))
            {
                exCount_XML = 0;
                // Populate activeEvents from XDB.
                switch (pass)
                {
                // Pass 0:  Parse the XLator Configs.
                case 0:
                    if (eventStatus)
                    {
                        if ((!bConfigLoaded) | (XTRMObject.getDictionaryEntry("ReloadConfig", "Y").Equals("Y")))
                        {
                            // Get the XLator Event Folder (from the dictionary).
                            //string strPendingEventFolder = XLib.XDB_Objects.XObject.getDictionaryEntry("XLatorPendingEventFolder");
                            // May be a list of config files!
                            //string strPendingEventFolder = myConfigLoader.configFile;
                            myConfigLoaders.Clear();
                            foreach (string thisConfig in myConfigs)
                            {
                                XTRMRoot thisLoader = new XTRMRoot(ResolveText(thisConfig, XDictionary));
                                thisLoader.ParseConfig(2, true);
                                myConfigLoaders.Add(thisLoader);
                            }
                            bConfigLoaded = true;
                        }
                        // Commit.
                    }
                    break;

                // Pass 2:  Process all active XDB events against each of the loaders.
                case 2:
                    if (eventStatus)
                    {
                        // Loop through all XDB events
                        // Run query to get active XDB events.
                        rc = LoadActiveEvents();
                        if (rc < 0)
                        {
                            XLogger(1102, -1, string.Format("Run::LoadActiveEvents() Failure; Pass={0}; rc={1}", pass, rc));
                        }
                        XTRMEvent thisEvent = new XTRMEvent(false);
                        // For each event:
                        foreach (int thisEventSerial in activeEvents)
                        {
                            int eventState = 0;
                            //XEvent thisEvent = new XEvent();
                            rc = thisEvent.Initialize(thisEventSerial);
                            // For each loader:
                            if (rc >= 0)
                            {
                                // XEvent Retrieved Successfully!
                                foreach (XTRMRoot thisLoader in myConfigLoaders)
                                {
                                    XTRMMatchMaker myEventChecker = new XTRMMatchMaker();
                                    rc = myEventChecker.ProcessActiveEvent(thisLoader, thisEvent);
                                    if (rc >= 0)
                                    {
                                        eventState += rc;
                                    }
                                    else
                                    {
                                        XLogger(1103, -1, string.Format("Run::XTRMEvent.ProcessActiveEvent() Failure; Pass={0}; UUID={1}; rc={2}", pass, thisEvent.eventUUID, rc));
                                    }
                                }
                                thisEvent.eventState = eventState;
                                rc = thisEvent.Save();
                                if (rc >= 0)
                                {
                                    XLogger(1124, eventState, string.Format("Event={0}; {1}", rc, thisEvent.banner), thisEvent.eventUser);
                                }
                                else
                                {
                                    XLogger(1123, -1, string.Format("Unable to Save() Active Event; rc={2}", pass, thisEvent.eventUUID, rc));
                                }
                            }
                            else
                            {
                                // Error!
                                XLogger(1104, -1, string.Format("Run::XEvent.Initialize() Failure; Pass={0}; UUID={1}; rc={2}", pass, thisEvent.eventUUID, rc));
                            }
                            thisEvent.Clear();
                        }
                    }
                    break;
                }
            }
            else
            {
                myLog.WriteEntry("Master XDB Connection Failure");
            }
            return(rc);
        }
        /*
         * public int startIteration()
         * {
         *  int rc = 0;
         *  int interval = 60;
         *  try
         *  {
         *      XObject.XDictionary = createDictionary();
         *      myConfigs = XLib.XDB_Objects.XObject.getDictionaryEntries("XLatorConfigFile");
         *      interval = Convert.ToInt32(getConfig(XObject.XDictionary, "MonitorInterval", "60"));
         *  }
         *  catch (Exception ex)
         *  {
         *      interval = 60;
         *  }
         *  return interval;
         * }
         * */
        // Make Full Pass Through Processing.
        public int Run(int pass = 0, bool logBeat = false)
        {
            int rc = 0;

            // Determine what we are currently processing!
            eventStatus      = getDictionaryEntry("ProcessEvents", "Y").Equals("Y");
            commandStatus    = getDictionaryEntry("ProcessCommands", "Y").Equals("Y");
            dataStatus       = getDictionaryEntry("ProcessData", "Y").Equals("Y");
            maxEventFileSize = Convert.ToInt32(getDictionaryEntry("MaxEventFileSize", "1024000"));

            //Process execProcess = Process.GetCurrentProcess();

            /*
             * if (logBeat)
             * {
             *  XLogger(1131, 0, string.Format("Heartbeat: Current={0}; Peak={1}; WSS={2}; TotProc={3};", execProcess.VirtualMemorySize64, execProcess.PeakVirtualMemorySize64, execProcess.WorkingSet64, execProcess.TotalProcessorTime));
             * }
             *
             * // Check memory.
             * // Check registry.
             * if (execProcess.VirtualMemorySize64 > 500000000)
             * {
             *  XLogger(1137, 0, string.Format("Forcing Garbage Collection: Current={0}; Peak={1}; WSS={2}; TotProc={3};", execProcess.VirtualMemorySize64, execProcess.PeakVirtualMemorySize64, execProcess.WorkingSet64, execProcess.TotalProcessorTime));
             *  GC.Collect();
             *  XLogger(1138, 0, string.Format("After Garbage Collection: Current={0}; Peak={1}; WSS={2}; TotProc={3};", execProcess.VirtualMemorySize64, execProcess.PeakVirtualMemorySize64, execProcess.WorkingSet64, execProcess.TotalProcessorTime));
             *  if (execProcess.VirtualMemorySize64 > 300000000)
             *  {
             *      XLogger(1139, 0, string.Format("Re-Instantiating: Current={0}; Peak={1}; WSS={2}; TotProc={3};", execProcess.VirtualMemorySize64, execProcess.PeakVirtualMemorySize64, execProcess.WorkingSet64, execProcess.TotalProcessorTime));
             *
             *      return -1;
             *  }
             * }
             * */

            // Validate Connection.
            if (validateConnection(MasterConnection))
            {
                exCount_XML = 0;
                // Populate activeEvents from XDB.
                switch (pass)
                {
                // Pass 0:  Parse the XLator Configs.
                case 0:
                    if (eventStatus)
                    {
                        if ((!bConfigLoaded) | (XTRMObject.getDictionaryEntry("ReloadConfig", "Y").Equals("Y")))
                        {
                            // Get the XLator Event Folder (from the dictionary).
                            //string strPendingEventFolder = XLib.XDB_Objects.XObject.getDictionaryEntry("XLatorPendingEventFolder");
                            // May be a list of config files!
                            //string strPendingEventFolder = myConfigLoader.configFile;
                            myConfigLoaders.Clear();
                            foreach (string thisConfig in myConfigs)
                            {
                                XTRMRoot thisLoader = new XTRMRoot(ResolveText(thisConfig, XDictionary));
                                thisLoader.ParseConfig(2, true);
                                myConfigLoaders.Add(thisLoader);
                            }
                            bConfigLoaded = true;
                        }
                        // Commit.
                    }
                    break;

                // Pass 1:  Process any pending events referenced by any of the loaders.
                case 1:
                    if (eventStatus)
                    {
                        foreach (XTRMRoot thisLoader in myConfigLoaders)
                        {
                            //myConfigLoader.ParseConfig(thisConfig, 2, true);
                            foreach (string strPendingEventFolder in thisLoader.eventFolders)
                            {
                                rc = ProcessPendingEvents(strPendingEventFolder);
                                if (rc < 0)
                                {
                                    XLogger(1100, -1, string.Format("Run::ProcessPendingEvents() Failure; Pass={0}; rc={1}; folder={2}", pass, rc, strPendingEventFolder));
                                }
                            }
                            //myConfigLoaders.Add(myConfigLoader);
                        }
                        if (exCount_XML > 0)
                        {
                            //Console.Write("XML Parser Exceptions\n");
                            XLogger(1101, exCount_XML, string.Format("Run::XML Parser xceptions > 0; Pass={0}; rc={1}", pass, rc));
                        }
                    }
                    break;
                }
            }
            else
            {
                myLog.WriteEntry("Master XDB Connection Failure");
            }
            return(rc);
        }
Esempio n. 9
0
        public int ParseConfig(string configFile, bool bDeep = false)
        {
            //
            // Consume XML to create the XFSEntity objects.
            // if bDeep is false, then ONLY do this object.
            // if bDeep is true, then also do recursive objects.
            XmlTextReader reader = null;

            int                         rc            = -1;
            string                      connectString = XTRMObject.getDictionaryEntry("TaskConnectString");
            string                      outerXML;
            int                         lElementType       = 0;
            XDictionaryLoader           myDictionaryLoader = new XDictionaryLoader();
            Dictionary <String, String> elementAttributes;

            entities.Clear();
            try
            {
                // Load the reader with the data file and ignore all white space nodes.
                reader = new XmlTextReader(configFile);
                reader.WhitespaceHandling = WhitespaceHandling.None;
                // Parse the file and display each of the nodes.
                bool bResult = reader.Read();
                while (bResult)
                {
                    bool bProcessed = false;
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        string elementName = reader.Name;
                        switch (elementName.ToUpper())
                        {
                        case "XFSENTITY":
                            outerXML = reader.ReadOuterXml();
                            XTRMFSEntity thisEntity = (XTRMFSEntity)XTRMFSEntity.consumeXML(outerXML, 1, true);
                            entities.Add(thisEntity);
                            bProcessed = true;
                            break;
                        }
                        if (!bProcessed)
                        {
                            // May wish to get all the  attributes here for new elements!
                            elementAttributes = new Dictionary <String, String>();
                            if (reader.HasAttributes)
                            {
                                reader.MoveToFirstAttribute();
                                for (int i = 0; i < reader.AttributeCount; i++)
                                {
                                    //reader.GetAttribute(i);
                                    elementAttributes.Add(reader.Name, reader.Value);
                                    reader.MoveToNextAttribute();
                                }
                                if (elementAttributes.ContainsKey("Tag"))
                                {
                                    agentTag = elementAttributes["Tag"];
                                }
                                if (elementAttributes.ContainsKey("Source"))
                                {
                                    agentSource = elementAttributes["Source"];
                                }
                                if (elementAttributes.ContainsKey("User"))
                                {
                                    agentUser = elementAttributes["User"];
                                }
                                if (elementAttributes.ContainsKey("EventPath"))
                                {
                                    agentEventPath = elementAttributes["EventPath"];
                                }
                                reader.MoveToElement();
                            }
                            // Need to see if we are interested in this element!
                            //string elementName = reader.Name;
                            switch (elementName.ToUpper())
                            {
                            case "XFILEAGENTCONFIG":
                                // Advance into Elements!
                                reader.MoveToContent();
                                bResult = reader.Read();
                                break;

                            default:
                                bResult = reader.Read();
                                break;
                            }
                        }
                        break;

                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.ProcessingInstruction:
                        //writer.WriteProcessingInstruction(reader.Name, reader.Value);
                        bResult = reader.Read();
                        break;

                    case XmlNodeType.Comment:
                        //writer.WriteComment(reader.Value);
                        bResult = reader.Read();
                        break;

                    case XmlNodeType.EndElement:
                        //writer.WriteFullEndElement();
                        bResult = reader.Read();
                        break;

                    case XmlNodeType.Text:
                        //Console.Write(reader.Value);
                        switch (lElementType)
                        {
                        default:
                            break;
                        }
                        bResult = reader.Read();
                        break;

                    default:
                        bResult = reader.Read();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                exCount_XML++;
                XLogger(2400, -1, string.Format("XTRMFileAgent::parseConfig(); ConfigFile={0}; Message={1}", configFile, ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }


            return(rc);
        }