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 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);
            }
        }
        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;
        }