private async void XLogin_OnClick(object sender, RoutedEventArgs e)
        {
            this.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
            AuthDialogController = await this.ShowProgressAsync("Login", "Please Wait...");

            AuthDialogController.SetIndeterminate();

            var state = await TalosQuests.Instance.Login(xUsername.Text, xPassword.Password);

            if (state)
            {
                AuthDialogController.SetMessage("Welcome.\nLoading Data...");
                await TalosQuests.Instance.FetchInfo();

                await AuthDialogController.CloseAsync();

                MainWindow l = new MainWindow();
                l.Show();
                Close();
            }
            else
            {
                await Task.Run(() =>
                {
                    Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        AuthDialogController.SetMessage(
                            "Either your Credentials are incorrect either your have no access.");
                    }));
                    Thread.Sleep(3000);
                });

                await AuthDialogController.CloseAsync();
            }
        }
 private async void Button_OnClick(object sender, RoutedEventArgs e)
 {
     MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
     await Dispatcher.InvokeAsync(new Action(async() =>
     {
         MainDialogController =
             await this.ShowProgressAsync("Searching Users", "Please Wait...");
         MainDialogController.SetIndeterminate();
         try
         {
             await TalosQuests.Instance.SearchUsers(searchUserField.Text);
             await Task.Run(() =>
             {
                 Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
                 {
                     userGrid.ItemsSource = null;
                     userGrid.Items.Refresh();
                     userGrid.ItemsSource = TalosQuests.Instance.Users;
                     userGrid.Items.Refresh();
                 }));
             });
             await MainDialogController.CloseAsync();
         }
         catch (TalosQuestsException exc)
         {
             MainDialogController.SetMessage("Error: \n" + exc.Message);
             MainDialogController.SetCancelable(true);
             MainDialogController.Canceled += (o, args) => MainDialogController.CloseAsync();
         }
     }));
 }
        public async Task Run(ProgressDialogController progress)
        {
            var dialog = new CommonOpenFileDialog()
            {
                Title          = "プロジェクトフォルダを選択してください",
                IsFolderPicker = true,
            };

            var result = dialog.ShowDialog();

            if (result != CommonFileDialogResult.Ok)
            {
                await progress.CloseAsync();

                return;
            }

            var projectPath = dialog.FileName;

            progress.Canceled += (sender, args) => Kill();

            await Task.Run(() =>
            {
                // restore nuget & run
                Command(progress, projectPath, "restore");
                Command(progress, projectPath, "run");
            });

            await progress.CloseAsync();
        }
        private void TaskCompleted()
        {
            HashFileName.Header   = $"Hash File: '{HashFile}'";
            SourceFileName.Header = $"Original Source File: '{_sourceFileName}'";
            HashFileContent.Text  = _hashFileContent;
            SourceFileHash.Text   = _sourceFileHash;

            if (_task.Result)
            {
                HashFileContent.Background = Brushes.GreenYellow;
                HashFileContent.Foreground = Brushes.Black;
                SourceFileHash.Background  = Brushes.GreenYellow;
                SourceFileHash.Foreground  = Brushes.Black;
            }
            else
            {
                HashFileContent.Background = Brushes.DarkRed;
                HashFileContent.Foreground = Brushes.White;
                SourceFileHash.Background  = Brushes.DarkRed;
                SourceFileHash.Foreground  = Brushes.White;
            }

            _controller.CloseAsync();
            _controller.Closed += ControllerClosed;
        }
 private async void wipeQuests_Click(object sender, RoutedEventArgs e)
 {
     MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
     await Dispatcher.InvokeAsync(new Action(async() =>
     {
         MainDialogController =
             await this.ShowProgressAsync("Wiping Quests", "Please Wait...");
         MainDialogController.SetIndeterminate();
         try
         {
             var state = await TalosQuests.Instance.WipeQuests();
             await Task.Run(() =>
             {
                 Dispatcher.Invoke(DispatcherPriority.Normal, new Action(async() =>
                 {
                     if (state)
                     {
                         MainDialogController.SetMessage("Quests Wiped.");
                         await TalosQuests.Instance.FetchInfo();
                     }
                 }));
             });
             await MainDialogController.CloseAsync();
         }
         catch (TalosQuestsException exc)
         {
             MainDialogController.SetMessage("Error: \n" + exc.Message);
             MainDialogController.SetCancelable(true);
             MainDialogController.Canceled += (o, args) => MainDialogController.CloseAsync();
         }
     }));
 }
Beispiel #6
0
        private async Task ReloadScheme()
        {
            ProgressDialogController dialogController = null;

            try
            {
                dialogController = await _dialogCoordinator.ShowProgressAsync(this, "Scheme Loading", "Loading...");

                dialogController.SetIndeterminate();
                _scheme = await _repository.LoadScheme();

                Scheme.Reload(_scheme);
                await dialogController.CloseAsync();
            }
            catch (Exception e)
            {
                if (dialogController != null)
                {
                    await dialogController.CloseAsync();
                }

                await _dialogCoordinator.ShowMessageAsync(this, "Error", e.Message);

                Close();
            }
        }
Beispiel #7
0
        // upload
        private async void BtUploadArchive_OnClick(object sender, RoutedEventArgs e)
        {
            if (!await ModPlusAPI.Web.Connection.HasAllConnectionAsync(1))
            {
                await this.ShowMessageAsync(ModPlusAPI.Language.GetItem(LangItem, "msg23"), string.Empty);

                return;
            }

            if (File.Exists(_currentFileToUpload))
            {
                ProgressDialogController controller = null;
                try
                {
                    var settings = new MetroDialogSettings
                    {
                        AnimateShow         = true,
                        AnimateHide         = true,
                        DialogTitleFontSize = 20
                    };
                    controller = await this.ShowProgressAsync(ModPlusAPI.Language.GetItem(LangItem, "msg24"), string.Empty, false, settings);

                    controller.Minimum = 0;
                    controller.Maximum = 2;

                    using (var client = ModPlusAPI.Web.ApiClient.CreateClient())
                    {
                        controller.SetMessage(ModPlusAPI.Language.GetItem(LangItem, "msg25"));
                        controller.SetProgress(1);
                        await client.UploadUserFile(new[] { "DwgForBaseFromUsers" }, _currentFileToUpload, false, true);

                        controller.SetMessage(ModPlusAPI.Language.GetItem(LangItem, "msg26"));
                        controller.SetProgress(2);
                        var emailSettings = await client.GetEmailSettings();
                        await SendEmailNotification(emailSettings);
                    }

                    await controller.CloseAsync();

                    await this.ShowMessageAsync(
                        string.Empty,
                        ModPlusAPI.Language.GetItem(LangItem, "msg27") + ": " + _currentFileToUpload + " " +
                        ModPlusAPI.Language.GetItem(LangItem, "msg28") + Environment.NewLine +
                        ModPlusAPI.Language.GetItem(LangItem, "msg29"));
                }
                catch (Exception exception)
                {
                    if (controller != null)
                    {
                        await controller.CloseAsync();
                    }
                    ExceptionBox.Show(exception);
                }
            }
            else
            {
                MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg22"));
            }
        }
Beispiel #8
0
        private async Task ValidateData(bool silent)
        {
            var uiWorkflow  = IoC.Resolve <IUiWorkflow>();
            var textService = IoC.Resolve <ITextService>();
            ProgressDialogController waiter = null;

            if (!silent)
            {
                waiter = await DialogCoordinator.Instance.ShowProgressAsync(uiWorkflow,
                                                                            textService.Compile("Validate.Progress.Title", CultureInfo.CurrentUICulture, out _).ToString(),
                                                                            textService.Compile("Validate.Progress.Message", CultureInfo.CurrentUICulture, out _).ToString()
                                                                            );

                waiter.SetIndeterminate();
            }

            try
            {
                MailData previewData;
                await using (var strategy = Create())
                {
                    previewData = await strategy.GetPreviewData();
                }

                ValidationState.IsValidated = previewData != null;
                StructureCacheService.SetExampleData(previewData);

                if (!silent)
                {
                    await waiter.CloseAsync();

                    if (!ValidationState.IsValidated)
                    {
                        await DialogCoordinator.Instance.ShowMessageAsync(uiWorkflow,
                                                                          textService.Compile("ImportData.Errors.Validate.Title", CultureInfo.CurrentUICulture, out _)
                                                                          .ToString(),
                                                                          textService.Compile("ImportData.Errors.Validate.Description", CultureInfo.CurrentUICulture,
                                                                                              out _,
                                                                                              new FormattableArgument("ImportData.Errors.Validate.GeneralError", true)).ToString()
                                                                          );
                    }
                }
            }
            catch (Exception e)
            {
                if (!silent)
                {
                    await waiter.CloseAsync();

                    await DialogCoordinator.Instance.ShowMessageAsync(uiWorkflow,
                                                                      textService.Compile("ImportData.Errors.Validate.Title", CultureInfo.CurrentUICulture, out _).ToString(),
                                                                      textService.Compile("ImportData.Errors.Validate.Description", CultureInfo.CurrentUICulture, out _,
                                                                                          new FormattableArgument(e.Message, false)).ToString()
                                                                      );
                }
            }
        }
Beispiel #9
0
        private void initTimer()
        {
            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += async(object sender, EventArgs e) => {
                if (controller == null && !Inject)
                {
                    controller = await this.ShowProgressAsync("等待", "等待游戏启动.....", true, Settings);

                    controller.SetIndeterminate();
                }
                if (controller != null)
                {
                    if (controller.IsCanceled)
                    {
                        timer.Stop();
                        await controller.CloseAsync();

                        controller = null;
                    }
                }
                var Proce = Process.GetProcessesByName("League of Legends");
                if (Proce.Length >= 1)
                {
                    var Game = Proce[0];
                    if (CurrentId == Game.Id)
                    {
                        if (controller != null)
                        {
                            await controller.CloseAsync();

                            controller = null;
                        }
                        return;
                    }
                    else
                    {
                        Inject = false;
                    }

                    Debug.WriteLine(System.IO.Path.GetFullPath("LOL Trace.dll"));

                    WinApi.Inject(Game.Id, Encoding.Default.GetBytes(System.IO.Path.GetFullPath("LOL Trace.dll")));
                    Inject    = true;
                    CurrentId = Game.Id;
                    InjectCount++;
                    _ = await this.ShowMessageAsync("成功", $"累计给你注入了 {InjectCount} 次!");
                }
                else
                {
                    Inject = false;
                }
            };
        }
Beispiel #10
0
        private async void cargar_prestashop()
        {
            var metroWindow = this;

            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogOptions.ColorScheme;
            ProgressDialogController ProgressAlert = null;
            LeerPedidos carga_data = null;

            try
            {
                dg1.Columns[13].Visibility = Visibility.Collapsed;

                carga_data = new LeerPedidos();

                ProgressAlert = await this.ShowProgressAsync(Ent_Msg.msgcargando, "Espere un momento por favor, cargando pedidos");  //show message

                ProgressAlert.SetIndeterminate();
                string _cargar_data = await Task.Run(() => (Ent_Global._err_con_mysql)?"" : carga_data.ImportaDataPrestaShop());

                if (_cargar_data.Length == 0)
                {
                    //await Task.Run(() => refrescagrilla_prestashop());
                    dt = await Task.Run(() => Dat_Liquidacion.liquidacionXfacturar());

                    await ProgressAlert.CloseAsync();

                    dg1.AutoGenerateColumns = false;
                    dg1.ItemsSource         = dt.DefaultView;
                    totales(dt);
                }
                else
                {
                    dt = await Task.Run(() => Dat_Liquidacion.liquidacionXfacturar());

                    //await ProgressAlert.CloseAsync();
                    dg1.AutoGenerateColumns = false;
                    dg1.ItemsSource         = dt.DefaultView;
                    totales(dt);

                    await ProgressAlert.CloseAsync();

                    await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, "ERROR EN LA IMPORTACION DE DATOS.. POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _cargar_data + ")", MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);
                }
            }
            catch (Exception exc)
            {
                await ProgressAlert.CloseAsync();

                await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, "ERROR EN LA IMPORTACION DE DATOS.. POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + exc.Message + ")", MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);

                //throw;
            }
        }
Beispiel #11
0
        private async Task ReloadSchemePart()
        {
            if (!CanReloadPart)
            {
                return;
            }

            if (!Scheme.Boards.Any(x => x.IsSelected))
            {
                await _dialogCoordinator.ShowMessageAsync(this, "Nothing to load", "Boards are empty");

                return;
            }

            ProgressDialogController dialogController = null;

            try
            {
                dialogController = await _dialogCoordinator.ShowProgressAsync(this, "Scheme Loading", "Loading...");

                dialogController.SetIndeterminate();

                var boardIds = Scheme.Boards.Where(x => x.IsSelected).Select(x => x.Id).ToArray();
                foreach (var board in Scheme.Boards)
                {
                    board.IsEnabled = board.IsSelected;
                }

                var columnsTask = _repository.LoadSchemeColumns(boardIds);
                var rowsTask    = _repository.LoadSchemeRows(boardIds);
                _scheme.Columns = await columnsTask;
                _scheme.Rows    = await rowsTask;

                Scheme.UpdateColumns(_scheme.Columns);
                Scheme.UpdateRows(_scheme.Rows);

                CanReloadPart = false;

                await dialogController.CloseAsync();
            }
            catch (Exception e)
            {
                if (dialogController != null)
                {
                    await dialogController.CloseAsync();
                }

                await _dialogCoordinator.ShowMessageAsync(this, "Error", e.Message);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Downloads a statement from the net and then parses it.
        /// </summary>
        /// <param name="name">The name of the parser and downloader.</param>
        public async Task LoadFromWeb(string name)
        {
            var downloader = await GetDownloaderByName(name);

            if (downloader == null)
            {
                return;
            }
            var parser = await GetParserByName(name);

            if (parser == null)
            {
                return;
            }

            ProgressDialogController progress = await _dialogService.ShowProgressAsync("Load Statement from Web", "Downloading");

            Exception ex   = null;
            var       flex = await Task.Run(() =>
            {
                try
                {
                    return(downloader.DownloadStatement());
                }
                catch (Exception caughtException)
                {
                    ex = caughtException;
                    return("");
                }
            });

            if (flex == "" || ex != null)
            {
                await progress.CloseAsync();

                await _dialogService.ShowMessageAsync("Error downloading statement", ex.Message);

                return;
            }

            await Task.Run(() => parser.Parse(flex, progress));

            progress.SetMessage("Updating open trades");

            _tradeRepository.UpdateOpenTrades();
            _tradeRepository.Save();

            progress.CloseAsync().Forget();
        }
Beispiel #13
0
        /// <summary>
        /// Downloads a statement from the net and then parses it.
        /// </summary>
        /// <param name="name">The name of the parser and downloader.</param>
        public async Task LoadFromWeb(string name)
        {
            var downloader = await GetDownloaderByName(name).ConfigureAwait(false);

            if (downloader == null)
            {
                return;
            }
            var parser = await GetParserByName(name).ConfigureAwait(false);

            if (parser == null)
            {
                return;
            }

            ProgressDialogController progress = await _dialogService.ShowProgressAsync(_mainVm, "Load Statement from Web", "Downloading").ConfigureAwait(false);

            Exception ex   = null;
            string    flex = "";

            try
            {
                flex = await downloader.DownloadStatement().ConfigureAwait(false);
            }
            catch (Exception e)
            {
                ex = e;
            }

            if (flex == "" || ex != null)
            {
                await progress.CloseAsync().ConfigureAwait(true);

                await _dialogService.ShowMessageAsync(_mainVm, "Error downloading statement", ex?.Message).ConfigureAwait(true);

                return;
            }

            await Task.Run(() => parser.Parse(flex, progress)).ConfigureAwait(true);

            progress.SetMessage("Updating open trades");

            await _tradeRepository.UpdateOpenTrades().ConfigureAwait(true);

            await _tradeRepository.Save().ConfigureAwait(true);

            progress.CloseAsync().Forget();
        }
Beispiel #14
0
        /// <summary>
        /// warn if there are missing business days between the last data in the db and first data in the import
        /// </summary>
        /// <param name="newData"></param>
        /// <param name="progressDialog"></param>
        /// <returns>false to abort import</returns>
        private async Task <bool> ImportDateCheck(Dictionary <string, DataContainer> newData, ProgressDialogController progressDialog)
        {
            DateTime?lastDateInDb;

            using (var dbContext = _contextFactory.Get())
            {
                lastDateInDb = dbContext.FXRates.OrderByDescending(x => x.Date).FirstOrDefault()?.Date;
            }

            var      fxRateDateEarliestDates = newData.Select(x => x.Value.FXRates.OrderBy(x => x.Date).FirstOrDefault()).Where(x => x != null).ToList();
            DateTime?firstDateInImport       = fxRateDateEarliestDates.Count > 0 ? fxRateDateEarliestDates.OrderBy(x => x.Date).First().Date : (DateTime?)null;

            if (lastDateInDb.HasValue && firstDateInImport.HasValue && lastDateInDb.Value < firstDateInImport.Value &&
                Utils.CountBusinessDaysBetween(lastDateInDb.Value, firstDateInImport.Value) > 0)
            {
                var firstMissingBusinessDay = Utils.AddBusinessDays(lastDateInDb.Value, 1);

                var result = await DialogService.ShowMessageAsync(this, "Potential Import Mistake Warning",
                                                                  "There are missing business days between the last data in the db and the first data in the file you are importing. " +
                                                                  $"It is recommended you Cancel the import and load a flex statement starting from {firstMissingBusinessDay:d}.\n\nDo you want to proceed anyway?",
                                                                  MessageDialogStyle.AffirmativeAndNegative);

                if (result == MessageDialogResult.Negative)
                {
                    await progressDialog.CloseAsync();

                    return(false);
                }
            }

            return(true);
        }
Beispiel #15
0
        private async void btnExportAll_Click(object sender, RoutedEventArgs e)
        {
            var folderDialog = new CommonOpenFileDialog();

            folderDialog.Title            = "Where should I save your data?";
            folderDialog.IsFolderPicker   = true;
            folderDialog.EnsureFileExists = true;
            folderDialog.EnsurePathExists = true;
            folderDialog.EnsureValidNames = true;
            folderDialog.EnsureReadOnly   = false;
            folderDialog.Multiselect      = false;
            folderDialog.ShowPlacesList   = true;

            if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                Telemetry.TrackEvent(TelemetryCategory.Export, Telemetry.TelemetryEvent.Export.Full);

                var folder = folderDialog.FileName;

                BandCloudManager.Instance.Events.Clear();

                _fullExportProgressDialog = await((MetroWindow)(Window.GetWindow(this))).ShowProgressAsync("Exporting Full Activity Data", "Loading Activities list...");
                _fullExportProgressDialog.SetCancelable(true); // TODO: this needs to be implemented. No event?
                _fullExportProgressDialog.SetIndeterminate();

                // HACK HACK HACK HACK
                // TODO: add a Cancelled Event into the MahApps.Metro library

                // polling method to cancel the export if the user requests that it be cancelled
                Task.Run(async() =>
                {
                    while (_fullExportProgressDialog != null && _fullExportProgressDialog.IsOpen)
                    {
                        if (_fullExportProgressDialog.IsCanceled)
                        {
                            BandCloudManager.Instance.CancelFullExport = true;

                            Telemetry.TrackEvent(TelemetryCategory.Export, Telemetry.TelemetryEvent.Export.FullCancelled);

                            // we'd exit from the while loop anyway, but only when the progress dialog finally exits
                            // which can take up to 10 seconds, so might as well shut this down asap
                            return;
                        }

                        await Task.Delay(500);
                    }
                });

                await LoadEvents();

                var progressIndicator = new Progress <BandCloudExportProgress>(ReportFullExportProgress);

                // TODO: progress reporter
                await BandCloudManager.Instance.ExportFullEventData(folder, ExportSettings, progressIndicator);

                _fullExportProgressDialog.CloseAsync();

                SaveExportSettings();
            }
        }
Beispiel #16
0
        private async void Command_Decompile(MainWindow win)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Sourcepawn Plugins (*.smx)|*.smx";
            ofd.Title  = Program.Translations.GetLanguage("ChDecomp");
            var result = ofd.ShowDialog();

            if (result.Value)
            {
                if (!string.IsNullOrWhiteSpace(ofd.FileName))
                {
                    FileInfo fInfo = new FileInfo(ofd.FileName);
                    if (fInfo.Exists)
                    {
                        ProgressDialogController task = null;
                        if (win != null)
                        {
                            task = await this.ShowProgressAsync(Program.Translations.GetLanguage("Decompiling"), fInfo.FullName, false, this.MetroDialogOptions);

                            MainWindow.ProcessUITasks();
                        }
                        string destFile = fInfo.FullName + ".sp";
                        File.WriteAllText(destFile, LysisDecompiler.Analyze(fInfo), Encoding.UTF8);
                        TryLoadSourceFile(destFile, true, false);
                        if (task != null)
                        {
                            await task.CloseAsync();
                        }
                    }
                }
            }
        }
        public async Task UnlockUi(object requestor)
        {
            await _lockProgressController.CloseAsync();

            _lockProgressController = null;
            _lockProgress           = null;
        }
Beispiel #18
0
        public async Task UnlockUi()
        {
            await _lockProgressController.CloseAsync();

            _lockProgressController = null;
            _lockProgress           = null;
        }
Beispiel #19
0
        private async void ConnectionManager_PluginUploadStarted(object sender, EventArgs e)
        {
            ProgressDialogController progressDialog = null;
            EventHandler <PluginUploadProgressChangedEventArgs> handler = null;
            var alreadyFinished = false;

            handler = (s, args) =>
            {
                progressDialog?.SetProgress(args.Progress);
                progressDialog?.SetMessage(
                    $"{FormatBytesConverter.BytesToString(args.BytesSent)} {Application.Current.Resources["Of"]} {FormatBytesConverter.BytesToString(args.TotalBytes)}");

                if (Math.Abs(args.Progress - 1) < .1)
                {
                    ((MainViewModel)DataContext).ConnectionManager.PluginUploadProgressChanged -= handler;
                    progressDialog?.CloseAsync();
                    alreadyFinished = true;
                }
            };
            ((MainViewModel)DataContext).ConnectionManager.PluginUploadProgressChanged += handler;

            progressDialog = await this.ShowProgressAsync((string)Application.Current.Resources["UploadingPlugin"], "");

            if (alreadyFinished)
            {
                await progressDialog.CloseAsync();
            }
        }
Beispiel #20
0
        private async void GenerateReport(List <Trade> tradeIDs)
        {
            if (tradeIDs == null)
            {
                throw new NullReferenceException("tradeIDs");
            }
            if (tradeIDs.Count == 0)
            {
                await DialogService.ShowMessageAsync(this, "Error", "No trades meet the given criteria");

                return;
            }

            var gen = new ReportGenerator();
            ProgressDialogController progressDialog = await DialogService.ShowProgressAsync(this, "Generating Report", "Generating Report");

            var ds = await Task.Run(() => gen.TradeStats(
                                        tradeIDs,
                                        PerformanceReportPageViewModel.ReportSettings,
                                        Settings,
                                        Datasourcer,
                                        _contextFactory,
                                        backtestData: PerformanceReportPageViewModel.BacktestData,
                                        progressDialog: progressDialog));

            progressDialog.CloseAsync().Forget(); //don't await it!

            var window = new PerformanceReportWindow(ds, PerformanceReportPageViewModel.ReportSettings);

            window.Show();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            ClearText();

            beginShowProgressTimer.Interval = TimeSpan.FromSeconds(NUD_ShowProgressDelay.Value ?? 0);

            AppendText($"set timer to {NUD_ShowProgressDelay.Value} second(s)");

            beginShowProgressTimer.Start();

            AppendText("timer started");

            // Run our Process
            AppendText($"process started and will run {NUD_TaskDuration.Value} Second(s)");
            await Task.Delay(TimeSpan.FromSeconds(NUD_TaskDuration.Value ?? 1));

            AppendText("process finished");

            // Esure we stop the timer
            beginShowProgressTimer.Stop();
            AppendText("timer stopped");

            // If we have the dialog close it.
            if (dialogController != null)
            {
                await dialogController.CloseAsync();

                AppendText("dialog closed");
                dialogController = null;
                AppendText("dialog set to 'null'");
            }
        }
Beispiel #22
0
        private async Task ProgressFailed(ProgressDialogController controller, String reason)
        {
            controller.SetMessage("Failure to login: " + reason);
            await Task.Delay(1500);

            await controller.CloseAsync();
        }
Beispiel #23
0
        private async void ExportEventSummaryToCSV(int?count = null)
        {
            Telemetry.TrackEvent(TelemetryCategory.Export, Telemetry.TelemetryEvent.Export.Summary);

            var saveDialog = new SaveFileDialog();

            saveDialog.AddExtension = true;
            saveDialog.FileName     = "band_export.csv";
            saveDialog.DefaultExt   = ".csv";

            var result = saveDialog.ShowDialog();

            if (result == true)
            {
                _summaryExportProgressDialog = await((MetroWindow)(Window.GetWindow(this))).ShowProgressAsync("Exporting Data", "...");
                _summaryExportProgressDialog.SetCancelable(true); // TODO: this needs to be implemented. No event?
                _summaryExportProgressDialog.SetProgress(0);

                var progressIndicator = new Progress <BandCloudExportProgress>(ReportSummaryExportProgress);

                await BandCloudManager.Instance.ExportEventsSummaryToCSV(count, ExportSettings, saveDialog.FileName, progressIndicator);

                _summaryExportProgressDialog.CloseAsync();

                if (ExportSettings.OpenFileAfterExport)
                {
                    Process.Start(saveDialog.FileName);
                }

                SaveExportSettings();
            }
        }
        public async Task UploadSelectedRuns()
        {
            MetroWindow pluginWindow = Window.GetWindow(this) as MetroWindow;

            if (string.IsNullOrEmpty(PluginSettings.Instance.AccountName) || string.IsNullOrEmpty(PluginSettings.Instance.EncryptedPassword))
            {
                MessageDialogResult messageDialogResult = await pluginWindow.ShowMessageAsync("Error", "Empty account name and/or password. Do you want to open the settings?", MessageDialogStyle.AffirmativeAndNegative);

                if (messageDialogResult == MessageDialogResult.Affirmative)
                {
                    OpenSettings();
                }
                return;
            }
            ArenaMasteryUploaderLogic controller = new ArenaMasteryUploaderLogic(PluginSettings.Instance.AccountName, PluginSettings.Instance.Password);
            ProgressDialogController  progressDialogController = await pluginWindow.ShowProgressAsync("Upload to Arena Mastery", "Uploading arena runs to Arena Mastery");

            Result <UploadResults> result = await controller.LoginAndSubmitArenaRuns(SelectedDecks, progressDialogController.SetProgress);

            collectionView.Refresh();
            await progressDialogController.CloseAsync();

            if (result.Outcome != UploadResults.Success)
            {
                await pluginWindow.ShowMessageAsync("Error", "Error uploading arena runs: " + result.ErrorMessage);
            }
        }
        public async Task RestartService()
        {
            ProgressDialogController progress = null;

            try
            {
                progress = await this.dialogCoordinator.ShowProgressAsync(this, "Restarting service", "Waiting for the service to stop", false);

                progress.SetIndeterminate();

                await this.windowsServiceProvider.StopServiceAsync();

                progress.SetMessage("Wating for the service to start");

                await this.windowsServiceProvider.StartServiceAsync();
            }
            catch (Exception ex)
            {
                logger.LogError(EventIDs.UIGenericError, ex, "Could not restart service");
            }
            finally
            {
                if (progress?.IsOpen ?? false)
                {
                    await progress.CloseAsync();
                }
            }
        }
        public async Task DisableUIAndWaitForNode()
        {
            ProgressDialogController controller = null;

            if (Interlocked.CompareExchange(ref isUiLocked, 1, 0) != 0)
            {
                return;
            }

            try
            {
                controller = await this.dialogCoordinator.ShowProgressAsync(this, "Cluster node no longer active", "This server is no longer hosting the clustered service. Configuration is currently disabled. You can wait for the service to return to this node, or close the app without saving any configuration changes. ", true, new MetroDialogSettings()
                {
                    NegativeButtonText = "Close app without saving"
                });

                controller.Canceled += (sender, args) =>
                {
                    this.clusterWaitSemaphore.Release();
                    Application.Current.Shutdown();
                };

                await this.clusterWaitSemaphore.WaitAsync();
            }
            finally
            {
                isUiLocked = 0;
                await controller?.CloseAsync();
            }
        }
        public async Task Export(ProgressDialogController progress)
        {
            if (!Exists)
            {
                return;
            }

            await Task.Run(() =>
            {
                // export bacpac
                var bacpacName = $"{DateTime.Now:yyyyMMdd_HHmm}.bacpac";
                _dacService.ProgressChanged += (sender, args) => progress.SetMessage($"{args.Status} : {args.Message}");
                _dacService.ExportBacpac(bacpacName, _databaseName);

                // save file
                var filePath = Path.Combine(Directory.GetCurrentDirectory(), bacpacName);
                var result   = new SaveFileDialogService().Show(
                    bacpacName
                    , fileName =>
                {
                    if (!File.Exists(fileName))
                    {
                        File.Move(filePath, fileName);
                    }
                }
                    , () => File.Delete(filePath)
                    );
                progress.SetMessage(result ? "Success" : "Fail");
            });

            await progress.CloseAsync();
        }
Beispiel #28
0
        public async void DeleteCamera(string id, string videoStreamArn, string dataStreamName, string eventSourceUUID, string streamProcessorName, CameraView cv)
        {
            ProgressDialogController controller = await this.ShowProgressAsync("Please wait...", "");

            controller.SetIndeterminate();
            controller.SetCancelable(false);

            controller.SetMessage("Deleting event source mapping");
            await Task.Run(() => Models.Lambda.DeleteEventSourceMapping(eventSourceUUID));

            controller.SetMessage("Deleting data stream");
            await Task.Run(() => Models.DataStream.DeleteDataStream(dataStreamName));

            controller.SetMessage("Deleting video stream");
            await Task.Run(() => Models.VideoStream.DeleteVideoStream(videoStreamArn));

            controller.SetMessage("Deleting stream processor");
            await Task.Run(() => Models.StreamProcessorManager.DeleteStreamProcessor(streamProcessorName));

            controller.SetMessage("Deleting database record");
            await Task.Run(() => Models.Dynamodb.DeleteItem(id, Models.MyAWSConfigs.CamerasDBTableName));

            await controller.CloseAsync();

            cv.LoadCamerasData().ConfigureAwait(false);

            notifyIcon.Visible = true;
            notifyIcon.ShowBalloonTip(1000, "Deleted", "Camera deleted Successfully", System.Windows.Forms.ToolTipIcon.Info);
        }
Beispiel #29
0
 public static async Task HideDefaultProgressAsync()
 {
     if (ProgressDialogController != null)
     {
         await ProgressDialogController.CloseAsync().ConfigureAwait(false);
     }
 }
Beispiel #30
0
        private async void GeneratorProgressUpdate(object sender, ProgressEventArgs e)
        {
            if (e.IsFinished)
            {
                DumpTimigs(generator.Timing);
                ErrorsCount = generator.ErrorsCount;
                generator.Dispose();
                excelStream.Dispose();
                templateStream.Dispose();
                await controller.CloseAsync();

                if (Completed != null)
                {
                    Completed(this, EventArgs.Empty);
                }
            }
            else
            {
                if (controller.IsCanceled)
                {
                    generator.CancellationRequested = true;
                }
                controller.SetProgress(e.Progress);
                controller.SetMessage(e.StepName);
            }
        }