private webModel.ModulePushNotification ScheduleJob(webModel.ModuleBackgroundJobOptions options) { var notification = new webModel.ModulePushNotification(CurrentPrincipal.GetCurrentUserName()); switch (options.Action) { case webModel.ModuleAction.Install: notification.Title = "Install Module"; break; case webModel.ModuleAction.Update: notification.Title = "Update Module"; break; case webModel.ModuleAction.Uninstall: notification.Title = "Uninstall Module"; break; } _pushNotifier.Upsert(notification); BackgroundJob.Enqueue(() => ModuleBackgroundJob(options, notification)); return(notification); }
public IHttpActionResult UninstallModule(string id) { var options = new webModel.ModuleBackgroundJobOptions { Action = webModel.ModuleAction.Uninstall, PackageId = id }; var result = ScheduleJob(options); return(Ok(result)); }
public IHttpActionResult InstallModule(string fileName) { var options = new webModel.ModuleBackgroundJobOptions { Action = webModel.ModuleAction.Install, PackageFilePath = Path.Combine(_uploadsPath, fileName), }; var result = ScheduleJob(options); return(Ok(result)); }
public IHttpActionResult UpdateModule(string id, string fileName) { var options = new webModel.ModuleBackgroundJobOptions { Action = webModel.ModuleAction.Update, PackageId = id, PackageFilePath = Path.Combine(_uploadsPath, fileName) }; var result = ScheduleJob(options); return(Ok(result)); }
public void ModuleBackgroundJob(webModel.ModuleBackgroundJobOptions options, webModel.ModulePushNotification notification) { try { notification.Started = DateTime.UtcNow; var reportProgress = new Progress <ProgressMessage>(m => { notification.ProgressLog.Add(m.ToWebModel()); _pushNotifier.Upsert(notification); }); switch (options.Action) { case webModel.ModuleAction.Install: _packageService.Install(options.PackageFilePath, reportProgress); break; case webModel.ModuleAction.Update: _packageService.Update(options.PackageId, options.PackageFilePath, reportProgress); break; case webModel.ModuleAction.Uninstall: _packageService.Uninstall(options.PackageId, reportProgress); break; } } catch (Exception ex) { notification.ProgressLog.Add(new webModel.ProgressMessage { Level = ProgressMessageLevel.Error.ToString(), Message = ex.ExpandExceptionMessage(), }); } finally { notification.Finished = DateTime.UtcNow; _pushNotifier.Upsert(notification); } }
public IHttpActionResult UninstallModule(string id) { var options = new webModel.ModuleBackgroundJobOptions { Action = webModel.ModuleAction.Uninstall, PackageId = id }; var result = ScheduleJob(options); return Ok(result); }
public IHttpActionResult UpdateModule(string id, string fileName) { var options = new webModel.ModuleBackgroundJobOptions { Action = webModel.ModuleAction.Update, PackageId = id, PackageFilePath = Path.Combine(_uploadsPath, fileName) }; var result = ScheduleJob(options); return Ok(result); }
public IHttpActionResult InstallModule(string fileName) { var options = new webModel.ModuleBackgroundJobOptions { Action = webModel.ModuleAction.Install, PackageFilePath = Path.Combine(_uploadsPath, fileName), }; var result = ScheduleJob(options); return Ok(result); }