41 Commits

Author SHA1 Message Date
Samuele Locatelli d4f640e062 Merge tag 'AddSublicGen02' into develop
Aggiunta metodi gen chiave con GUID iniziale opzionale
2024-09-26 07:50:54 +02:00
Samuele Locatelli 317a5dff60 Merge branch 'release/AddSublicGen02' 2024-09-26 07:50:36 +02:00
Samuele Locatelli 1d8d58f7ba Update metodi gen chiave 2024-09-26 07:50:20 +02:00
Samuele Locatelli 2adb338fdd Merge tag 'AddSublicGen01' into develop
Aggiunta gestione generazione UID macchine + Sublic key gen
2024-09-25 11:43:33 +02:00
Samuele Locatelli e57e429115 Merge branch 'release/AddSublicGen01' 2024-09-25 11:43:03 +02:00
Samuele Locatelli 321a7091c6 Aggiunta classi x gestione
- machine info
- inclusione librerie x DeviceId
- Generatore CodImpiego + Key x machines
2024-09-25 11:42:28 +02:00
Samuele Locatelli 7e51b6b977 Merge tag 'FixDataPager01' into develop
Fix comportamento datapager x display vert + cambio blocco
2024-09-24 16:20:19 +02:00
Samuele Locatelli 094bce95a1 Merge branch 'release/FixDataPager01' 2024-09-24 16:20:05 +02:00
Samuele Locatelli a052a589de Update comportamento DataPager + fix display vert 2024-09-24 16:19:36 +02:00
Samuele Locatelli 7ebd686e8f Merge tag 'AddCalcFestIta' into develop
Aggiunta calcolo festività italiane
2024-09-12 15:02:50 +02:00
Samuele Locatelli 2273cbfadb Merge branch 'release/AddCalcFestIta' 2024-09-12 15:02:44 +02:00
Samuele Locatelli 020fb301a5 Aggiunta classe Gest Calendario x calcolo festività ITA 2024-09-12 15:02:20 +02:00
Samuele Locatelli 227d5027aa Merge tag 'UpdateDataPager02' into develop
Update gestione DataPager x display piena larghezza
2024-09-12 08:57:57 +02:00
Samuele Locatelli 7a8094d9d0 Merge branch 'release/UpdateDataPager02' 2024-09-12 08:57:41 +02:00
Samuele Locatelli 582b4bc584 Fix align pager 2024-09-12 08:37:53 +02:00
Samuele Locatelli 24865ae12b Merge tag 'UpdateDataPager01' into develop
Update comportamento datapager x modificare num max pagine mostrate +
size (bozza)
2024-09-12 08:28:03 +02:00
Samuele Locatelli 142338cf80 Merge branch 'release/UpdateDataPager01' 2024-09-12 08:27:28 +02:00
Samuele Locatelli bfb6f1e21d Update datapager 2024-09-12 08:26:59 +02:00
Samuele Locatelli 593ecf9e7a Merge tag 'FixTogllerTestRadzen' into develop
Fix toggler (spazio sx) + test componenti radzen
2024-09-12 07:55:31 +02:00
Samuele Locatelli db077a34ac Merge branch 'release/FixTogllerTestRadzen' 2024-09-12 07:55:17 +02:00
Samuele Locatelli c449bb0741 Fix toggler display 2024-09-12 07:54:44 +02:00
Samuele Locatelli c29dcd8fc9 Update appunti Radzen 2024-09-06 08:47:45 +02:00
Samuele Locatelli 2dde594e40 Aggiunto componenti x test RadZen Scheduler 2024-09-06 08:43:12 +02:00
Samuele Locatelli bc458303fc Merge tag 'FixCalWeekColumns04' into develop
Fix display calendario x dettaglio evento
2024-08-27 10:35:46 +02:00
Samuele Locatelli 62c1452702 Merge branch 'release/FixCalWeekColumns04' 2024-08-27 10:35:33 +02:00
Samuele Locatelli c5fd7bdf2f Calendario Week:
- Update contenitore dati con a capo gestito
2024-08-27 10:35:17 +02:00
Samuele Locatelli 964ca83a5e Merge tag 'FixCalWeekColumns03' into develop
Aggiunto evento ritorno a settimana e dettaglio giorno
2024-08-27 09:55:53 +02:00
Samuele Locatelli 3a14cdfa1f Merge branch 'release/FixCalWeekColumns03' 2024-08-27 09:55:43 +02:00
Samuele Locatelli b2bd46664a Update gestione calendario settimanale 2024-08-26 11:40:08 +02:00
Samuele Locatelli 316c477eb0 Update display cone vento ritorno sel giorno da week 2024-08-26 10:19:35 +02:00
Samuele Locatelli fcf271be58 Merge tag 'FixCalWeekColumns02' into develop
Esposto aprametro x variare fattore scala calendario
2024-08-23 16:12:54 +02:00
Samuele Locatelli e4a1728762 Merge branch 'release/FixCalWeekColumns02' 2024-08-23 16:12:37 +02:00
Samuele Locatelli 6df43b66dc Esposto parametro PercY:
- x controllare shift valorii su calendario vert giorno
- int in centesimi di variazioen su val shift orizzontale
2024-08-23 16:12:17 +02:00
Samuele Locatelli 3bbab02331 Merge tag 'FixCalWeekColumns01' into develop
Fix comportamento calendario settimanale inc aso di sovrapposizioni
eventi
2024-08-23 15:31:08 +02:00
Samuele Locatelli 018411ff17 Merge branch 'release/FixCalWeekColumns01' 2024-08-23 15:30:55 +02:00
Samuele Locatelli 375ac0f066 Review calendario settimanale x sovrapposizioni 2024-08-23 15:29:54 +02:00
Samuele Locatelli cc374a1305 Merge tag 'UpdCopyClipboard01' into develop
update test + update nuget x copy2clipboard
2024-06-01 11:36:31 +02:00
Samuele Locatelli 44c351f638 Merge branch 'release/UpdCopyClipboard01' 2024-06-01 11:36:14 +02:00
Samuele Locatelli c9804678ab Update componente CopyClipboard 2024-06-01 11:35:32 +02:00
Samuele Locatelli d1ed4b0813 Merge branches 'develop' and 'develop' of https://gitlab.steamware.net/egalware/egwcorelib into develop 2024-05-08 18:13:54 +02:00
Samuele Locatelli 3b2be606d5 fIX TEST bARCODErEADER 2024-05-08 18:13:47 +02:00
43 changed files with 1898 additions and 476 deletions
@@ -0,0 +1,49 @@
@inject DialogService DialogService
<RadzenTemplateForm TItem="Appointment" Data="@model" Submit=@OnSubmit>
<RadzenStack Gap="1rem">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="Title" Style="width: 4rem;" />
<RadzenTextBox @bind-Value="@model.Text" Name="Text" Style="width: 12rem;" />
<RadzenRequiredValidator Component="Text" Text="Title is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="Detail" Style="width: 4rem;" />
<RadzenTextBox @bind-Value="@model.Detail" Name="Detail" Style="width: 12rem;" />
<RadzenRequiredValidator Component="Detail" Text="Detail is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="Start" Style="width: 4rem;" />
<RadzenDatePicker @bind-Value="@model.Start" Name="Start" ShowTime="true" Style="width: 12rem;" />
<RadzenRequiredValidator Component="Start" Text="Start is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="End" Style="width: 4rem;" />
<RadzenDatePicker Name="End" @bind-Value="@model.End" ShowTime="true" Style="width: 12rem;" />
<RadzenRequiredValidator Component="End" Text="End is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.End" >
<RadzenButton ButtonType="ButtonType.Submit" Text="Save" />
</RadzenStack>
</RadzenStack>
</RadzenTemplateForm>
@code {
[Parameter]
public DateTime Start { get; set; }
[Parameter]
public DateTime End { get; set; }
Appointment model = new Appointment();
protected override void OnParametersSet()
{
model.Start = Start;
model.End = End;
}
void OnSubmit(Appointment model)
{
DialogService.Close(model);
}
}
@@ -0,0 +1,11 @@
namespace EgwCoreLib.BlazorTest.Components
{
public class Appointment
{
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string Text { get; set; } = "";
public string Detail { get; set; } = "";
}
}
@@ -0,0 +1,45 @@
@inject DialogService DialogService
<RadzenTemplateForm TItem="Appointment" Data="@model" Submit=@OnSubmit>
<RadzenStack Gap="1rem">
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="Title" Style="width: 6rem;" />
<RadzenTextBox @bind-Value="@model.Text" Name="Text" Style="width: 12rem;" />
<RadzenRequiredValidator Component="Text" Text="Title is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="Detail" Style="width: 6rem;" />
<RadzenTextBox @bind-Value="@model.Detail" Name="Detail" Style="width: 12rem;" />
<RadzenRequiredValidator Component="Detail" Text="Detail is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="Start" Style="width: 6rem;" />
<RadzenDatePicker @bind-Value="@model.Start" Name="Start" ShowTime="true" Style="width: 12rem;" />
<RadzenRequiredValidator Component="Start" Text="Start is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Wrap="FlexWrap.Wrap">
<RadzenLabel Text="End" Style="width: 6rem;" />
<RadzenDatePicker Name="End" @bind-Value="@model.End" ShowTime="true" Style="width: 12rem;" />
<RadzenRequiredValidator Component="End" Text="End is required" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.End" >
<RadzenButton ButtonType="ButtonType.Submit" Text="Save" />
</RadzenStack>
</RadzenStack>
</RadzenTemplateForm>
@code {
[Parameter]
public Appointment Appointment { get; set; }
Appointment model = new Appointment();
protected override void OnParametersSet()
{
model = Appointment;
}
void OnSubmit(Appointment model)
{
DialogService.Close(model);
}
}
@@ -0,0 +1,76 @@
@using Radzen
@using System.Text.Json
@inject IJSRuntime JSRuntime
<RadzenCard Variant="Variant.Outlined" class="rz-mt-4">
<RadzenStack Orientation="Orientation.Vertical" Gap="0.5rem" @attributes=@Attributes>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.SpaceBetween">
<RadzenText TextStyle="TextStyle.Subtitle1" TagName="TagName.P" class="rz-m-0">Console log</RadzenText>
<RadzenButton Click=@OnClearClick Text="Clear console" ButtonStyle="ButtonStyle.Base" Variant="Variant.Flat" Size="ButtonSize.Small" />
</RadzenStack>
<RadzenStack Orientation="Orientation.Vertical" Gap="0" ID="event-console" class="rz-pt-1" Style="border-top: var(--rz-grid-cell-border); min-height: 2rem; max-height: 12rem; overflow: auto;">
@foreach (var message in messages)
{
<RadzenAlert ShowIcon="false" Variant="Variant.Flat" AlertStyle="message.AlertStyle" Size="AlertSize.ExtraSmall" Shade="Shade.Lighter" AllowClose="false" Style="font-size: 0.75rem">
<span Style="opacity: 0.6;">@message.Date.ToString("HH:mm:ss.ff")</span> @message.Text
</RadzenAlert>
}
</RadzenStack>
</RadzenStack>
</RadzenCard>
@code {
/* ------------------------------------------------
* Radzen Blazor
* https://www.radzen.com/blazor-components/
* dettagli installazione:
* NET6: https://blazor.radzen.com/get-started/net6-server
* NET8: https://blazor.radzen.com/get-started/net8
*
* demo compo
* https://github.com/radzenhq/radzen-blazor/blob/master/RadzenBlazorDemos/Shared/EventConsole.razor
* ------------------------------------------------*/
class Message
{
public DateTime Date { get; set; }
public string Text { get; set; }
public AlertStyle AlertStyle { get; set; }
}
[Parameter(CaptureUnmatchedValues = true)]
public IDictionary<string, object> Attributes { get; set; }
IList<Message> messages = new List<Message>();
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
{
await JSRuntime.InvokeVoidAsync("eval", $"document.getElementById('event-console').scrollTop = document.getElementById('event-console').scrollHeight");
}
}
void OnClearClick()
{
Clear();
}
public void Clear()
{
messages.Clear();
InvokeAsync(StateHasChanged);
}
public void Log(string message, AlertStyle alertStyle = AlertStyle.Info)
{
messages.Add(new Message { Date = DateTime.Now, Text = message, AlertStyle = alertStyle });
InvokeAsync(StateHasChanged);
}
public void Log(object value)
{
Log(JsonSerializer.Serialize(value));
}
}
+2
View File
@@ -17,6 +17,8 @@ namespace EgwCoreLib.BlazorTest.Data
{"TestSvgDraw", "Test SVG draw"},
{"TestGauges", "Test Gauges"},
{"TestChart", "Test Chart.js"},
{"TestRadzenSched", "Test Radzen Scheduler" },
{"TestHwInfo", "Test HW Info" }
};
}
}
@@ -19,6 +19,13 @@
<None Include="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DeviceId" Version="6.7.0" />
<PackageReference Include="DeviceId.Windows" Version="6.6.0" />
<PackageReference Include="DeviceId.Windows.Wmi" Version="6.6.0" />
<PackageReference Include="Radzen.Blazor" Version="5.1.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EgwCoreLib.Razor\EgwCoreLib.Razor.csproj" />
</ItemGroup>
@@ -5,17 +5,17 @@
<div class="card my-2">
<div class="card-header"><h4>Test Barcode Reader</h4></div>
<div class="card-body">
<BarcodeReader ScanResult="(e) => ScanDoneHandler(e)"
<BarcodeReader
@ref="barcodeReaderCustom"
ScanResult="(e) => ScanDoneHandler(e)"
ScanBtnTitle="Scan"
ResetBtnTitle="Reset"
CloseBtnTitle="Close"
UseBuiltinDiv="false"
@ref="barcodeReaderCustom"
SelectDeviceBtnTitle="Select Device">
</BarcodeReader>
<div @ref="barcodeReaderCustom.Element" class="d-flex justify-content-center">
@* <div style="width: 480px; max-width: 100%"> *@
<div @ref="barcodeReaderCustom.Element" class="d-flex justify-content-center">
<div class="col-12 col-md-8 col-lg-6">
<button class="btn btn-outline-success p-2 m-1 w-25" data-action="startButton">Scan</button>
<button class="btn btn-outline-success p-2 m-1 w-25" data-action="resetButton">Reset</button>
@@ -26,7 +26,7 @@
</select>
</div>
<div>
<video id="video" playsinline="true" autoplay="true" class="w-100 h-100 border rounded shadow" muted="true"></video>
<video id="video" playsinline="true" autoplay="true" class="w-100 h-100 border rounded shadow shadow-lg image-mirror" muted="true"></video>
</div>
</div>
</div>
@@ -34,7 +34,6 @@
</div>
@code {
private int currentCount = 0;
protected BarcodeReader barcodeReaderCustom { get; set; } = null!;
protected Random rnd = new Random();
@@ -42,36 +41,11 @@
{
await Task.Delay(1);
}
private void IncrementCount()
{
currentCount++;
}
protected override void OnInitialized()
{
base.OnInitialized();
listBord01 = new();
listBord01.Add("");
listBord01.Add("White");
listBord01.Add("");
listBord01.Add("");
listBord02 = new();
listBord02.Add("");
listBord02.Add("White");
listBord02.Add("");
listBord02.Add("White");
listBord03 = new();
listBord03.Add("");
listBord03.Add("White");
listBord03.Add("");
listBord03.Add("Blue");
}
protected List<string> listBord01 { get; set; } = new();
protected List<string> listBord02 { get; set; } = new();
protected List<string> listBord03 { get; set; } = new();
protected string qrCodeVal { get; set; } = "https://office.egalware.com/WDC/UI";
}
@@ -0,0 +1,7 @@
.image-mirror {
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
/* Safari and Chrome */
-moz-transform: rotateY(180deg);
/* Firefox */
}
@@ -0,0 +1,5 @@
.image-mirror {
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg); /* Safari and Chrome */
-moz-transform: rotateY(180deg); /* Firefox */
}
@@ -0,0 +1 @@
.image-mirror{transform:rotateY(180deg);-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg);}
@@ -8,6 +8,12 @@
</div>
<div class="card-body py-1">
<div class="row bg-dark py-3">
<div class="col">
<CalendarWeek DateList="@ListDate" EventList="@EventListWeek" PercX="150" PercY="0" backToCalendar="ForceReloadWeek" EC_HeadDateSel="SetDayDetail"></CalendarWeek>
</div>
</div>
<div class="row bg-dark">
<div class="col">
<CircleGauge maxVal="480" currVal="240" Titolo="4:00" Testo="Lavorate"></CircleGauge>
@@ -1,3 +1,5 @@
using EgwCoreLib.Razor.Data;
namespace EgwCoreLib.BlazorTest.Pages
{
public partial class TestCalendario
@@ -8,8 +10,15 @@ namespace EgwCoreLib.BlazorTest.Pages
{
dtCurr = DateTime.Today;
await Task.Delay(1);
setupMonthSim();
// preparo calendario settimanale...
setupWeekSim();
}
private void setupMonthSim()
{
DateCheck = new Dictionary<DateTime, string>();
Random rnd = new Random();
// random colorate...
for (int i = 0; i < 10; i++)
{
@@ -25,6 +34,61 @@ namespace EgwCoreLib.BlazorTest.Pages
}
}
/// <summary>
/// Forza ricaricamento week
/// </summary>
protected void ForceReloadWeek()
{
// preparo calendario settimanale...
setupWeekSim();
}
protected void SetDayDetail(DateTime selDate)
{
var tmpDays = ListDate.Where(x => x.Equals(selDate)).ToList();
var tmpEv = EventListWeek.Where(x => x.Inizio.Date.Equals(selDate)).ToList();
// salvo valori simulati
ListDate = tmpDays;
EventListWeek = tmpEv;
}
protected Random rnd = new Random();
private void setupWeekSim()
{
DateTime oggi = DateTime.Today;
var tmpDays = new List<DateTime>();
var tmpEv = new List<CalendarEvent>();
for (int i = 0; i < 5; i++)
{
tmpDays.Add(oggi.AddDays(i));
// genero qualche evento da 0 a 6...
int numEv = rnd.Next(0, 8);
if (numEv > 0)
{
for (int e = 0; e < numEv; e++)
{
int inizio = rnd.Next(8, 12);
int fine = inizio + rnd.Next(2,8);
CalendarEvent newEv = new CalendarEvent()
{
CssClass = "bg-success opacity-25",
Description = $"Permesso #{e}, testo molto lungo per provare andata a capo con o senza un segnaposto",
Type = "PERM",
Inizio = oggi.AddDays(i).AddHours(inizio),
Fine = oggi.AddDays(i).AddHours(fine),
Title = "O.S.",
ToolTip = $"O.S. {oggi.AddDays(i).AddHours(inizio)} - {oggi.AddDays(i).AddHours(fine)}"
};
tmpEv.Add(newEv);
}
}
}
// salvo valori simulati
ListDate = tmpDays;
EventListWeek = tmpEv;
}
#endregion Protected Methods
#region Private Fields
@@ -37,6 +101,9 @@ namespace EgwCoreLib.BlazorTest.Pages
private DateTime dtCurr { get; set; } = DateTime.Today;
private List<DateTime> ListDate { get; set; } = new List<DateTime>();
private List<CalendarEvent> EventListWeek { get; set; } = new List<CalendarEvent>();
private bool singleWeek = false;
#endregion Private Properties
@@ -46,7 +113,7 @@ namespace EgwCoreLib.BlazorTest.Pages
private void DisplayDate(DateTime dtSel)
{
dtCurr = dtSel;
singleWeek= true;
singleWeek = true;
}
private async Task resetCal()
@@ -5,14 +5,14 @@
<PageTitle>Test</PageTitle>
<div class="card">
<div class="card shadow">
<div class="card-header">
<h1>Test Componenti custom</h1>
</div>
<div class="card-body py-1">
<div class="card-body py-4">
<div class="row">
<div class="col-3">
<div class="card">
<div class="card shadow">
<div class="card-header">
Test Image
</div>
@@ -22,7 +22,7 @@
</div>
</div>
<div class="col-3">
<div class="card">
<div class="card shadow">
<div class="card-header">
Input password
</div>
@@ -45,13 +45,16 @@
</div>
</div>
<div class="col-3">
<div class="card">
<div class="card shadow">
<div class="card-header">
Input Speciali
</div>
<div class="card-body py-1">
<small>Test copia clipboard, GUID (presudo)random</small>
<CopyToClipboard Text="@textToCopy"></CopyToClipboard>
<br />
<small>Test copia clipboard, valore hidden</small>
<CopyToClipboard Text="@textToCopy" ShowText="false"></CopyToClipboard>
<hr />
<small>Input numerico con gestione cifre (es x double)</small>
<NumInput CssClass="form-control" @bind-Value="@valDecimale"></NumInput>
@@ -62,7 +65,7 @@
</div>
</div>
<div class="col-3">
<div class="card">
<div class="card shadow">
<div class="card-header">
QueryString
</div>
@@ -125,19 +128,51 @@
</div>
</div>
</div>
<div class="col-3">
<div class="card ">
<div class="card-header"><h4>Test toggler</h4></div>
<div class="card-body">
<Toggler SelFilter="@TogFilter"></Toggler>
<br/>
<NumInput Value="@numero"></NumInput>
</div>
</div>
</div>
<div class="col-3">
<span class="form-check form-switch">
<label class="form-check-label">Small Pager</label>
<input class="form-check-input" type="checkbox" @bind="@ShowSmallPager">
</span>
</div>
</div>
</div>
<div class="card-footer">
@if(ShowSmallPager)
{
<DataPager currPage="1" totalCount="@numero" NumPages="4" DisplSize="DataPager.ObjSize.small"></DataPager>
}
else
{
<DataPager currPage="1" totalCount="@numero"></DataPager>
}
</div>
</div>
@code {
Toggler.SelectGlobalToggle TogFilter { get; set; } = new Toggler.SelectGlobalToggle();
protected string textToCopy = $"{Guid.NewGuid()}";
protected decimal valDecimale = 12345;
private string qsNome = "";
private int qsIntero = -1;
private int numero = 0;
private bool ShowSmallPager { get; set; } = false;
protected Random rnd = new Random();
protected override void OnInitialized()
{
@@ -145,6 +180,16 @@
qsNome = NavMan.ExtractQueryStringByKey<string>("Nome");
qsIntero = NavMan.ExtractQueryStringByKey<int>("Intero");
NavMan.LocationChanged += LocationChanged;
// toggler!
TogFilter = new()
{
isActive = true,
leftString = "opzione sx",
rightString = "opzione dx"
};
//test input
numero = rnd.Next(100, 300);
}
async void LocationChanged(object sender, LocationChangedEventArgs e)
{
@@ -2,8 +2,8 @@
<PageTitle>Test</PageTitle>
<div class="card">
<div class="card-header"><h4>Test Componenti Arrow SVG</h4></div>
<div class="card shadow ">
<div class="card-header"><h4>Test Grapth Compo: Arrow SVG</h4></div>
<div class="card-body">
<div class="row bg-secondary py-2">
<div class="col">
@@ -22,8 +22,8 @@
</div>
</div>
@code {
private int currentCount = 0;
protected Random rnd = new Random();
@@ -46,10 +46,8 @@
listBord03.Add("White");
listBord03.Add("");
listBord03.Add("Blue");
}
protected List<string> listBord01 { get; set; } = new();
protected List<string> listBord02 { get; set; } = new();
protected List<string> listBord03 { get; set; } = new();
@@ -0,0 +1,125 @@
@page "/TestHwInfo"
@using DeviceId
@using EgwCoreLib.Utils
<div class="row small">
<div class="col-6">
<ul class="list-group">
<li class="list-group-item active">
Device ID
</li>
@if (ListDevId != null && ListDevId.Count > 0)
{
@foreach (var item in ListDevId)
{
<li class="list-group-item d-flex justify-content-between">
<div class="px-1">@item.Key</div>
<div class="px-1">@item.Value</div>
</li>
}
}
</ul>
<hr />
<ul class="list-group">
<li class="list-group-item active">
Sublicense
</li>
<li class="list-group-item d-flex justify-content-between">
<div class="px-1">CodImpiego</div>
<div class="px-1">@codImpiego</div>
</li>
<li class="list-group-item d-flex justify-content-between">
<div class="px-1">Payload</div>
<div class="px-1">@decVal</div>
</li>
<li class="list-group-item d-flex justify-content-between">
<div class="px-1">AppKey</div>
<div class="px-1">@appKey</div>
</li>
<li>
<button class="btn btn-primary" @onclick="Regenerate">ReGen</button>
</li>
</ul>
</div>
<div class="col-6">
<ul class="list-group">
<li class="list-group-item active">
Machine Info
</li>
@if (ListMachineInfo != null && ListMachineInfo.Count > 0)
{
@foreach (var item in ListMachineInfo)
{
<li class="list-group-item d-flex justify-content-between">
<div class="px-1">@item.Key</div>
<div class="px-1">@item.Value</div>
</li>
}
}
</ul>
</div>
</div>
@code {
protected Dictionary<string, string> ListDevId { get; set; } = new Dictionary<string, string>();
protected Dictionary<string, string> ListMachineInfo { get; set; } = new Dictionary<string, string>();
protected MachineDataValidator MDValidator { get; set; } = new MachineDataValidator();
protected SubLicManager SubLicManager { get; set; } = new SubLicManager();
protected string codImpiego = "";
protected string appKey = "";
protected string decVal = "";
protected override void OnInitialized()
{
string deviceId = "";
deviceId = new DeviceIdBuilder()
.OnWindows(windows => windows.AddWindowsDeviceId())
.ToString();
ListDevId.Add("DevId_01", deviceId);
deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
// .AddFileToken("machine.uid")
.ToString();
ListDevId.Add("DevId_02", deviceId);
deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddUserName()
.AddOsVersion()
.OnWindows(windows => windows
.AddMacAddressFromWmi(excludeWireless: true, excludeNonPhysical: true)
.AddProcessorId()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber())
.ToString();
ListDevId.Add("DevId_03", deviceId);
ListMachineInfo = MachineDataValidator.userInfo;
foreach (var item in MachineDataValidator.netInfo)
{
if (!ListMachineInfo.ContainsKey(item.Key))
{
ListMachineInfo.Add(item.Key, item.Value);
}
}
Regenerate();
}
protected void Regenerate()
{
codImpiego = SubLicManager.CodImpiego();
appKey = SubLicManager.GenKey(passphrase, false);
decVal = SteamCrypto.DecryptString(appKey, passphrase);
}
private string passphrase = "SaltPass";
}
@@ -0,0 +1,184 @@
@page "/TestRadzenSched"
@inject DialogService DialogService
<PageTitle>Test Radzen Scheduler</PageTitle>
<div class="card">
<div class="card-header">
<h1>Test Radzen Scheduler</h1>
</div>
<div class="card-body">
@if (currView == "year" || currView == "planner")
{
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="0.5rem" class="rz-p-4 rz-mb-6 rz-border-radius-1" Style="border: var(--rz-grid-cell-border);">
<RadzenLabel Text="Schedule Start Month:" />
<RadzenSelectBar @bind-Value="@startMonth" TextProperty="Text" ValueProperty="Value" Data="@(Enum.GetValues(typeof(Month)).Cast<Month>().Select(t => new { Text = $"{t}", Value = t }))" Size="ButtonSize.Small" class="rz-display-none rz-display-xl-flex" />
<RadzenDropDown @bind-Value="@startMonth" Change="StartMonthChange" TextProperty="Text" ValueProperty="Value" Data="@(Enum.GetValues(typeof(Month)).Cast<Month>().Select(t => new { Text = $"{t}", Value = t }))" class="rz-display-inline-flex rz-display-xl-none" />
</RadzenStack>
}
else
{
<h3>@currView</h3>
}
<div style="@schedHeight">
<RadzenScheduler @ref=@scheduler SlotRender=@OnSlotRender style="height: 100%;" TItem="Appointment" Data=@appointments StartProperty="Start" EndProperty="End"
TextProperty="Text" SelectedIndex="2"
SlotSelect=@OnSlotSelect AppointmentSelect=@OnAppointmentSelect AppointmentRender=@OnAppointmentRender
AppointmentMove=@OnAppointmentMove LoadData=OnLoadData>
<Template Context="appointments">
<div>
<strong>@appointments.Text</strong>
</div>
<small>
@appointments.Detail
</small>
</Template>
<ChildContent>
<RadzenDayView />
<RadzenWeekView />
<RadzenMonthView />
<RadzenYearPlannerView StartMonth="@startMonth" />
@* <RadzenYearTimelineView StartMonth="@startMonth" /> *@
<RadzenYearView StartMonth="@startMonth" />
</ChildContent>
</RadzenScheduler>
</div>
<EventConsole @ref=@console />
</div>
</div>
@code {
/* ------------------------------------------------
* Radzen Blazor
* https://www.radzen.com/blazor-components/
*
* dettagli installazione:
* NET6: https://blazor.radzen.com/get-started/net6-server
* NET8: https://blazor.radzen.com/get-started/net8
*
* Test componente Scheduler:
* https://blazor.radzen.com/scheduler?theme=material3
* https://blazor.radzen.com/docs/guides/components/scheduler.html
* ------------------------------------------------*/
RadzenScheduler<Appointment> scheduler;
EventConsole console;
Dictionary<DateTime, string> events = new Dictionary<DateTime, string>();
Month startMonth = Month.January;
bool showSelMonth { get; set; } = true;
async Task StartMonthChange()
{
await scheduler.Reload();
}
IList<Appointment> appointments = new List<Appointment>
{
new Appointment { Start = DateTime.Today.AddDays(-2), End = DateTime.Today.AddDays(-2), Text = "Birthday", Detail="My Birthday" },
new Appointment { Start = DateTime.Today.AddDays(-11), End = DateTime.Today.AddDays(-10), Text = "Day off", Detail="Rest required" },
new Appointment { Start = DateTime.Today.AddDays(-10), End = DateTime.Today.AddDays(-8), Text = "Work from home", Detail="WIP from remote" },
new Appointment { Start = DateTime.Today.AddHours(10), End = DateTime.Today.AddHours(12), Text = "Online meeting", Detail="Teams" },
new Appointment { Start = DateTime.Today.AddHours(10), End = DateTime.Today.AddHours(13), Text = "Skype call", Detail="Google Meet?" },
new Appointment { Start = DateTime.Today.AddHours(14), End = DateTime.Today.AddHours(14).AddMinutes(30), Text = "Dentist appointment", Detail="Anestetics" },
new Appointment { Start = DateTime.Today.AddDays(1), End = DateTime.Today.AddDays(12), Text = "Vacation", Detail="Long awaited!!!" },
};
void OnSlotRender(SchedulerSlotRenderEventArgs args)
{
// Highlight today in month view
if (args.View.Text == "Month" && args.Start.Date == DateTime.Today)
{
args.Attributes["style"] = "background: var(--rz-scheduler-highlight-background-color, rgba(255,220,40,.2));";
}
// Highlight working hours (9-18)
if ((args.View.Text == "Week" || args.View.Text == "Day") && args.Start.Hour > 8 && args.Start.Hour < 19)
{
args.Attributes["style"] = "background: var(--rz-scheduler-highlight-background-color, rgba(255,220,40,.2));";
}
}
async Task OnSlotSelect(SchedulerSlotSelectEventArgs args)
{
console.Log($"SlotSelect: Start={args.Start} End={args.End}");
if (args.View.Text != "Year")
{
Appointment data = await DialogService.OpenAsync<AddAppointmentPage>("Add Appointment",
new Dictionary<string, object> { { "Start", args.Start }, { "End", args.End } });
if (data != null)
{
appointments.Add(data);
// Either call the Reload method or reassign the Data property of the Scheduler
await scheduler.Reload();
}
}
}
async Task OnAppointmentSelect(SchedulerAppointmentSelectEventArgs<Appointment> args)
{
console.Log($"AppointmentSelect: Appointment={args.Data.Text}");
var copy = new Appointment
{
Start = args.Data.Start,
End = args.Data.End,
Text = args.Data.Text,
Detail = args.Data.Detail
};
var data = await DialogService.OpenAsync<EditAppointmentPage>("Edit Appointment", new Dictionary<string, object> { { "Appointment", copy } });
if (data != null)
{
// Update the appointment
args.Data.Start = data.Start;
args.Data.End = data.End;
args.Data.Text = data.Text;
args.Data.Detail = data.Detail;
}
await scheduler.Reload();
}
void OnAppointmentRender(SchedulerAppointmentRenderEventArgs<Appointment> args)
{
// Never call StateHasChanged in AppointmentRender - would lead to infinite loop
if (args.Data.Text == "Birthday")
{
args.Attributes["style"] = "background: red";
}
}
async Task OnAppointmentMove(SchedulerAppointmentMoveEventArgs args)
{
var draggedAppointment = appointments.FirstOrDefault(x => x == args.Appointment.Data);
if (draggedAppointment != null)
{
draggedAppointment.Start = draggedAppointment.Start + args.TimeSpan;
draggedAppointment.End = draggedAppointment.End + args.TimeSpan;
await scheduler.Reload();
}
}
async Task OnLoadData(SchedulerLoadDataEventArgs args)
{
await Task.Delay(1);
currView = scheduler.SelectedView.Text.ToLowerInvariant();
schedHeight = (currView == "year" || currView == "planner") ? "height: 50rem;" : "height: 40rem;";
// // Get the appointments for between the Start and End
// data = await MyAppointmentService.GetData(args.Start, args.End);
}
private string currView { get; set; } = "";
private string schedHeight { get; set; } = "height: 40rem;";
}
@@ -1,161 +0,0 @@
@page "/TestOld"
<PageTitle>Test</PageTitle>
<h1>Test</h1>
<div class="row">
<div class="col-2">
<img src="_content/EgwCoreLib.Razor/images/LogoEgw.png" class="img-fluid" width="200" height="200" />
<PasswordBox></PasswordBox>
<PasswordBox ItemLabel="pwd"></PasswordBox>
</div>
<div class="col-10">
<TestJsInterop></TestJsInterop>
<div class="row">
<div class="col">
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.AZTEC"></QrCodeDisplay>
</div>
<div class="col">
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.QR_CODE"></QrCodeDisplay>
</div>
<div class="col">
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.DATA_MATRIX" Width="400" Height="200"></QrCodeDisplay>
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.PDF_417" Width="600" Height="200"></QrCodeDisplay>
</div>
<div class="col">
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.AZTEC"></QrCodeDisplay>
</div>
<div class="col">
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.QR_CODE"></QrCodeDisplay>
</div>
<div class="col">
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.DATA_MATRIX" Width="400" Height="200"></QrCodeDisplay>
<QrCodeDisplay rawCode="@qrCodeVal" ImgFormat="ZXing.BarcodeFormat.PDF_417" Width="600" Height="200"></QrCodeDisplay>
</div>
</div>
</div>
</div>
<hr />
<div class="row bg-secondary py-2">
<div class="col">
<StepArrow ObjId="123" StepText="Prova Arrow 01" BlockStyle="@($"fill: #123456;")" StrokeWidth="4" ObjW="650" ObjH="100" StrokeColors="@listBord01" TipAngle="90"></StepArrow>
</div>
<div class="col">
<StepArrow ObjId="456" StepText="Prova Arrow 02" BlockStyle="@($"fill: #456789;")" StrokeWidth="4" ObjW="600" ObjH="100" StrokeColors="@listBord02" TipAngle="60"></StepArrow>
</div>
<div class="col">
<StepArrow ObjId="456" StepText="Prova Arrow 03" BlockStyle="@($"fill: #6789AB;")" StrokeWidth="4" ObjW="500" ObjH="100" StrokeColors="@listBord03" TipAngle="120"></StepArrow>
</div>
<div class="col">
<StepArrow ObjId="456" StepText="Prova Arrow 04" BlockStyle="@($"fill: #89ABCD;")" StrokeWidth="0" ObjW="700" ObjH="100" TipAngle="108"></StepArrow>
</div>
</div>
<div class="row bg-secondary py-2">
<div class="col">
<ProgBar singleLine="true" baseUM="$" currVal="@(rnd.Next(50,250))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="true" baseUM="gg" currVal="@(rnd.Next(200,450))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="true" baseUM="min" currVal="@(rnd.Next(400,650))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="true" baseUM="px" currVal="@(rnd.Next(600,900))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="true" baseUM="h" currVal="@(rnd.Next(500,1000))" maxVal="1000" redLim="200" yelLim="400" />
</div>
</div>
<div class="row bg-dark py-2">
<div class="col">
<ProgBar singleLine="false" baseUM="$" currVal="@(rnd.Next(50,250))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="false" baseUM="gg" currVal="@(rnd.Next(200,450))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="false" baseUM="min" currVal="@(rnd.Next(400,650))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="false" baseUM="px" currVal="@(rnd.Next(600,900))" maxVal="1000" redLim="200" yelLim="400" />
</div>
<div class="col">
<ProgBar singleLine="false" baseUM="h" currVal="@(rnd.Next(500,1000))" maxVal="1000" redLim="200" yelLim="400" />
</div>
</div>
<BarcodeReader ScanResult="(e) => ScanDoneHandler(e)"
ScanBtnTitle="Scan"
ResetBtnTitle="Reset"
CloseBtnTitle="Close"
UseBuiltinDiv="false"
@ref="barcodeReaderCustom"
SelectDeviceBtnTitle="Select Device">
</BarcodeReader>
<div @ref="barcodeReaderCustom.Element" class="d-flex justify-content-center">
@* <div style="width: 480px; max-width: 100%"> *@
<div class="col-12 col-md-8 col-lg-6">
<button class="btn btn-outline-success p-2 m-1 w-25" data-action="startButton">Scan</button>
<button class="btn btn-outline-success p-2 m-1 w-25" data-action="resetButton">Reset</button>
<div data-action="sourceSelectPanel" style="display:none">
<label for="sourceSelect">Source:</label>
<select data-action="sourceSelect" style="max-width:100%" class="form-control">
</select>
</div>
<div>
<video id="video" playsinline="true" autoplay="true" class="w-100 h-100 border rounded shadow" muted="true"></video>
</div>
</div>
</div>
@code {
private int currentCount = 0;
protected BarcodeReader barcodeReaderCustom { get; set; } = null!;
protected Random rnd = new Random();
protected async Task ScanDoneHandler(string value)
{
await Task.Delay(1);
}
private void IncrementCount()
{
currentCount++;
}
protected override void OnInitialized()
{
base.OnInitialized();
listBord01 = new();
listBord01.Add("");
listBord01.Add("White");
listBord01.Add("");
listBord01.Add("");
listBord02 = new();
listBord02.Add("");
listBord02.Add("White");
listBord02.Add("");
listBord02.Add("White");
listBord03 = new();
listBord03.Add("");
listBord03.Add("White");
listBord03.Add("");
listBord03.Add("Blue");
}
protected List<string> listBord01 { get; set; } = new();
protected List<string> listBord02 { get; set; } = new();
protected List<string> listBord03 { get; set; } = new();
protected string qrCodeVal { get; set; } = "https://office.egalware.com/WDC/UI";
}
@@ -1,4 +1,5 @@
@using Microsoft.AspNetCore.Components.Web
@using Radzen.Blazor
@namespace EgwCoreLib.BlazorTest.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@@ -13,6 +14,7 @@
<link rel="stylesheet" href="css/site.css" />
<link rel="stylesheet" href="EgwCoreLib.BlazorTest.styles.css" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
<component type="typeof(RadzenTheme)" render-mode="ServerPrerendered" param-Theme="@("material")" />
</head>
<body>
@RenderBody()
@@ -63,5 +65,6 @@
@*Gestione ricollegamento successivo: https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/signalr?view=aspnetcore-6.0*@
@* <script>Blazor.defaultReconnectionHandler._reconnectCallback = function (d) { document.location.reload(); }</script> *@
<script src="_content/Radzen.Blazor/Radzen.Blazor.js?v=@(typeof(Radzen.Colors).Assembly.GetName().Version)"></script>
</body>
</html>
+15 -5
View File
@@ -1,6 +1,7 @@
using EgwCoreLib.BlazorTest;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Radzen;
var builder = WebApplication.CreateBuilder(args);
@@ -8,6 +9,15 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
// aggiunto compressione
builder.Services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
});
// aggiungo componenti radzen
builder.Services.AddRadzenComponents();
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -18,11 +28,11 @@ if (!app.Environment.IsDevelopment())
app.UseHsts();
}
//// disabilita risposta compressa in debug
//if (!app.Environment.IsDevelopment())
//{
// app.UseResponseCompression();
//}
// disabilita risposta compressa in debug
if (!app.Environment.IsDevelopment())
{
app.UseResponseCompression();
}
app.UseHttpsRedirection();
@@ -7,7 +7,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7118;http://localhost:5145"
"applicationUrl": "https://localhost:7118;http://localhost:5146"
},
"IIS Express": {
"commandName": "IISExpress",
@@ -22,7 +22,7 @@
"launchUrl": "https://localhost:7118",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "https://localhost:7118;http://localhost:5145"
"ASPNETCORE_URLS": "https://localhost:7118;http://localhost:5146"
},
"distributionName": ""
}
@@ -13,6 +13,7 @@
<article class="content px-2">
@Body
<RadzenComponents />
</article>
<div class="fixed-bottom bottom-row">
+3 -1
View File
@@ -10,4 +10,6 @@
@using EgwCoreLib.BlazorTest.Components
@using EgwCoreLib.BlazorTest.Shared
@using EgwCoreLib.Razor
@using EgwCoreLib.Razor.Data
@using EgwCoreLib.Razor.Data
@using Radzen
@using Radzen.Blazor
@@ -14,5 +14,9 @@
{
"outputFile": "Pages/TestGauges.razor.css",
"inputFile": "Pages/TestGauges.razor.less"
},
{
"outputFile": "Pages/TestBarcodeReader.razor.css",
"inputFile": "Pages/TestBarcodeReader.razor.less"
}
]
+1 -3
View File
@@ -6,11 +6,9 @@
<div class="modal-content">
<!-- Edit form for the current item -->
<div class="modal-body" @ref="Element">
<button class="btn btn-primary p-2 m-1 w-25" data-action="startButton">@ScanBtnTitle</button>
<button class="btn btn-secondary p-2 m-1 w-25" data-action="resetButton">@ResetBtnTitle</button>
<button type="button" class="btn btn-info p-2 m-1 w-25" data-action="closeButton">@CloseBtnTitle</button>
<div data-action="sourceSelectPanel" style="display:none">
<label for="sourceSelect">@SelectDeviceBtnTitle:</label>
<select data-action="sourceSelect" style="max-width:100%" class="form-select form-control">
@@ -24,7 +22,7 @@
x-webkit-airplay="allow"
x5-video-player-type="h5"
x5-video-player-fullscreen="true"
x5-video-orientation="portraint"
x5-video-orientation="portrait"
style="min-height:150px;max-height:50%; max-width: 100%;border: 1px solid gray"></video>
</div>
</div>
+162 -131
View File
@@ -9,47 +9,7 @@ namespace EgwCoreLib.Razor
{
public partial class BarcodeReader : IAsyncDisposable
{
[Inject]
[NotNull]
private IJSRuntime? JS { get; set; }
private IJSObjectReference? module;
private DotNetObjectReference<BarcodeReader>? Instance { get; set; }
[NotNull]
private StorageService? Storage { get; set; }
/// <summary>
/// Scan button title
/// </summary>
[Parameter]
public string ScanBtnTitle { get; set; } = "扫码";
/// <summary>
/// Reset button title
/// </summary>
[Parameter]
public string ResetBtnTitle { get; set; } = "复位";
/// <summary>
/// Close button title
/// </summary>
[Parameter]
public string CloseBtnTitle { get; set; } = "关闭";
/// <summary>
/// Select device button title
/// </summary>
[Parameter]
public string SelectDeviceBtnTitle { get; set; } = "选择设备";
/// <summary>
/// Scan result callback method
/// </summary>
[Parameter]
public EventCallback<string> ScanResult { get; set; }
#region Public Properties
/// <summary>
/// Close scan code callback method
@@ -58,21 +18,17 @@ namespace EgwCoreLib.Razor
public EventCallback Close { get; set; }
/// <summary>
/// Error callback method
/// Close button title
/// </summary>
[Parameter]
public Func<string, Task>? OnError { get; set; }
public string CloseBtnTitle { get; set; } = "关闭";
/// <summary>
/// Use builtin Div
/// </summary>
[Parameter] public bool UseBuiltinDiv { get; set; } = true;
/// <summary>
/// Decode only Pdf417 format
/// Decode All Formats, performance is poor, you can set options.formats to customize
/// specify the encoding formats. The default is false
/// </summary>
[Parameter]
public bool Pdf417Only { get; set; }
public bool DecodeAllFormats { get; set; }
/// <summary>
/// Decode Once or Decode Continuously, default is Once
@@ -81,10 +37,20 @@ namespace EgwCoreLib.Razor
public bool Decodeonce { get; set; } = true;
/// <summary>
/// Decode All Formats, performance is poor, you can set options.formats to customize specify the encoding formats. The default is false
/// Device ID
/// </summary>
[Parameter]
public bool DecodeAllFormats { get; set; }
public string? DeviceID { get; set; }
/// <summary>
/// </summary>
public ElementReference Element { get; set; }
/// <summary>
/// Error callback method
/// </summary>
[Parameter]
public Func<string, Task>? OnError { get; set; }
/// <summary>
/// ZXingOptions
@@ -93,15 +59,16 @@ namespace EgwCoreLib.Razor
public ZXingOptions? Options { get; set; }
/// <summary>
///
/// </summary>
public ElementReference Element { get; set; }
/// <summary>
/// Device ID
/// Decode only Pdf417 format
/// </summary>
[Parameter]
public string? DeviceID { get; set; }
public bool Pdf417Only { get; set; }
/// <summary>
/// Reset button title
/// </summary>
[Parameter]
public string ResetBtnTitle { get; set; } = "复位";
/// <summary>
/// Save the last used device ID to be called automatically next time
@@ -109,69 +76,36 @@ namespace EgwCoreLib.Razor
[Parameter]
public bool SaveDeviceID { get; set; } = true;
// To prevent making JavaScript interop calls during prerendering
protected override async Task OnAfterRenderAsync(bool firstRender)
{
try
{
if (!firstRender) return;
Storage = new StorageService(JS);
module = await JS.InvokeAsync<IJSObjectReference>("import", "./_content/EgwCoreLib.Razor/BarcodeReader.razor.js" + "?v=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
Instance = DotNetObjectReference.Create(this);
if (Options == null)
{
Options = new ZXingOptions()
{
Pdf417 = Pdf417Only,
Decodeonce = Decodeonce,
DecodeAllFormats = DecodeAllFormats,
//TRY_HARDER = true
};
}
try
{
if (SaveDeviceID) DeviceID = await Storage.GetValue("CamsDeviceID", DeviceID);
}
catch (Exception)
{
/// <summary>
/// Scan button title
/// </summary>
[Parameter]
public string ScanBtnTitle { get; set; } = "扫码";
}
await module.InvokeVoidAsync("init", Instance, Element, Element.Id, Options, DeviceID);
}
catch (Exception e)
{
if (OnError != null) await OnError.Invoke(e.Message);
}
/// <summary>
/// Scan result callback method
/// </summary>
[Parameter]
public EventCallback<string> ScanResult { get; set; }
}
/// <summary>
/// Select device button title
/// </summary>
[Parameter]
public string SelectDeviceBtnTitle { get; set; } = "选择设备";
public async Task Start()
{
await module!.InvokeVoidAsync("start", Element.Id);
}
/// <summary>
/// Use builtin Div
/// </summary>
[Parameter] public bool UseBuiltinDiv { get; set; } = true;
public async Task Stop()
{
await module!.InvokeVoidAsync("stop", Element.Id);
}
#endregion Public Properties
public async Task Reload()
{
await module!.InvokeVoidAsync("reload", Element.Id);
}
[JSInvokable]
public async Task GetResult(string val) => await ScanResult.InvokeAsync(val);
#region Public Methods
[JSInvokable]
public async Task CloseScan() => await Close.InvokeAsync();
[JSInvokable]
public async Task GetError(string err)
{
if (OnError != null) await OnError.Invoke(err);
}
async ValueTask IAsyncDisposable.DisposeAsync()
{
await module!.InvokeVoidAsync("destroy", Element.Id);
@@ -182,6 +116,20 @@ namespace EgwCoreLib.Razor
}
}
[JSInvokable]
public async Task GetError(string err)
{
if (OnError != null) await OnError.Invoke(err);
}
[JSInvokable]
public async Task GetResult(string val) => await ScanResult.InvokeAsync(val);
public async Task Reload()
{
await module!.InvokeVoidAsync("reload", Element.Id);
}
/// <summary>
/// 选择摄像头回调方法
/// </summary>
@@ -203,19 +151,102 @@ namespace EgwCoreLib.Razor
}
}
#region StorageService
public async Task Start()
{
await module!.InvokeVoidAsync("start", Element.Id);
}
public async Task Stop()
{
await module!.InvokeVoidAsync("stop", Element.Id);
}
#endregion Public Methods
#region Protected Methods
// To prevent making JavaScript interop calls during prerendering
protected override async Task OnAfterRenderAsync(bool firstRender)
{
try
{
if (!firstRender) return;
Storage = new StorageService(JS);
module = await JS.InvokeAsync<IJSObjectReference>("import", "./_content/EgwCoreLib.Razor/BarcodeReader.razor.js" + "?v=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
Instance = DotNetObjectReference.Create(this);
if (Options == null)
{
Options = new ZXingOptions()
{
Pdf417 = Pdf417Only,
Decodeonce = Decodeonce,
DecodeAllFormats = DecodeAllFormats,
//TRY_HARDER = true
};
}
try
{
if (SaveDeviceID)
{
DeviceID = await Storage.GetValue("CamsDeviceID", DeviceID);
}
}
catch (Exception)
{
}
await module.InvokeVoidAsync("init", Instance, Element, Element.Id, Options, DeviceID);
}
catch (Exception e)
{
if (OnError != null) await OnError.Invoke(e.Message);
}
}
#endregion Protected Methods
#region Private Fields
private IJSObjectReference? module;
#endregion Private Fields
#region Private Properties
private DotNetObjectReference<BarcodeReader>? Instance { get; set; }
[Inject]
[NotNull]
private IJSRuntime? JS { get; set; }
[NotNull]
private StorageService? Storage { get; set; }
#endregion Private Properties
#region Private Classes
private class StorageService
{
private readonly IJSRuntime JSRuntime;
#region Public Constructors
public StorageService(IJSRuntime jsRuntime)
{
JSRuntime = jsRuntime;
}
public async Task SetValue<TValue>(string key, TValue value)
#endregion Public Constructors
#region Public Methods
public static T? GetValueI<T>(string value)
{
await JSRuntime.InvokeVoidAsync("eval", $"localStorage.setItem('{key}', '{value}')");
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
if (converter != null)
{
return (T?)converter.ConvertFrom(value);
}
return default;
//return (T)Convert.ChangeType(value, typeof(T));
}
public async Task<TValue?> GetValue<TValue>(string key, TValue? def)
@@ -233,28 +264,28 @@ namespace EgwCoreLib.Razor
var newValue = GetValueI<TValue>(cValue);
return newValue ?? def;
}
}
public static T? GetValueI<T>(string value)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
if (converter != null)
{
return (T?)converter.ConvertFrom(value);
}
return default;
//return (T)Convert.ChangeType(value, typeof(T));
}
public async Task RemoveValue(string key)
{
await JSRuntime.InvokeVoidAsync("eval", $"localStorage.removeItem('{key}')");
}
public async Task SetValue<TValue>(string key, TValue value)
{
await JSRuntime.InvokeVoidAsync("eval", $"localStorage.setItem('{key}', '{value}')");
}
#endregion Public Methods
#region Private Fields
private readonly IJSRuntime JSRuntime;
#endregion Private Fields
}
#endregion
#endregion Private Classes
}
}
}
+2 -3
View File
@@ -18,7 +18,6 @@ else
@*<rect x="0" y="0" width="@vBox.Width" height="@vBox.Height" class="canv"></rect>*@
@foreach (var item in BoxItems())
{
@*<a data-bs-toggle="modal" data-bs-target="#detailModal" style="text-decoration: none;" @onclick="()=>selItem(item)">*@
<a style="text-decoration: none;" @onclick="()=>selItem(item)">
<g transform="translate(@(item.pX),@(item.pY))">
<rect x="0" y="0" width="@item.width" height="@item.height" class="@item.cssClass" rx="30"></rect>
@@ -41,10 +40,10 @@ else
<svg viewBox="0 0 @(vBox.Height/4) @(vBox.Height/4)" xmlns="http://www.w3.org/2000/svg" >
<g>
<rect x="0" y="0" width="@(vBox.Height/4)" height="@(vBox.Height/4)" class="@currData.cssClass" rx="30"></rect>
<foreignObject x="@mFO" y="@mFO" width="@(vBox.Height/3)" height="@(vBox.Height/3)">
<foreignObject x="@mFO" y="@mFO" width="@(vBox.Height/4)" height="@(vBox.Height/3)">
<div class="event-title">@currData.title</div>
<div class="event-time">@($"{currData.start:HH:mm}")-@($"{currData.end:HH:mm}")</div>
<div class="event-body">@currData.value</div>
<div class="event-body-detail">@currData.value</div>
</foreignObject>
</g>
</svg>
+45 -21
View File
@@ -42,6 +42,22 @@ namespace EgwCoreLib.Razor
[Parameter]
public ColType ItemMode { get; set; } = ColType.dataContainer;
/// <summary>
/// Fattore di shift in X, se 0 = nessuno shift, se &gt; 0 è percentuale moltiplica il
/// gradino calcolato
/// Default: 100 (poi riportato a intero, quindi 100/100 = 1.0)
/// </summary>
[Parameter]
public int PercX { get; set; } = 100;
/// <summary>
/// Fattore di shift in Y, se 0 = nessuno shift, se &gt; 0 è percentuale moltiplica il
/// gradino calcolato
/// Default: 90 (poi riportato a intero, quindi 90/100 = 0.9)
/// </summary>
[Parameter]
public int PercY { get; set; } = 90;
[Parameter]
public int ValMax { get; set; } = 19;
@@ -56,6 +72,14 @@ namespace EgwCoreLib.Razor
#endregion Public Properties
#region Protected Fields
protected string Messaggio = "";
protected string titleDx = "";
protected string titleSx = "";
#endregion Protected Fields
#region Protected Properties
protected boxData? currData { get; set; } = null;
@@ -70,6 +94,8 @@ namespace EgwCoreLib.Razor
get => vBox.Width * 4 / 100;
}
protected bool showDetail { get; set; } = false;
protected int wFO
{
get => vBox.Width * 98 / 100;
@@ -84,20 +110,24 @@ namespace EgwCoreLib.Razor
List<boxData> answ = new List<boxData>();
int step = vBox.Height / (ValMax - ValMin);
int numEv = EventList.Count;
int evWidth = numEv > 1 ? (int)(1.2 * vBox.Width / numEv) : (int)(0.9 * vBox.Width);
int evWidth = numEv > 1 ? (int)(0.5 * vBox.Width) : (int)(0.9 * vBox.Width);
//int evWidth = numEv > 1 ? (int)(1.5 * vBox.Width / numEv) : (int)(0.9 * vBox.Width);
int offsetX = 1;
int offsetY = 0;// step / 2;
if (numEv > 0)
{
int xStep = evWidth / EventList.Count;
int xStep = evWidth / (EventList.Count + 1) * PercX / 100;
int yStep = evWidth * PercY / 100;
//int yStep = xStep * 5;
//int yStep = xStep * (EventList.Count + 50) / (EventList.Count + 6);
int deltaX = 0;
answ = EventList
.OrderBy(x => x.Inizio)
.ThenByDescending(x => x.Durata)
.Select(x => new boxData()
{
pX = offsetX + xStep * (deltaX++),
//pY = offsetY + (x.Inizio.Hour - ValMin) * step,
pY = offsetY + (int)(x.Inizio.AddHours(-ValMin).TimeOfDay.TotalHours * step),
pX = offsetX + xStep * (deltaX),
pY = offsetY + yStep * (deltaX++) + (int)(x.Inizio.AddHours(-ValMin).TimeOfDay.TotalHours * step),
width = evWidth,
height = offsetY + (int)(x.Fine.Subtract(x.Inizio).TotalHours * step),
title = x.Type,
@@ -111,21 +141,6 @@ namespace EgwCoreLib.Razor
return answ;
}
/// <summary>
/// Converte la stringa in formato markup valido
/// </summary>
/// <param name="rawData"></param>
/// <returns></returns>
protected MarkupString getMarkup(string rawData)
{
return new MarkupString(rawData);
}
protected bool showDetail { get; set; } = false;
protected string titleDx = "";
protected string titleSx = "";
protected async Task DetClosed(bool closed)
{
if (closed)
@@ -136,6 +151,16 @@ namespace EgwCoreLib.Razor
await Task.Delay(1);
}
/// <summary>
/// Converte la stringa in formato markup valido
/// </summary>
/// <param name="rawData"></param>
/// <returns></returns>
protected MarkupString getMarkup(string rawData)
{
return new MarkupString(rawData);
}
/// <summary>
/// Genera una lista di etichette con corrdinate
/// </summary>
@@ -168,7 +193,6 @@ namespace EgwCoreLib.Razor
await InvokeAsync(StateHasChanged);
}
protected string Messaggio = "";
#endregion Protected Methods
#region Protected Classes
+12 -2
View File
@@ -54,7 +54,10 @@
}
.event-time {
color: #69CDFF;
font-size: 2rem;
font-size: 1.6rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.hour-label {
color: #9ABCDE;
@@ -63,6 +66,13 @@
.event-body {
/*color: #C8DCFF;*/
color: #A8BCFF;
font-size: 1.9rem;
font-size: 1.4rem;
word-break: break-word;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.event-body-detail {
color: #A8BCFF;
font-size: 1.4rem;
}
+16 -3
View File
@@ -67,7 +67,11 @@
.event-time {
color: #69CDFF;
font-size: 2rem;
font-size: 1.6rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.hour-label {
@@ -77,7 +81,16 @@
.event-body {
/*color: #C8DCFF;*/
color: #A8BCFF ;
font-size: 1.9rem;
color: #A8BCFF;
font-size: 1.4rem;
word-break: break-word;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.event-body-detail {
color: #A8BCFF;
font-size: 1.4rem;
}
+1 -1
View File
@@ -1 +1 @@
.lblText{font-size:.3rem;fill:white;}.lblBoxTitle{font-size:.25rem;fill:white;}.lblBoxText{font-size:.2rem;fill:white;word-wrap:break-word;}.heavy{font:bold 30px sans-serif;fill:white;}.canv{fill:#34495e;}.blockMal{fill:rgba(3,155,229,.75);stroke:rgba(3,155,229,.9);stroke-width:.5rem;}.blockPerm{fill:rgba(153,102,222,.75);stroke:rgba(153,102,222,.9);stroke-width:.5rem;}.blockFerie{fill:rgba(0,185,0,.75);stroke:rgba(0,255,0,.9);stroke-width:.5rem;}.block104{fill:rgba(222,0,171,.75);stroke:rgba(222,0,171,.9);stroke-width:.5rem;}.blockChius{fill:rgba(165,185,0,.75);stroke:rgba(235,255,71,.9);stroke-width:.5rem;}.blockFest{fill:rgba(242,35,35,.75);stroke:rgba(242,35,35,.9);stroke-width:.5rem;}.event-title{color:#fff;font-size:2rem;}.event-time{color:#69cdff;font-size:2rem;}.hour-label{color:#9abcde;font-size:2rem;}.event-body{color:#a8bcff;font-size:1.9rem;word-break:break-word;}
.lblText{font-size:.3rem;fill:white;}.lblBoxTitle{font-size:.25rem;fill:white;}.lblBoxText{font-size:.2rem;fill:white;word-wrap:break-word;}.heavy{font:bold 30px sans-serif;fill:white;}.canv{fill:#34495e;}.blockMal{fill:rgba(3,155,229,.75);stroke:rgba(3,155,229,.9);stroke-width:.5rem;}.blockPerm{fill:rgba(153,102,222,.75);stroke:rgba(153,102,222,.9);stroke-width:.5rem;}.blockFerie{fill:rgba(0,185,0,.75);stroke:rgba(0,255,0,.9);stroke-width:.5rem;}.block104{fill:rgba(222,0,171,.75);stroke:rgba(222,0,171,.9);stroke-width:.5rem;}.blockChius{fill:rgba(165,185,0,.75);stroke:rgba(235,255,71,.9);stroke-width:.5rem;}.blockFest{fill:rgba(242,35,35,.75);stroke:rgba(242,35,35,.9);stroke-width:.5rem;}.event-title{color:#fff;font-size:2rem;}.event-time{color:#69cdff;font-size:1.6rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.hour-label{color:#9abcde;font-size:2rem;}.event-body{color:#a8bcff;font-size:1.4rem;word-break:break-word;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.event-body-detail{color:#a8bcff;font-size:1.4rem;}
+4 -4
View File
@@ -6,11 +6,11 @@ else
{
<table class="cssTable" style="@HeadStyle">
<thead>
<tr class="">
<th class="text-center text-light" @onclick="()=>openCalendarMonth()" style="width: @lblWidth;"><i class="fa-regular fa-circle-xmark"></i></th>
<tr>
<th class="text-center text-light" @onclick="()=>OpenCalendarMonth()" style="width: @lblWidth;"><i class="fa-regular fa-circle-xmark"></i></th>
@foreach (var item in DateList)
{
<th class="text-center" style="width: @dataWidth;">
<th class="text-center" style="width: @dataWidth;" @onclick="()=>SelectDate(item)">
<div>
@($"{item:ddd}".Substring(0, 1).ToUpper())
</div>
@@ -29,7 +29,7 @@ else
@foreach (var item in DateList)
{
<td>
<CalWeekColumn ItemMode="CalWeekColumn.ColType.dataContainer" vBox="vBoxCont" EventList="@DayEvent(item)" ValMin="8" ValMax="20"></CalWeekColumn>
<CalWeekColumn ItemMode="CalWeekColumn.ColType.dataContainer" vBox="vBoxCont" EventList="@DayEvent(item)" ValMin="8" ValMax="20" PercX="@PercX" PercY="@PercY"></CalWeekColumn>
</td>
}
</tr>
+92 -61
View File
@@ -8,31 +8,42 @@ namespace EgwCoreLib.Razor
{
#region Public Properties
/// <summary>
/// Evento x ritorno click
/// </summary>
[Parameter]
public EventCallback<bool> backToCalendar { get; set; }
/// <summary>
/// Periodo da mostrare (tipicamente 1 settimana)
/// </summary>
[Parameter]
public List<DateTime> DateList { get; set; } = new List<DateTime>();
/// <summary>
/// Eventi da inserire
/// </summary>
[Parameter]
public List<CalendarEvent> EventList { get; set; } = new List<CalendarEvent>();
/// <summary>
/// Evento selezione data valida (= entro il periodo selezionato)
/// </summary>
[Parameter]
public EventCallback<DateTime> DateSelected { get; set; }
/// <summary>
/// Evento selezione data singola giornata da header
/// </summary>
[Parameter]
public EventCallback<bool> backToCalendar{ get; set; }
public EventCallback<DateTime> EC_HeadDateSel { get; set; }
/// <summary>
/// Ora fine visualizzazione calendario
/// </summary>
[Parameter]
public int EndHour { get; set; } = 20;
/// <summary>
/// Eventi da inserire
/// </summary>
[Parameter]
public List<CalendarEvent> EventList { get; set; } = new List<CalendarEvent>();
/// <summary>
/// Css titolo
/// default: color: red
@@ -52,6 +63,22 @@ namespace EgwCoreLib.Razor
[Parameter]
public int labelWidth { get; set; } = 15;
/// <summary>
/// Fattore di shift in X, se 0 = nessuno shift, se &gt; 0 è percentuale moltiplica il
/// gradino calcolato
/// Default: 100 (poi riportato a intero, quindi 100/100 = 1.0)
/// </summary>
[Parameter]
public int PercX { get; set; } = 100;
/// <summary>
/// Fattore di shift in Y, se 0 = nessuno shift, se &gt; 0 è percentuale moltiplica il
/// gradino calcolato
/// Default: 90 (poi riportato a intero, quindi 90/100 = 0.9)
/// </summary>
[Parameter]
public int PercY { get; set; } = 90;
[Parameter]
public int StartHour { get; set; } = 8;
@@ -82,6 +109,12 @@ namespace EgwCoreLib.Razor
get => numDays + 1;
}
protected int contWidth
{
get => (vBox.Width * 2) / (2 * numDays + 1);
//get => numDays > 1 ? (vBox.Width * 2) / (2 * numDays + 1) : vBox.Width * 90 / 100;
}
protected DateTime DtRif
{
get
@@ -100,48 +133,26 @@ namespace EgwCoreLib.Razor
get => DateList.Count;
}
protected int contWidth
protected Size vBoxCont
{
get => (vBox.Width * 2) / (2 * numDays + 1);
}
private string lblWidth
{
get => $"{(double)(vBox.Width - (contWidth * numDays)) / vBox.Width:P2}".Replace(",", ".");
}
private string dataWidth
{
get => $"{(double)contWidth / vBox.Width:P2}".Replace(",", ".");
get
{
// label e' MENO di 1/tot columns
Size answ = new Size(contWidth, vBox.Height);
return answ;
}
}
protected Size vBoxLabel
{
get
{
// label MENO di 1/tot columns
// label e' MENO di 1/tot columns
Size answ = new Size(contWidth / 2, vBox.Height);
//Size answ = new Size(labelWidth, vBox.Height);
return answ;
}
}
protected Size vBoxCont
{
get
{
// label MENO di 1/tot columns
Size answ = new Size(contWidth, vBox.Height);
return answ;
}
}
//protected Size vBoxLabel
//{
// get
// {
// // label MENO di 1/tot columns
// Size answ = new Size(labelWidth, vBox.Height);
// return answ;
// }
//}
#endregion Protected Properties
@@ -157,27 +168,6 @@ namespace EgwCoreLib.Razor
await WeekChanged.InvokeAsync(delta);
}
protected override async Task OnParametersSetAsync()
{
HourSlot = new List<int>();
for (int i = StartHour; i <= EndHour; i++)
{
HourSlot.Add(i);
}
await InvokeAsync(StateHasChanged);
}
/// <summary>
/// GetIso8601WeekOfYear
/// </summary>
/// <param name="DtReq"></param>
/// <returns></returns>
protected int weekNum(DateTime DtReq)
{
int wNum = WeekData.GetIso8601WeekOfYear(DtReq);
return wNum;
}
protected List<CalendarEvent> DayEvent(DateTime DtReq)
{
List<CalendarEvent> answ = new List<CalendarEvent>();
@@ -207,10 +197,51 @@ namespace EgwCoreLib.Razor
return answ;
}
protected async Task openCalendarMonth()
protected override async Task OnParametersSetAsync()
{
HourSlot = new List<int>();
for (int i = StartHour; i <= EndHour; i++)
{
HourSlot.Add(i);
}
await InvokeAsync(StateHasChanged);
}
protected async Task OpenCalendarMonth()
{
await backToCalendar.InvokeAsync(true);
}
protected async Task SelectDate(DateTime selDate)
{
await EC_HeadDateSel.InvokeAsync(selDate);
}
/// <summary>
/// GetIso8601WeekOfYear
/// </summary>
/// <param name="DtReq"></param>
/// <returns></returns>
protected int weekNum(DateTime DtReq)
{
int wNum = WeekData.GetIso8601WeekOfYear(DtReq);
return wNum;
}
#endregion Protected Methods
#region Private Properties
private string dataWidth
{
get => $"{(double)contWidth / vBox.Width:P2}".Replace(",", ".");
}
private string lblWidth
{
get => $"{(double)(vBox.Width - (contWidth * numDays)) / vBox.Width:P2}".Replace(",", ".");
}
#endregion Private Properties
}
}
+10 -2
View File
@@ -2,14 +2,14 @@
@using Microsoft.JSInterop;
@inject IJSRuntime JSRuntime
<div class="input-group input-group-sm">
<div class="@mainDivClass">
@if (ShowText)
{
<input class="form-control" readonly type="text" value="@Text" />
}
else
{
<span class="form-control fas fa-eye-slash" readonly></span>
<span class="form-control text-center fas fa-eye-slash fs-5" readonly></span>
}
<button type="button" class="btn @btnStyle" @onclick="CopyTextToClipboard" title="Copy to Clipboard">
@if (copyDone)
@@ -41,6 +41,14 @@
[Parameter]
public bool AddSlash { get; set; } = false;
[Parameter]
public bool IsSmall { get; set; } = true;
private string mainDivClass
{
get => IsSmall ? "input-group input-group-sm" : "input-group";
}
protected string btnStyle = "btn-primary";
protected bool copyDone = false;
+6
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -11,6 +12,11 @@ namespace EgwCoreLib.Razor.Data
public int id { get; set; } = 0;
public DateTime Inizio { get; set; } = DateTime.Today.AddHours(8);
public DateTime Fine { get; set; } = DateTime.Today.AddHours(10);
[NotMapped]
public double Durata
{
get => Fine.Subtract(Inizio).TotalMinutes;
}
public string CssClass { get; set; } = "";
public string Title { get; set; } = "";
public string Description { get; set; } = "";
+12 -12
View File
@@ -1,25 +1,25 @@
<div class="row">
<div class="col-12 col-lg-8 text-start">
<div class="d-flex justify-content-between align-items-center align-content-center @cssSize">
<div class="px-0">
<div class="row">
<div class="col-12 small">
<div class="col-12 @cssSize">
@if (totalCount > 0)
{
<ul class="pagination pagination-sm mb-1">
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(1)"><i class="fas fa-angle-double-left"></i></button></li>
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(prevBlock)"><i class="fas fa-angle-left"></i></button></li>
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(1)" title="@TxtStart"><i class="fas fa-angle-double-left"></i></button></li>
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(prevBlock)" title="@TxtPrev"><i class="fas fa-angle-left"></i></button></li>
@for (int i = @startPage; i <= endPage; ++i)
{
var pageNum = i;
<li class="page-item @cssActive(pageNum)"><button class="page-link" @onclick="() => PaginationItemClick(pageNum)">@pageNum</button></li>
}
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(nextBlock)"><i class="fas fa-angle-right"></i></button></li>
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(LastPage)"><i class="fas fa-angle-double-right"></i></button></li>
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(nextBlock)" title="@TxtNext"><i class="fas fa-angle-right"></i></button></li>
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(LastPage)" title="@TxtEnd"><i class="fas fa-angle-double-right"></i></button></li>
</ul>
}
</div>
</div>
<div class="row">
<div class="col-12 small">
<div class="col-12 @cssSize">
@if (showLoading)
{
<div class="progress" style="height: 10px;">
@@ -29,12 +29,12 @@
</div>
</div>
</div>
<div class="col-12 col-lg-4">
<div class="d-flex">
<div class="px-0">
<div class="d-flex align-items-center">
<div class="p-1 flex-fill text-end">
@if (!showLoading)
{
<span>@totalCount records</span>
<span class="text-nowrap">@totalCount rec</span>
}
@if (exportEnabled && totalCount > 0)
{
@@ -48,7 +48,7 @@
}
}
</div>
<div class="p-1 flex-fill text-end small">
<div class="p-1 flex-fill text-end @cssSize">
@if (totalCount > 0)
{
<div class="input-group input-group-sm">
+88 -16
View File
@@ -4,6 +4,17 @@ namespace EgwCoreLib.Razor
{
public partial class DataPager : ComponentBase
{
#region Public Enums
public enum ObjSize
{
small,
standard,
large
}
#endregion Public Enums
#region Public Properties
/// <summary>
@@ -27,6 +38,12 @@ namespace EgwCoreLib.Razor
}
}
/// <summary>
/// Dimensione controlli x resize
/// </summary>
[Parameter]
public ObjSize DisplSize { get; set; } = ObjSize.standard;
/// <summary>
/// Export (csv) abilitato
/// </summary>
@@ -38,21 +55,53 @@ namespace EgwCoreLib.Razor
/// </summary>
[Parameter]
public EventCallback<int> exportRequested { get; set; }
/// <summary>
/// Filename x export
/// </summary>
[Parameter]
public string fileName { get; set; } = "";
/// <summary>
/// Evento cambio pagina nel paginatore
/// </summary>
[Parameter]
public EventCallback<int> numPageChanged { get; set; }
/// <summary>
/// Massimo numero di pagine da mostrare (x display piccoli)
/// </summary>
[Parameter]
public int NumPages { get; set; } = 10;
/// <summary>
/// Test btn vai a inizio
/// </summary>
[Parameter]
public string TxtStart { get; set; } = "Start";
/// <summary>
/// Test btn vai a fine
/// </summary>
[Parameter]
public string TxtEnd { get; set; } = "End";
/// <summary>
/// Test btn vai a PrevBlock
/// </summary>
[Parameter]
public string TxtPrev { get; set; } = "Prev";
/// <summary>
/// Test btn vai a NextBlock
/// </summary>
[Parameter]
public string TxtNext{ get; set; } = "Next";
/// <summary>
/// PageSize = Num record da mostrare cambiato
/// </summary>
[Parameter]
public EventCallback<int> numRecordChanged { get; set; }
/// <summary>
/// Attuale PageSize
/// </summary>
@@ -74,6 +123,15 @@ namespace EgwCoreLib.Razor
}
}
/// <summary>
/// Elenco dei PageSize ammessi
/// </summary>
[Parameter]
public List<int> PageSizeList { get; set; } = new List<int>()
{
5,10,25,50,100
};
/// <summary>
/// Fase di loading
/// </summary>
@@ -98,21 +156,13 @@ namespace EgwCoreLib.Razor
_showLoading = value;
}
}
/// <summary>
/// Totale record da mostrare
/// </summary>
[Parameter]
public int totalCount { get; set; } = 0;
/// <summary>
/// Elenco dei PageSize ammessi
/// </summary>
[Parameter]
public List<int> PageSizeList { get; set; } = new List<int>()
{
5,10,25,50,100
};
#endregion Public Properties
#region Public Methods
@@ -152,6 +202,28 @@ namespace EgwCoreLib.Razor
get => $"{exportDir}\\{fileName}";
}
private string cssSize
{
get
{
string answ = "";
switch (DisplSize)
{
case ObjSize.small:
answ = "small";
break;
case ObjSize.standard:
break;
case ObjSize.large:
answ = "large";
break;
default:
break;
}
return answ;
}
}
protected int percLoading { get; set; } = 0;
#endregion Protected Properties
@@ -186,7 +258,7 @@ namespace EgwCoreLib.Razor
{
get
{
int answ = (int)(currPage / numPages) * numPages + numPages;
int answ = startPage + NumPages -1;
answ = answ < LastPage ? answ : LastPage;
return answ;
}
@@ -204,30 +276,30 @@ namespace EgwCoreLib.Razor
{
get
{
int answ = currPage + numPages;
int answ = currPage + NumPages;
answ = answ < LastPage ? answ : LastPage;
return answ;
}
}
private int numPages { get; set; } = 10;
private int prevBlock
{
get
{
int answ = currPage - numPages;
int answ = currPage - NumPages;
answ = answ > 0 ? answ : 1;
return answ;
}
}
// calcola un set 1 .. numPages centrato sulla pagina corrente...
/// <summary>
/// calcola un set 1 .. NumPages centrato sulla pagina corrente...
/// </summary>
private int startPage
{
get
{
int answ = (int)(currPage / numPages) * numPages;
int answ = ((int)((currPage -1) / NumPages) ) * NumPages + 1;
answ = answ > 0 ? answ : 1;
return answ;
}
+2 -2
View File
@@ -5,8 +5,8 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PackageId>EgwCoreLib.Razor</PackageId>
<version>0.9.0.0</version>
<Authors>S.E. Locatelli, Z.Majid</Authors>
<version>1.5.0.0</version>
<Authors>S.E. Locatelli</Authors>
<Company>EgalWare</Company>
<Description>Libreria componenti Razor/Blazor</Description>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
+1 -1
View File
@@ -1,6 +1,6 @@
<div class="input-group input-group-sm">
<div class="input-group-text py-0 @placardCss">
<span class="me-1 @leftStringCSS">@leftString</span>
<span class="me-3 @leftStringCSS">@leftString</span>
<div class="form-check form-check-sm form-switch py-1" title="@toolTip">
<input class="form-check-input" type="checkbox" name="setupAlarms" checked @onclick="() => toggle()">
</div>
+6 -1
View File
@@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>EgwCoreLib.Utils</PackageId>
<version>0.9.0.0</version>
<version>1.5.0.0</version>
<Authors>S.E. Locatelli</Authors>
<Company>EgalWare</Company>
<Description>Libreria Utility base dotnet core</Description>
@@ -16,7 +16,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DeviceId" Version="6.7.0" />
<PackageReference Include="DeviceId.Windows" Version="6.6.0" />
<PackageReference Include="DeviceId.Windows.Wmi" Version="6.6.0" />
<PackageReference Include="NLog" Version="5.3.4" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
</ItemGroup>
+128
View File
@@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwCoreLib.Utils
{
/// <summary>
/// Utility gestione calendario
/// </summary>
public class GestCalendario
{
#region Public Methods
/// <summary>
/// Calcolo data domenica di pasqua dell'YearReq indicato
/// </summary>
/// <param name="year"></param>
/// <returns></returns>
public static DateTime GetEasterSunday(int year)
{
int num = 0;
int num2 = 0;
int num3 = year % 19;
int num4 = year / 100;
int num5 = (num4 - num4 / 4 - (8 * num4 + 13) / 25 + 19 * num3 + 15) % 30;
int num6 = num5 - num5 / 28 * (1 - num5 / 28 * (29 / (num5 + 1)) * ((21 - num3) / 11));
num = num6 - (year + year / 4 + num6 + 2 - num4 + num4 / 4) % 7 + 28;
num2 = 3;
if (num > 31)
{
num2++;
num -= 31;
}
return new DateTime(year, num2, num);
}
/// <summary>
/// Elenco festività (limitato ad ITALIA)
/// </summary>
/// <param name="YearReq"></param>
/// <param name="CurrCult"></param>
/// <returns></returns>
public static List<EventDetail> ListHolidaysIta(int YearReq)
{
List<EventDetail> list = new List<EventDetail>();
list.Add(new EventDetail
{
What = "Capodanno",
When = new DateTime(YearReq, 1, 1)
});
list.Add(new EventDetail
{
What = "Epifania",
When = new DateTime(YearReq, 1, 6)
});
list.Add(new EventDetail
{
What = "Lavoro",
When = new DateTime(YearReq, 5, 1)
});
list.Add(new EventDetail
{
What = "Ferragosto",
When = new DateTime(YearReq, 8, 15)
});
list.Add(new EventDetail
{
What = "Ognissanti",
When = new DateTime(YearReq, 11, 1)
});
list.Add(new EventDetail
{
What = "Immacolata",
When = new DateTime(YearReq, 12, 8)
});
list.Add(new EventDetail
{
What = "Natale",
When = new DateTime(YearReq, 12, 25)
});
list.Add(new EventDetail
{
What = "S.Stefano",
When = new DateTime(YearReq, 12, 26)
});
list.Add(new EventDetail
{
What = "Pasqua",
When = GetEasterSunday(YearReq)
});
list.Add(new EventDetail
{
What = "Pasquetta",
When = GetEasterSunday(YearReq).AddDays(1.0)
});
list.Add(new EventDetail
{
What = "Liberazione",
When = new DateTime(YearReq, 4, 25)
});
list.Add(new EventDetail
{
What = "Repubblica",
When = new DateTime(YearReq, 6, 2)
});
return list;
}
#endregion Public Methods
#region Public Classes
public class EventDetail
{
#region Public Properties
public string What { get; set; } = "";
public DateTime When { get; set; }
#endregion Public Properties
}
#endregion Public Classes
}
}
+219
View File
@@ -0,0 +1,219 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace EgwCoreLib.Utils
{
/// <summary>
/// Classe validazione valori
/// </summary>
public class MachineDataValidator
{
#region Public Fields
public static Dictionary<string, string> biosInfo = new Dictionary<string, string>();
public static Dictionary<string, string> cpuInfo = new Dictionary<string, string>();
public static Dictionary<string, string> netInfo = new Dictionary<string, string>();
public static Dictionary<string, string> osInfo = new Dictionary<string, string>();
public static Dictionary<string, string> ramInfo = new Dictionary<string, string>();
public static Dictionary<string, string> userInfo = new Dictionary<string, string>();
public static Dictionary<string, string> volInfo = new Dictionary<string, string>();
#endregion Public Fields
#region Public Constructors
/// <summary>
/// Init classe validatore
/// </summary>
/// <param name="currMachineData"></param>
public MachineDataValidator()
{
// inizializzo info di base
if (machTestData == null || machTestData.Count == 0)
{
machTestData = setupData();
}
}
#endregion Public Constructors
#region Public Properties
/// <summary>
/// Restituisce HASH del codice impiego = payload utente
/// </summary>
/// <returns></returns>
public string macHash
{
get => calcMachineHash();
}
#endregion Public Properties
#if false
/// <summary>
/// Verifica validità info correnti
/// </summary>
/// <returns></returns>
public async Task<bool> testCurrInfo()
{
return await testInfo();
}
#endif
#region Public Methods
/// <summary>
/// Verifica validità info correnti
/// </summary>
/// <returns></returns>
public static async Task<bool> testCurrInfo()
{
var cDV = new MachineDataValidator();
return await cDV.testInfo();
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// Dati rispetto cui fare i calcoli di validazione
/// </summary>
private static Dictionary<string, string> machTestData = new Dictionary<string, string>();
#endregion Private Fields
#region Private Methods
/// <summary>
/// Calcola HASH del codice impiego = payload utente
/// </summary>
/// <returns></returns>
private string calcMachineHash()
{
string hash = "";
string buffData = currBaseBuffer();
if (!string.IsNullOrEmpty(buffData))
{
// hashing!
using (var hAlgo = SHA512.Create())
//using (var hAlgo = MD5.Create())
{
byte[] InputBytes = Encoding.UTF8.GetBytes(buffData);
var byteHash = hAlgo.ComputeHash(InputBytes);
hash = BitConverter.ToString(byteHash).Replace("-", "").Replace("/", "").Replace("\\", "").ToLowerInvariant();
}
}
return hash;
}
/// <summary>
/// Calcola hash key da info PC
/// </summary>
/// <returns></returns>
private string currBaseBuffer()
{
string answ = "????????????????????????????????????????????";
StringBuilder sb = new StringBuilder();
try
{
// calcolo hashKey da alcuni valori solamente
sb.Append($"{machTestData["SystemName"]}|");
sb.Append($"{machTestData["ProcessorId"]}|");
sb.Append($"{machTestData["PartNumber"]}|");
sb.Append($"{machTestData["MACAddress"]}|");
sb.Append($"{machTestData["SerialNumber"]}|");
sb.Append($"{machTestData["OSArchitecture"]}|");
sb.Append($"{machTestData["SoftwareElementID"]}|");
sb.Append($"{machTestData["SystemBiosMajorVersion"]}|");
sb.Append($"{machTestData["SystemBiosMinorVersion"]}|");
sb.Append($"{machTestData["CpuVersion"]}|");
sb.Append($"{machTestData["BiosVersion"]}|");
if (sb.Length > 0)
{
answ = sb.ToString();
// lo uso 2 volte dritto e reverse...
answ += ReverseString(sb.ToString());
}
}
catch
{ }
return answ;
}
/// <summary>
/// Legge la hash key dal file licenza salvato
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
private async Task<string> getSavedHash()
{
string answ = "############################################################";
string filePath = "Conf/lic.file";
if (File.Exists(filePath))
{
answ = await File.ReadAllTextAsync(filePath);
}
return answ;
}
/// <summary>
/// Esegue reverse delal stringa
/// </summary>
/// <param name="myStr"></param>
/// <returns></returns>
private string ReverseString(string myStr)
{
char[] myArr = myStr.ToCharArray();
Array.Reverse(myArr);
return new string(myArr);
}
/// <summary>
/// Predispone elenco dati di test
/// </summary>
/// <returns></returns>
private Dictionary<string, string> setupData()
{
// creo un unico array di info
Dictionary<string, string> testData = new Dictionary<string, string>();
biosInfo = MachineInfo.GetInfo("BIOS");
cpuInfo = MachineInfo.GetInfo("CPU");
netInfo = MachineInfo.GetInfo("NET");
osInfo = MachineInfo.GetInfo("OS");
ramInfo = MachineInfo.GetInfo("RAM");
userInfo = MachineInfo.GetInfo("USER");
volInfo = MachineInfo.GetInfo("VOL");
testData = biosInfo.Concat(cpuInfo).Concat(netInfo).Concat(osInfo).Concat(ramInfo).GroupBy(ele => ele.Key).ToDictionary(ele => ele.Key, ele => ele.First().Value);
return testData;
}
/// <summary>
/// Effettua verifica putuale tra hash Key fornita ed hash key calcolata da info PC
/// </summary>
/// <returns></returns>
private async Task<bool> testInfo()
{
// recupero hash key da conf applicativo (licenza)
string fileHash = await getSavedHash();
/// recupero hash calcolata
string calcHash = calcMachineHash();
// confronto con hashKey calcolata da info PC + dati...
return fileHash.Equals(calcHash);
}
#endregion Private Methods
}
}
+335
View File
@@ -0,0 +1,335 @@
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;
namespace EgwCoreLib.Utils
{
/// <summary>
/// Gestione info macchina
/// ATTENZIONE! per ora solo windows...
/// </summary>
public class MachineInfo
{
#region Public Methods
/// <summary>
/// Restitusice info richieste
/// </summary>
/// <param name="infoType"></param>
/// <returns></returns>
public static Dictionary<string, string> GetInfo(string infoType)
{
var outInfo = new Dictionary<string, string>();
switch (infoType)
{
case "BIOS":
outInfo = GetBiosInfo();
break;
case "CPU":
outInfo = GetCpuInfo();
break;
case "NET":
outInfo = GetNetInfo();
break;
case "OS":
outInfo = GetOsInfo();
break;
case "RAM":
outInfo = GetRamInfo();
break;
case "USER":
outInfo = GetUserInfo();
break;
case "VOL":
outInfo = GetVolumeInfo();
break;
default:
break;
}
return outInfo;
}
#endregion Public Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Methods
/// <summary>
/// Info BIOS
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> GetBiosInfo()
{
ManagementObjectCollection moc;
Dictionary<string, string> DictParam = new Dictionary<string, string>();
try
{
moc = new ManagementObjectSearcher("select * from Win32_BIOS").Get();
}
catch
{
Log.Error("Error: WMI API Not loaded.");
return DictParam;
}
foreach (ManagementObject obj in moc)
{
searchWmiParam(DictParam, obj, "Manufacturer", "Manufacturer");
searchWmiParam(DictParam, obj, "ReleaseDate", "ReleaseDate");
searchWmiParam(DictParam, obj, "SMBIOSBIOSVersion", "SMBIOSBIOSVersion");
searchWmiParam(DictParam, obj, "SMBIOSMajorVersion", "SMBIOSMajorVersion");
searchWmiParam(DictParam, obj, "SMBIOSMinorVersion", "SMBIOSMinorVersion");
searchWmiParam(DictParam, obj, "SoftwareElementID", "SoftwareElementID");
searchWmiParam(DictParam, obj, "SoftwareElementState", "SoftwareElementState");
searchWmiParam(DictParam, obj, "SystemBiosMajorVersion", "SystemBiosMajorVersion");
searchWmiParam(DictParam, obj, "SystemBiosMajorVersion", "SystemBiosMajorVersion");
searchWmiParam(DictParam, obj, "SystemBiosMinorVersion", "SystemBiosMinorVersion");
searchWmiParam(DictParam, obj, "BiosVersion", "Version");
}
return DictParam;
}
/// <summary>
/// Info processore
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> GetCpuInfo()
{
ManagementObjectCollection moc;
Dictionary<string, string> DictParam = new Dictionary<string, string>();
try
{
moc = new ManagementObjectSearcher("select * from Win32_Processor").Get();
}
catch
{
Log.Error("Error: WMI API Not loaded.");
return DictParam;
}
foreach (ManagementObject obj in moc)
{
searchWmiParam(DictParam, obj, "AddressWidth", "AddressWidth");
searchWmiParam(DictParam, obj, "Architecture", "Architecture");
searchWmiParam(DictParam, obj, "CurrentClockSpeed", "CurrentClockSpeed");
searchWmiParam(DictParam, obj, "CurrentVoltage", "CurrentVoltage");
searchWmiParam(DictParam, obj, "DataWidth", "DataWidth");
searchWmiParam(DictParam, obj, "Description", "Description");
searchWmiParam(DictParam, obj, "ExtClock", "ExtClock");
searchWmiParam(DictParam, obj, "Family", "Family");
searchWmiParam(DictParam, obj, "L2CacheSize", "L2CacheSize");
searchWmiParam(DictParam, obj, "L3CacheSize", "L3CacheSize");
searchWmiParam(DictParam, obj, "Level", "Level");
searchWmiParam(DictParam, obj, "LoadPercentage", "LoadPercentage");
searchWmiParam(DictParam, obj, "Manufacturer", "Manufacturer");
searchWmiParam(DictParam, obj, "NumberOfCores", "NumberOfCores");
searchWmiParam(DictParam, obj, "NumberOfLogicalProcessors", "NumberOfLogicalProcessors");
searchWmiParam(DictParam, obj, "ProcessorId", "ProcessorId");
searchWmiParam(DictParam, obj, "ProcessorType", "ProcessorType");
searchWmiParam(DictParam, obj, "Revision", "Revision");
searchWmiParam(DictParam, obj, "Role", "Role");
searchWmiParam(DictParam, obj, "SocketDesignation", "SocketDesignation");
searchWmiParam(DictParam, obj, "SystemName", "SystemName");
searchWmiParam(DictParam, obj, "CpuVersion", "Version");
}
return DictParam;
}
/// <summary>
/// Info Networking
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> GetNetInfo()
{
ManagementObjectCollection moc;
Dictionary<string, string> DictParam = new Dictionary<string, string>();
try
{
moc = new ManagementObjectSearcher("select * from Win32_NetworkAdapter WHERE NetEnabled = 'true'").Get();
}
catch
{
Log.Error("Error: WMI API Not loaded.");
return DictParam;
}
foreach (ManagementObject obj in moc)
{
searchWmiParam(DictParam, obj, "AdapterType", "AdapterType");
searchWmiParam(DictParam, obj, "Description", "Description");
searchWmiParam(DictParam, obj, "GUID", "GUID");
searchWmiParam(DictParam, obj, "MACAddress", "MACAddress");
searchWmiParam(DictParam, obj, "Manufacturer", "Manufacturer");
searchWmiParam(DictParam, obj, "Name", "Name");
searchWmiParam(DictParam, obj, "SystemName", "SystemName");
searchWmiParam(DictParam, obj, "PhysicalAdapter", "PhysicalAdapter");
searchWmiParam(DictParam, obj, "ProductName", "ProductName");
searchWmiParam(DictParam, obj, "ServiceName", "ServiceName");
}
return DictParam;
}
/// <summary>
/// Info OS
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> GetOsInfo()
{
ManagementObjectCollection moc;
Dictionary<string, string> DictParam = new Dictionary<string, string>();
try
{
moc = new ManagementObjectSearcher("select * from Win32_OperatingSystem").Get();
}
catch
{
Log.Error("Error: WMI API Not loaded.");
return DictParam;
}
foreach (ManagementObject obj in moc)
{
searchWmiParam(DictParam, obj, "Caption", "Caption");
searchWmiParam(DictParam, obj, "Version", "Version");
searchWmiParam(DictParam, obj, "MaxNumberOfProcesses", "MaxNumberOfProcesses");
searchWmiParam(DictParam, obj, "MaxProcessMemorySize", "MaxProcessMemorySize");
searchWmiParam(DictParam, obj, "OSArchitecture", "OSArchitecture");
searchWmiParam(DictParam, obj, "SerialNumber", "SerialNumber");
searchWmiParam(DictParam, obj, "BuildNumber", "BuildNumber");
searchWmiParam(DictParam, obj, "RegisteredUser", "RegisteredUser");
}
return DictParam;
}
/// <summary>
/// Info RAM
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> GetRamInfo()
{
ManagementObjectCollection moc;
Dictionary<string, string> DictParam = new Dictionary<string, string>();
try
{
moc = new ManagementObjectSearcher("select * from Win32_PhysicalMemory").Get();
}
catch
{
Log.Error("Error: WMI API Not loaded.");
return DictParam;
}
foreach (ManagementObject obj in moc)
{
searchWmiParam(DictParam, obj, "DeviceLocator", "DeviceLocator");
searchWmiParam(DictParam, obj, "DataWidth", "DataWidth");
searchWmiParam(DictParam, obj, "ConfiguredVoltage", "ConfiguredVoltage");
searchWmiParam(DictParam, obj, "FormFactor", "FormFactor");
searchWmiParam(DictParam, obj, "ConfiguredClockSpeed", "ConfiguredClockSpeed");
searchWmiParam(DictParam, obj, "MaxVoltage", "MaxVoltage");
searchWmiParam(DictParam, obj, "MinVoltage", "MinVoltage");
searchWmiParam(DictParam, obj, "Speed", "Speed");
searchWmiParam(DictParam, obj, "SMBIOSMemoryType", "SMBIOSMemoryType");
searchWmiParam(DictParam, obj, "PartNumber", "PartNumber");
}
return DictParam;
}
/// <summary>
/// Info User (macchina, dominio, username)
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> GetUserInfo()
{
ManagementObjectCollection moc;
Dictionary<string, string> DictParam = new Dictionary<string, string>();
try
{
DictParam.Add("MachineName", Environment.MachineName);
DictParam.Add("UserDomainName", Environment.UserDomainName);
DictParam.Add("UserName", Environment.UserName);
}
catch(Exception exc)
{
Log.Error($"Error in GetUserInfo{Environment.NewLine}{exc}");
}
return DictParam;
}
/// <summary>
/// Info Volumes (HDD/SSD)
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> GetVolumeInfo()
{
ManagementObjectCollection moc;
Dictionary<string, string> DictParam = new Dictionary<string, string>();
try
{
moc = new ManagementObjectSearcher("select DriveLetter, DeviceID from Win32_Volume").Get();
}
catch
{
Log.Error("Error: WMI API Not loaded.");
return DictParam;
}
foreach (ManagementObject obj in moc)
{
// mi limito al disco "C:"
string sDrive = "DriveLetter";
var objVal = $"{obj[sDrive]}";
if (objVal == "C:")
{
searchWmiParam(DictParam, obj, "DeviceID", "DeviceID");
searchWmiParam(DictParam, obj, "DriveLetter", "DriveLetter");
}
}
return DictParam;
}
/// <summary>
/// Effettua estrazione parametri WMI da elenco recuperato
/// </summary>
/// <param name="Processor"></param>
/// <param name="obj"></param>
/// <param name="pName"></param>
/// <param name="pKey"></param>
private static void searchWmiParam(Dictionary<string, string> Processor, ManagementObject obj, string pName, string pKey)
{
try
{
var objVal = $"{obj[pKey]}";
string strVal = objVal != null ? objVal : "";
Processor.Add(pName, strVal);
}
catch
{ }
}
#endregion Private Methods
}
}
+82
View File
@@ -0,0 +1,82 @@
using DeviceId;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwCoreLib.Utils
{
/// <summary>
/// Classe gestione SubLicenze (attivazioni)
/// </summary>
public class SubLicManager
{
#region Public Constructors
public SubLicManager()
{
MachineDataValidator = new MachineDataValidator();
MachineInfo = new MachineInfo();
}
#endregion Public Constructors
#region Public Methods
public string CodImpiego()
{
Guid tempKey = Guid.NewGuid();
string codice = $"{tempKey}";
// impiego libreria nuget
codice = new DeviceIdBuilder()
.AddMachineName()
.AddUserName()
.AddOsVersion()
.OnWindows(windows => windows
.AddMacAddressFromWmi(excludeWireless: true, excludeNonPhysical: true)
.AddProcessorId()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber())
.ToString();
return codice;
}
/// <summary>
/// Genera KEY macchina in modalità encrypt
/// </summary>
/// <param name="passphrase"></param>
/// <param name="addGuid"></param>
/// <returns></returns>
public string GenKey(string passphrase, bool addGuid = false)
{
Guid tempKey = Guid.NewGuid();
var UserData = MachineInfo.GetInfo("USER");
string payload = addGuid ? $"|{tempKey}|" : "";
if (UserData.ContainsKey("MachineName"))
{
payload += $"{UserData["MachineName"]}|";
}
if (UserData.ContainsKey("UserDomainName"))
{
payload += $"{UserData["UserDomainName"]}|";
}
if (UserData.ContainsKey("UserName"))
{
payload += $"{UserData["UserName"]}|";
}
payload += $"{DateTime.Now:yyMMdd}-{DateTime.Now:HHmmss}|";
return SteamCrypto.EncryptString(payload, passphrase);
}
#endregion Public Methods
#region Private Properties
private MachineDataValidator MachineDataValidator { get; set; } = null!;
private MachineInfo MachineInfo { get; set; } = null!;
#endregion Private Properties
}
}