public void DoubleQueueingTest()
 {
     using (var @event = new FbRemoteEvent(Connection.ConnectionString))
     {
         Assert.DoesNotThrow(() => @event.QueueEvents("test"));
         Assert.Throws <InvalidOperationException>(() => @event.QueueEvents("test"));
     }
 }
Example #2
0
        private void Restart()
        {
            fctSQL.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} Event tracking stopped...{Environment.NewLine}");
            hsTracking.Marked = false;
            List <string> events = new List <string>();

            foreach (ListViewItem lvi in lvEvents.Items)
            {
                if (string.IsNullOrEmpty(lvi.Text))
                {
                    continue;
                }
                events.Add(lvi.Text);
            }
            if (events.Count > 0)
            {
                revent.CancelEvents();
                revent.QueueEvents(events.ToArray());


                //revent.QueueEvents(new string[] { "new_user","update_user" });

                fctSQL.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} Event tracking restarted...{Environment.NewLine}");
                hsTracking.Marked = true;
            }
            else
            {
                fctSQL.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} No events will be tracked !!!{Environment.NewLine}");
            }
        }
Example #3
0
        public void ProperCountsSingleTest()
        {
            var exception = (Exception)null;
            var triggered = false;

            using (var @event = new FbRemoteEvent(Connection.ConnectionString))
            {
                @event.RemoteEventError += (sender, e) =>
                {
                    exception = e.Error;
                };
                @event.RemoteEventCounts += (sender, e) =>
                {
                    triggered = e.Name == "test" && e.Counts == 5;
                };
                @event.Open();
                @event.QueueEvents("test");
                using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "execute block as begin post_event 'test'; post_event 'test'; post_event 'test'; post_event 'test'; post_event 'test'; end";
                    cmd.ExecuteNonQuery();
                    Thread.Sleep(2000);
                }
                Assert.IsNull(exception);
                Assert.IsTrue(triggered);
            }
        }
Example #4
0
        public void CancelTest()
        {
            var exception = (Exception)null;
            var triggered = 0;

            using (var @event = new FbRemoteEvent(Connection.ConnectionString))
            {
                @event.RemoteEventError += (sender, e) =>
                {
                    exception = e.Error;
                };
                @event.RemoteEventCounts += (sender, e) =>
                {
                    triggered++;
                };
                @event.Open();
                @event.QueueEvents("test");
                using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "execute block as begin post_event 'test'; end";
                    cmd.ExecuteNonQuery();
                    Thread.Sleep(2000);
                }
                @event.CancelEvents();
                using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "execute block as begin post_event 'test'; end";
                    cmd.ExecuteNonQuery();
                    Thread.Sleep(2000);
                }
                Assert.IsNull(exception);
                Assert.AreEqual(1, triggered);
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            try
            {
                FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
                cs.DataSource = "localhost";
                cs.Database   = @"E:\Samples\Tempo2012MVVM\Tempo2012\Tempo2012.UI.WPF\bin\Debug\data\TEMPO2012.fdb";
                cs.UserID     = "SYSDBA";
                cs.Password   = "******";
                cs.Charset    = "UTF8";

                connection = new FbConnection(cs.ToString());
                connection.Open();

                FbRemoteEvent revent = new FbRemoteEvent(connection);
                revent.AddEvents(new string[] { "acc_insert", "acc_update", });

                // Add callback to the Firebird events
                revent.RemoteEventCounts += new FbRemoteEventEventHandler(EventCounts);

                // Queue events
                revent.QueueEvents();

                Console.ReadLine();
                connection.Close();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
Example #6
0
 static void FirebirdEventListener(string connectionString)
 {
     using (var events = new FbRemoteEvent(connectionString))
     {
         events.RemoteEventCounts += (sender, e) => Console.WriteLine($"Event: {e.Name} | Counts: {e.Counts}");
         events.RemoteEventError  += (sender, e) => Console.WriteLine($"ERROR: {e.Error}");
         events.QueueEvents("NEWFOOBARD_POSTEVENT", "OtherEvent");
         Console.WriteLine("Listening...");
         Console.ReadLine();
     }
 }
Example #7
0
        public void InitConnection(string serverAddr)
        {
            _serverAddr = serverAddr;
            strConn     = "User=sysdba;Password=masterkey;Database=d:/anprdb/gbuanpr_geoje.fdb;Server=" + serverAddr + ";Port=3050";
            conn        = new FbConnection(strConn);
            conn.Open();
            fbEvent = new FbRemoteEvent(conn);
            fbEvent.AddEvents(new string[] { "item_inserted" });
            fbEvent.RemoteEventCounts += new EventHandler <FbRemoteEventEventArgs>(fbEvent_RemoteEventCounts);
            fbEvent.QueueEvents();

            dbReadThread = new Thread(DbReadThreadFunction);
        }
 public override void StartListenEvents()
 {
     if (ConfigDb.ListenEvents)
     {
         base.StartListenEvents();
         if (conn.State != System.Data.ConnectionState.Open)
         {
             conn.Open();
         }
         remoteEvent = new FbRemoteEvent(conn, new string[] { "LOG_ALERT" });
         remoteEvent.RemoteEventCounts += new FbRemoteEventEventHandler(remoteEvent_RemoteEventCounts);
         remoteEvent.QueueEvents();
     }
 }
Example #9
0
        public void StartListening()
        {
            using (Logger.BeginScope(LoggerHelper.GetCaller()))
            {
                _remoteEvent?.Dispose();

                _remoteEvent = new FbRemoteEvent(ConnectionString);

                var events = _triggers.Select(item => item.EventName).ToList();
                _remoteEvent.QueueEvents(events.ToArray());
                _remoteEvent.RemoteEventCounts += OnDbEvent;

                var eventsStr = events.Aggregate("", (current, item) => current + $"{item} ");
                Logger.LogDebug($"Listening events: {eventsStr}");
            }
        }
        public void NoExceptionWithDispose()
        {
            var exception = (Exception)null;

            using (var @event = new FbRemoteEvent(Connection.ConnectionString))
            {
                @event.RemoteEventError += (sender, e) =>
                {
                    exception = e.Error;
                };
                @event.QueueEvents("test");
                Thread.Sleep(200);
            }
            Thread.Sleep(200);
            Assert.IsNull(exception);
        }
Example #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Inizini();
            FbConnectionStringBuilder cs = new FbConnectionStringBuilder();

            cs.DataSource = "localhost";
            cs.Database   = "C:/trilogis/trilogis.fb20";
            cs.UserID     = userdb;
            cs.Password   = passdb;
            cs.Charset    = "NONE";
            FbConnection connection = new FbConnection(cs.ToString());

            connection.Open();
            FbRemoteEvent revent = new FbRemoteEvent(connection);

            revent.AddEvents(new string[] { "pronto" });
            revent.RemoteEventCounts += new FbRemoteEventEventHandler(EventCounts);
            revent.QueueEvents();
        }
Example #12
0
        public void EventNameSeparateSelectionTest()
        {
            var exception  = (Exception)null;
            var triggeredA = false;
            var triggeredB = false;

            using (var @event = new FbRemoteEvent(Connection.ConnectionString))
            {
                @event.RemoteEventError += (sender, e) =>
                {
                    exception = e.Error;
                };
                @event.RemoteEventCounts += (sender, e) =>
                {
                    switch (e.Name)
                    {
                    case "a":
                        triggeredA = e.Counts == 1;
                        break;

                    case "b":
                        triggeredB = e.Counts == 1;
                        break;
                    }
                };
                @event.Open();
                @event.QueueEvents("a", "b");
                using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "execute block as begin post_event 'b'; end";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "execute block as begin post_event 'a'; end";
                    cmd.ExecuteNonQuery();
                    Thread.Sleep(2000);
                }
                Assert.IsNull(exception);
                Assert.IsTrue(triggeredA);
                Assert.IsTrue(triggeredB);
            }
        }
        public void NoEventsAfterDispose()
        {
            var triggered = 0;

            using (var @event = new FbRemoteEvent(Connection.ConnectionString))
            {
                @event.RemoteEventCounts += (sender, e) =>
                {
                    triggered++;
                };
                @event.QueueEvents("test");
                Thread.Sleep(200);
            }
            Thread.Sleep(200);
            using (var cmd = Connection.CreateCommand())
            {
                cmd.CommandText = "execute block as begin post_event 'test'; end";
                cmd.ExecuteNonQuery();
                Thread.Sleep(200);
            }
            Assert.AreEqual(0, triggered);
        }
Example #14
0
    static void Main(string[] args)
    {
        FbConnectionStringBuilder cs = new FbConnectionStringBuilder();

        cs.DataSource = "localhost";
        cs.Database   = @"TESTDATABASE.FDB";
        cs.UserID     = "SYSDBA";
        cs.Password   = "******";
        cs.Charset    = "NONE";
        cs.Pooling    = false;

        FbConnection connection = new FbConnection(cs.ToString());

        connection.Open();

        FbRemoteEvent revent = new FbRemoteEvent(connection);

        revent.AddEvents(new string[] { "new_order" });

        // Add callback to the Firebird events
        revent.RemoteEventCounts += new FbRemoteEventEventHandler(EventCounts);

        // Queue events
        revent.QueueEvents();

        string sql = "EXECUTE BLOCK AS BEGIN POST_EVENT 'new_order'; END";

        FbCommand command = new FbCommand(sql, connection);

        for (int i = 0; i < 5; i++)
        {
            command.ExecuteNonQuery();
        }

        System.Threading.Thread.Sleep(2000);
        connection.Close();
        Console.ReadLine();
    }
Example #15
0
 public static void IniciarEscuta()
 {
     events = new FbRemoteEvent("database = localhost:C:\\Aplicacoes\\BD\\BASE.FDB; user = sysdba; password = masterkey");
     events.QueueEvents("ATUALIZAPROGRESSO", "PROCESSOCONCLUIDO");
 }
Example #16
0
 public EventsListener(IConnectionOptions builder, params string[] events)
 {
     _remoteEvent = new FbRemoteEvent(builder.ToInsecureConnectionString());
     _remoteEvent.RemoteEventCounts += OnRemoteEvent;
     _remoteEvent.QueueEvents(events);
 }