private webModel.ModulePushNotification ScheduleJob(webModel.ModuleBackgroundJobOptions options) { var notification = new webModel.ModulePushNotification(_userNameResolver.GetCurrentUserName()); switch (options.Action) { case webModel.ModuleAction.Install: notification.Title = "Install Module"; notification.ProgressLog.Add(new webModel.ProgressMessage { Level = ProgressMessageLevel.Info.ToString(), Message = "Starting installation..." }); break; case webModel.ModuleAction.Uninstall: notification.Title = "Uninstall Module"; notification.ProgressLog.Add(new webModel.ProgressMessage { Level = ProgressMessageLevel.Info.ToString(), Message = "Starting uninstall..." }); break; } _pushNotifier.Upsert(notification); BackgroundJob.Enqueue(() => ModuleBackgroundJob(options, notification)); return(notification); }
public void ModuleBackgroundJob(webModel.ModuleBackgroundJobOptions options, webModel.ModulePushNotification notification) { try { notification.Started = DateTime.UtcNow; var moduleInfos = _moduleCatalog.Modules.OfType <ManifestModuleInfo>() .Where(x => options.Modules.Any(y => y.Identity.Equals(x.Identity))) .ToArray(); var reportProgress = new Progress <ProgressMessage>(m => { lock (_lockObject) { notification.ProgressLog.Add(m.ToWebModel()); _pushNotifier.Upsert(notification); } }); switch (options.Action) { case webModel.ModuleAction.Install: _moduleInstaller.Install(moduleInfos, reportProgress); break; case webModel.ModuleAction.Uninstall: _moduleInstaller.Uninstall(moduleInfos, reportProgress); break; } } catch (Exception ex) { notification.ProgressLog.Add(new webModel.ProgressMessage { Level = ProgressMessageLevel.Error.ToString(), Message = ex.ExpandExceptionMessage(), }); } finally { _settingsManager.SetValue(_autoInstallStateSetting, webModel.AutoInstallState.Completed); notification.Finished = DateTime.UtcNow; notification.ProgressLog.Add(new webModel.ProgressMessage { Level = ProgressMessageLevel.Info.ToString(), Message = "Installation finished.", }); _pushNotifier.Upsert(notification); } }
private webModel.ModulePushNotification ScheduleJob(webModel.ModuleBackgroundJobOptions options) { var notification = new webModel.ModulePushNotification(_userNameResolver.GetCurrentUserName()); switch (options.Action) { case webModel.ModuleAction.Install: notification.Title = "Install Module"; notification.ProgressLog.Add(new webModel.ProgressMessage { Level = ProgressMessageLevel.Info.ToString(), Message = "Starting installation..." }); break; case webModel.ModuleAction.Uninstall: notification.Title = "Uninstall Module"; notification.ProgressLog.Add(new webModel.ProgressMessage { Level = ProgressMessageLevel.Info.ToString(), Message = "Starting uninstall..." }); break; } _pushNotifier.Upsert(notification); BackgroundJob.Enqueue(() => ModuleBackgroundJob(options, notification)); return notification; }