public void Execute(IJobExecutionContext context) { var notificationEmail = Settings.GetNotificationEmail(); Logger.Instance.Info($"Job started: {GetType().Name}"); var tasks = new Tasks(); tasks.StartTask(JobName); var priceLevels = new PriceLevels(); priceLevels.UpdateTemporaryTables(); priceLevels.Empty(); string mappedDsnName = Mapping.GetDsnName("PriceLevels"); var newMapping = new Mapping(mappedDsnName); if (newMapping.MigrateData("PriceLevels") && priceLevels.Publish(out var publishDetails)) { Logger.Instance.Info("Price Levels synced."); tasks.SetStatus(JobName, "Success"); if (!string.IsNullOrWhiteSpace(notificationEmail)) { Mail.SendProcessCompleteEmail(notificationEmail, publishDetails, $"{JobName} Publish", response => Logger.Instance.Info(response)); } } else { Logger.Instance.Error("Price Levels failed to sync."); tasks.SetStatus(JobName, "Failed"); if (!string.IsNullOrWhiteSpace(notificationEmail)) { Mail.SendProcessCompleteEmail(notificationEmail, $"{JobName} Publish failed, please check logs or contact support", $"{JobName} Publish", response => Logger.Instance.Info(response)); } } tasks.EndTask(JobName); Logger.Instance.Info($"Job finished: {GetType().Name}"); }
private void syncPriceLevels_Click(object sender, EventArgs e) { var notificationEmail = Settings.GetNotificationEmail(); var priceLevels = new PriceLevels(); priceLevels.UpdateTemporaryTables(); priceLevels.Empty(); string mappedDsnName = Mapping.GetDsnName("PriceLevels"); var newMapping = new Mapping(mappedDsnName); if (newMapping.MigrateData("PriceLevels")) { if (priceLevels.Publish(out var publishDetails)) { MessageBox.Show(@"Your price levels have been published", @"Published Successfully"); Logger.Instance.Info("Price Levels synced."); if (!string.IsNullOrWhiteSpace(notificationEmail)) { Mail.SendProcessCompleteEmail(notificationEmail, publishDetails, "PriceLevel Publish", response => Logger.Instance.Info(response)); } } else { MessageBox.Show(@"Unable to publish your Price Levels", @"Publish Failed"); Logger.Instance.Error("Price Levels failed to sync."); if (!string.IsNullOrWhiteSpace(notificationEmail)) { Mail.SendProcessCompleteEmail(notificationEmail, "PriceLevel Publish failed, please check logs or contact support", "Price Level Publish", response => Logger.Instance.Info(response)); } } } else { if (!newMapping._validFields) { MessageBox.Show(@"Mapping failed, please validate your table mapping", @"Publish Failed"); if (!string.IsNullOrWhiteSpace(notificationEmail)) { Mail.SendProcessCompleteEmail(notificationEmail, "Price Level Publish failed, please check your table mapping.", "Price Level Publish", response => Logger.Instance.Info(response)); } } else { MessageBox.Show(@"An unexpected error has occured, please check your logs or contact support", @"Publish Failed"); Logger.Instance.Error("Price Levels failed to migrate."); if (!string.IsNullOrWhiteSpace(notificationEmail)) { Mail.SendProcessCompleteEmail(notificationEmail, "Price Level Publish failed, please check logs or contact support", "Price Level Publish", response => Logger.Instance.Info(response)); } } } }