public Task <IInternalConnection> GetNewConnection(CancellationToken token, IEventNotifier eventNotifier)
        {
            Logger.Instance?.WriteLine($"{nameof(InternalConnectionFactory)}.{nameof(GetNewConnection)} start");

            var socket     = CreateSocket(token);
            var connection = CreateConnection(socket, token); //will dispose socket on fail

            connection.EventNotifier = eventNotifier;

            try
            {
                connection.Login();
                return(Task.FromResult((IInternalConnection)connection));
            }
            catch (AseException)
            {
                connection.Dispose();
                socket?.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                Logger.Instance?.WriteLine($"{nameof(InternalConnectionFactory)}.{nameof(GetNewConnection)} encountered exception: {ex}");
                connection.Dispose();
                socket?.Dispose();
                throw new OperationCanceledException();
            }
        }
Esempio n. 2
0
        private IInternalConnection FetchIdlePooledConnection(IEventNotifier eventNotifier)
        {
            var now = DateTime.UtcNow;

            while (_available.TryTake(out var connection))
            {
                if (ShouldRemoveAndReplace(connection, now))
                {
                    RemoveAndReplace(connection);
                    continue;
                }

                if (_parameters.PingServer && !connection.Ping())
                {
                    RemoveAndReplace(connection);
                    continue;
                }

                Logger.Instance?.WriteLine($"{nameof(FetchIdlePooledConnection)} returned idle connection");
                connection.EventNotifier = eventNotifier;
                return(connection);
            }

            Logger.Instance?.WriteLine($"{nameof(FetchIdlePooledConnection)} found no idle connection");
            return(null);
        }
        public void IEventNotifier <T>(IEventNotifier notifier, T @event)
        {
            notifier.Publish(@event);

            T[] events = new[] { @event };
            notifier.PublishMany(events);
        }
Esempio n. 4
0
 private static void RegisterEvents(IEventNotifier sourceClass)
 {
     sourceClass.StatusEvent  += StatusEventHandler;
     sourceClass.DebugEvent   += DebugEventHandler;
     sourceClass.ErrorEvent   += ErrorEventHandler;
     sourceClass.WarningEvent += WarningEventHandler;
 }
Esempio n. 5
0
        public void IEventNotifier(IEventNotifier notifier)
        {
            BadEvent @event = new BadEvent();

            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ notifier.Publish(@event) /**/;

            BadEvent[] events = new[] { @event };
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ notifier.PublishMany(events) /**/;
        }

        public void IEventNotifier(IEventPublisher publisher)
        {
            BadEvent @event = new BadEvent();

            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.Publish(6606, @event) /**/;
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.Publish(6606, @event, DateTime.Now) /**/;

            BadEvent[] events = new[] { @event };
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.PublishMany(6606, events) /**/;
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.PublishMany(6606, events, DateTime.Now) /**/;
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.ObsoleteAndUnboundedPublishMany(6606, events) /**/;
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.ObsoleteAndUnboundedPublishMany(6606, events, DateTime.Now) /**/;
        }

        public void RefiredEventEnvelopeTests()
        {
            BadEvent @event = new BadEvent();

            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ RefiredEventEnvelope.Create(6606, @event) /**/;
        }
Esempio n. 6
0
        public MongoEventStore(IMongoDatabase database, IEventNotifier notifier)
            : base(database)
        {
            Guard.NotNull(notifier, nameof(notifier));

            this.notifier = notifier;
        }
 public PviProcessor(IPviApplication pviApplication, IEventNotifier notifier, ISqlApi sqlApi)
 {
     _pviApplication     = pviApplication;
     _notifier           = notifier;
     _sqlApi             = sqlApi;
     _notifier.Shutdown += _notifier_Shutdown;
 }
Esempio n. 8
0
 public PollingSubscription(MongoEventStore eventStore, IEventNotifier eventNotifier, string streamFilter, string position)
 {
     this.position      = position;
     this.eventStore    = eventStore;
     this.eventNotifier = eventNotifier;
     this.streamFilter  = streamFilter;
 }
Esempio n. 9
0
 public ToDoEventHandlers(IIdentityMapper identityMapper, IEventNotifier notifier)
 {
     Contract.Requires <ArgumentNullException>(identityMapper != null, "identityMapper");
     Contract.Requires <ArgumentNullException>(notifier != null, "notifier");
     _identityMapper = identityMapper;
     this.notifier   = notifier;
 }
 /// <summary>
 /// Use this method to chain events between classes
 /// </summary>
 /// <param name="sourceClass"></param>
 private static void RegisterEvents(IEventNotifier sourceClass)
 {
     // Ignore: sourceClass.DebugEvent += OnDebugEvent;
     sourceClass.StatusEvent    += OnStatusEvent;
     sourceClass.ErrorEvent     += OnErrorEvent;
     sourceClass.WarningEvent   += OnWarningEvent;
     sourceClass.ProgressUpdate += ProgressChanged;
 }
Esempio n. 11
0
 public HomeController(ITestDependency testDependency,
     IContentManager contentManager,
     IEventNotifier eventNotifier)
 {
     _testDependency = testDependency;
     _contentManager = contentManager;
     _eventNotifier = eventNotifier;
 }
Esempio n. 12
0
 public HomeController(ITestDependency testDependency,
                       IContentManager contentManager,
                       IEventNotifier eventNotifier)
 {
     _testDependency = testDependency;
     _contentManager = contentManager;
     _eventNotifier  = eventNotifier;
 }
Esempio n. 13
0
 private static void RegisterEvents(IEventNotifier processingClass)
 {
     processingClass.DebugEvent     += OnDebugEvent;
     processingClass.StatusEvent    += OnStatusEvent;
     processingClass.ErrorEvent     += OnErrorEvent;
     processingClass.WarningEvent   += OnWarningEvent;
     processingClass.ProgressUpdate += OnProgressUpdate;
 }
Esempio n. 14
0
        public Bank(string name, IEventNotifier notifier, decimal CreditPercentage, Person person)
        {
            this.Name = name;
            Notifier  = notifier;

            this.person           = person;
            this.CreditPercentage = CreditPercentage;
        }
Esempio n. 15
0
 internal AseConnection(string connectionString, IConnectionPoolManager connectionPoolManager)
 {
     ConnectionString          = connectionString;
     InternalConnectionTimeout = 15; // Default to 15s as per the SAP AseClient http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc20066.1570100/doc/html/san1364409555258.html
     _connectionPoolManager    = connectionPoolManager;
     _isDisposed    = false;
     _eventNotifier = new EventNotifier(this);
 }
Esempio n. 16
0
 private static void RegisterEvents(IEventNotifier processingClass)
 {
     // processingClass.ProgressUpdate += ProcessingClass_ProgressUpdate;
     processingClass.DebugEvent   += ProcessingClass_DebugEvent;
     processingClass.ErrorEvent   += ProcessingClass_ErrorEvent;
     processingClass.StatusEvent  += ProcessingClass_StatusEvent;
     processingClass.WarningEvent += ProcessingClass_WarningEvent;
 }
Esempio n. 17
0
 /// <summary>Use this method to chain events between classes</summary>
 /// <param name="sourceClass"></param>
 private static void RegisterEvents(IEventNotifier sourceClass)
 {
     sourceClass.DebugEvent   += OnDebugEvent;
     sourceClass.StatusEvent  += OnStatusEvent;
     sourceClass.ErrorEvent   += OnErrorEvent;
     sourceClass.WarningEvent += OnWarningEvent;
     // sourceClass.ProgressUpdate += OnProgressUpdate;
 }
        public void IEventNotifier(IEventNotifier notifier)
        {
            GoodEvent @event = new GoodEvent();

            notifier.Publish(@event);

            GoodEvent[] events = new[] { @event };
            notifier.PublishMany(events);
        }
        public void Setup()
        {
            _notifier = Substitute.For<IEventNotifier>();
            _event = new GitHubPushEvent(_notifier);

            string text =
                File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SampleJson", "GitHubPushJson.txt"));
            _event.Handle(text);
        }
 public void Initialize(IEventNotifier notifier) {
     notifier.OnEvent<EntityAddedEvent>(evnt => {
         OnEntityCreated(evnt.Entity);
     });
     notifier.OnEvent<EntityRemovedEvent>(evnt => {
         OnEntityDestroyed(evnt.Entity);
     });
     notifier.OnEvent<AddedDataEvent>(OnDataAdded);
     notifier.OnEvent<RemovedDataEvent>(OnDataRemoved);
 }
 public EventHandledNotificationFlow(
     ILogger <EventHandledNotificationFlow> logger,
     IEventNotifier eventNotifier,
     IL l)
 {
     _logger        = logger;
     _eventNotifier = eventNotifier;
     _l             = l;
     _eventHandledNotifierContextSeq = new Subject <IEventNotifierContext>();
 }
Esempio n. 22
0
        public MongoEventStore(IMongoDatabase database, IEventNotifier notifier, IClock clock)
            : base(database)
        {
            Guard.NotNull(clock, nameof(clock));
            Guard.NotNull(notifier, nameof(notifier));

            this.clock = clock;

            this.notifier = notifier;
        }
Esempio n. 23
0
 public void Setup()
 {
     var to = new Jid("*****@*****.**");
     var from = new Jid("*****@*****.**");
     var msg = new Message(to, from, MessageType.groupchat, "slow clap");
     var eventObj = new GroupChatMessageArrived(msg, "testroom");
     _notifier = Substitute.For<IEventNotifier>();
     var handler = new GroupChatScriptHandler(_notifier);
     handler.ScriptFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "scripts");
     handler.Handle(eventObj);
 }
 public void Initialize(IEventNotifier notifier)
 {
     notifier.OnEvent <EntityAddedEvent>(evnt => {
         OnEntityCreated(evnt.Entity);
     });
     notifier.OnEvent <EntityRemovedEvent>(evnt => {
         OnEntityDestroyed(evnt.Entity);
     });
     notifier.OnEvent <AddedDataEvent>(OnDataAdded);
     notifier.OnEvent <RemovedDataEvent>(OnDataRemoved);
 }
        public VariableManager(Service service, IVariableApi variableApi, IEventNotifier notifier)
        {
            _logger      = new Log4netAdapter(LogManager.GetLogger("ServiceLogger"));
            _notifier    = notifier;
            _service     = service;
            _variableApi = variableApi;

            bool t;

            if (Boolean.TryParse(ConfigurationProvider.ShutdownTrigger, out t))
            {
                _triggerValue = t;
            }
        }
Esempio n. 26
0
        public void RunInitialize()
        {
            mongoDatabase = mongoClient.GetDatabase(Guid.NewGuid().ToString());

            var log = new SemanticLog(new ILogChannel[0], new ILogAppender[0], () => new JsonLogWriter(Formatting.Indented, true));

            eventConsumerInfos = new MongoEventConsumerInfoRepository(mongoDatabase);
            eventNotifier      = new DefaultEventNotifier(new InMemoryPubSub());
            eventStore         = new MongoEventStore(mongoDatabase, eventNotifier);
            eventConsumer      = new MyEventConsumer(NumEvents);

            eventReceiver = new EventReceiver(formatter, eventStore, eventNotifier, eventConsumerInfos, log);
            eventReceiver.Subscribe(eventConsumer);
        }
        /// <summary>
        /// Discovers allocatable event monitors, allocates them, and then initializes them with the
        /// given event notifier.
        /// </summary>
        /// <param name="eventNotifier">The event notifier to initialize the monitors with</param>
        private static void CreateEventMonitors(IEventNotifier eventNotifier) {
            var monitors =
                from assembly in AppDomain.CurrentDomain.GetAssemblies()
                from type in assembly.GetTypes()
                where typeof(IEventMonitor).IsAssignableFrom(type)
                where type.IsAbstract == false
                where type.IsInterface == false
                where type.IsClass == true
                where Attribute.IsDefined(type, typeof(EventMonitorAutomaticInstantiationAttribute))
                select (IEventMonitor)Activator.CreateInstance(type, /*nonPublic:*/ true);

            foreach (IEventMonitor monitor in monitors) {
                monitor.Initialize(eventNotifier);
            }
        }
Esempio n. 28
0
 public OrchardShell(
     IEnumerable <IRouteProvider> routeProviders,
     IRoutePublisher routePublisher,
     IEnumerable <IMiddlewareProvider> middlewareProviders,
     ShellSettings shellSettings,
     IServiceProvider serviceProvider,
     IEventNotifier eventNotifier)
 {
     _routeProviders      = routeProviders;
     _routePublisher      = routePublisher;
     _middlewareProviders = middlewareProviders;
     _shellSettings       = shellSettings;
     _serviceProvider     = serviceProvider;
     _eventNotifier       = eventNotifier;
 }
        private void RegisterEvents(IEventNotifier sourceClass, bool writeDebugEventsToLog = true)
        {
            if (writeDebugEventsToLog)
            {
                sourceClass.DebugEvent += DebugEventHandler;
            }
            else
            {
                sourceClass.DebugEvent += DebugEventHandlerConsoleOnly;
            }

            sourceClass.StatusEvent  += StatusEventHandler;
            sourceClass.ErrorEvent   += ErrorEventHandler;
            sourceClass.WarningEvent += WarningEventHandler;
            // sourceClass.ProgressUpdate += ProgressUpdateHandler;
        }
Esempio n. 30
0
        public PollingSubscription(
            IEventStore eventStore,
            IEventNotifier eventNotifier,
            IEventSubscriber eventSubscriber,
            string streamFilter,
            string position)
        {
            Guard.NotNull(eventStore, nameof(eventStore));
            Guard.NotNull(eventNotifier, nameof(eventNotifier));
            Guard.NotNull(eventSubscriber, nameof(eventSubscriber));

            this.position        = position;
            this.eventNotifier   = eventNotifier;
            this.eventStore      = eventStore;
            this.eventSubscriber = eventSubscriber;
            this.streamFilter    = streamFilter;

            streamRegex = new Regex(streamFilter);

            timer = new CompletionTimer(5000, async ct =>
            {
                try
                {
                    await eventStore.GetEventsAsync(async storedEvent =>
                    {
                        await eventSubscriber.OnEventAsync(this, storedEvent);

                        position = storedEvent.EventPosition;
                    }, ct, streamFilter, position);
                }
                catch (Exception ex)
                {
                    if (!ex.Is <OperationCanceledException>())
                    {
                        await eventSubscriber.OnErrorAsync(this, ex);
                    }
                }
            });

            notification = eventNotifier.Subscribe(streamName =>
            {
                if (streamRegex.IsMatch(streamName))
                {
                    timer.SkipCurrentDelay();
                }
            });
        }
Esempio n. 31
0
        protected int Days = 0;         // Days since account is created

        public Account(decimal sum, int percentage, Person owner, IEventNotifier notifier)
        {
            if (sum < 0)
            {
                throw new NegativeValue(nameof(sum));
            }

            Sum             = sum;
            this.percentage = percentage;
            id       = ++Counter;
            Notifier = notifier;


            Owner  = owner;
            accNum = accNumint;
            GetNextAccNumber();
        }
Esempio n. 32
0
        /// <summary>
        /// Discovers allocatable event monitors, allocates them, and then initializes them with the
        /// given event notifier.
        /// </summary>
        /// <param name="eventNotifier">The event notifier to initialize the monitors with</param>
        private static void CreateEventMonitors(IEventNotifier eventNotifier)
        {
            var monitors =
                from assembly in AppDomain.CurrentDomain.GetAssemblies()
                from type in assembly.GetTypes()
                where typeof(IEventMonitor).IsAssignableFrom(type)
                where type.IsAbstract == false
                where type.IsInterface == false
                where type.IsClass == true
                where Attribute.IsDefined(type, typeof(EventMonitorAutomaticInstantiationAttribute))
                select(IEventMonitor) Activator.CreateInstance(type, /*nonPublic:*/ true);

            foreach (IEventMonitor monitor in monitors)
            {
                monitor.Initialize(eventNotifier);
            }
        }
Esempio n. 33
0
        public EventReceiver(
            EventDataFormatter formatter,
            IEventStore eventStore,
            IEventNotifier eventNotifier,
            IEventConsumerInfoRepository eventConsumerInfoRepository,
            ISemanticLog log)
        {
            Guard.NotNull(log, nameof(log));
            Guard.NotNull(formatter, nameof(formatter));
            Guard.NotNull(eventStore, nameof(eventStore));
            Guard.NotNull(eventNotifier, nameof(eventNotifier));
            Guard.NotNull(eventConsumerInfoRepository, nameof(eventConsumerInfoRepository));

            this.log           = log;
            this.formatter     = formatter;
            this.eventStore    = eventStore;
            this.eventNotifier = eventNotifier;
            this.eventConsumerInfoRepository = eventConsumerInfoRepository;
        }
        public void IEventNotifier(IEventNotifier notifier)
        {
            BadEvent @event = new BadEvent();

            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ notifier.Publish(@event) /**/;

            BadEvent[] events = new[] { @event };
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ notifier.PublishMany(events) /**/;
        }

        public void IEventNotifier(IEventPublisher publisher)
        {
            BadEvent @event = new BadEvent();

            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.Publish(6606, @event) /**/;
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.Publish(6606, @event, DateTime.Now) /**/;

            BadEvent[] events = new[] { @event };
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.PublishMany(6606, events) /**/;
            /* EventTypeMissingEventAttribute(Tests.BadEvent) */ publisher.PublishMany(6606, events, DateTime.Now) /**/;
        }
Esempio n. 35
0
        public Account(decimal sum, int percentage, IEventNotifier notifier, Bank <Account> linkedbank, Person person)
        {
            Sum             = sum;
            this.percentage = percentage;
            id          = ++Counter;
            Notifier    = notifier;
            Linkedbank  = linkedbank;
            this.person = person;



            var    chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var    stringChars = new char[8];
            Random r           = new Random();

            for (int i = 0; i < stringChars.Length; i++)
            {
                stringChars[i] = chars[r.Next(chars.Length)];
            }

            AccountNumber = new String(stringChars);
        }
Esempio n. 36
0
        static void Main(string[] args)
        {
            IocContainer.Current.LoadConfiguration();
            
            MessageQueueServer gymMessageQueueServer = new MessageQueueServer(DomainList.Gym);
            MessageQueueServer badmintonMessageQueueServer = new MessageQueueServer(DomainList.Badminton);
            _msgQueueServers.Add(gymMessageQueueServer);
            _msgQueueServers.Add(badmintonMessageQueueServer);

            _notifier = new EmailNotifier();

            gymMessageQueueServer.ItemsEnqued += new Action<List<IMessage>>(messageQueueServer_ItemsEnqued);
            gymMessageQueueServer.ItemDequeued += new Action<List<IMessage>>(gymMessageQueueServer_ItemDequeued);

            IEventListener listener = new SzForumGymEventListener();
            listener.Listen();
            listener.EventHapped += Listener_EventHapped;
            listener.EventHapped += _notifier.SendNotification;
            gymMessageQueueServer.Start();
            Console.WriteLine("Press the Enter key to exit the program.");
            Console.ReadLine();
            Stop();
        }
Esempio n. 37
0
 public TweetSearcher(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
     MessageFilter = new Regex("(.*) tweet");
 }
 public GroupChatScriptHandler(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
Esempio n. 39
0
 public void Setup()
 {
     _notifier = Substitute.For<IEventNotifier>();
     _notifier.When(noti => noti.SendText(Arg.Any<string>())).Do(call => _botText = (string) call[0]);
 }
Esempio n. 40
0
 public GitHubMemberEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
Esempio n. 41
0
 public Counter(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
     MessageFilter = new Regex("(.*)");
 }
 public GitHubPullRequestReviewCommentEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
 protected void AddNotifierType(Type notificationChannelType, IEventNotifier notifier)
 {
     Notifiers.Add(notificationChannelType, notifier);
 }
 public GitHubWikiUpdateEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
Esempio n. 45
0
 public GitHubPushEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
 public GitHubPullRequestEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
Esempio n. 47
0
 public GitHubForkEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
 public GitHubCommitCommentEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
Esempio n. 49
0
 public GitHubIssueEvent(IEventNotifier eventNotifier)
 {
     _eventNotifier = eventNotifier;
 }
Esempio n. 50
0
 public HttpDataSender(IEventNotifier notifier, ServiceDefinition serviceDefinition, string relativeUri)
 {
     _notifier = notifier;
     _serviceDefinition = serviceDefinition;
     _relativeUri = relativeUri;
 }