Beispiel #1
0
        public EventDefinitionInfo GetEventDefinition(string applicationName, string messageSignature, out bool added)
        {
            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentNullException("applicationName");
            }

            added = false;

            EventDefinitionInfo key = new EventDefinitionInfo(applicationName, messageSignature);

            if (!this.eventDefinitions.ContainsKey(key))
            {
                eventDefinitions.Add(key, key);
                added = true;
            }

            if (eventDefinitions[key].EventId == -1)
            {
                eventDefinitions[key].EventId = nextId;
                nextId++;
            }

            return(eventDefinitions[key]);
        }
        public override EventStore.EventDefinitionInfo GetEventDefinition(string applicationName, string messageSignature)
        {
            //if (this.eventDefinitions == null)
            //    this.eventDefinitions = new Dictionary<EventDefinitionInfo, EventDefinitionInfo>();

            EventDefinitionInfo retVal = new EventDefinitionInfo(applicationName, messageSignature);

            //if( eventDefinitions.ContainsKey(retVal))
            //{
            //    return eventDefinitions[retVal];
            //}

            DatabaseAgent agent = GetAgent();

            lock (working)
            {
                EventDefinitionSearchFilter filter = new EventDefinitionSearchFilter();
                filter.AddParameter(EventDefinitionFields.ApplicationName, applicationName);
                filter.AddParameter(EventDefinitionFields.MessageSignature, messageSignature);
                EventDefinition[] definitions = EventDefinition.SelectListWhere(filter, agent);

                EventDefinition definition = null;
                if (definitions.Length == 0)
                {
                    definition = EventDefinition.New(agent);
                    definition.ApplicationName  = applicationName;
                    definition.MessageSignature = messageSignature;

                    if (definition.Insert() != -1)
                    {
                        retVal.EventId = definition.EventId;
                        //this.eventDefinitions.Add(retVal, retVal);
                    }
                }
                else if (definitions.Length > 1)
                {
                    //LogManager.CurrentLog.AddEntry("The event data on {0}, in the database {1} is corrupt.  More than one definition was found with the same app name and signature", this.EventStoreLocation, this.EventStoreName);
                    Log(string.Format("The event data in the database {0} is corrupt.  More than one definition was found with the same app name ({1}) and signature ({2})", agent.ConnectionString, applicationName, messageSignature));
                }
                else if (definitions.Length == 1)
                {
                    retVal.EventId = definitions[0].EventId;
                    //if (!this.eventDefinitions.ContainsKey(retVal))
                    //    this.eventDefinitions.Add(retVal, retVal);
                }
            }
            return(retVal);
        }
        public override EventStore.EventDefinitionInfo GetEventDefinition(string applicationName, string messageSignature)
        {
            //if (this.eventDefinitions == null)
            //    this.eventDefinitions = new Dictionary<EventDefinitionInfo, EventDefinitionInfo>();

            EventDefinitionInfo retVal = new EventDefinitionInfo(applicationName, messageSignature);

            //if( eventDefinitions.ContainsKey(retVal))
            //{
            //    return eventDefinitions[retVal];
            //}

            DatabaseAgent agent = GetAgent();
            lock (working)
            {
                EventDefinitionSearchFilter filter = new EventDefinitionSearchFilter();
                filter.AddParameter(EventDefinitionFields.ApplicationName, applicationName);
                filter.AddParameter(EventDefinitionFields.MessageSignature, messageSignature);
                EventDefinition[] definitions = EventDefinition.SelectListWhere(filter, agent);

                EventDefinition definition = null;
                if (definitions.Length == 0)
                {
                    definition = EventDefinition.New(agent);
                    definition.ApplicationName = applicationName;
                    definition.MessageSignature = messageSignature;

                    if (definition.Insert() != -1)
                    {
                        retVal.EventId = definition.EventId;
                        //this.eventDefinitions.Add(retVal, retVal);
                    }
                }
                else if (definitions.Length > 1)
                {
                    //LogManager.CurrentLog.AddEntry("The event data on {0}, in the database {1} is corrupt.  More than one definition was found with the same app name and signature", this.EventStoreLocation, this.EventStoreName);
                    Log(string.Format("The event data in the database {0} is corrupt.  More than one definition was found with the same app name ({1}) and signature ({2})", agent.ConnectionString, applicationName, messageSignature));
                }
                else if (definitions.Length == 1)
                {
                    retVal.EventId = definitions[0].EventId;
                    //if (!this.eventDefinitions.ContainsKey(retVal))
                    //    this.eventDefinitions.Add(retVal, retVal);
                }
            }
            return retVal;
        }
Beispiel #4
0
        public EventDefinitionInfo GetEventDefinition(string applicationName, string messageSignature, out bool added)
        {
            if (string.IsNullOrEmpty(applicationName))
                throw new ArgumentNullException("applicationName");

            added = false;

            EventDefinitionInfo key = new EventDefinitionInfo(applicationName, messageSignature);
            if (!this.eventDefinitions.ContainsKey(key))
            {
                eventDefinitions.Add(key, key);
                added = true;
            }

            if (eventDefinitions[key].EventId == -1)
            {
                eventDefinitions[key].EventId = nextId;
                nextId++;

            }

            return eventDefinitions[key];
        }
Beispiel #5
0
        protected virtual void SetDefinitions(EventDefinitionInfo[] value)
        {
            this.eventDefinitions.Clear();
            foreach (EventDefinitionInfo def in value)
            {
                if( !this.eventDefinitions.ContainsKey(def) )
                    this.eventDefinitions.Add(def, def);

                if (def.EventId >= nextId)
                {
                    nextId = def.EventId + 1;
                }
            }
        }