internal void Handle(UpdateSitesAvailability input) { Log.Trace("Store {0} site availabilities", input.Availability.Count); using (var dbConn = DatabaseManager.DbConn()) { var needsUpdate = false; var sais = dbConn.ExecuteBpl(new SiteAvailabilityGetAll()); if (sais.Count == input.Availability.Count) { foreach (var isai in input.Availability) { needsUpdate = true; foreach (var sai in sais) { if (_isEqual(isai, sai)) { needsUpdate = false; break; } } if (needsUpdate) { break; } } } else { needsUpdate = true; } if (needsUpdate) { dbConn.BeginTransaction(this); dbConn.ExecuteBpl(new SiteAvailabilityDeleteAll()); foreach (var isai in input.Availability) { dbConn.ExecuteBpl(new SiteAvailabilityAdd { i = isai }); } dbConn.CommitTransaction(); } } Reply(true); }
/// <summary>Update pois availability information retrived by the provider.</summary> protected void UpdateSitesAvailability(IEnumerable<SiteAvailabilityInfo> availabilities) { var msg = new UpdateSitesAvailability(); msg.Availability.AddRange(availabilities); Services.Invoke(msg); }