示例#1
0
        private async void OnSyncStatusChanged(object sender, SyncStatusEventArgs args)
        {
            var notification = args.GetNotification();

            if (notification?.Category == Category.TemplatesSync)
            {
                await NotificationsControl.AddOrUpdateNotificationAsync(notification);
            }
            else
            {
                await NotificationsControl.AddNotificationAsync(notification);
            }

            if (args.Status == SyncStatus.NoUpdates || args.Status == SyncStatus.Ready)
            {
                NotificationsControl.RemoveNotification();
            }

            if (args.Status == SyncStatus.Updated || args.Status == SyncStatus.Ready)
            {
                WizardStatus.SetVersions();

                await OnTemplatesAvailableAsync();
            }
        }
        private async Task OnRefreshTemplatesAsync()
        {
            try
            {
                await GenContext.ToolBox.Repo.RefreshAsync();

                WizardStatus.TemplatesVersion = GenContext.ToolBox.TemplatesVersion;
                await OnNewTemplatesAvailableAsync();

                WizardStatus.NewVersionAvailable = false;
                WizardStatus.SetStatus(StatusViewModel.Information(StringRes.StatusUpdated, true, 5));
            }
            catch (Exception ex)
            {
                WizardStatus.SetStatus(StatusViewModel.Information(StringRes.ErrorSyncRefresh));

                await AppHealth.Current.Error.TrackAsync(ex.ToString());

                await AppHealth.Current.Exception.TrackAsync(ex);
            }
            finally
            {
                WizardStatus.IsLoading = GenContext.ToolBox.Repo.SyncInProgress;
            }
        }
 public void CleanStatus(bool cleanValidationError = false)
 {
     WizardStatus.ClearStatus();
     if (cleanValidationError)
     {
         UpdateHasValidationErrors(false);
     }
 }
示例#4
0
 public BaseMainViewModel(Window mainView, BaseStyleValuesProvider provider, IEnumerable <StepData> steps, bool canFinish = true)
 {
     BaseInstance  = this;
     MainView      = mainView;
     SystemService = new SystemService();
     WizardStatus  = new WizardStatus();
     StylesService = new UIStylesService(provider);
     Navigation    = new WizardNavigation(mainView, steps, canFinish);
     ResourcesService.Instance.Initialize(mainView);
 }
        private async void SyncSyncStatusChanged(object sender, SyncStatusEventArgs status)
        {
            SafeThreading.JoinableTaskFactory.Run(async() =>
            {
                await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();
                WizardStatus.SetStatus(status.Status.GetStatusViewModel());
            });

            if (status.Status == SyncStatus.Updated)
            {
                WizardStatus.TemplatesVersion = GenContext.ToolBox.Repo.TemplatesVersion;
                CleanStatus();

                UpdateTemplatesAvailable(true);
                await OnTemplatesAvailableAsync();

                WizardStatus.IsLoading = false;
                UpdateCanCheckUpdates(true);
            }

            if (status.Status == SyncStatus.OverVersion)
            {
                SafeThreading.JoinableTaskFactory.Run(async() =>
                {
                    await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();
                    UpdateTemplatesAvailable(true);
                });
            }

            if (status.Status == SyncStatus.OverVersionNoContent)
            {
                SafeThreading.JoinableTaskFactory.Run(async() =>
                {
                    await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();
                    UpdateTemplatesAvailable(false);
                });
            }

            if (status.Status == SyncStatus.UnderVersion)
            {
                SafeThreading.JoinableTaskFactory.Run(async() =>
                {
                    await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();
                    UpdateTemplatesAvailable(false);
                });
            }

            if (status.Status == SyncStatus.NewVersionAvailable)
            {
                WizardStatus.NewVersionAvailable = true;
            }
        }
        private async Task OnCheckUpdatesAsync()
        {
            try
            {
                UpdateCanCheckUpdates(false);
                await GenContext.ToolBox.Repo.CheckForUpdatesAsync();
            }
            catch (Exception ex)
            {
                WizardStatus.SetStatus(StatusViewModel.Information(StringRes.ErrorSyncRefresh));
                await AppHealth.Current.Error.TrackAsync(ex.ToString());

                await AppHealth.Current.Exception.TrackAsync(ex);
            }
            finally
            {
                WizardStatus.IsLoading = GenContext.ToolBox.Repo.SyncInProgress;
                UpdateCanCheckUpdates(!GenContext.ToolBox.Repo.SyncInProgress);
            }
        }
        protected async Task BaseInitializeAsync()
        {
            GenContext.ToolBox.Repo.Sync.SyncStatusChanged += SyncSyncStatusChanged;
            try
            {
                await GenContext.ToolBox.Repo.SynchronizeAsync();

                WizardStatus.TemplatesVersion = GenContext.ToolBox.TemplatesVersion;
                WizardStatus.WizardVersion    = GenContext.ToolBox.WizardVersion;
            }
            catch (Exception ex)
            {
                WizardStatus.SetStatus(StatusViewModel.Information(StringRes.ErrorSync));

                await AppHealth.Current.Error.TrackAsync(ex.ToString());

                await AppHealth.Current.Exception.TrackAsync(ex);
            }
            finally
            {
                WizardStatus.IsLoading = GenContext.ToolBox.Repo.SyncInProgress;
                UpdateCanCheckUpdates(!GenContext.ToolBox.Repo.SyncInProgress);
            }
        }
 public void SetValidationErrors(string errorMessage, StatusType statusType = StatusType.Error)
 {
     WizardStatus.SetStatus(new StatusViewModel(statusType, errorMessage));
     UpdateHasValidationErrors(true);
 }