Exemplo n.º 1
0
        private void Init()
        {
            NoticeDelegate       = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            promotable = new NpgsqlPromotableSinglePhaseNotification(this);
        }
Exemplo n.º 2
0
        private void HandleIncoming(UdpClient UdpClient, IPEndPoint RemoteIP, UPnPHeaders Headers)
        {
            switch (Headers.Verb)
            {
            case "M-SEARCH":
                NotificationEventHandler h = this.OnSearch;
                if (!(h is null))
                {
                    try
                    {
                        h(this, new NotificationEventArgs(this, Headers, (IPEndPoint)UdpClient.Client.LocalEndPoint, RemoteIP));
                    }
                    catch (Exception ex)
                    {
                        this.RaiseOnError(ex);
                    }
                }
                break;

            case "NOTIFY":
                h = this.OnNotification;
                if (!(h is null))
                {
                    try
                    {
                        h(this, new NotificationEventArgs(this, Headers, (IPEndPoint)UdpClient.Client.LocalEndPoint, RemoteIP));
                    }
                    catch (Exception ex)
                    {
                        this.RaiseOnError(ex);
                    }
                }
                break;
            }
        }
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
        /// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
        /// </summary>
        /// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
        public NpgsqlConnection(String ConnectionString)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

            NpgsqlConnectionStringBuilder builder = cache[ConnectionString];

            if (builder == null)
            {
                settings = new NpgsqlConnectionStringBuilder(ConnectionString);
            }
            else
            {
                settings = builder.Clone();
            }

            LogConnectionString();

            NoticeDelegate       = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);

            // Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and
            // http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
            RSACryptoServiceProvider.UseMachineKeyStore = true;

            promotable = new NpgsqlPromotableSinglePhaseNotification(this);
        }
        public SubscriptionDlg()
        {
            InitializeComponent();

            m_SessionNotification      = new NotificationEventHandler(Session_Notification);
            m_SubscriptionStateChanged = new SubscriptionStateChangedEventHandler(Subscription_StateChanged);
            m_PublishStatusChanged     = new EventHandler(Subscription_PublishStatusChanged);
        }
        public SubscriptionDlg()
        {
            InitializeComponent();

            m_SessionNotification = new NotificationEventHandler(Session_Notification);
            m_SubscriptionStateChanged = new SubscriptionStateChangedEventHandler(Subscription_StateChanged);
            m_PublishStatusChanged = new EventHandler(Subscription_PublishStatusChanged);
        }
Exemplo n.º 6
0
 public DxfSectionReaderBase(
     IDxfStreamReader reader,
     DxfDocumentBuilder builder,
     NotificationEventHandler notification = null)
 {
     this._reader       = reader;
     this._builder      = builder;
     this._notification = notification;
 }
Exemplo n.º 7
0
        protected virtual void OnNotificationEvent(Event e)
        {
            NotificationEventHandler handler = NotificationEvent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemplo n.º 8
0
            public void Alarm()
            {
                NotificationEventHandler handeler = userevent;

                if (userevent != null)
                {
                    handeler(this, new NotifyEventArgs("Welcome to the team"));
                }
            }
Exemplo n.º 9
0
        public void OnNotificationEvent(UnconfirmedEventNotification notification)
        {
            NotificationEventHandler handler = NotificationEvent;

            if (handler != null)
            {
                handler(notification);
            }
        }
Exemplo n.º 10
0
        public void SetupNotification(string tableName, NotificationEventHandler changeEventHandler)
        {
            Interlocked.Increment(ref _NotificationCount);
            bool success = SetupNotification(2, tableName, changeEventHandler);

            if (!success)
            {
                _Logger?.LogError(string.Format("Failed initial notification setup with dbnotify service.\nNotificationServerList: {0} \nTableName: {1}", string.Join(", ", _NotificationServers), tableName));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes the object with default values.
        /// </summary>
        public NotificationMessageListCtrl()
        {
            MaxMessageCount = 10;

            InitializeComponent();
            SetColumns(m_ColumnNames);

            ItemsLV.Sorting       = SortOrder.Descending;
            m_SessionNotification = new NotificationEventHandler(Session_Notification);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes the object with default values.
        /// </summary>
        public NotificationMessageListCtrl()
        {
            MaxMessageCount = 10;

            InitializeComponent();                        
			SetColumns(m_ColumnNames);

            ItemsLV.Sorting = SortOrder.Descending;
            m_SessionNotification = new NotificationEventHandler(Session_Notification);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Read a dxf document in a stream
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="notification">Notification handler, sends any message or notification about the reading process.</param>
        /// <returns></returns>
        public static CadDocument Read(Stream stream, NotificationEventHandler notification = null)
        {
            CadDocument doc = null;

            using (DxfReader reader = new DxfReader(stream, notification))
            {
                doc = reader.Read();
            }

            return(doc);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
        /// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
        /// </summary>
        /// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
        public NpgsqlConnection(String ConnectionString)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

            connection_string = NpgsqlConnectionString.ParseConnectionString(ConnectionString);
            LogConnectionString();

            NoticeDelegate       = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            CertificateValidationCallbackDelegate = new CertificateValidationCallback(DefaultCertificateValidationCallback);
            CertificateSelectionCallbackDelegate  = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
            PrivateKeySelectionCallbackDelegate   = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);
        }
Exemplo n.º 15
0
        public PrototypeDevice()
        {
            DcClient = new DeviceHive.HttpClient(Resources.GetString(Resources.StringResources.CloudUrl), DateTime.MinValue, RequestTimeout);

            Initializing += new ConnectEventHandler(PreInit);
            Connecting += new ConnectEventHandler(PreConnect);
            Connected += new ConnectEventHandler(PostConnect);
            BeforeCommand += new CommandEventHandler(PreProcessCommand);
            AfterCommand += new CommandEventHandler(PostProcessCommand);
            BeforeNotification += new NotificationEventHandler(PreProcessNotification);
            AfterNotification += new NotificationEventHandler(PostProcessNotification);
            Disconnected += new SimpleEventHandler(OnDisconnect);
            LastTemp = 0.0f;
        }
Exemplo n.º 16
0
            public static string GetKey(string table, NotificationEventHandler eventHandler)
            {
                string result;

                if (eventHandler == null)
                {
                    result = string.Concat(table);
                }
                else
                {
                    result = string.Concat(table, "|", eventHandler.Method.DeclaringType.AssemblyQualifiedName);
                }
                return(result);
            }
Exemplo n.º 17
0
        /// <summary>
        /// Starts the specified session.
        /// </summary>
        /// <param name="session">The session.</param>
        public void Start(Session session)
        {
            m_NotificationEventHandler = new NotificationEventHandler(Session_Notification);
            session.Notification      += m_NotificationEventHandler;

            Subscription subscription = m_subscription = new Subscription();

            subscription.PublishingInterval         = m_samplingRate;
            subscription.KeepAliveCount             = 10;
            subscription.LifetimeCount              = 100;
            subscription.MaxNotificationsPerPublish = 50000;
            subscription.PublishingEnabled          = false;
            subscription.TimestampsToReturn         = TimestampsToReturn.Neither;
            subscription.Priority = 1;
            subscription.DisableMonitoredItemCache = true;

            session.AddSubscription(subscription);
            subscription.Create();

            DateTime start = HiResClock.UtcNow;

            for (int ii = 0; ii < m_itemCount; ii++)
            {
                MonitoredItem monitoredItem = new MonitoredItem((uint)ii);

                monitoredItem.StartNodeId      = new NodeId((uint)((1 << 24) + ii), 2);
                monitoredItem.AttributeId      = Attributes.Value;
                monitoredItem.SamplingInterval = -1;
                monitoredItem.Filter           = null;
                monitoredItem.QueueSize        = 0;
                monitoredItem.DiscardOldest    = true;
                monitoredItem.MonitoringMode   = MonitoringMode.Reporting;

                subscription.AddItem(monitoredItem);
            }

            subscription.ApplyChanges();
            DateTime end = HiResClock.UtcNow;

            ReportMessage("Time to add {1} items {0}ms.", (end - start).TotalMilliseconds, m_itemCount);

            start = HiResClock.UtcNow;
            subscription.SetPublishingMode(true);
            end = HiResClock.UtcNow;

            ReportMessage("Time to emable publishing {0}ms.", (end - start).TotalMilliseconds);
        }
Exemplo n.º 18
0
        private void Init()
        {
            NoticeDelegate       = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);
            CertificateValidationCallbackDelegate     = new CertificateValidationCallback(DefaultCertificateValidationCallback);
            CertificateSelectionCallbackDelegate      = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
            PrivateKeySelectionCallbackDelegate       = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);
            ValidateRemoteCertificateCallbackDelegate = new ValidateRemoteCertificateCallback(DefaultValidateRemoteCertificateCallback);

            // Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and
            // http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
            RSACryptoServiceProvider.UseMachineKeyStore = true;

            promotable = new NpgsqlPromotableSinglePhaseNotification(this);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Register "you" as someone he's interested in a particular topic
 /// </summary>
 /// <param name="you">the object insterested in receiving notifications</param>
 /// <param name="type">the topic "you" is interested in</param>
 /// <param name="priority">lower values mean that among all the subscribers of a particular topic, "you" will be notified first.
 /// Contrarly, big values means that "you" will be notified at last</param>
 /// <param name="action">the action to perform</param>
 /// <returns>the number of subscribers of the specified topic</returns>
 public int SubscribeFor(object you, int type, int priority, NotificationEventHandler action)
 {
     lock (this.Subscribers)
     {
         SortedList <int, SubscriptionInfo> subscriberForType = null;
         if (this.Subscribers.ContainsKey(type))
         {
             subscriberForType = this.Subscribers[type];
         }
         else
         {
             subscriberForType      = new SortedList <int, SubscriptionInfo>();
             this.Subscribers[type] = subscriberForType;
         }
         subscriberForType.Add(priority, new SubscriptionInfo(you, action));
         return(subscriberForType.Count);
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
        /// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
        /// </summary>
        /// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
        public NpgsqlConnection(String ConnectionString)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

            LoadConnectionStringBuilder(ConnectionString);

            NoticeDelegate       = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);
            CertificateValidationCallbackDelegate     = new CertificateValidationCallback(DefaultCertificateValidationCallback);
            CertificateSelectionCallbackDelegate      = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
            PrivateKeySelectionCallbackDelegate       = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);
            ValidateRemoteCertificateCallbackDelegate = new ValidateRemoteCertificateCallback(DefaultValidateRemoteCertificateCallback);

            // Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and
            // http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
            RSACryptoServiceProvider.UseMachineKeyStore = true;

            promotable = new NpgsqlPromotableSinglePhaseNotification(this);
        }
        public async Task Test_CanListenUnlisten(string channelName, bool sendSampleNotification)
        {
            using (ManualResetEvent notificationReceived = new ManualResetEvent(false))
                using (NpgsqlConnection conn = await OpenDbConnectionAsync(ConnectionString))
                {
                    NotificationEventHandler neh = (s, e)
                                                   => notificationReceived.Set();

                    Assert.IsFalse(conn.IsListening(channelName));

                    await conn.ListenAsync(channelName, neh);

                    Assert.IsTrue(conn.IsListening(channelName));

                    if (sendSampleNotification)
                    {
                        using (NpgsqlConnection connSend = await OpenDbConnectionAsync(ConnectionString))
                        {
                            await connSend.NotifyAsync(channelName,
                                                       withinTx : null);

                            await connSend.CloseAsync();
                        }

                        conn.Wait();
                        notificationReceived.WaitOne();
                    }
                    else
                    {
                        await Task.Delay(500);
                    }

                    await conn.UnlistenAsync(channelName, neh);

                    Assert.IsFalse(conn.IsListening(channelName));

                    await conn.CloseAsync();
                }
        }
Exemplo n.º 22
0
        private bool SetupNotification(int attemptsCount, string tableName, NotificationEventHandler changeEventHandler)
        {
            bool               result = false;
            string             key    = NotificationClient.GetKey(tableName, changeEventHandler);
            NotificationClient notificationClient;

            while (!_NotificationClients.TryGetValue(key, out notificationClient))
            {
                notificationClient = new NotificationClient()
                {
                    TableName = tableName, EventHandler = changeEventHandler
                };
                if (AddNotificationClient(notificationClient))
                {
                    break;
                }
            }
            result = SetupNotification(notificationClient, attemptsCount);
            if (!result)
            {
                AddNotificationToRepair(notificationClient);
            }
            return(result);
        }
Exemplo n.º 23
0
 public DwgDocumentBuilder(CadDocument document, DwgReaderFlags flags, NotificationEventHandler notification = null)
     : base(document, notification)
 {
     this.Flags = flags;
 }
Exemplo n.º 24
0
 protected CadReaderBase(Stream stream, NotificationEventHandler notification) : this(notification)
 {
     this._fileStream = new StreamIO(stream);
 }
 public void SetupNotification(string tableName, NotificationEventHandler changeEventHandler)
 {
     Interlocked.Increment(ref _NotificationCount);
     bool success = SetupNotification(2, tableName, changeEventHandler);
     if (!success)
         _Logger?.LogError(string.Format("Failed initial notification setup with dbnotify service.\nNotificationServerList: {0} \nTableName: {1}", string.Join(", ", _NotificationServers), tableName));
 }
 private bool SetupNotification(int attemptsCount, string tableName, NotificationEventHandler changeEventHandler)
 {
     bool result = false;
     string key = NotificationClient.GetKey(tableName, changeEventHandler);
     NotificationClient notificationClient;
     while (!_NotificationClients.TryGetValue(key, out notificationClient))
     {
         notificationClient = new NotificationClient() { TableName = tableName, EventHandler = changeEventHandler };
         if (AddNotificationClient(notificationClient))
             break;
     }
     result = SetupNotification(notificationClient, attemptsCount);
     if (!result)
     {
         AddNotificationToRepair(notificationClient);
     }
     return result;
 }
Exemplo n.º 27
0
 public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder, NotificationEventHandler notification = null)
     : base(reader, builder, notification)
 {
 }
Exemplo n.º 28
0
        /// <summary>
        /// Tests the session reconnect.
        /// </summary>
        private bool DoReconnectTest()
        {
            double increment = MaxProgress / 6;
            double position  = 0;

            bool success = true;

            lock (m_messages)
            {
                m_messages.Clear();
            }

            int currentKeepAlive = Session.KeepAliveInterval;
            List <Subscription>      subscriptions       = new List <Subscription>();
            KeepAliveEventHandler    keepAliveHandler    = new KeepAliveEventHandler(Session_Reconnect);
            NotificationEventHandler notificationHandler = new NotificationEventHandler(Session_Notification);

            try
            {
                Session.KeepAlive    += keepAliveHandler;
                Session.Notification += notificationHandler;

                for (int publishingInterval = 1000; publishingInterval <= 10000; publishingInterval += 1000)
                {
                    Subscription subscription = new Subscription();

                    subscription.MaxMessageCount    = 100;
                    subscription.LifetimeCount      = 100;
                    subscription.KeepAliveCount     = 10;
                    subscription.PublishingEnabled  = true;
                    subscription.PublishingInterval = publishingInterval;

                    MonitoredItem monitoredItem = new MonitoredItem();

                    monitoredItem.StartNodeId      = VariableIds.Server_ServerStatus_CurrentTime;
                    monitoredItem.AttributeId      = Attributes.Value;
                    monitoredItem.SamplingInterval = -1;
                    monitoredItem.QueueSize        = 0;
                    monitoredItem.DiscardOldest    = true;

                    subscription.AddItem(monitoredItem);
                    Session.AddSubscription(subscription);
                    subscription.Create();
                    subscriptions.Add(subscription);
                }

                m_keepAliveCount          = 0;
                Session.KeepAliveInterval = 1000;
                Log("Setting keep alive interval to {0}ms.", Session.KeepAliveInterval);

                int testDuration = 3000;

                for (int ii = 0; ii < 6; ii++)
                {
                    Session.Reconnect();

                    Log("Session reconnected. KeepAlives={0}", m_keepAliveCount);

                    if (m_errorEvent.WaitOne(testDuration, false))
                    {
                        Log("Unexpected error waiting for session keep alives. {0}", m_error.ToLongString());
                        return(false);
                    }

                    position += increment;
                    ReportProgress(position);
                }
            }
            finally
            {
                Session.RemoveSubscriptions(subscriptions);
                Session.KeepAliveInterval = currentKeepAlive;
                Session.KeepAlive        -= keepAliveHandler;
                Session.Notification     -= notificationHandler;
            }

            ReportProgress(MaxProgress);

            lock (m_messages)
            {
                foreach (KeyValuePair <uint, List <uint> > entry in m_messages)
                {
                    entry.Value.Sort();

                    for (int ii = 0; ii < entry.Value.Count - 1; ii++)
                    {
                        if (entry.Value[ii + 1] - entry.Value[ii] > 1)
                        {
                            Log("Missing message. Subscription={0}, SequenceNumber={1}-{2}", entry.Key, entry.Value[ii] + 1, entry.Value[ii + 1] - 1);
                        }

                        if (entry.Value[ii + 1] == entry.Value[ii])
                        {
                            // Log("Duplicate message. Subscription={0}, SequenceNumber={1}", entry.Key, entry.Value[ii]);
                        }
                    }
                }
            }

            return(success);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Runs the test for all of the browse roots.
        /// </summary>
        public override bool Run(ServerTestCase testcase, int iteration)
        {
            try
            {
                LockServer();
                if (ReadOnlyTests)
                {
                    Log("WARNING: TestCase {0} skipped because client could not acquire a lock on the Server.", testcase.Name);
                    return true;
                }

                Iteration = iteration;

                // need fetch nodes used for the test if not already available.
                if (AvailableNodes.Count == 0)
                {
                    if (!GetNodesInHierarchy())
                    {
                        return false;
                    }
                }

                // get the writeable variables.
                if (WriteableVariables.Count == 0)
                {
                    if (!GetWriteableVariablesInHierarchy())
                    {
                        Log("WARNING: No writeable variables found.");
                        Log(WriteTest.g_WriteableVariableHelpText);
                        return true;
                    }
                }

                // do main test.
                NotificationEventHandler handler = new NotificationEventHandler(Session_Notification);

                try
                {
                    Session.Notification += handler;

                    bool result = true;

                    switch (testcase.Name)
                    {
                        case "Deadband":
                        {
                            if (!DoDeadbandTest(false))
                            {
                                Log("WARNING: Re-doing Deadband test to check if random timing glitches were the cause of failure.");
                                result = DoDeadbandTest(false);
                                break;
                            }

                            return true;
                        }

                        case "ModifyDeadband":
                        {
                            if (!DoDeadbandTest(true))
                            {
                                Log("WARNING: Re-doing ModifyDeadband test to check if random timing glitches were the cause of failure.");
                                result = DoDeadbandTest(true);
                                break;
                            }

                            return true;
                        }

                        case "QueueSize":
                        {
                            if (!DoQueueSizeTest(false))
                            {
                                Log("WARNING: Re-doing QueueSize test to check if random timing glitches were the cause of failure.");
                                result = DoQueueSizeTest(false);
                                break;
                            }

                            return true;
                        }

                        case "ModifyQueueSize":
                        {
                            if (!DoQueueSizeTest(true))
                            {
                                Log("WARNING: Re-doing ModifyQueueSize test to check if random timing glitches were the cause of failure.");
                                result = DoQueueSizeTest(true);
                                break;
                            }

                            return true;
                        }

                        case "ModifySamplingInterval":
                        {
                            if (!DoSamplingIntervalTest(true))
                            {
                                Log("WARNING: Re-doing ModifySamplingInterval test to check if random timing glitches were the cause of failure.");
                                result = DoSamplingIntervalTest(true);
                                break;
                            }

                            return true;
                        }

                        default:
                        {
                            if (!DoSamplingIntervalTest(true))
                            {
                                Log("WARNING: Re-doing SamplingInterval test to check if random timing glitches were the cause of failure.");
                                result = DoSamplingIntervalTest(false);
                                break;
                            }

                            return true;
                        }
                    }

                    if (!result && m_writeDelayed)
                    {
                        Log("WARNING: Test skipped because the system is likely overloaded and cannot process the requests fast enough.");
                        result = true;
                    }

                    return result;
                }
                finally
                {
                    Session.Notification -= handler;
                }
            }
            finally
            {
                UnlockServer();
            }
        }        
Exemplo n.º 30
0
 internal SubscriptionInfo(object source, NotificationEventHandler action)
 {
     this.Source = source;
     this.Action = action;
 }
Exemplo n.º 31
0
        /// <summary>
        /// Starts the specified session.
        /// </summary>
        /// <param name="session">The session.</param>
        public void Start(Session session)
        {
            m_NotificationEventHandler = new NotificationEventHandler(Session_Notification);
            session.Notification += m_NotificationEventHandler;

            Subscription subscription = m_subscription = new Subscription();

            subscription.PublishingInterval = m_samplingRate;
            subscription.KeepAliveCount = 10;
            subscription.LifetimeCount = 100;
            subscription.MaxNotificationsPerPublish = 50000;
            subscription.PublishingEnabled = false;
            subscription.TimestampsToReturn = TimestampsToReturn.Neither;
            subscription.Priority = 1;
            subscription.DisableMonitoredItemCache = true;

            session.AddSubscription(subscription);
            subscription.Create();

            DateTime start = HiResClock.UtcNow;

            for (int ii = 0; ii < m_itemCount; ii++)
            {
                MonitoredItem monitoredItem = new MonitoredItem((uint)ii);

                monitoredItem.StartNodeId = new NodeId((uint)((1<<24) + ii), 2);
                monitoredItem.AttributeId = Attributes.Value;
                monitoredItem.SamplingInterval = -1;
                monitoredItem.Filter = null;
                monitoredItem.QueueSize = 0;
                monitoredItem.DiscardOldest = true;
                monitoredItem.MonitoringMode = MonitoringMode.Reporting;

                subscription.AddItem(monitoredItem);
            }

            subscription.ApplyChanges();
            DateTime end = HiResClock.UtcNow;

            ReportMessage("Time to add {1} items {0}ms.", (end - start).TotalMilliseconds, m_itemCount);

            start = HiResClock.UtcNow;
            subscription.SetPublishingMode(true);
            end = HiResClock.UtcNow;

            ReportMessage("Time to emable publishing {0}ms.", (end - start).TotalMilliseconds);
        }
Exemplo n.º 32
0
 private CadReaderBase(NotificationEventHandler notification)
 {
     this.OnNotificationHandler = notification;
 }
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
        /// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
        /// </summary>
        /// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
        public NpgsqlConnection(String ConnectionString)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");
            
            connection_string = NpgsqlConnectionString.ParseConnectionString(ConnectionString);
            LogConnectionString();

            NoticeDelegate = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            CertificateValidationCallbackDelegate = new CertificateValidationCallback(DefaultCertificateValidationCallback);
            CertificateSelectionCallbackDelegate = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
            PrivateKeySelectionCallbackDelegate = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);
        }
 public NotificationEventHandlerTests()
 {
     _sut = new NotificationEventHandler();
 }
Exemplo n.º 35
0
 protected override void ExecuteApplicationSpecificStart()
 {
     ExWatson.Register("E12IIS");
     StoreSession.UseRPCContextPool = true;
     UMClientCommonBase.InitializePerformanceCounters(false);
     OwaEventRegistry.RegisterEnum(typeof(Importance));
     OwaEventRegistry.RegisterEnum(typeof(Sensitivity));
     OwaEventRegistry.RegisterEnum(typeof(AddressOrigin));
     OwaEventRegistry.RegisterEnum(typeof(FlagAction));
     OwaEventRegistry.RegisterEnum(typeof(TaskStatus));
     OwaEventRegistry.RegisterEnum(typeof(BusyType));
     OwaEventRegistry.RegisterEnum(typeof(ResponseType));
     OwaEventRegistry.RegisterEnum(typeof(StoreObjectType));
     OwaEventRegistry.RegisterEnum(typeof(EmailAddressIndex));
     OwaEventRegistry.RegisterEnum(typeof(NavigationNodeGroupSection));
     OwaEventRegistry.RegisterEnum(typeof(InstantMessagingTypeOptions));
     OwaEventRegistry.RegisterEnum(typeof(NavigationModule));
     OwaEventRegistry.RegisterEnum(typeof(DefaultFolderType));
     OwaEventRegistry.RegisterEnum(typeof(RecipientBlockType));
     OwaEventRegistry.RegisterEnum(typeof(RecipientJunkEmailContextMenuType));
     OwaEventRegistry.RegisterEnum(typeof(SharingLevel));
     OwaEventRegistry.RegisterEnum(typeof(DenyResponseType));
     OwaEventRegistry.RegisterEnum(typeof(AddressBookItemEventHandler.ItemTypeToPeople));
     OwaEventRegistry.RegisterStruct(typeof(RecipientInfo));
     OwaEventRegistry.RegisterStruct(typeof(DeleteItemInfo));
     OwaEventRegistry.RegisterStruct(typeof(ReminderInfo));
     OwaEventRegistry.RegisterHandler(typeof(ProxyEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(PendingRequestEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(ProxyToEwsEventHandler));
     NotificationEventHandler.Register();
     ClientCacheEventHandler.Register();
     DocumentLibraryEventHandler.Register();
     DocumentEventHandler.Register();
     DatePickerEventHandler.Register();
     ReadADOrgPersonEventHandler.Register();
     ListViewEventHandler.Register();
     TreeEventHandler.Register();
     NavigationEventHandler.Register();
     RecipientWellEventHandler.Register();
     AttachmentEventHandler.Register();
     ReadMessageEventHandler.Register();
     ReadConversationEventHandler.Register();
     ReadVoiceMessageEventHandler.Register();
     OptionsEventHandler.Register();
     AddressBookItemEventHandler.Register();
     OwaEventRegistry.RegisterHandler(typeof(EditMessageEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(EditSmsEventHandler));
     EditCalendarItemEventHandler.Register();
     CalendarViewEventHandler.Register();
     OwaEventRegistry.RegisterHandler(typeof(EditMeetingInviteEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(EditMeetingResponseEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(ErrorEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(FlagEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(CategoryEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(InstantMessageEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(MonitoringEventHandler));
     OwaEventRegistry.RegisterHandler(typeof(MailTipsEventHandler));
     RemindersEventHandler.Register();
     EditContactItemEventHandler.Register();
     EditDistributionListEventHandler.Register();
     JunkEmailEventHandler.Register();
     EditTaskEventHandler.Register();
     ComplianceEventHandler.Register();
     WebReadyFileEventHandler.Register();
     EditPostEventHandler.Register();
     ReadPostEventHandler.Register();
     SMimeEventHandler.Register();
     NavigationNodeEventHandler.Register();
     MessageVirtualListViewEventHandler2.Register();
     TaskVirtualListViewEventHandler.Register();
     PersonalAutoAttendantOptionsEventHandler.Register();
     EditPAAEventHandler.Register();
     PerformanceConsoleEventHandler.Register();
     DirectoryVirtualListViewEventHandler.Register();
     ContactVirtualListViewEventHandler.Register();
     DumpsterVirtualListViewEventHandler.Register();
     SharingMessageEventHandler.Register();
     DeletePolicyEventHandler.Register();
     MovePolicyEventHandler.Register();
     PrintCalendarEventHandler.Register();
     MessageAnnotationEventHandler.Register();
 }
 public static string GetKey(string table, NotificationEventHandler eventHandler)
 {
     string result;
     if (eventHandler == null)
         result = string.Concat(table);
     else
         result = string.Concat(table, "|", eventHandler.Method.DeclaringType.AssemblyQualifiedName);
     return result;
 }
Exemplo n.º 37
0
 public DxfDocumentBuilder(CadDocument document, NotificationEventHandler notification = null) : base(document, notification)
 {
 }
Exemplo n.º 38
0
        private void Init()
        {
            NoticeDelegate = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);
            CertificateValidationCallbackDelegate = new CertificateValidationCallback(DefaultCertificateValidationCallback);
            CertificateSelectionCallbackDelegate = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
            PrivateKeySelectionCallbackDelegate = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);
            ValidateRemoteCertificateCallbackDelegate = new ValidateRemoteCertificateCallback(DefaultValidateRemoteCertificateCallback);

            // Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and
            // http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
            RSACryptoServiceProvider.UseMachineKeyStore = true;

            promotable = new NpgsqlPromotableSinglePhaseNotification(this);
        }
Exemplo n.º 39
0
		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
		/// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
		/// </summary>
		/// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
		public NpgsqlConnection(String ConnectionString)
		{
			NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

            LoadConnectionStringBuilder(ConnectionString);
			
			NoticeDelegate = new NoticeEventHandler(OnNotice);
			NotificationDelegate = new NotificationEventHandler(OnNotification);

            ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);
			CertificateValidationCallbackDelegate = new CertificateValidationCallback(DefaultCertificateValidationCallback);
			CertificateSelectionCallbackDelegate = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
			PrivateKeySelectionCallbackDelegate = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);
            ValidateRemoteCertificateCallbackDelegate = new ValidateRemoteCertificateCallback(DefaultValidateRemoteCertificateCallback);

			// Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and 
			// http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
			RSACryptoServiceProvider.UseMachineKeyStore = true;

			promotable = new NpgsqlPromotableSinglePhaseNotification(this);
		}
Exemplo n.º 40
0
 public CadDocumentBuilder(CadDocument document, NotificationEventHandler notification = null)
 {
     this.DocumentToBuild     = document;
     this.NotificationHandler = notification;
 }
Exemplo n.º 41
0
        /// <summary>
        /// Tests the session reconnect.
        /// </summary>
        private bool DoReconnectTest()
        {
            double increment = MaxProgress/6;
            double position  = 0;

            bool success = true;
            
            lock (m_messages)
            {
                m_messages.Clear();
            }

            int currentKeepAlive = Session.KeepAliveInterval;
            List<Subscription> subscriptions = new List<Subscription>();
            KeepAliveEventHandler keepAliveHandler = new KeepAliveEventHandler(Session_Reconnect);
            NotificationEventHandler notificationHandler = new NotificationEventHandler(Session_Notification);

            try
            {
                Session.KeepAlive += keepAliveHandler;
                Session.Notification += notificationHandler;

                for (int publishingInterval = 1000; publishingInterval <= 10000; publishingInterval += 1000)
                {
                    Subscription subscription = new Subscription();

                    subscription.MaxMessageCount = 100;
                    subscription.LifetimeCount = 100;
                    subscription.KeepAliveCount = 10;
                    subscription.PublishingEnabled = true;
                    subscription.PublishingInterval = publishingInterval;

                    MonitoredItem monitoredItem = new MonitoredItem();

                    monitoredItem.StartNodeId = VariableIds.Server_ServerStatus_CurrentTime;
                    monitoredItem.AttributeId = Attributes.Value;
                    monitoredItem.SamplingInterval = -1;
                    monitoredItem.QueueSize = 0;
                    monitoredItem.DiscardOldest = true;

                    subscription.AddItem(monitoredItem);
                    Session.AddSubscription(subscription);
                    subscription.Create();
                    subscriptions.Add(subscription);
                }

                m_keepAliveCount = 0;
                Session.KeepAliveInterval = 1000;
                Log("Setting keep alive interval to {0}ms.", Session.KeepAliveInterval);

                int testDuration = 3000;

                for (int ii = 0; ii < 6; ii++)
                {
                    Session.Reconnect();

                    Log("Session reconnected. KeepAlives={0}", m_keepAliveCount);

                    if (m_errorEvent.WaitOne(testDuration, false))
                    {
                        Log("Unexpected error waiting for session keep alives. {0}", m_error.ToLongString());
                        return false;
                    }

                    position += increment;
                    ReportProgress(position);
                }
            }
            finally
            {
                Session.RemoveSubscriptions(subscriptions);
                Session.KeepAliveInterval = currentKeepAlive;
                Session.KeepAlive -= keepAliveHandler;
                Session.Notification -= notificationHandler;
            } 
                
            ReportProgress(MaxProgress);

            lock (m_messages)
            {
                foreach (KeyValuePair<uint,List<uint>> entry in m_messages)
                {
                    entry.Value.Sort();

                    for (int ii = 0; ii < entry.Value.Count-1; ii++)
                    {
                        if (entry.Value[ii+1] - entry.Value[ii] > 1)
                        {
                            Log("Missing message. Subscription={0}, SequenceNumber={1}-{2}", entry.Key, entry.Value[ii]+1, entry.Value[ii+1]-1);
                        }

                        if (entry.Value[ii+1] == entry.Value[ii])
                        {
                            // Log("Duplicate message. Subscription={0}, SequenceNumber={1}", entry.Key, entry.Value[ii]);
                        }
                    }
                }
            }

            return success;
        }
		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
		/// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
		/// </summary>
		/// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
		public NpgsqlConnection(String ConnectionString)
		{
			NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

			NpgsqlConnectionStringBuilder builder = cache[ConnectionString];
			if (builder == null)
			{
				settings = new NpgsqlConnectionStringBuilder(ConnectionString);
			}
			else
			{
				settings = builder.Clone();
			}

			LogConnectionString();

			NoticeDelegate = new NoticeEventHandler(OnNotice);
			NotificationDelegate = new NotificationEventHandler(OnNotification);

            ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);

			// Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and 
			// http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
			RSACryptoServiceProvider.UseMachineKeyStore = true;

			promotable = new NpgsqlPromotableSinglePhaseNotification(this);
		}
Exemplo n.º 43
0
 protected CadReaderBase(string filename, NotificationEventHandler notification) : this(notification)
 {
     this._fileStream = new StreamIO(filename, FileMode.Open, FileAccess.Read);
 }