static void Main(string[] args) { const string url = "http://localhost:8080"; #region Database initialiser using (var context = new ArtistContext()) { Database.SetInitializer<ArtistContext>(new ArtistIntializer()); context.Artists.ToList(); } #endregion #region Notifier using (var notifer = new EntityChangeNotifier<Artist, ArtistContext>(artist => artist.Trigger == "Y")) { notifer.Changed += OnNotifierChanged; using (WebApplication.Start<Startup>(url)) { Console.WriteLine("Server running on {0}", url); Console.ReadLine(); } } #endregion }
private EntityChangeNotifier <SpRicezioneSpedizioniLightNotifier, GemapDbContext> StartNotifier() { var notifer = new EntityChangeNotifier <SpRicezioneSpedizioniLightNotifier, GemapDbContext>( p => p.SPEDIZIONE_STATO_GENERAZIONE == "I" || p.SPEDIZIONE_STATO_GENERAZIONE == "U"); notifer.Error += (sender, e) => { /*log*/ }; notifer.Changed += (sender, e) => { /*action when chagned*/ }; return(notifer); }
public AuditProcess(IRevisionInfoGenerator revisionInfoGenerator, ISessionImplementor session) { this.revisionInfoGenerator = revisionInfoGenerator; this.session = session; workUnits = new LinkedList<IAuditWorkUnit>(); undoQueue = new Queue<IAuditWorkUnit>(); usedIds = new Dictionary<Pair<string, object>, IAuditWorkUnit>(); entityChangeNotifier = new EntityChangeNotifier(revisionInfoGenerator, session); }
static void Main(string[] args) { string productName = "Lamp"; using (var cache = new EntityCache <Product, StoreDbContext>(p => p.Name == "Lamp")) { Console.WriteLine("Press any key to stop listening for changes..."); while (true) { Console.WriteLine(cache.Results.Count()); Thread.Sleep(1000); if (Console.KeyAvailable) { break; } } } return; using (var notifer = new EntityChangeNotifier <Product, StoreDbContext>(p => p.Name == productName)) { notifer.Error += (sender, e) => { Console.WriteLine("[{0}, {1}, {2}]:\n{3}", e.Reason.Info, e.Reason.Source, e.Reason.Type, e.Sql); }; notifer.Changed += (sender, e) => { Console.WriteLine(e.Results.Count()); foreach (var p in e.Results) { Console.WriteLine(" {0}", p.Name); } }; using (var otherNotifier = new EntityChangeNotifier <Product, StoreDbContext>(x => x.Name == "Desk")) { otherNotifier.Changed += (sender, e) => { Console.WriteLine(e.Results.Count()); }; Console.WriteLine("Press any key to stop listening for changes..."); Console.ReadKey(true); } Console.WriteLine("Press any key to stop..."); Console.ReadKey(true); } }
static void Main(string[] args) { string productName = "Lamp"; //using (var cache = new EntityCache<Product, StoreDbContext>(p => p.Name == "Lamp")) //{ // Console.WriteLine("Press any key to stop listening for changes..."); // while (true) // { // Console.WriteLine(cache.Results.Count()); // Thread.Sleep(1000); // if (Console.KeyAvailable) // break; // } //} //return; using (var notifer = new EntityChangeNotifier<Product, StoreDbContext>(p => p.Name == productName)) { notifer.Error += (sender, e) => { Console.WriteLine("[{0}, {1}, {2}]:\n{3}", e.Reason.Info, e.Reason.Source, e.Reason.Type, e.Sql); }; notifer.Changed += (sender, e) => { Console.WriteLine(e.Results.Count()); foreach (var p in e.Results) { Console.WriteLine(" {0}", p.Name); } }; using (var otherNotifier = new EntityChangeNotifier<Product, StoreDbContext>(x => x.Name == "Desk")) { otherNotifier.Changed += (sender, e) => { Console.WriteLine(e.Results.Count()); }; Console.WriteLine("Press any key to stop listening for changes..."); Console.ReadKey(true); } Console.WriteLine("Press any key to stop..."); Console.ReadKey(true); } }
static ArtistsController() { Notifier = new EntityChangeNotifier<Artist, ChinookContext>(a => a.ArtistId > 0); Notifier.Error += (sender, e) => Debug.WriteLine("[{0}, {1}, {2}]:\n{3}", e.Reason.Info, e.Reason.Source, e.Reason.Type, e.Sql); Notifier.Changed += notifier_Changed; }
public Form1() { InitializeComponent(); _entityChangeNotifier = StartNotifier(); }