Beispiel #1
0
 public void ShowSuccess(string message, string icon)
 {
     _toaster.Add(
         message,
         MatToastType.Primary,
         "Success!",
         icon: icon);
 }
Beispiel #2
0
        public async Task Execute(IDispatcher dispatcher, FetchDataJobParameters parameters)
        {
            _toaster.Add($"Started to fetch workitems for {parameters.Members.Count()} members.", MatToastType.Info, "Fetch Workitems", MatIconNames.Info);
            await _client.RunWorkitemsJob(parameters.Members, parameters.Reset);

            await dispatcher.Dispatch <FetchProfiles>();
        }
Beispiel #3
0
 public static void AddErrors(this IMatToaster toaster, IEnumerable <string> errors)
 {
     foreach (var error in errors)
     {
         toaster.Add(error, MatToastType.Danger);
     }
 }
Beispiel #4
0
        /// <summary>
        ///     Displays a notification with information about successful encryption or decryption.
        /// </summary>
        /// <param name="notification"></param>
        /// <param name="crypt">Mode of text conversion(encryption or decryption).</param>
        /// <exception cref="ArgumentOutOfRangeException">Unknown conversion mode.</exception>
        public static void ShowSuccessCrypt(this IMatToaster notification, Cipher.CryptMode crypt)
        {
            switch (crypt)
            {
            case Cipher.CryptMode.Decrypt:
                notification.Add("The text has been successfully decrypted.", MatToastType.Success, "Successfully");
                break;

            case Cipher.CryptMode.Encrypt:
                notification.Add("The text has been successfully encrypted.", MatToastType.Success, "Successfully");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(crypt), crypt, null);
            }
        }
Beispiel #5
0
 public void HandleSucces(ApiSucces succes)
 {
     if (succes.Show)
     {
         _matToaster.Add(succes.Message, MatToastType.Success);
     }
 }
Beispiel #6
0
        public async Task Execute(IDispatcher dispatcher, ReportViewModel report)
        {
            try
            {
                await Utils.ExecuteWithLoading(dispatcher, async() =>
                {
                    await _client.Delete <ReportViewModel>(report.Id);
                });

                await dispatcher.Dispatch <FetchReports>();

                _toaster.Add($"{report.ReportType} was deleted successfully.", MatToastType.Success, "Report deleted", MatIconNames.Delete);
            }
            catch (System.Exception ex)
            {
                _toaster.Add(ex.Message, MatToastType.Danger, "Error deleting report", MatIconNames.Error);
            }
        }
Beispiel #7
0
        public async Task Execute(IDispatcher dispatcher, GenerateReportViewModel request)
        {
            try
            {
                dispatcher.Dispatch(new ReceiveReportRequestAction
                {
                    Request = request
                });

                var reportId = await _client.GenerateReport(request);

                _navigation.NavigateTo($"/reports/view/{request.ReportType}/{reportId}");

                _toaster.Add("Report generated successfully", MatToastType.Success, "Report", MatIconNames.Done);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error generating report");
                _toaster.Add($"Error generating report: {ex.Message}", MatToastType.Danger, "Report", MatIconNames.Error);
            }
        }
Beispiel #8
0
        public async Task Execute(IDispatcher dispatcher, VstsRepositoryViewModel repository)
        {
            await Utils.ExecuteWithLoading(dispatcher, async() =>
            {
                await _client.Delete <VstsRepositoryViewModel>(repository.Id);
            });

            // TODO: instead of refresh delete?
            await dispatcher.Dispatch <FetchRepositories>();

            _toaster.Add($"Repository {repository.Name} was deleted successfully.", MatToastType.Success, "Delete", MatIconNames.Delete);
        }
Beispiel #9
0
        public async Task Execute(IDispatcher dispatcher, ProfileViewModel profile)
        {
            await Utils.ExecuteWithLoading(dispatcher, async() =>
            {
                await _client.Delete <ProfileViewModel>(profile.Id);
            });

            // TODO: instead of refresh delete?
            await dispatcher.Dispatch <FetchProfiles>();

            _toaster.Add($"Profile {profile.Name} was deleted successfully.", MatToastType.Success, "Delete", MatIconNames.Delete);
        }
Beispiel #10
0
 private void VerifyResponseStatusCode(HttpResponseMessage response, string caller)
 {
     if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
     {
         _navigation.NavigateTo(Routes.LoginExpiredSession);
     }
     else if (!response.IsSuccessStatusCode)
     {
         var message = $"Calling {caller} resulted in {response.StatusCode} {response.ReasonPhrase}";
         _toaster.Add(message, MatToastType.Danger, "Server responded with error", MatIconNames.Error);
         throw new EtherApiException(response.StatusCode, message);
     }
 }
Beispiel #11
0
 public static async Task CatchAndDisplayErrors(this IMatToaster matToaster, Func <Task> action)
 {
     try
     {
         await action();
     }
     catch (AccessTokenNotAvailableException exception)
     {
         exception.Redirect();
     }
     catch (BussinessException ex)
     {
         matToaster.Add(
             message: ex.GetErrorMessage(),
             type: MatToastType.Danger,
             title: "Operation Failed");
     }
 }
        public void Show(string message, ViewNotifierType type, string title = null, string icon = null)
        {
            var matType = MatToastType.Success;

            switch (type)
            {
            case ViewNotifierType.Error:
                matType = MatToastType.Danger;
                break;

            case ViewNotifierType.Warning:
                matType = MatToastType.Warning;
                break;

            case ViewNotifierType.Info:
                matType = MatToastType.Info;
                break;
            }

            matToaster.Add(message, matType, title, icon);
        }
Beispiel #13
0
 public static void NotifyFail(this IMatToaster toaster, string title, string message)
 {
     toaster.Add(message, MatToastType.Danger, title);
 }
Beispiel #14
0
        private async Task UpdateModelDataOrPhaseShift()
        {
            if (null == Phase1Data.S_KuikiNo &&
                null == Phase1Data.S_Junro &&
                null == Phase1Data.S_KuikiJunro &&
                null == Phase1Data.S_DokuCode &&
                null == Phase1Data.S_DokuName &&
                null == Phase1Data.S_DokuKana &&
                null == Phase1Data.S_Sigai &&
                null == Phase1Data.S_Tel &&
                null == Phase1Data.S_ChomeiCode &&
                null == Phase1Data.S_Banti &&
                null == Phase1Data.S_Gou &&
                null == Phase1Data.S_BuildName &&
                null == Phase1Data.S_BuildKana &&
                null == Phase1Data.S_RoomNo)
            {
                Toaster.Add("条件を一つ以上選択してください", MatToastType.Danger, "エラー");
            }
            else
            {
                //検索
                C_SearchingList = C_DokusyaList.Where(x => (x.Kuiki == Phase1Data.S_KuikiNo || null == Phase1Data.S_KuikiNo) &&
                                                      (x.Junro_K95080 >= Phase1Data.S_Junro * 100 || null == Phase1Data.S_Junro) &&
                                                      (x.KuikiJunro % 100 >= Phase1Data.S_KuikiJunro % 100 || null == Phase1Data.S_KuikiJunro) &&
                                                      (x.DokuCode == Phase1Data.S_DokuCode || null == Phase1Data.S_DokuCode) &&
                                                      (null == Phase1Data.S_DokuName || x.DokuName.Contains(Phase1Data.S_DokuName)) &&
                                                      (null == Phase1Data.S_DokuKana || x.DokuKana.Contains(Phase1Data.S_DokuKana)) &&

                                                      (null == Phase1Data.S_Sigai || x.Sigai1.Contains(Phase1Data.S_Sigai)) &&
                                                      (null == Phase1Data.S_Sigai || x.Sigai2.Contains(Phase1Data.S_Sigai)) &&
                                                      (null == Phase1Data.S_Sigai || x.Sigai3.Contains(Phase1Data.S_Sigai)) &&
                                                      (null == Phase1Data.S_Sigai || x.Sigai4.Contains(Phase1Data.S_Sigai)) &&
                                                      (null == Phase1Data.S_Sigai || x.Sigai5.Contains(Phase1Data.S_Sigai)) &&
                                                      (null == Phase1Data.S_Sigai || x.Sigai6.Contains(Phase1Data.S_Sigai)) &&

                                                      (null == Phase1Data.S_Tel || x.Tel1.Contains(Phase1Data.S_Tel)) &&
                                                      (null == Phase1Data.S_Tel || x.Tel2.Contains(Phase1Data.S_Tel)) &&
                                                      (null == Phase1Data.S_Tel || x.Tel3.Contains(Phase1Data.S_Tel)) &&
                                                      (null == Phase1Data.S_Tel || x.Tel4.Contains(Phase1Data.S_Tel)) &&
                                                      (null == Phase1Data.S_Tel || x.Tel5.Contains(Phase1Data.S_Tel)) &&
                                                      (null == Phase1Data.S_Tel || x.Tel6.Contains(Phase1Data.S_Tel)) &&

                                                      (null == Phase1Data.S_ChomeiCode || x.ChomeiCode == Phase1Data.S_ChomeiCode) &&
                                                      (null == Phase1Data.S_Banti || x.Banti_Kansa == Phase1Data.S_Banti) &&
                                                      (null == Phase1Data.S_Gou || x.Gou == Phase1Data.S_Gou) &&
                                                      (null == Phase1Data.S_BuildName || x.BuildName.Contains(Phase1Data.S_BuildName)) &&
                                                      (null == Phase1Data.S_BuildKana || x.BuildName.Contains(Phase1Data.S_BuildKana)) &&
                                                      (null == Phase1Data.S_RoomNo || x.RoomNo.Contains(Phase1Data.S_RoomNo.ToString())) &&
                                                      (x.Tenpo == Phase1Data.Select_TenpoNo) &&

                                                      ((true == KubunList[0].Active && x.DokuKbn == KubunList[0].KubunCode)) ||
                                                      ((true == KubunList[1].Active && x.DokuKbn == KubunList[1].KubunCode)) ||
                                                      ((true == KubunList[2].Active && x.DokuKbn == KubunList[2].KubunCode)) ||
                                                      ((true == KubunList[3].Active && x.DokuKbn == KubunList[3].KubunCode)) ||
                                                      ((true == KubunList[4].Active && x.DokuKbn == KubunList[4].KubunCode)) ||
                                                      ((true == KubunList[5].Active && x.DokuKbn == KubunList[5].KubunCode)) ||
                                                      ((true == KubunList[6].Active && x.DokuKbn == KubunList[6].KubunCode)) ||
                                                      ((true == KubunList[7].Active && x.DokuKbn == KubunList[7].KubunCode)) ||
                                                      ((true == KubunList[8].Active && x.DokuKbn == KubunList[8].KubunCode)) ||
                                                      ((true == KubunList[9].Active && x.DokuKbn == KubunList[9].KubunCode)) ||
                                                      ((true == KubunList[10].Active && x.DokuKbn == KubunList[10].KubunCode))


                                                      ).ToList();

                if (C_SearchingList.Count == 0)
                {
                    Toaster.Add("存在しませんでした", MatToastType.Danger, "エラー");
                }
                else
                {
                    Console.WriteLine("OK");
                    Phase1Data.PhaseNo = 2;
                    await C_SearchingListChanged.InvokeAsync(C_SearchingList);

                    await Phase1DataChanged.InvokeAsync(Phase1Data);

                    StateHasChanged();
                }
            }
        }
Beispiel #15
0
 /// <summary>
 ///     Display a notification with information about the error.
 /// </summary>
 /// <param name="notification"></param>
 /// <param name="errorMessage">Text of the error that will be displayed inside the notification.</param>
 public static void ShowError(this IMatToaster notification, string errorMessage)
 {
     notification.Add(errorMessage, MatToastType.Danger, "Error");
 }
Beispiel #16
0
 public static void ShowSuccessSending(this IMatToaster notification)
 {
     notification.Add("The message was sent successfully!", MatToastType.Success, "Successfully");
 }
Beispiel #17
0
 /// <summary>
 ///     Displays a notification with information about successful file upload.
 /// </summary>
 /// <param name="notification"></param>
 public static void ShowSuccessUploading(this IMatToaster notification)
 {
     notification.Add("The file was uploaded successfully.", MatToastType.Success, "Successfully");
 }
Beispiel #18
0
 private void ShowMessage(string message, MessageType messageType)
 {
     m_toaster.Add(message, messageType.AsMatType(), messageType.ToString());
 }
Beispiel #19
0
 public static void NotifySuccess(this IMatToaster toaster, string title, string message)
 {
     toaster.Add(message, MatToastType.Success, title);
 }
Beispiel #20
0
 public static void AddNotification(NotificationMessage message)
 {
     _toaster.Add(message.Message, (MatToastType)message.NotificationType);
 }
        public async Task InitConnectionAsync()
        {
            if (IsConnected)
            {
                return;
            }

            var accessTokenState = await _tokenProvider.RequestAccessToken();

            if (accessTokenState.TryGetToken(out var accessToken))
            {
                var apiBaseUrl        = _configurtion["api:baseUrl"];
                var accessTokenString = accessToken.Value;
                _hubConnection = new HubConnectionBuilder()
                                 .WithUrl($"{apiBaseUrl}tictactoe?access_token={accessTokenString}", options =>
                {
                    options.AccessTokenProvider = () => Task.FromResult(accessTokenString);
                })
                                 .WithAutomaticReconnect(new[] { TimeSpan.Zero, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10) })
                                 .Build();


                _hubConnection.On("StartGame", (GameSession data) =>
                {
                    GameRunning?.Invoke(this, new GameRunningEventArgs {
                        Running = true
                    });
                    ActiveSession?.Invoke(this, new ActiveSessionEventArgs {
                        Session = data
                    });
                });

                _hubConnection.On("GameOver", (string data) =>
                {
                    GameRunning?.Invoke(this, new GameRunningEventArgs {
                        Running = false
                    });
                    ActiveSession?.Invoke(this, new ActiveSessionEventArgs {
                        Session = null
                    });
                    GameOver?.Invoke(this, new GameOverEventArgs {
                        WinnerId = data
                    });
                });

                _hubConnection.On <int>("Play", (data) =>
                {
                    Console.WriteLine($"Round Played. Data is {data}");
                    RoundPlayed?.Invoke(this, new GameEventArgs()
                    {
                        Value = data
                    });
                });

                _hubConnection.Closed += async(exception) => {
                    _toaster.Add(exception.Message, MatToastType.Danger);
                    await _sessionStateManager.SetSignOutState();

                    _navigationManager.NavigateTo("authentication/logout");
                };

                try
                {
                    Console.WriteLine("start signalr connection");
                    await _hubConnection.StartAsync();

                    _toaster.Add("Erfolgreich angemeldet.", MatToastType.Success, null, null, (options) => {
                        options.ShowProgressBar      = false;
                        options.ShowCloseButton      = false;
                        options.VisibleStateDuration = 2500;
                    });
                    await JoinNewSession();
                }
                catch (Exception e)
                {
                    _toaster.Add(
                        $"Beim Verbinden zum Server ist etwas schief gelaufen. Error: {e.Message}",
                        MatToastType.Danger);
                }
            }
        }