diff --git a/TIAM.Entities/Transfers/TransferDestination.cs b/TIAM.Entities/Transfers/TransferDestination.cs index d955a70c..a659bb64 100644 --- a/TIAM.Entities/Transfers/TransferDestination.cs +++ b/TIAM.Entities/Transfers/TransferDestination.cs @@ -59,6 +59,12 @@ namespace TIAM.Entities.Transfers { Description = description; } + + public override string ToString() + { + return $"{nameof(Id)}: {Id}; {nameof(AddressId)}: {AddressId}; {nameof(Name)}: {Name}; {nameof(Description)}: {Description}; {nameof(Price)}: {Price}; " + + $"{nameof(Price2)}: {Price2}; {nameof(Price3)}: {Price3}; {nameof(ProductCommis)}: {ProductCommis}; {nameof(ExtraPrice)}: {ExtraPrice}; {nameof(AddressString)}: {AddressString};"; + } } } \ No newline at end of file diff --git a/TIAMSharedUI/Pages/Components/InputWizard.razor.cs b/TIAMSharedUI/Pages/Components/InputWizard.razor.cs index 6a64fbe1..4e30cb61 100644 --- a/TIAMSharedUI/Pages/Components/InputWizard.razor.cs +++ b/TIAMSharedUI/Pages/Components/InputWizard.razor.cs @@ -5,20 +5,14 @@ using Microsoft.AspNetCore.Components.Web; using System.ComponentModel.DataAnnotations; using System.Linq.Expressions; using TIAMWebApp.Shared.Application.Utility; -using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; -using TIAMWebApp.Shared.Application.Models.PageModels; -using DevExpress.Pdf.Native.BouncyCastle.Asn1.X509.Qualified; using Microsoft.Extensions.Localization; using TIAM.Resources; using TIAMWebApp.Shared.Application.Interfaces; using System.Reflection; using TIAMWebApp.Shared.Application.Models; -using DevExpress.XtraPrinting; using TIAMSharedUI.Shared; -using DevExpress.Pdf.Native.BouncyCastle.Asn1.Cms; using System.Text.RegularExpressions; using AyCode.Core.Consts; -using AyCode.Core.Loggers; using TIAM.Core.Loggers; using AyCode.Services.Loggers; @@ -78,14 +72,14 @@ namespace TIAMSharedUI.Pages.Components _spinnerClass = "spinner-border spinner-border-sm"; await Task.Delay(500); - string debugString = "Success: "; + var debugString = "Success: "; - Type myType = Data.GetType(); + var myType = Data.GetType(); IList props = new List(myType.GetProperties()); - foreach (PropertyInfo prop in props) + foreach (var prop in props) { - object propValue = prop.GetValue(Data, null); + var propValue = prop.GetValue(Data, null); // Do something with propValue debugString += $"{prop.Name} = {propValue}\n"; @@ -116,24 +110,23 @@ namespace TIAMSharedUI.Pages.Components public RenderFragment CreateEditFormFields() => formLayoutBuilder => { - - var _type = Data.GetType(); + var type = Data.GetType(); //for (var i = 0; i < 1000; i++) - _logger.Info("Hellooooo " + _type.AssemblyQualifiedName); + _logger.Info("Hellooooo " + type.AssemblyQualifiedName); - var propertyList = _type.GetProperties(); - var _length = propertyList.Length - IgnoreReflection.Count; + var propertyList = type.GetProperties(); + var length = propertyList.Length - IgnoreReflection.Count; //var propertyList = typeof(TestUserData).GetProperties(); formLayoutBuilder.OpenComponent(0); formLayoutBuilder.AddAttribute(1, "ChildContent", (RenderFragment)((layoutItemBuilder) => { - int i = 0; - int k = 0; + var i = 0; + var k = 0; foreach (var property in propertyList) { - bool isActive = k == CurrentStep; + var isActive = k == CurrentStep; //if (property.Name == "Id" || property.Name == "Latitude" || property.Name == "Longitude" || property.Name == "Created" || property.Name == "Modified") //if (property.Name == "Id" || property.Name == "Created" || property.Name == "Modified") if (IgnoreReflection.Contains(property.Name)) @@ -141,17 +134,17 @@ namespace TIAMSharedUI.Pages.Components continue; } - Guid _stepID = Guid.Empty; + Guid stepId; if (!FormSteps.ContainsKey(k)) { - _stepID = Guid.NewGuid(); - _logger.Detail($"Adding step {k}, {_stepID}, for {property.Name}"); - FormSteps.Add(k, _stepID); + stepId = Guid.NewGuid(); + _logger.Detail($"Adding step {k}, {stepId}, for {property.Name}"); + FormSteps.Add(k, stepId); } else { - _stepID = FormSteps[k]; + stepId = FormSteps[k]; } //the following line creates an expression that accesses the property value by name @@ -159,10 +152,10 @@ namespace TIAMSharedUI.Pages.Components //the following line creates a lambda expression that returns the value of the property var lambda = Expression.Lambda(typeof(Func<>).MakeGenericType(property.PropertyType), access); - _logger.Detail(lambda.ToString()); + _logger.Detail($"lambda: {lambda.ToString()}"); layoutItemBuilder.OpenElement(i++, "div");//open div - layoutItemBuilder.AddAttribute(i++, "id", _stepID.ToString()); + layoutItemBuilder.AddAttribute(i++, "id", stepId.ToString()); layoutItemBuilder.AddAttribute(i++, "class", "disply-flex align-items-center "+CssClass); layoutItemBuilder.AddAttribute(i++, "style", "width: 100%;"); if (k != CurrentStep) @@ -176,8 +169,8 @@ namespace TIAMSharedUI.Pages.Components } - DataTypeAttribute attrList = (DataTypeAttribute)property.GetCustomAttributes(typeof(DataTypeAttribute), false).First(); - DisplayAttribute displayLabel = (DisplayAttribute)property.GetCustomAttributes(typeof(DisplayAttribute), false).First(); + var attrList = (DataTypeAttribute)property.GetCustomAttributes(typeof(DataTypeAttribute), false).First(); + var displayLabel = (DisplayAttribute)property.GetCustomAttributes(typeof(DisplayAttribute), false).First(); layoutItemBuilder.OpenComponent(i++); //open dxformlayoutitem layoutItemBuilder.AddAttribute(i++, "Caption", localizer.GetString(displayLabel.Name)); layoutItemBuilder.AddAttribute(i++, "ColSpanMd", 12); @@ -363,7 +356,7 @@ namespace TIAMSharedUI.Pages.Components { editor.OpenComponent(j); - editor.AddAttribute(j++, "OwlId", "owlSelector" + _stepID); + editor.AddAttribute(j++, "OwlId", "owlSelector" + stepId); editor.AddAttribute(j++, "TextValue", property.GetValue(Data)); //editor.AddAttribute(j++, "TExpression", lambda); editor.AddAttribute(j++, "OnSliderChanged", EventCallback.Factory.Create(this, result => @@ -400,16 +393,16 @@ namespace TIAMSharedUI.Pages.Components _logger.Detail($"FirstName changed to {result}"); //find property with name FirstName - PropertyInfo firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName"); + var firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName"); firstNameProperty.SetValue(Data, result); //find property with name LastName - PropertyInfo lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName"); + var lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName"); //combine the two values, if they are not null if (firstNameProperty != null && lastNameProperty != null) { - string firstName = result; - string lastName = (string)lastNameProperty.GetValue(Data); - string fullName = $"{firstName} {lastName}"; + var firstName = result; + var lastName = (string)lastNameProperty.GetValue(Data); + var fullName = $"{firstName} {lastName}"; property.SetValue(Data, fullName); } })); @@ -419,16 +412,16 @@ namespace TIAMSharedUI.Pages.Components _logger.Detail($"LastName changed to {result}"); //find property with name FirstName - PropertyInfo firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName"); + var firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName"); //find property with name LastName - PropertyInfo lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName"); + var lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName"); lastNameProperty.SetValue(Data, result); //combine the two values, if they are not null if (firstNameProperty != null && lastNameProperty != null) { - string firstName = (string)firstNameProperty.GetValue(Data); - string lastName = result; - string fullName = $"{firstName} {lastName}"; + var firstName = (string)firstNameProperty.GetValue(Data); + var lastName = result; + var fullName = $"{firstName} {lastName}"; property.SetValue(Data, fullName); } _logger.Detail($"bleh: {property.Name} = {property.GetValue(Data)}"); @@ -490,7 +483,7 @@ namespace TIAMSharedUI.Pages.Components layoutItemBuilder.AddAttribute(i++, "Click", EventCallback.Factory.Create(this, OnNext)); layoutItemBuilder.AddAttribute(i++, "SubmitFormOnClick", false); layoutItemBuilder.AddAttribute(i++, "CssClass", "btn btn-primary mt-3"); - if (!(k < _length - 1)) + if (!(k < length - 1)) { layoutItemBuilder.AddAttribute(i++, "disabled", "true"); @@ -511,7 +504,7 @@ namespace TIAMSharedUI.Pages.Components layoutItemBuilder.CloseElement(); - _logger.Detail($"loop {k}, length: {_length}, formSteps: {FormSteps.Count} "); + _logger.Detail($"loop {k}, length: {length}, formSteps: {FormSteps.Count} "); k++; } @@ -526,7 +519,7 @@ namespace TIAMSharedUI.Pages.Components editor.AddAttribute(i++, "type", "submit"); editor.AddAttribute(i++, "class", "btn btn-primary mt-3 w-100"); editor.AddAttribute(i++, "style", "margin: 0 auto"); - if (CurrentStep < _length - 1) + if (CurrentStep < length - 1) { editor.AddAttribute(i++, "disabled", "true"); @@ -571,7 +564,8 @@ namespace TIAMSharedUI.Pages.Components [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] public class MinPasswordLengthAttribute : ValidationAttribute { - int MinLength { get; } + private int MinLength { get; } + public MinPasswordLengthAttribute(int minLength, string errorMsg) : base(errorMsg) { MinLength = minLength; diff --git a/TIAMSharedUI/Shared/Components/Navbar.razor.cs b/TIAMSharedUI/Shared/Components/Navbar.razor.cs index 7a454f29..96dccab3 100644 --- a/TIAMSharedUI/Shared/Components/Navbar.razor.cs +++ b/TIAMSharedUI/Shared/Components/Navbar.razor.cs @@ -8,14 +8,19 @@ using System.Text; using System.Threading.Tasks; using AyCode.Core.Loggers; using AyCode.Services.Loggers; +using TIAM.Core.Loggers; using TIAMSharedUI.Resources; using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Utility; +using TIAMSharedUI.Pages.Components; namespace TIAMSharedUI.Shared.Components { public partial class Navbar : ComponentBase { + [Inject] + public required IEnumerable LogWriters { get; set; } + [Inject] public ISecureStorageHandler SecureStorageHandler { get; set; } @@ -30,19 +35,19 @@ namespace TIAMSharedUI.Shared.Components [Inject] public IComponentUpdateService componentUpdateService { get; set; } - [Inject] - public IAcLogWriterClientBase BrowserConsoleLogWriter { get; set; } - private bool collapseNavMenu = true; private bool myUser = false; private bool hasProperty = false; + private ILogger _logger; + //componentUpdateService.RefreshRequested += RefreshMe; private void RefreshMe() { - BrowserConsoleLogWriter.Info($"Navbar refresh called! {DateTime.Now} "); + _logger.Info($"Navbar refresh called! {DateTime.Now} "); + OnInitialized(); StateHasChanged(); } @@ -67,36 +72,33 @@ namespace TIAMSharedUI.Shared.Components protected override void OnInitialized() { base.OnInitialized(); + + _logger = new LoggerClient(LogWriters.ToArray()); + componentUpdateService.RefreshRequested += RefreshMe; - BrowserConsoleLogWriter.Info($"Navbar OnInit {DateTime.Now} "); + _logger.Info($"Navbar OnInit {DateTime.Now} "); + if (sessionService.User != null) { myUser = true; } else { - BrowserConsoleLogWriter.Info($"Navbar myUser false! {DateTime.Now} "); + _logger.Info($"Navbar myUser false! {DateTime.Now} "); myUser = false; } - var _properties = sessionService.User?.HasProperties; + var properties = sessionService.User?.HasProperties; - if (sessionService.User?.HasProperties != null) + if (properties == null) + return; + + hasProperty = properties.Count > 0; + + foreach (var property in properties) { - if(_properties.Count > 0) - { - hasProperty = true; - } - else - { - hasProperty = false; - } - foreach (var property in _properties) - { - BrowserConsoleLogWriter.Info($"First property: {property.Value} "); - } + _logger.Detail($"First property: {property.Value} "); } - } } diff --git a/TIAMSharedUI/Shared/SliderItemSelector.razor b/TIAMSharedUI/Shared/SliderItemSelector.razor index 0adb753e..25b4d332 100644 --- a/TIAMSharedUI/Shared/SliderItemSelector.razor +++ b/TIAMSharedUI/Shared/SliderItemSelector.razor @@ -1,10 +1,12 @@ @using System.Linq.Expressions @using AyCode.Core.Loggers @using AyCode.Services.Loggers +@using TIAM.Core.Loggers @using TIAM.Entities.Transfers +@using TIAMSharedUI.Pages @using TIAMWebApp.Shared.Application.Interfaces @using TIAMWebApp.Shared.Application.Utility -@inject IAcLogWriterClientBase BrowserConsoleLogWriter +@inject IEnumerable LogWriters