Compare commits
4 Commits
89c5f76797
...
8ed185299f
| Author | SHA1 | Date |
|---|---|---|
|
|
8ed185299f | |
|
|
21441abf34 | |
|
|
1370a09e0f | |
|
|
62eef091ce |
|
|
@ -51,13 +51,13 @@ namespace TIAMSharedUI.Pages.Components
|
||||||
//}
|
//}
|
||||||
componentUpdateService.CallRequestRefresh();
|
componentUpdateService.CallRequestRefresh();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
|
//throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnAfterRender(bool firstRender)
|
protected override void OnAfterRender(bool firstRender)
|
||||||
{
|
{
|
||||||
base.OnAfterRender(firstRender);
|
base.OnAfterRender(firstRender);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleAuthComponent(Microsoft.AspNetCore.Components.Web.MouseEventArgs e)
|
private void ToggleAuthComponent(Microsoft.AspNetCore.Components.Web.MouseEventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,10 @@
|
||||||
@using TIAM.Models.Dtos.Users
|
@using TIAM.Models.Dtos.Users
|
||||||
@using TIAMWebApp.Shared.Application.Interfaces
|
@using TIAMWebApp.Shared.Application.Interfaces
|
||||||
@using TIAMWebApp.Shared.Application.Utility
|
@using TIAMWebApp.Shared.Application.Utility
|
||||||
@inject IUserDataService NwindDataService
|
@using AyCode.Services.Loggers
|
||||||
|
@using TIAM.Core.Loggers
|
||||||
@inject IServiceProviderDataService serviceProviderDataService
|
@inject IServiceProviderDataService serviceProviderDataService
|
||||||
@inject BrowserConsoleLogWriter BrowserConsoleLogWriter
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||||
|
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
UserProductMapping
|
UserProductMapping
|
||||||
|
|
@ -66,8 +67,11 @@
|
||||||
|
|
||||||
public UserModelDtoDetail UserInfo;
|
public UserModelDtoDetail UserInfo;
|
||||||
|
|
||||||
|
ILogger _logger;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
_logger = new LoggerClient<UserGrid_MasterDetail_NestedGrid_ServiceProviders>(LogWriters.ToArray());
|
||||||
|
|
||||||
//get userproductmappings by customer id
|
//get userproductmappings by customer id
|
||||||
if (Customer.ServiceProviders == null)
|
if (Customer.ServiceProviders == null)
|
||||||
|
|
@ -76,7 +80,7 @@
|
||||||
DetailGridData = Customer.ServiceProviders;
|
DetailGridData = Customer.ServiceProviders;
|
||||||
|
|
||||||
AvailableServices = await serviceProviderDataService.GetServiceProvidersAsync();
|
AvailableServices = await serviceProviderDataService.GetServiceProvidersAsync();
|
||||||
BrowserConsoleLogWriter.Info($"DetailGridData: {DetailGridData.Count}");
|
_logger.Info($"DetailGridData: {DetailGridData.Count}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||||
|
|
@ -96,10 +100,10 @@
|
||||||
{
|
{
|
||||||
if (e.IsNew)
|
if (e.IsNew)
|
||||||
//add new orderData to orderData array
|
//add new orderData to orderData array
|
||||||
BrowserConsoleLogWriter.Info("New orderData added");
|
_logger.Info("New orderData added");
|
||||||
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
|
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
|
||||||
else
|
else
|
||||||
BrowserConsoleLogWriter.Info("orderData updated");
|
_logger.Info("orderData updated");
|
||||||
|
|
||||||
//await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel);
|
//await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel);
|
||||||
|
|
||||||
|
|
@ -109,14 +113,14 @@
|
||||||
{
|
{
|
||||||
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
|
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
|
||||||
//remove orderData from orderData array
|
//remove orderData from orderData array
|
||||||
BrowserConsoleLogWriter.Info("orderData deleted");
|
_logger.Info("orderData deleted");
|
||||||
//await UpdateDataAsync();
|
//await UpdateDataAsync();
|
||||||
}
|
}
|
||||||
async Task UpdateDataAsync()
|
async Task UpdateDataAsync()
|
||||||
{
|
{
|
||||||
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
|
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
|
||||||
//refresh grid
|
//refresh grid
|
||||||
BrowserConsoleLogWriter.Info("orderData grid refreshed");
|
_logger.Info("orderData grid refreshed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private Exception _currentError;
|
private Exception? _currentError;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<Exception> OnError { get; set; }
|
public EventCallback<Exception> OnError { get; set; }
|
||||||
|
|
@ -21,11 +21,8 @@ else
|
||||||
protected override Task OnErrorAsync(Exception exception)
|
protected override Task OnErrorAsync(Exception exception)
|
||||||
{
|
{
|
||||||
_currentError = exception;
|
_currentError = exception;
|
||||||
if (OnError.HasDelegate)
|
|
||||||
{
|
return OnError.HasDelegate ? OnError.InvokeAsync(exception) : base.OnErrorAsync(exception);
|
||||||
return OnError.InvokeAsync(exception);
|
|
||||||
}
|
|
||||||
return base.OnErrorAsync(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
@using AyCode.Core.Extensions
|
||||||
@using AyCode.Interfaces.StorageHandlers;
|
@using AyCode.Interfaces.StorageHandlers;
|
||||||
@using AyCode.Services.Loggers
|
@using AyCode.Services.Loggers
|
||||||
@using Newtonsoft.Json;
|
@using Newtonsoft.Json;
|
||||||
|
|
@ -10,7 +11,10 @@
|
||||||
@using TIAMWebApp.Shared.Application.Models;
|
@using TIAMWebApp.Shared.Application.Models;
|
||||||
@using TIAMWebApp.Shared.Application.Utility;
|
@using TIAMWebApp.Shared.Application.Utility;
|
||||||
@using System.IdentityModel.Tokens.Jwt;
|
@using System.IdentityModel.Tokens.Jwt;
|
||||||
|
@using System.Runtime.CompilerServices
|
||||||
@using TIAM.Core.Loggers;
|
@using TIAM.Core.Loggers;
|
||||||
|
@using System.Diagnostics
|
||||||
|
@using AyCode.Utils.Extensions
|
||||||
@inject NavigationManager NavManager
|
@inject NavigationManager NavManager
|
||||||
@inject IJSRuntime jsRuntime
|
@inject IJSRuntime jsRuntime
|
||||||
@inject ISecureStorageHandler SecureStorageHandler
|
@inject ISecureStorageHandler SecureStorageHandler
|
||||||
|
|
@ -49,28 +53,50 @@
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private ILogger _logger;
|
||||||
|
|
||||||
public PopupMessageBox PopupMessageBox { get; private set; } = default!;
|
public PopupMessageBox PopupMessageBox { get; private set; } = default!;
|
||||||
ILogger _logger;
|
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
private void HandleError(Exception exception)
|
|
||||||
{
|
{
|
||||||
|
_logger = new LoggerClient<MainLayout>(LogWriters.ToArray());
|
||||||
|
|
||||||
|
base.OnInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleError(Exception exception)//, [CallerMemberName] string? memberName = null)
|
||||||
|
{
|
||||||
|
exception.GetCategoryAndMemberNameFromStackTraceString(out var memberName, out var categoryName);
|
||||||
|
|
||||||
|
if (memberName.IsNullOrWhiteSpace()) memberName = "..."; //ne "HandleError" memberName-el logoljunk! - J.
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.Error($"An error occurred: {exception.Message}", exception, categoryName, memberName);
|
||||||
|
}
|
||||||
|
catch (Exception loggerException)
|
||||||
|
{
|
||||||
|
jsRuntime.InvokeVoidAsync("console.error", $"{nameof(MainLayout)}->HandleError; Logger error! {loggerException.Message}");
|
||||||
|
|
||||||
|
jsRuntime.InvokeVoidAsync("console.error", $"{nameof(MainLayout)}->{memberName}; An error occurred: {exception.Message}");
|
||||||
|
jsRuntime.InvokeVoidAsync("console.warn", $"{nameof(MainLayout)}->{memberName}; Error details: {exception.StackTrace}");
|
||||||
|
}
|
||||||
|
|
||||||
// Log the error to server
|
// Log the error to server
|
||||||
LogErrorToServer(exception);
|
//LogErrorToServer(exception);
|
||||||
|
|
||||||
// Show a notification on UI
|
// Show a notification on UI
|
||||||
ShowErrorNotification("An unexpected error occurred. Please try again later.");
|
ShowErrorNotification("An unexpected error occurred. Please try again later.");
|
||||||
|
|
||||||
jsRuntime.InvokeVoidAsync("console.error", $"An error occurred: {exception.Message}");
|
//jsRuntime.InvokeVoidAsync("console.error", $"An error occurred: {exception.Message}");
|
||||||
jsRuntime.InvokeVoidAsync("console.warn", $"Error details: {exception.StackTrace}");
|
//jsRuntime.InvokeVoidAsync("console.warn", $"Error details: {exception.StackTrace}");
|
||||||
_logger.Info($"An error occurred: {exception.Message}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogErrorToServer(Exception exception)
|
// private void LogErrorToServer(Exception exception)
|
||||||
{
|
// {
|
||||||
//_logger.Error($"An error occurred: {exception.Message}");
|
// //_logger.Error($"An error occurred: {exception.Message}");
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void ShowErrorNotification(string message)
|
private void ShowErrorNotification(string message)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
using AyCode.Interfaces.StorageHandlers;
|
using AyCode.Core.Loggers;
|
||||||
|
using AyCode.Interfaces.StorageHandlers;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
|
using AyCode.Services.Loggers;
|
||||||
|
using TIAM.Core.Loggers;
|
||||||
using TIAM.Database.DataLayers.Users;
|
using TIAM.Database.DataLayers.Users;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.ServiceProviders;
|
using TIAM.Entities.ServiceProviders;
|
||||||
|
|
@ -18,16 +21,14 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
{
|
{
|
||||||
private readonly HttpClient http;
|
private readonly HttpClient http;
|
||||||
private readonly ISecureStorageHandler secureStorageHandler;
|
private readonly ISecureStorageHandler secureStorageHandler;
|
||||||
private readonly IJSRuntime jsRuntime;
|
private readonly ILogger _logger;
|
||||||
private readonly BrowserConsoleLogWriter _browserConsoleLogWriter;
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceProviderDataService(HttpClient http, ISecureStorageHandler secureStorageHandler, IJSRuntime jSRuntime)
|
public ServiceProviderDataService(HttpClient http, ISecureStorageHandler secureStorageHandler, IEnumerable<IAcLogWriterClientBase> logWriters)
|
||||||
{
|
{
|
||||||
this.http = http;
|
this.http = http;
|
||||||
this.secureStorageHandler = secureStorageHandler;
|
this.secureStorageHandler = secureStorageHandler;
|
||||||
this.jsRuntime = jSRuntime;
|
_logger = new LoggerClient<ServiceProviderDataService>(logWriters.ToArray());
|
||||||
this._browserConsoleLogWriter = new BrowserConsoleLogWriter(jsRuntime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//22.
|
//22.
|
||||||
|
|
@ -74,7 +75,7 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var result = await response.Content.ReadFromJsonAsync<Dictionary<Guid, string>>();
|
var result = await response.Content.ReadFromJsonAsync<Dictionary<Guid, string>>();
|
||||||
_browserConsoleLogWriter.Info(result.FirstOrDefault().Value);
|
_logger.Debug(result.FirstOrDefault().Value);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -123,7 +124,7 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var result = await response.Content.ReadAsStringAsync();
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
_browserConsoleLogWriter.Info("SKBitmap width: " + result);
|
_logger.Debug("SKBitmap width: " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -139,8 +140,9 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var result = await response.Content.ReadAsStringAsync();
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
_browserConsoleLogWriter.Info("Json: " + result);
|
//_logger.Detail("Json: " + result);
|
||||||
var data = JsonConvert.DeserializeObject<IEnumerable<Product>>(result);
|
var data = JsonConvert.DeserializeObject<IEnumerable<Product>>(result);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
return data;
|
return data;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
using System.Globalization;
|
using AyCode.Core.Enums;
|
||||||
using AyCode.Core.Consts;
|
|
||||||
using AyCode.Core.Enums;
|
|
||||||
using AyCode.Core.Loggers;
|
using AyCode.Core.Loggers;
|
||||||
using AyCode.Services.Loggers;
|
using AyCode.Services.Loggers;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
|
||||||
|
|
||||||
namespace TIAMWebApp.Shared.Application.Utility;
|
namespace TIAMWebApp.Shared.Application.Utility;
|
||||||
|
|
||||||
|
|
@ -21,19 +18,25 @@ public class BrowserConsoleLogWriter : AcTextLogWriterBase, IAcLogWriterClientBa
|
||||||
{
|
{
|
||||||
private readonly IJSRuntime _jsRuntime;
|
private readonly IJSRuntime _jsRuntime;
|
||||||
|
|
||||||
//public BrowserConsoleLogWriter() : base(AppType.Web, LogLevel.Debug)
|
private readonly Dictionary<LogLevel, string> _invokeConsoleNames = new()
|
||||||
//{
|
{
|
||||||
// _jsRuntime = Services.GetRequiredService<IJSRuntime>();
|
[LogLevel.Detail] = "console.info", //trace
|
||||||
//}
|
[LogLevel.Trace] = "console.info",
|
||||||
|
[LogLevel.Debug] = "console.info",
|
||||||
|
[LogLevel.Info] = "console.info",
|
||||||
|
[LogLevel.Suggest] = "console.info",
|
||||||
|
[LogLevel.Warning] = "console.warn",
|
||||||
|
[LogLevel.Error] = "console.error"
|
||||||
|
};
|
||||||
|
|
||||||
public BrowserConsoleLogWriter(IJSRuntime jsRuntime) : base(AppType.Web, LogLevel.Debug)
|
public BrowserConsoleLogWriter(IJSRuntime jsRuntime) : base(AppType.Web, LogLevel.Info)
|
||||||
{
|
{
|
||||||
_jsRuntime = jsRuntime;
|
_jsRuntime = jsRuntime;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WriteText(string? logText, LogLevel logLevel)
|
protected override void WriteText(string? logText, LogLevel logLevel)
|
||||||
{
|
{
|
||||||
_jsRuntime.InvokeVoidAsync("console.log", logText);
|
_jsRuntime.InvokeVoidAsync(_invokeConsoleNames[logLevel], logText);
|
||||||
}
|
}
|
||||||
|
|
||||||
//public void Info(string message)
|
//public void Info(string message)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue