private void Sync(object _) { try { var tenant = CoreContext.TenantManager.GetTenants().OrderByDescending(t => t.Version).FirstOrDefault(); if (tenant != null) { using (var wcfClient = new TariffSyncClient()) { var quotaService = new DbQuotaService(ConfigurationManager.ConnectionStrings[config.ConnectionStringName]); var oldtariffs = quotaService.GetTenantQuotas().ToDictionary(t => t.Id); // save new foreach (var tariff in wcfClient.GetTariffs(tenant.Version, CoreContext.Configuration.GetKey(tenant.TenantId))) { quotaService.SaveTenantQuota(tariff); oldtariffs.Remove(tariff.Id); } // remove old foreach (var tariff in oldtariffs.Values) { tariff.Visible = false; quotaService.SaveTenantQuota(tariff); } } } } catch (Exception error) { log.Error(error); } }
public void Sync() { var tenant = TenantManager.GetTenants(false).OrderByDescending(t => t.Version).FirstOrDefault(); if (tenant != null) { using var wcfClient = new TariffSyncClient(); var quotaService = DbQuotaService; var oldtariffs = quotaService.GetTenantQuotas().ToDictionary(t => t.Id); // save new foreach (var tariff in wcfClient.GetTariffs(tenant.Version, CoreSettings.GetKey(tenant.TenantId))) { quotaService.SaveTenantQuota(tariff); oldtariffs.Remove(tariff.Id); } // remove old foreach (var tariff in oldtariffs.Values) { tariff.Visible = false; quotaService.SaveTenantQuota(tariff); } } }