Ejemplo n.º 1
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;
        }