private void SQLDependancyMonitoring() { string connectionString = ""; // your Connection string int table_1_Identey = 1; int table_2_Identiy = 2; // you must add unique identity for each table motioning SqlDependencyEx listener1 = new SqlDependencyEx(connectionString, "Database name", "your Table Name", identity: table_1_Identey); SqlDependencyEx listener2 = new SqlDependencyEx(connectionString, "your Database name", "your table name", identity: table_1_Identey); listener1.TableChanged += (o, ee) => { // Here changes in table 1 // you got the rows has been added/ updated/ deleted // you got row as as XML format string string UpdatedRow = ee.Data.ToString(); }; // e.Data contains actual changed data in the XML format listener2.TableChanged += (o, ee) => { // Here changes in table 2 // you got the rows has been added/ updated/ deleted // you got row as as XML format string string UpdatedRow = ee.Data.ToString(); }; listener1.Start(); // starting Listing for table 1 listener2.Start(); // starting Listing for table 2 // YOU ,MUST STOP LISTING ON END OF YOUR APPLICATION listener1.Stop(); // STOP LISTENIG FOR TABLE 1 listener2.Stop(); // STOP LISTENIG FOR TABLE 2 }
private static void Run(Options args) { var listener = new SqlDependencyEx(args.ConnectionString, args.Database, args.Table); listener.TableChanged += ListenerOnTableChanged; listener.Start(); DisplayPrompt(args); do { Thread.Sleep(100); } while (Console.ReadKey().KeyChar != 'x'); listener.Stop(); }
static void Main(string[] args) { SqlDependencyEx listener = new SqlDependencyEx( @"Data Source=rutwik-c\sqlexpress;Initial Catalog=Student.Data.StudentContext;Integrated Security=True", "Student.Data.StudentContext", "Studs"); listener.TableChanged += TableChangedEvent; listener.Start(); Console.WriteLine("Listening.."); Thread.Sleep(100000); listener.Stop(); Console.WriteLine("Stopped!"); Console.ReadLine(); }
public void Listen() { string cmd = "select name_point from point where post=0;"; // See constructor optional parameters to configure it according to your needs SqlDependencyEx listener = new SqlDependencyEx ("Server=sql-001.base2base.com.ua,14332;Database=b2b-test;User Id=base2base-test-user;Password=bW3GtOUQ02o0;", "b2b-test", "point"); // e.Data contains actual changed data in the XML format listener.TableChanged += (o, e) => Console.WriteLine("Your table was changed!"); // After you call the Start method you will receive table notifications with // the actual changed data in the XML format listener.Start(); // ... Your code is here // Don't forget to stop the listener somewhere! listener.Stop(); }
static void Main(string[] args) { var listener = new SqlDependencyEx(ConfigurationManager.ConnectionStrings["ReconsileConnection"].ConnectionString, ConfigurationManager.AppSettings["DatabaseName"], ConfigurationManager.AppSettings["TableName"]); ReconclieProcessing processing = new ReconclieProcessing(); listener.TableChanged += (o, e) => processing.RefreshCacheList(); listener.Start(); Thread t = new Thread(processing.ProcessFile); t.IsBackground = true; t.Start(); while (true) { var keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.C && keyInfo.Modifiers == ConsoleModifiers.Control) { processing.KeepGoing = false; listener.Stop(); break; } } t.Join(); }
public void Stop() { _Dependency.Stop(); }
public void Stop() { processing.KeepGoing = false; listener.Stop(); }
public void Stop() { _sqlDependency.Stop(); _instance = null; _instance = new Lazy <DataNotificator>(() => new DataNotificator()); }