Merge branch 'develop' into SDK

This commit is contained in:
Samuele Locatelli
2024-04-27 11:58:37 +02:00
62 changed files with 2375 additions and 398 deletions
+2 -5
View File
@@ -11,9 +11,9 @@ variables:
- |
$hasSource = C:\Tools\nuget.exe sources list | find "`"Steamware Nexus`"" /C
if ($hasSource -eq 0) {
C:\Tools\nuget.exe sources Add -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
C:\Tools\nuget.exe sources Add -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"$NEXUS_PASSWD`""
} else {
C:\Tools\nuget.exe sources Update -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
C:\Tools\nuget.exe sources Update -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"$NEXUS_PASSWD`""
}
echo $hasSource
@@ -27,7 +27,6 @@ variables:
New-Item $Target".sha1"
$MD5.Hash | Set-Content -Path $Target".md5"
$SHA1.Hash | Set-Content -Path $Target".sha1"
echo "Created HASH files for $Target"
# helper x send su NEXUS
@@ -56,8 +55,6 @@ variables:
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "Resources\manifest.xml" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/manifest.xml
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "Resources\ChangeLog.html" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/ChangeLog.html
# mCurl -v -u $env:NEXUS_USER:$env:NEXUS_PASSWD --upload-file bin/release/$env:APP_NAME.zip $env:NEXUS_SERVER/utility/$env:NEXUS_PATH/$version/$env:APP_NAME-$version.zip
# helper x fix version number
.version-fix: &version-fix
- |
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.21.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
</provider></providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -0,0 +1,121 @@
using EgwProxy.DataLayer.DbModel;
using EgwProxy.MagMan.DTO;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Data.Entity.Infrastructure.Design.Executor;
namespace EgwProxy.DataLayer.Controllers
{
public class LogMachineController : IDisposable
{
#region Public Constructors
/// <summary>
/// Init classe
/// </summary>
/// <param name="connString"></param>
public LogMachineController()
{
}
#endregion Public Constructors
#region Public Methods
public void Dispose()
{
}
/// <summary>
/// Helper conversione a LogMachineDTO
/// </summary>
/// <param name="currRec"></param>
/// <param name="keyNum"></param>
/// <param name="machineCloudId"></param>
/// <param name="projCloudId"></param>
/// <returns></returns>
public static LogMachineDTO ConvToItemDto(LogMachineModel currRec, int keyNum, int machineCloudId, int projCloudId)
{
LogMachineDTO answ = new LogMachineDTO()
{
DtEvent = currRec.DtEvent,
EvType = (MagMan.MachLogTypes)currRec.EvType,
KeyNum = keyNum,
MachineCloudId = machineCloudId,
ProjCloudId = projCloudId,
VarAddress = currRec.VarAddress,
VarValue = currRec.VarValue
};
return answ;
}
/// <summary>
/// Recupero i dati in ordine crescente fino al num max indicato
/// </summary>
/// <param name="numMax"></param>
/// <returns></returns>
public List<LogMachineModel> GetUnsentAsc(int numMax)
{
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
// retrieve
return localDbCtx
.DbSetLogMac
.Where(x => x.DtSent == null)
.OrderBy(x => x.DtEvent)
.Take(numMax)
.ToList();
}
}
/// <summary>
/// Aggiorna i record indicati inserendo dataora corrente x DtSent
/// </summary>
/// <param name="rec2upd"></param>
/// <returns></returns>
public bool SetDtSent(List<LogMachineModel> rec2upd)
{
bool done = false;
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
DateTime adesso = DateTime.Now;
foreach (var item in rec2upd)
{
var currRec = localDbCtx
.DbSetLogMac
.Where(x => x.DtSent == null && x.LogDbId == item.LogDbId)
.FirstOrDefault();
if (currRec != null)
{
currRec.DtSent = adesso;
}
// indico modificato
localDbCtx.Entry(currRec).State = System.Data.Entity.EntityState.Modified;
}
// Salvataggio finale
localDbCtx.SaveChanges();
}
return done;
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.DataLayer.Core
{
public class MachLog
{
public enum MachLogTypes
{
NULL = 0
, PART_STATUS = 1
, MACHGROUP_STATUS = 2
, MACHINE_MODE = 3
, MACHINE_STATUS = 4
, MACHINE_COMMAND = 5
, READ_VAR = 6
, WRITE_VAR = 7
, ALARM = 8
, OPERATOR_MSG = 9
, PROGRAM_SEND = 10
}
}
}
+49
View File
@@ -0,0 +1,49 @@
using EgwProxy.DataLayer.DbModel;
using MySql.Data.EntityFramework;
using NLog;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.DataLayer
{
[DbConfigurationType(typeof(MySqlEFConfiguration))]
public partial class DatabaseContext : DbContext
{
#region Public Constructors
public DatabaseContext(string currConnString) : base(currConnString)
{
connString = currConnString;
}
#endregion Public Constructors
#region Public Properties
public virtual DbSet<LogMachineModel> DbSetLogMac { get; set; }
#endregion Public Properties
#region Protected Methods
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private string connString = "";
#endregion Private Fields
#region Private Methods
#endregion Private Methods
}
}
+32
View File
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EgwProxy.DataLayer
{
public static class DbConfig
{
public static string DATABASE_NAME = "EgtBwDb";
public static int DATABASE_PROCESS_TIMEOUT = 5;
public static string DATABASE_PWD = "viacremasca";
// Database config
public static string DATABASE_SERV = "127.0.0.1";
public static string DATABASE_USER = "EgtUser";
/// <summary>
/// DB Connection string per azioni amministrative:
/// aggiunto parametro "allow user variables", da https://forums.mysql.com/read.php?38,609672,610320#msg-610320
/// </summary>
public static string ADMIN_CONNECTION_STRING { get; set; } = "";
/// <summary>
/// DB Connection string, per effettuare migration riportare valore connessione admin cablato (server=localhost;port=3306;database=EgtBwDb_000102;uid=root;pwd=Egalware_24068!;)
/// </summary>
public static string CONNECTION_STRING { get; set; } = "server=localhost;port=3306;database=EgtBwDb_000470;uid=root;pwd=Egalware_24068!;allow user variables=true";
}
}
@@ -0,0 +1,56 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EgwProxy.DataLayer.DbModel
{
/// <summary>
/// Tabella dei LOG Macchina
/// </summary>
[Table("LogMachine")]
public class LogMachineModel
{
#region Public Properties
/// <summary>
/// Chiave primaria evento LOG
/// </summary>
[Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int LogDbId { get; set; }
/// <summary>
/// Stato da enum Core
/// </summary>
[Column("EvType")]
public Core.MachLog.MachLogTypes EvType { get; set; } = Core.MachLog.MachLogTypes.NULL;
/// <summary>
/// Data Evento
/// </summary>
[Column("DtEvent")]
public DateTime DtEvent { get; set; } = DateTime.Now;
/// <summary>
/// Indirizzo VAR (Supervisore)
/// </summary>
[Column("VarAddress")]
public string VarAddress { get; set; } = "";
/// <summary>
/// Valore VAR
/// </summary>
[Column("VarValue")]
public string VarValue { get; set; } = "";
/// <summary>
/// Data di invio evento (su cloud)
/// </summary>
[Column("DtSent")]
public DateTime? DtSent { get; set; } = null;
#endregion Public Properties
}
}
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{87935FC9-C1BC-4984-83CA-A9EDABBE2228}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EgwProxy.DataLayer</RootNamespace>
<AssemblyName>EgwProxy.DataLayer</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4, Version=1.1.11.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.1.1.11\lib\net46\K4os.Compression.LZ4.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.1.11.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.1.11\lib\net46\K4os.Compression.LZ4.Streams.dll</HintPath>
</Reference>
<Reference Include="K4os.Hash.xxHash, Version=1.0.6.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=8.0.21.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.21\lib\net452\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="MySql.Data.EntityFramework, Version=8.0.21.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.EntityFramework.8.0.21\lib\net452\MySql.Data.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.2.8\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="Renci.SshNet, Version=2016.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
<HintPath>..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Design" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Ubiety.Dns.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.21\lib\net452\Ubiety.Dns.Core.dll</HintPath>
</Reference>
<Reference Include="Zstandard.Net, Version=1.1.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.21\lib\net452\Zstandard.Net.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\LogMachineController.cs" />
<Compile Include="Core\MachLog.cs" />
<Compile Include="DatabaseContext.cs" />
<Compile Include="DbConfig.cs" />
<Compile Include="DbModel\LogMachineModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EgwProxy.MagMan\EgwProxy.MagMan.csproj">
<Project>{1696d7a5-765a-4d25-8d29-ca7345023479}</Project>
<Name>EgwProxy.MagMan</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
</Target>
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EgwProxy.DataLayer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EgwProxy.DataLayer")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("87935fc9-c1bc-4984-83ca-a9edabbe2228")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.8.3.1" targetFramework="net472" />
<package id="EntityFramework" version="6.4.4" targetFramework="net472" />
<package id="Google.Protobuf" version="3.6.1" targetFramework="net472" />
<package id="K4os.Compression.LZ4" version="1.1.11" targetFramework="net472" />
<package id="K4os.Compression.LZ4.Streams" version="1.1.11" targetFramework="net472" />
<package id="K4os.Hash.xxHash" version="1.0.6" targetFramework="net472" />
<package id="MySql.Data" version="8.0.21" targetFramework="net472" />
<package id="MySql.Data.EntityFramework" version="8.0.21" targetFramework="net472" />
<package id="NLog" version="5.2.8" targetFramework="net472" />
<package id="SSH.NET" version="2016.1.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0" targetFramework="net472" />
</packages>
+6
View File
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.MagMan", "EgwProxy
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TestWinFormVB", "TestWinFormVB\TestWinFormVB.vbproj", "{665C94F5-27A6-4CD0-9487-036D199CDC47}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwProxy.DataLayer", "EgwProxy.DataLayer\EgwProxy.DataLayer.csproj", "{87935FC9-C1BC-4984-83CA-A9EDABBE2228}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
{665C94F5-27A6-4CD0-9487-036D199CDC47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{665C94F5-27A6-4CD0-9487-036D199CDC47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{665C94F5-27A6-4CD0-9487-036D199CDC47}.Release|Any CPU.Build.0 = Release|Any CPU
{87935FC9-C1BC-4984-83CA-A9EDABBE2228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87935FC9-C1BC-4984-83CA-A9EDABBE2228}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87935FC9-C1BC-4984-83CA-A9EDABBE2228}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87935FC9-C1BC-4984-83CA-A9EDABBE2228}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+54
View File
@@ -0,0 +1,54 @@
using System;
namespace EgwProxy.MagMan.DTO
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
public class LogMachineDTO
{
/// <summary>
/// Key di riferimento per il progetto
/// </summary>
public int KeyNum { get; set; } = 0;
/// <summary>
/// ID Macchina (cloud)
/// </summary>
public int MachineCloudId { get; set; } = 0;
/// <summary>
/// Key progetto (DB) / CLOUD
/// </summary>
public int ProjCloudId { get; set; } = 0;
#if false
/// <summary>
/// ID del DB EgtBW, univoco con KeyNum, (DB) / istanza locale
/// </summary>
public int ProjLocalId { get; set; } = 0;
#endif
/// <summary>
/// Stato da enum
/// </summary>
public MachLogTypes EvType { get; set; } = MachLogTypes.NULL;
/// <summary>
/// Data Evento
/// </summary>
public DateTime DtEvent { get; set; } = DateTime.Now;
/// <summary>
/// Indirizzo VAR (Supervisore)
/// </summary>
public string VarAddress { get; set; } = "";
/// <summary>
/// Valore VAR
/// </summary>
public string VarValue { get; set; } = "";
}
}
+154 -85
View File
@@ -4,6 +4,7 @@ using NLog;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading;
@@ -376,6 +377,77 @@ namespace EgwProxy.MagMan
return await Task.FromResult(answ);
}
/// <summary>
/// Invio elenco LogMachine da tab locale
/// </summary>
/// <param name="rec2send">record da inviare</param>
/// <returns></returns>
public bool LogMachineSend(List<LogMachineDTO> rec2send)
{
bool answ = false;
if (rec2send != null && rec2send.Count > 0)
{
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.LogData newPayload = new RestPayload.LogData()
{
LogList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"LogMachine/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
Log.Debug($"LogMachineSend | #rec: {rec2send.Count} | Response StatusCode: {response.StatusCode} | content: {response.Content}");
answ = true;
}
else
{
Log.Error($"LogMachineSend | #rec: {rec2send.Count} | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
}
return answ;
}
/// <summary>
/// Versione async Invio elenco LogMachine da tab locale
/// </summary>
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
/// <returns></returns>
public async Task<bool> LogMachineSendAsync(List<LogMachineDTO> rec2send)
{
bool answ = false;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.LogData newPayload = new RestPayload.LogData()
{
LogList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"LogMachine/upsert/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
Log.Debug($"LogMachineSendAsync | #rec: {rec2send.Count} | Response StatusCode: {response.StatusCode} | content: {response.Content}");
answ = true;
}
else
{
Log.Error($"LogMachineSendAsync | #rec: {rec2send.Count} | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
/// <summary>
/// Elenco Materiali dato RestToken
/// </summary>
@@ -587,8 +659,7 @@ namespace EgwProxy.MagMan
}
/// <summary>
/// Invio record Proj x upsert
/// <param name="rec2send">record da inviare</param>
/// Invio record Proj x upsert <param name="rec2send">record da inviare</param>
/// </summary>
/// <returns>ProjCloudId (essitente o nuovo)</returns>
public int ProjectSend(ProjectDTO rec2send)
@@ -610,7 +681,6 @@ namespace EgwProxy.MagMan
if (response.StatusCode == HttpStatusCode.OK)
{
int.TryParse(response.Content, out answ);
}
else
{
@@ -652,6 +722,82 @@ namespace EgwProxy.MagMan
return await Task.FromResult(answ);
}
/// <summary>
/// Verifica elenco di risorse associate ad un progetto
/// </summary>
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
/// <param name="dtRif">DataOra di riferimento del record</param>
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
/// <returns>0 = errore comunicazione / 1 = risorse invariate / 2 = risorse cambiate</returns>
public int ResourceCheck(int idxProjDbId, ProjResState recType, DateTime dtRif, List<ResourceDTO> rec2send)
{
int answ = 0;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Resources newPayload = new RestPayload.Resources()
{
DtReq = dtRif,
ProjCloudId = idxProjDbId,
ReqState = recType,
ResourceList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Resources/check/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = response.Content == "EQUAL" ? 1 : 2;
}
else
{
Log.Error($"ResourceCheck | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return answ;
}
/// <summary>
/// Versione async Verifica elenco di risorse associate ad un progetto
/// </summary>
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
/// <returns>0 = errore comunicazione / 1 = risorse invariate / 2 = risorse cambiate</returns>
public async Task<int> ResourceCheckAsync(int idxProjDbId, ProjResState recType, List<ResourceDTO> rec2send)
{
int answ = 0;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Resources newPayload = new RestPayload.Resources()
{
ProjCloudId = idxProjDbId,
ReqState = recType,
ResourceList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Resources/check/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = response.Content == "EQUAL" ? 1 : 2;
}
else
{
Log.Error($"ResourceCheckAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
/// <summary>
/// Elenco risorse associate a progetto
/// </summary>
@@ -780,87 +926,15 @@ namespace EgwProxy.MagMan
return await Task.FromResult(answ);
}
/// <summary>
/// Verifica elenco di risorse associate ad un progetto
/// </summary>
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
/// <param name="dtRif">DataOra di riferimento del record</param>
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
/// <returns>0 = errore comunicazione / 1 = risorse invariate / 2 = risorse cambiate</returns>
public int ResourceCheck(int idxProjDbId, ProjResState recType, DateTime dtRif, List<ResourceDTO> rec2send)
{
int answ = 0;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Resources newPayload = new RestPayload.Resources()
{
DtReq = dtRif,
ProjCloudId = idxProjDbId,
ReqState = recType,
ResourceList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Resources/check/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = client.Post(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = response.Content == "EQUAL" ? 1 : 2;
}
else
{
Log.Error($"ResourceCheck | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return answ;
}
/// <summary>
/// Versione async Verifica elenco di risorse associate ad un progetto
/// </summary>
/// <param name="idxProjDbId">DbId del progetto da inviare</param>
/// <param name="recType">tipo di registrazione da inviare (stima, consumo, ...)</param>
/// <param name="rec2send">record da inviare, se consumo Qty deve essere negativa</param>
/// <returns>0 = errore comunicazione / 1 = risorse invariate / 2 = risorse cambiate</returns>
public async Task<int> ResourceCheckAsync(int idxProjDbId, ProjResState recType, List<ResourceDTO> rec2send)
{
int answ = 0;
// cerco online
using (RestClient client = new RestClient(rcOptions))
{
string MKeyEnc = HttpUtility.UrlEncode(RestToken);
// impacchetto dati x invio...
RestPayload.Resources newPayload = new RestPayload.Resources()
{
ProjCloudId = idxProjDbId,
ReqState = recType,
ResourceList = rec2send
};
var jsonBody = JsonConvert.SerializeObject(newPayload);
var request = new RestRequest($"Resources/check/{MKeyEnc}", Method.Post).AddJsonBody(jsonBody);
var response = await client.PostAsync(request);
// controllo risposta
if (response.StatusCode == HttpStatusCode.OK)
{
answ = response.Content == "EQUAL" ? 1 : 2;
}
else
{
Log.Error($"ResourceCheckAsync | Response StatusCode: {response.StatusCode} | content: {response.Content}");
}
}
return await Task.FromResult(answ);
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// Istanza logger
/// </summary>
private static Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// URL dell'API x chiamate gestione licenze
/// </summary>
@@ -868,11 +942,6 @@ namespace EgwProxy.MagMan
private int callTimeout = 500;
/// <summary>
/// Istanza logger
/// </summary>
private static Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// Opzioni standard di chiamata
/// </summary>
+1
View File
@@ -86,6 +86,7 @@
<Compile Include="DTO\ItemDTO.cs" />
<Compile Include="DTO\MaterialDTO.cs" />
<Compile Include="DTO\ProjectDTO.cs" />
<Compile Include="DTO\LogMachineDTO.cs" />
<Compile Include="DTO\ResourceDTO.cs" />
<Compile Include="DTO\ResourceExpDTO.cs" />
<Compile Include="Enums.cs" />
+21 -1
View File
@@ -12,27 +12,47 @@ namespace EgwProxy.MagMan
BEAM = 1,
WALL = 2
}
public enum MachLogTypes
{
NULL = 0
, PART_STATUS = 1
, MACHGROUP_STATUS = 2
, MACHINE_MODE = 3
, MACHINE_STATUS = 4
, MACHINE_COMMAND = 5
, READ_VAR = 6
, WRITE_VAR = 7
, ALARM = 8
, OPERATOR_MSG = 9
, PROGRAM_SEND = 10
}
public enum ProjResState
{
/// <summary>
/// Registrazione consumo effettivo (update giacenza su tab RawItemList)
/// </summary>
Consumed = -1,
/// <summary>
/// Non definito
/// </summary>
ND = 0,
/// <summary>
/// Consumo stimato da nesting (solo simulazione)
/// </summary>
Estimated,
/// <summary>
/// Consumo confermato (da ordinare)
/// </summary>
Confirmed,
/// <summary>
/// Riservato (utile x calcolo quantità da ordinare)
/// </summary>
Reserved
}
}
}
+13
View File
@@ -83,6 +83,19 @@ namespace EgwProxy.MagMan
#endregion Public Properties
}
public class LogData
{
#region Public Properties
/// <summary>
/// Elenco record log x invio POST
/// </summary>
public List<LogMachineDTO> LogList { get; set; }
#endregion Public Properties
}
#endregion Public Classes
}
}
+58
View File
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MagMan.Core.DTO
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
public class LogMachineDTO
{
/// <summary>
/// Key di riferimento per il progetto
/// </summary>
public int KeyNum { get; set; } = 0;
/// <summary>
/// ID Macchina (cloud)
/// </summary>
public int MachineCloudId { get; set; } = 0;
/// <summary>
/// Key progetto (DB) / CLOUD
/// </summary>
public int ProjCloudId { get; set; } = 0;
#if false
/// <summary>
/// ID del DB EgtBW, univoco con KeyNum, (DB) / istanza locale
/// </summary>
public int ProjLocalId { get; set; } = 0;
#endif
/// <summary>
/// Stato da enum
/// </summary>
public Enums.MachLogTypes EvType { get; set; } = Enums.MachLogTypes.NULL;
/// <summary>
/// Data Evento
/// </summary>
public DateTime DtEvent { get; set; } = DateTime.Now;
/// <summary>
/// Indirizzo VAR (Supervisore)
/// </summary>
public string VarAddress { get; set; } = "";
/// <summary>
/// Valore VAR
/// </summary>
public string VarValue { get; set; } = "";
}
}
+22 -2
View File
@@ -22,37 +22,57 @@ namespace MagMan.Core
Request,
}
public enum MachLogTypes
{
NULL = 0
, PART_STATUS = 1
, MACHGROUP_STATUS = 2
, MACHINE_MODE = 3
, MACHINE_STATUS = 4
, MACHINE_COMMAND = 5
, READ_VAR = 6
, WRITE_VAR = 7
, ALARM = 8
, OPERATOR_MSG = 9
, PROGRAM_SEND = 10
}
public enum ProjResState
{
/// <summary>
/// Registrazione consumo effettivo (update giacenza su tab RawItemList)
/// </summary>
Consumed = -1,
/// <summary>
/// Non definito
/// </summary>
ND = 0,
/// <summary>
/// Consumo stimato da nesting (solo simulazione)
/// </summary>
Estimated,
/// <summary>
/// Consumo confermato (da ordinare)
/// </summary>
Confirmed,
/// <summary>
/// Riservato (utile x calcolo quantità da ordinare)
/// </summary>
Reserved
}
#if false
public enum ResultTypes
{
NULL = 0,
EXECUTED = 1,
RESULT = 2
}
}
#endif
#endregion Public Enums
}
+11
View File
@@ -35,6 +35,17 @@ namespace MagMan.Core
#endregion Public Properties
}
public class LogData
{
#region Public Properties
/// <summary>
/// Elenco record log x invio POST
/// </summary>
public List<LogMachineDTO> LogList { get; set; } = new List<LogMachineDTO>();
#endregion Public Properties
}
public class Materials
{
@@ -12,6 +12,8 @@ using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using static MagMan.Core.Enums;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace MagMan.Data.Tenant.Controllers
@@ -522,6 +524,62 @@ namespace MagMan.Data.Tenant.Controllers
return done;
}
/// <summary>
/// Elenco Materiali gestiti a magazzino formato DTO
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="machineId">idMacchina di cui si vuole log</param>
/// <param name="numRec">num rec max da recuperare</param>
/// <returns></returns>
public List<LogMachineModel> LogMacGetLast(string connString, int machineId, int numRec)
{
List<LogMachineModel> dbResult = new List<LogMachineModel>();
using (MagManContext dbCtx = new MagManContext(connString))
{
dbResult = dbCtx
.DbSetLogMac
.Where(x => x.MachineID == machineId)
.OrderByDescending(x => x.DtEvent)
.Take(numRec)
.ToList();
}
return dbResult;
}
public int LogMacUpdate(string connString, List<LogMachineModel> recList)
{
int numMod = 0;
using (MagManContext dbCtx = new MagManContext(connString))
{
try
{
// verifico record x data/progetto...
foreach (var item in recList)
{
// cerco
var recOld = dbCtx
.DbSetLogMac
.Where(x => x.DtEvent == item.DtEvent && x.ProjDbId == item.ProjDbId && x.MachineID == item.MachineID)
.FirstOrDefault();
if (recOld == null)
{
dbCtx
.DbSetLogMac
.Add(item);
numMod++;
}
}
// salvo su DB
dbCtx.SaveChanges();
}
catch (Exception exc)
{
Log.Error($"Eccezione in LogMacUpdate{Environment.NewLine}{exc}");
}
}
return numMod;
}
/// <summary>
/// Elimina Materiale da magazzino
/// </summary>
@@ -972,6 +1030,39 @@ namespace MagMan.Data.Tenant.Controllers
return newId;
}
/// <summary>
/// Recupera ultimo record attivo di un progetto/stato indicato
/// </summary>
/// <param name="connString">Stringa connessione (variabile x cliente)</param>
/// <param name="ProjCloudId">ID del progetto da cercare</param>
/// <param name="ResState">Stato richiesta da cercare</param>
/// <returns></returns>
public RequestPlanModel ReqPlanGetLast(string connString, int ProjCloudId, ProjResState ResState)
{
RequestPlanModel dbResult = new RequestPlanModel(); ;
using (MagManContext dbCtx = new MagManContext(connString))
{
try
{
/*
* Ricerca x Id corrispondente
* */
var currData = dbCtx
.DbSetReqPlan
.Where(x => x.ProjDbId == ProjCloudId && x.ReqState == ResState && x.IsActive)
.OrderByDescending(x => x.DtRequest)
.FirstOrDefault();
dbResult = currData ?? new RequestPlanModel();
}
catch (Exception exc)
{
Log.Error($"Eccezione in ReqPlanGetLast{Environment.NewLine}{exc}");
}
}
return dbResult;
}
/// <summary>
/// Aggiunge/Modifica un record ReqPlan
/// </summary>
@@ -1047,6 +1138,23 @@ namespace MagMan.Data.Tenant.Controllers
return newId;
}
/// <summary>
/// Converte il DTO in ResourceModel
/// </summary>
/// <param name="origItem">DTO di partenza</param>
/// <returns></returns>
public ResourceModel ResourceFromDto(ResourceDTO origItem, int reqId)
{
ResourceModel answ = new ResourceModel()
{
Qty = origItem.Qty,
RawItemId = origItem.RawItemCloudId,
RequestId = reqId,
ResourceId = 0
};
return answ;
}
/// <summary>
/// Elenco risorse dato progetto e stato
/// </summary>
@@ -1139,22 +1247,6 @@ namespace MagMan.Data.Tenant.Controllers
}
return dbResult;
}
/// <summary>
/// Converte il DTO in ResourceModel
/// </summary>
/// <param name="origItem">DTO di partenza</param>
/// <returns></returns>
public ResourceModel ResourceFromDto(ResourceDTO origItem, int reqId)
{
ResourceModel answ = new ResourceModel()
{
Qty = origItem.Qty,
RawItemId = origItem.RawItemCloudId,
RequestId = reqId,
ResourceId = 0
};
return answ;
}
/// <summary>
/// Aggiunge/Modifica un elenco di Resource (+ eventuali update giacenze)
+15 -4
View File
@@ -24,15 +24,26 @@ namespace MagMan.Data.Tenant.DbModels
[Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int LogDbId { get; set; }
/// <summary>
/// Key di riferimento per il progetto
/// </summary>
public int KeyNum { get; set; } = 0;
/// <summary>
/// Id macchina (diMagMan)
/// </summary>
public int MachineID { get; set; } = 0;
/// <summary>
/// Key di riferimento per il progetto
/// Progetto di riferimento (CloudId)
/// </summary>
public int KeyNum { get; set; } = 0;
public int ProjDbId { get; set; }
/// <summary>
/// Data Registrazione
/// </summary>
[Column("DtEvent")]
public DateTime DtEvent { get; set; } = DateTime.Now;
#if false
/// <summary>
@@ -101,8 +112,8 @@ namespace MagMan.Data.Tenant.DbModels
/// <summary>
/// Stato da enum Core
/// </summary>
[Column("ResultType")]
public ResultTypes ResultType { get; set; } = ResultTypes.NULL;
[Column("EvType")]
public MachLogTypes EvType { get; set; } = MachLogTypes.NULL;
/// <summary>
/// Indirizzo VAR
+1
View File
@@ -47,6 +47,7 @@ namespace MagMan.Data.Tenant
public virtual DbSet<RequestPlanModel> DbSetReqPlan { get; set; } = null!;
public virtual DbSet<ResourceModel> DbSetResources { get; set; } = null!;
public virtual DbSet<MovMagModel> DbSetMovMag { get; set; } = null!;
public virtual DbSet<LogMachineModel> DbSetLogMac { get; set; } = null!;
@@ -0,0 +1,394 @@
// <auto-generated />
using System;
using MagMan.Data.Tenant;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace MagMan.Data.Tenant.Migrations
{
[DbContext(typeof(MagManContext))]
[Migration("20240427093933_AddLogMachine")]
partial class AddLogMachine
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.25")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.AliasModel", b =>
{
b.Property<string>("Family")
.HasColumnType("varchar(255)");
b.Property<string>("ValueOriginal")
.HasColumnType("varchar(255)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<string>("ValueAlias")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Family", "ValueOriginal");
b.ToTable("AliasList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ConfigModel", b =>
{
b.Property<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnOrder(0);
b.Property<string>("Note")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasColumnOrder(3);
b.Property<string>("Val")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnOrder(1);
b.Property<string>("ValStd")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnOrder(2)
.HasComment("Valore di default/riferimento per la variabile");
b.HasKey("KeyName");
b.ToTable("Config");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.LogMachineModel", b =>
{
b.Property<int>("LogDbId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("DbId");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)")
.HasColumnName("DtEvent");
b.Property<int>("EvType")
.HasColumnType("int")
.HasColumnName("EvType");
b.Property<int>("KeyNum")
.HasColumnType("int");
b.Property<int>("MachineID")
.HasColumnType("int");
b.Property<int>("ProjDbId")
.HasColumnType("int");
b.Property<string>("VarAddress")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("VarAddress");
b.Property<string>("VarValue")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("VarValue");
b.HasKey("LogDbId");
b.HasIndex("KeyNum");
b.HasIndex("MachineID");
b.ToTable("LogMachine");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b =>
{
b.Property<int>("MatId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<decimal>("HMm")
.HasColumnType("decimal(65,30)");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("MatCode")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("MatDesc")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("WMm")
.HasColumnType("decimal(65,30)");
b.HasKey("MatId");
b.ToTable("MaterialsList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
{
b.Property<int>("MovID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtRec")
.HasColumnType("datetime(6)");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("QtyRec")
.HasColumnType("int");
b.Property<int>("RawItemId")
.HasColumnType("int");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("MovID");
b.HasIndex("RawItemId");
b.ToTable("MovMag");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ProjModel", b =>
{
b.Property<int>("ProjDbId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("BTLFileName")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("DtCreated")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtLastAction")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtSchedule")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtStartProd")
.HasColumnType("datetime(6)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsArchived")
.HasColumnType("tinyint(1)");
b.Property<int>("KeyNum")
.HasColumnType("int");
b.Property<string>("ListName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Machine")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MachineID")
.HasColumnType("int");
b.Property<int>("PType")
.HasColumnType("int");
b.Property<double>("ProcTimeEst")
.HasColumnType("double");
b.Property<double>("ProcTimeReal")
.HasColumnType("double");
b.Property<string>("ProjDescription")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("ProjExtDbId")
.HasColumnType("int");
b.Property<int>("ProjExtId")
.HasColumnType("int");
b.HasKey("ProjDbId");
b.HasIndex("IsActive");
b.HasIndex("IsArchived");
b.HasIndex("KeyNum");
b.HasIndex("MachineID");
b.HasIndex("ProjExtDbId");
b.ToTable("ProjList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
{
b.Property<int>("RawItemId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<decimal>("HMm")
.HasColumnType("decimal(65,30)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsRemn")
.HasColumnType("tinyint(1)");
b.Property<decimal>("LMm")
.HasColumnType("decimal(65,30)");
b.Property<string>("Location")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("MatId")
.HasColumnType("int");
b.Property<string>("Note")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("QtyAvail")
.HasColumnType("int");
b.Property<decimal>("WMm")
.HasColumnType("decimal(65,30)");
b.HasKey("RawItemId");
b.HasIndex("MatId");
b.ToTable("RawItemList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
{
b.Property<int>("RequestId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtRequest")
.HasColumnType("datetime(6)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<int>("ProjDbId")
.HasColumnType("int");
b.Property<int>("ReqState")
.HasColumnType("int");
b.HasKey("RequestId");
b.ToTable("RequestPlan");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
{
b.Property<int>("ResourceId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Qty")
.HasColumnType("int");
b.Property<int>("RawItemId")
.HasColumnType("int");
b.Property<int>("RequestId")
.HasColumnType("int");
b.HasKey("ResourceId");
b.HasIndex("RawItemId");
b.HasIndex("RequestId");
b.ToTable("ResourceList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MovMagModel", b =>
{
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
.WithMany()
.HasForeignKey("RawItemId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("ItemNav");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RawItemModel", b =>
{
b.HasOne("MagMan.Data.Tenant.DbModels.MaterialModel", "MaterialNav")
.WithMany("RawItemList")
.HasForeignKey("MatId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("MaterialNav");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.ResourceModel", b =>
{
b.HasOne("MagMan.Data.Tenant.DbModels.RawItemModel", "ItemNav")
.WithMany()
.HasForeignKey("RawItemId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("MagMan.Data.Tenant.DbModels.RequestPlanModel", "RequestNav")
.WithMany("ResourcesList")
.HasForeignKey("RequestId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("ItemNav");
b.Navigation("RequestNav");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b =>
{
b.Navigation("RawItemList");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.RequestPlanModel", b =>
{
b.Navigation("ResourcesList");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,52 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MagMan.Data.Tenant.Migrations
{
public partial class AddLogMachine : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "LogMachine",
columns: table => new
{
DbId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
KeyNum = table.Column<int>(type: "int", nullable: false),
MachineID = table.Column<int>(type: "int", nullable: false),
ProjDbId = table.Column<int>(type: "int", nullable: false),
DtEvent = table.Column<DateTime>(type: "datetime(6)", nullable: false),
EvType = table.Column<int>(type: "int", nullable: false),
VarAddress = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
VarValue = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_LogMachine", x => x.DbId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_LogMachine_KeyNum",
table: "LogMachine",
column: "KeyNum");
migrationBuilder.CreateIndex(
name: "IX_LogMachine_MachineID",
table: "LogMachine",
column: "MachineID");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LogMachine");
}
}
}
@@ -70,6 +70,49 @@ namespace MagMan.Data.Tenant.Migrations
b.ToTable("Config");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.LogMachineModel", b =>
{
b.Property<int>("LogDbId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("DbId");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)")
.HasColumnName("DtEvent");
b.Property<int>("EvType")
.HasColumnType("int")
.HasColumnName("EvType");
b.Property<int>("KeyNum")
.HasColumnType("int");
b.Property<int>("MachineID")
.HasColumnType("int");
b.Property<int>("ProjDbId")
.HasColumnType("int");
b.Property<string>("VarAddress")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("VarAddress");
b.Property<string>("VarValue")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("VarValue");
b.HasKey("LogDbId");
b.HasIndex("KeyNum");
b.HasIndex("MachineID");
b.ToTable("LogMachine");
});
modelBuilder.Entity("MagMan.Data.Tenant.DbModels.MaterialModel", b =>
{
b.Property<int>("MatId")
+126 -1
View File
@@ -17,6 +17,7 @@ using System.Runtime;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static MagMan.Core.Enums;
namespace MagMan.Data.Tenant.Services
{
@@ -242,7 +243,7 @@ namespace MagMan.Data.Tenant.Services
public RawItemModel ItemFromDto(ItemDTO origItem, bool isActive, int nKey)
{
RawItemModel answ = ItemFromDto(origItem, isActive);
if(string.IsNullOrEmpty(answ.Note))
if (string.IsNullOrEmpty(answ.Note))
{
string cString = ConnString(nKey);
var matRec = dbController.MaterialGetFilt(cString, origItem.MatCloudId, false).FirstOrDefault();
@@ -253,6 +254,7 @@ namespace MagMan.Data.Tenant.Services
}
return answ;
}
/// <summary>
/// Converte il DTO in ItemModel
/// </summary>
@@ -494,6 +496,106 @@ namespace MagMan.Data.Tenant.Services
return fatto;
}
/// <summary>
/// Converte il DTO in ItemModel
/// </summary>
/// <param name="origItem">DTO di partenza</param>
/// <returns></returns>
public LogMachineModel LogMacFromDto(LogMachineDTO origItem)
{
LogMachineModel answ = new LogMachineModel()
{
ProjDbId = origItem.ProjCloudId,
DtEvent = origItem.DtEvent,
EvType = origItem.EvType,
MachineID = origItem.MachineCloudId,
KeyNum = origItem.KeyNum,
VarAddress = origItem.VarAddress,
VarValue = origItem.VarValue
};
return answ;
}
/// <summary>
/// Lista Projects gestiti a magazzino
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="machineId">idMacchina di cui si vuole log</param>
/// <param name="numRec">num rec max da recuperare</param>
/// <returns></returns>
public async Task<List<LogMachineModel>> LogMacGetLast(int nKey, int machineId, int numRec)
{
string source = "DB";
string cString = ConnString(nKey);
List<LogMachineModel>? dbResult = new List<LogMachineModel>();
DateTime adesso = DateTime.Now;
try
{
// cache al minuto...
string currKey = $"{Const.rKeyConfig}:{nKey}:LogMacLast:{machineId}:{adesso:yyMMdd}::{adesso:HHmm}:{numRec}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<LogMachineModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<LogMachineModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.LogMacGetLast(cString, machineId, numRec);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, FastCache);
}
if (dbResult == null)
{
dbResult = new List<LogMachineModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"LogMacGetLast | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Error during LogMacGetLast:{Environment.NewLine}{exc}");
}
return dbResult;
}
/// <summary>
/// Aggiunge/Modifica un record Resource
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="recList">Elenco record da aggiungere/aggiornare</param>
/// <returns></returns>
public async Task<int> LogMacUpdate(int nKey, List<LogMachineModel> recList)
{
int newId = 0;
string cString = ConnString(nKey);
try
{
newId = dbController.LogMacUpdate(cString, recList);
if (newId > 0)
{
await FlushRedisCache();
}
}
catch (Exception exc)
{
Log.Error($"Error during LogMacUpdate:{Environment.NewLine}{exc}");
}
return newId;
}
/// <summary>
/// Elimina Materiale da magazzino + refresh cache
/// </summary>
@@ -1148,6 +1250,29 @@ namespace MagMan.Data.Tenant.Services
return prjCloudId;
}
/// <summary>
/// Recupera ultimo record attivo ReqPlan x tipo richiesto
/// </summary>
/// <param name="nKey">Key di riferimento</param>
/// <param name="ProjCloudId">ID del progetto da cercare</param>
/// <param name="ResState">Stato richiesta da cercare</param>
/// <returns>Record cercato o default se non trovato</returns>
public RequestPlanModel ReqPlanGetLast(int nKey, int ProjCloudId, ProjResState ResState)
{
RequestPlanModel lastRec = new RequestPlanModel();
string cString = ConnString(nKey);
try
{
// cerco record (se fosse con valori "ini" p non trovata
lastRec = dbController.ReqPlanGetLast(cString, ProjCloudId, ResState);
}
catch (Exception exc)
{
Log.Error($"Error during ReqPlanGetLast:{Environment.NewLine}{exc}");
}
return lastRec;
}
/// <summary>
/// Aggiunge/Modifica un record ReqPlan
/// </summary>
@@ -1,26 +1,71 @@
@page
@model ForgotPasswordModel
@{
ViewData["Title"] = "Forgot your password?";
ViewData["Title"] = "Password dimenticata?";
}
<h1>@ViewData["Title"]</h1>
<h2>Enter your email.</h2>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<button type="submit" class="w-100 btn btn-lg btn-primary">Reset Password</button>
</form>
</div>
<div class="d-flex justify-content-center">
<h1>@ViewData["Title"]</h1>
</div>
<div style="
display: flex;
justify-content: center;
">
<div class="row p-3 w-100" style="border-radius: 2rem; min-height:500px; height: auto; box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;">
<div class="col py-3 d-flex justify-content-center align-content-center flex-wrap">
<div>
<div class="d-flex justify-content-center fw-bold fs-2">
EgtBeam&Wall
</div>
<div class="d-flex justify-content-center mb-4">
Powered by
</div>
<div class="d-flex justify-content-center">
<img src="~/images/LogoEgw.png" style="height: 10rem; width: 10rem;" />
</div>
<div class="d-flex justify-content-center fw-bold fs-3">
EgalWare
</div>
</div>
</div>
<div class="col" style="border-radius: 2rem; background-color: #f3f3f8; box-shadow: rgba(62, 39, 35, 0.2) 0px 8px 24px;">
<div class="cardRightHeader"></div>
<div class="row">
<div class="py-3 px-5 d-flex justify-content-center align-content-center2 flex-wrap">
<form method="post" class="w-100">
<h2>Inserisci email.</h2>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating mb-2">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="mb-4">
<button type="submit" class="w-100 btn btn-lg btn-dark">Reset Password</button>
</div>
<div>
<p>
<a id="already-register" asp-page="./Login" class="text-decoration-none text-dark">Hai già un profilo? <b>Clicca qui</b></a>
</p>
<p>
<a asp-page="./Register" class="text-decoration-none text-dark">Registra <b>nuovo utente</b></a>
</p>
<p>
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation" class="text-decoration-none text-dark"><b>Reinvia email</b> di conferma</a>
</p>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@section Scripts {
<partial name="_ValidationScriptsPartial" />
}
@@ -2,83 +2,75 @@
@model LoginModel
@{
ViewData["Title"] = "Log in";
ViewData["Title"] = "MagMan";
}
<div class="row shadow">
<h1>@ViewData["Title"]</h1>
<div class="offset-3 col-md-6">
<section>
<form id="account" method="post">
<h2>Use a local account to log in.</h2>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
<div class="d-flex justify-content-center">
<h1>@ViewData["Title"]</h1>
</div>
<div style="display: flex; justify-content: center;">
<div class="row p-3 w-100" style="border-radius: 2rem; min-height:500px; height: auto; box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;">
<div class="col py-3 d-flex justify-content-center align-content-center flex-wrap">
<div>
<div class="d-flex justify-content-center fw-bold fs-2">
EgtBeam&Wall
</div>
<div class="form-floating">
<input asp-for="Input.Password" class="form-control" autocomplete="current-password" aria-required="true" />
<label asp-for="Input.Password" class="form-label"></label>
<span asp-validation-for="Input.Password" class="text-danger"></span>
<div class="d-flex justify-content-center mb-4">
Powered by
</div>
<div>
<div class="checkbox">
<label asp-for="Input.RememberMe" class="form-label">
<input class="form-check-input" asp-for="Input.RememberMe" />
@Html.DisplayNameFor(m => m.Input.RememberMe)
</label>
</div>
<div class="d-flex justify-content-center">
<img src="~/images/LogoEgw.png" style="height: 10rem; width: 10rem;" />
</div>
<div>
<button id="login-submit" type="submit" class="w-100 btn btn-lg btn-primary">Log in</button>
<div class="d-flex justify-content-center fw-bold fs-3">
EgalWare
</div>
<hr />
<div>
<p>
<a id="forgot-password" asp-page="./ForgotPassword">Forgot your password?</a>
</p>
<p>
<a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl">Register as a new user</a>
</p>
<p>
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation">Resend email confirmation</a>
</p>
</div>
</form>
</section>
</div>
@* <div class="col-md-6 col-md-offset-2">
<section>
<h3>Use another service to log in.</h3>
<hr />
@{
if ((Model.ExternalLogins?.Count ?? 0) == 0)
{
<div>
<p>
There are no external authentication services configured. See this <a href="https://go.microsoft.com/fwlink/?LinkID=532715">article
about setting up this ASP.NET application to support logging in via external services</a>.
</p>
</div>
}
else
{
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
</div>
</div>
<div class="col" style="border-radius: 2rem; background-color: #f3f3f8;box-shadow: rgba(41, 128, 185, 0.2) 0px 8px 24px;">
<div class="cardRightHeader"></div>
<div class="row">
<div class="py-3 px-5 d-flex justify-content-center align-content-center flex-wrap">
<form id="account" method="post" class="w-100">
<h2 class="text-dark">Login Utente</h2>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating mb-1">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-floating mb-1">
<input asp-for="Input.Password" class="form-control" autocomplete="current-password" aria-required="true" />
<label asp-for="Input.Password" class="form-label"></label>
<span asp-validation-for="Input.Password" class="text-danger"></span>
</div>
<div>
<div class="checkbox text-dark text-start">
<label asp-for="Input.RememberMe" class="form-label">
<input class="form-check-input" asp-for="Input.RememberMe" />
@Html.DisplayNameFor(m => m.Input.RememberMe)
</label>
</div>
</div>
<div class="mb-4">
<button id="login-submit" type="submit" class="w-100 btn btn-lg btn-dark">Log in</button>
</div>
<div>
<p>
@foreach (var provider in Model.ExternalLogins!)
{
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
}
<a id="forgot-password" asp-page="./ForgotPassword" class="text-decoration-none text-dark">Password <b>dimenticata</b>?</a>
</p>
<p>
<a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl" class="text-decoration-none text-dark">Registra <b>nuovo utente</b></a>
</p>
<p>
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation" class="text-decoration-none text-dark"><b>Reinvia email</b> di conferma</a>
</p>
</div>
</form>
}
}
</section>
</div> *@
</div>
</div>
</div>
</div>
</div>
@section Scripts {
@@ -160,7 +160,7 @@ namespace MagMan.UI.Areas.Identity.Pages.Account
/// intended to be used directly from your code. This API may change or be removed in
/// future releases.
/// </summary>
[Display(Name = "Remember me?")]
[Display(Name = "Ricordami")]
public bool RememberMe { get; set; }
#endregion Public Properties
@@ -8,7 +8,7 @@
<h3>@ViewData["Title"]</h3>
<partial name="_StatusMessage" for="StatusMessage" />
<div class="row">
<div class="col-md-6">
<div class="col-12">
<form id="change-password-form" method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating">
@@ -8,7 +8,7 @@
<h3>@ViewData["Title"]</h3>
<partial name="_StatusMessage" for="StatusMessage" />
<div class="row">
<div class="col-md-6">
<div class="col-12">
<form id="email-form" method="post">
<div asp-validation-summary="All" class="text-danger"></div>
@if (Model.IsEmailConfirmed)
@@ -8,7 +8,7 @@
<h3>@ViewData["Title"]</h3>
<partial name="_StatusMessage" for="StatusMessage" />
<div class="row">
<div class="col-md-6">
<div class="col-12">
<form id="profile-form" method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating">
@@ -20,7 +20,7 @@
<label asp-for="Input.PhoneNumber" class="form-label"></label>
<span asp-validation-for="Input.PhoneNumber" class="text-danger"></span>
</div>
<button id="update-profile-button" type="submit" class="w-100 btn btn-lg btn-primary">Save</button>
<button id="update-profile-button" type="submit" class="w-100 btn btn-lg btn-primary">Salva</button>
</form>
</div>
</div>
@@ -8,16 +8,17 @@
<h3>@ViewData["Title"]</h3>
<div class="row">
<div class="col-md-6">
<div class="col-12">
<p>Your account contains personal data that you have given us. This page allows you to download or delete that data.</p>
<p>
<form id="download-data" asp-page="DownloadPersonalData" method="post">
<button class="btn btn-primary w-100" type="submit">Download</button>
</form>
<hr />
<p class="mt-5">
<strong>Deleting this data will permanently remove your account, and this cannot be recovered.</strong>
</p>
<form id="download-data" asp-page="DownloadPersonalData" method="post">
<button class="btn btn-primary" type="submit">Download</button>
</form>
<p>
<a id="delete" asp-page="DeletePersonalData" class="btn btn-danger">Delete</a>
<a id="delete" asp-page="DeletePersonalData" class="btn btn-danger w-100">Delete</a>
</p>
</div>
</div>
@@ -12,7 +12,7 @@
account so you can log in without an external login.
</p>
<div class="row">
<div class="col-md-6">
<div class="col-12">
<form id="set-password-form" method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating">
@@ -1,5 +1,5 @@
@{
if (ViewData.TryGetValue("ParentLayout", out var parentLayout) && parentLayout != null)
if (ViewData.TryGetValue("ParentLayout", out var parentLayout) && parentLayout != null)
{
Layout = parentLayout.ToString();
}
@@ -9,21 +9,41 @@
}
}
<h1>Manage your account</h1>
<div>
<h2>Change your account settings</h2>
<hr />
<div class="row">
<div class="col-md-3">
<partial name="_ManageNav" />
<div class="d-flex justify-content-center">
<h1>Gestione account</h1>
<h5></h5>
</div>
<div style="display: flex; justify-content: center;" class="w-100">
<div class="row p-3 w-100" style="border-radius: 2rem; min-height:500px; height: auto; box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;">
<div class="col-4 py-3 d-flex justify-content-center align-content-center flex-wrap">
<div>
<div class="d-flex justify-content-center fw-bold fs-2">
EgtBeam&Wall
</div>
<partial name="_ManageNav" />
<hr />
<div class="d-flex justify-content-center mb-4">
Powered by
</div>
<div class="d-flex justify-content-center">
<img src="~/images/LogoEgw.png" style="height: 10rem; width: 10rem;" />
</div>
<div class="d-flex justify-content-center fw-bold fs-3">
EgalWare
</div>
</div>
</div>
<div class="col-md-9">
@RenderBody()
<div class="col-8" style="border-radius: 2rem; background-color: #f3f3f8;box-shadow: rgba(41, 128, 185, 0.2) 0px 8px 24px;">
<div class="cardRightHeader"></div>
<div class="row">
<div class="py-3 px-5 w-100">
@RenderBody()
</div>
</div>
</div>
</div>
</div>
@section Scripts {
@RenderSection("Scripts", required: false)
}
}
@@ -10,6 +10,6 @@
{
<li id="external-logins" class="nav-item"><a id="external-login" class="nav-link @ManageNavPages.ExternalLoginsNavClass(ViewContext)" asp-page="./ExternalLogins">External logins</a></li>
}
<li class="nav-item"><a class="nav-link @ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)" id="two-factor" asp-page="./TwoFactorAuthentication">Two-factor authentication</a></li>
@* <li class="nav-item"><a class="nav-link @ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)" id="two-factor" asp-page="./TwoFactorAuthentication">Two-factor authentication</a></li> *@
<li class="nav-item"><a class="nav-link @ManageNavPages.PersonalDataNavClass(ViewContext)" id="personal-data" asp-page="./PersonalData">Personal data</a></li>
</ul>
@@ -1,67 +1,74 @@
@page
@model RegisterModel
@{
ViewData["Title"] = "Register";
ViewData["Title"] = "Registrazione";
}
<div class="d-flex justify-content-center">
<h1>@ViewData["Title"]</h1>
</div>
<div class="row">
<div class="col-md-4">
<form id="registerForm" asp-route-returnUrl="@Model.ReturnUrl" method="post">
<h2>Create a new account.</h2>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
<div style="display: flex; justify-content: center;">
<div class="row p-3 w-100" style="border-radius: 2rem; height: auto; min-height:500px;box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;">
<div class="col py-3 d-flex justify-content-center align-content-center flex-wrap">
<div>
<div class="d-flex justify-content-center fw-bold fs-2">
EgtBeam&Wall
</div>
<div class="d-flex justify-content-center mb-4">
Powered by
</div>
<div class="d-flex justify-content-center">
<img src="~/images/LogoEgw.png" style="height: 10rem; width: 10rem;" />
</div>
<div class="d-flex justify-content-center fw-bold fs-3">
EgalWare
</div>
</div>
<div class="form-floating">
<input asp-for="Input.Password" class="form-control" autocomplete="new-password" aria-required="true" />
<label asp-for="Input.Password"></label>
<span asp-validation-for="Input.Password" class="text-danger"></span>
</div>
<div class="form-floating">
<input asp-for="Input.ConfirmPassword" class="form-control" autocomplete="new-password" aria-required="true" />
<label asp-for="Input.ConfirmPassword"></label>
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
</div>
<button id="registerSubmit" type="submit" class="w-100 btn btn-lg btn-primary">Register</button>
</form>
</div>
<div class="col-md-6 col-md-offset-2">
<section>
<h3>Use another service to register.</h3>
<hr />
@{
if ((Model.ExternalLogins?.Count ?? 0) == 0)
{
<div>
<p>
There are no external authentication services configured. See this <a href="https://go.microsoft.com/fwlink/?LinkID=532715">article
about setting up this ASP.NET application to support logging in via external services</a>.
</p>
</div>
}
else
{
<form id="external-account" asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
</div>
<div class="col" style="border-radius: 2rem; background-color: #f3f3f8; box-shadow: rgba(62, 39, 35, 0.2) 0px 8px 24px;">
<div class="cardRightHeader"></div>
<div class="row">
<div class="py-3 px-5 d-flex justify-content-center align-content-center flex-wrap">
<form id="+Form" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="w-100">
<h2 class="text-dark">Nuovo Account</h2>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating mb-1">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-floating mb-1">
<input asp-for="Input.Password" class="form-control" autocomplete="new-password" aria-required="true" />
<label asp-for="Input.Password"></label>
<span asp-validation-for="Input.Password" class="text-danger"></span>
</div>
<div class="form-floating mb-1">
<input asp-for="Input.ConfirmPassword" class="form-control" autocomplete="new-password" aria-required="true" />
<label asp-for="Input.ConfirmPassword"></label>
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
</div>
<button id="registerSubmit" type="submit" class="w-100 btn btn-lg btn-dark mb-3">Registra</button>
<div>
<p>
@foreach (var provider in Model.ExternalLogins!)
{
<button type="submit" class="btn btn-primary" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
}
<a id="already-register" asp-page="./Login" class="text-decoration-none text-dark">Hai già un profilo? <b>Clicca qui</b></a>
</p>
<p>
<a id="forgot-password" asp-page="./ForgotPassword" class="text-decoration-none text-dark">Password <b>dimenticata</b>?</a>
</p>
<p>
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation" class="text-decoration-none text-dark"><b>Reinvia email</b> di conferma</a>
</p>
</div>
</form>
}
}
</section>
</div>
</div>
</div>
</div>
</div>
</div>
@section Scripts {
<partial name="_ValidationScriptsPartial" />
}
@@ -1,26 +1,72 @@
@page
@model ResendEmailConfirmationModel
@{
ViewData["Title"] = "Resend email confirmation";
ViewData["Title"] = "Reinvio email di conferma";
}
<h1>@ViewData["Title"]</h1>
<h2>Enter your email.</h2>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-floating">
<input asp-for="Input.Email" class="form-control" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<button type="submit" class="w-100 btn btn-lg btn-primary">Resend</button>
</form>
</div>
<div class="d-flex justify-content-center">
<h1>@ViewData["Title"]</h1>
</div>
<div style="
display: flex;
justify-content: center;
">
<div class="row p-3 w-100" style="border-radius: 2rem; height: auto; min-height:500px;box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;">
<div class="col py-3 d-flex justify-content-center align-content-center flex-wrap">
<div>
<div class="d-flex justify-content-center fw-bold fs-2">
EgtBeam&Wall
</div>
<div class="d-flex justify-content-center mb-4">
Powered by
</div>
<div class="d-flex justify-content-center">
<img src="~/images/LogoEgw.png" style="height: 10rem; width: 10rem;" />
</div>
<div class="d-flex justify-content-center fw-bold fs-3">
EgalWare
</div>
</div>
</div>
<div class="col" style="border-radius: 2rem; background-color: #f3f3f8; box-shadow: rgba(62, 39, 35, 0.2) 0px 8px 24px;">
<div class="cardRightHeader"></div>
<div class="row">
<div class="py-3 px-5 d-flex justify-content-center align-content-center flex-wrap">
<form method="post" class="w-100">
<h2 class="text-dark">Inserisci l'email</h2>
<hr />
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-floating">
<input asp-for="Input.Email" class="form-control" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="mb-4">
<button type="submit" class="w-100 btn btn-lg btn-dark">Reinvia</button>
</div>
<div>
<p>
<a id="already-register" asp-page="./Login" class="text-decoration-none text-dark">Hai già un profilo? <b>Clicca qui</b></a>
</p>
<p>
<a asp-page="./Register" class="text-decoration-none text-dark">Registra <b>nuovo utente</b></a>
</p>
<p>
<a id="forgot-password" asp-page="./ForgotPassword" class="text-decoration-none text-dark">Password <b>dimenticata</b>?</a>
</p>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@section Scripts {
<partial name="_ValidationScriptsPartial" />
}
+8 -1
View File
@@ -8,7 +8,14 @@
<label class="small">Valore Originale</label>
</div>
<div class="form-floating">
<input type="text" class="form-control" @bind="@CurrRecord.ValueAlias">
<select class="form-select" @bind="@CurrRecord.ValueAlias">
@foreach (var option in ListAliasTarget)
{
<option value="@option">
@option
</option>
}
</select>
<label class="small">Valore Alias</label>
</div>
<div class="form-floating">
+20
View File
@@ -63,6 +63,26 @@ namespace MagMan.UI.Components
}
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
private List<string> ListAliasTarget { get; set; } = new List<string>();
private List<Core.DTO.MaterialDTO> AllMaterials { get; set; } = new List<Core.DTO.MaterialDTO>();
protected async Task ReloadData()
{
// rileggo TUTTI i materiali
AllMaterials = await TService.MaterialDtoGetAll(KeyNum, false);
// proietto elenco alias ammissibili
ListAliasTarget = AllMaterials
.GroupBy(x => x.MatCode)
.Select(grp=> grp.First())
.OrderBy(x => x.MatCode)
.Select(x => x.MatCode)
.ToList();
}
#endregion Protected Methods
}
}
+2 -1
View File
@@ -109,12 +109,13 @@ namespace MagMan.UI.Components
if (selItem != null)
{
MaterialId = selItem.MatCloudId;
E_MaterialSel.InvokeAsync(TService.MaterialFromDto(selItem));
}
else
{
MaterialId = 0;
E_MaterialSel.InvokeAsync(null);
}
E_MaterialSel.InvokeAsync(TService.MaterialFromDto(selItem));
}
protected async Task ForceReload(bool force)
+4 -4
View File
@@ -55,7 +55,7 @@
return model.Password == "f@mmiEntrare!";
}
}
protected bool DbLogOk { get; set; } = false;
protected bool DbCustOk { get; set; } = false;
protected bool DbAllOk { get; set; } = false;
protected bool DbIdentity { get; set; } = false;
protected bool processRunning { get; set; } = false;
@@ -88,10 +88,10 @@
protected async Task ReloadData()
{
var resultIden = await Health.Checks.DbIdentity(MagMan.Data.Admin.DbConfig.DATABASE_NAME);
var resultLog = await Health.Checks.DbPlantTable(MagMan.Data.Tenant.DbConfig.DATABASE_NAME);
var resultCustCnt = await Health.Checks.CustomersCount();
DbIdentity = (resultIden.Status == HealthStatus.Healthy);
DbLogOk = (resultLog.Status == HealthStatus.Healthy);
DbAllOk = (DbLogOk && DbIdentity);
DbCustOk = (resultCustCnt.Status == HealthStatus.Healthy);
DbAllOk = (DbCustOk && DbIdentity);
}
}
+1 -1
View File
@@ -52,7 +52,7 @@ namespace MagMan.UI.Controllers
[HttpGet]
public async Task<List<AliasModel>> Get()
{
// se non ho chaive --> vuoto!
// se non ho chiave --> vuoto!
List<AliasModel> ListRecords = new List<AliasModel>();
await Task.Delay(100);
return ListRecords;
+1 -1
View File
@@ -37,7 +37,7 @@ namespace MagMan.UI.Controllers
[HttpGet]
public async Task<List<AuthKeyModel>> Get()
{
// se non ho chaive --> vuoto!
// se non ho chiave --> vuoto!
List<AuthKeyModel> ListRecords = new List<AuthKeyModel>();
await Task.Delay(100);
return ListRecords;
@@ -0,0 +1,138 @@
using MagMan.Core.DTO;
using MagMan.Core;
using MagMan.Data.Admin.DbModels;
using MagMan.Data.Admin.Services;
using MagMan.Data.Tenant.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NLog;
using MagMan.Data.Tenant.DbModels;
namespace MagMan.UI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class LogMachineController : ControllerBase
{
#region Public Constructors
public LogMachineController(MTAdminService MTDataService, TenantService TDataService)
{
MTAdmService = MTDataService;
TService = TDataService;
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
JSSettings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
Log.Info("Avviata classe LogMachineController");
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Controllo status Alive
/// GET: api/LogMachine/alive
/// </summary>
/// <returns></returns>
[HttpGet("alive")]
public string alive()
{
return $"OK";
}
// GET api/LogMachine
[HttpGet]
public async Task<List<LogMachineModel>> Get()
{
// se non ho chiave --> vuoto!
List<LogMachineModel> ListRecords = new List<LogMachineModel>();
await Task.Delay(100);
return ListRecords;
}
/// <summary>
/// Elenco ultimi valori LogMachineModel dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <param name="KeyNum">Chiave associata ai progetti</param>
/// <param name="machineId">idMacchina di cui si vuole log</param>
/// <param name="numRec">num rec max da recuperare</param>
/// <returns></returns>
// GET api/LogMachine/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("{id}")]
public async Task<List<LogMachineModel>> Get(string id, int KeyNum, int machineId, int numRec)
{
List<LogMachineModel> ListRecords = new List<LogMachineModel>();
if (!string.IsNullOrEmpty(id))
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
var rawList = await TService.LogMacGetLast(nKey, machineId,numRec);
if(rawList!=null)
{
ListRecords.AddRange(rawList);
}
}
return ListRecords;
}
/// <summary>
/// Processa una chiamata POST per l'invio di un oggetto di upsert progetto
/// PUT: api/Inventory/upsert/00000000-0000-0000-0000-000000000000
/// </summary>
/// <param name="id">token comunicazione</param>
/// <returns>ID del progetto creato da usare come CloudId</returns>
[HttpPost("upsert/{id}")]
public async Task<int> upsert(string id, [FromBody] RestPayload.LogData rawData)
{
int answ = 0;
// verifico ci sia valore
if (!string.IsNullOrEmpty(id) && rawData != null && rawData.LogList != null)
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
if (nKey > 0)
{
// converto elenco da Dto --> DB
var listRec = rawData.LogList.Select(x=> TService.LogMacFromDto(x)).ToList();
try
{
// upsert!
answ = await TService.LogMacUpdate(nKey, listRec);
}
catch (Exception exc)
{
Log.Error($"LogMachineController.upsert | Errore in fase salvataggio di {rawData.LogList.Count} LogMacDTO{Environment.NewLine}{exc}");
}
// resetto cache redis
await MTAdmService.FlushRedisCache();
}
}
return answ;
}
#endregion Public Methods
#region Private Fields
private static JsonSerializerSettings? JSSettings;
/// <summary>
/// Classe per logging
/// </summary>
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Properties
private MTAdminService MTAdmService { get; set; } = null!;
private TenantService TService { get; set; } = null!;
#endregion Private Properties
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ namespace MagMan.UI.Controllers
[HttpGet]
public async Task<List<MachineModel>> Get()
{
// se non ho chaive --> vuoto!
// se non ho chiave --> vuoto!
List<MachineModel> ListRecords = new List<MachineModel>();
await Task.Delay(100);
return ListRecords;
+1 -1
View File
@@ -51,7 +51,7 @@ namespace MagMan.UI.Controllers
[HttpGet]
public async Task<List<MaterialDTO>> Get()
{
// se non ho chaive --> vuoto!
// se non ho chiave --> vuoto!
List<MaterialDTO> ListRecords = new List<MaterialDTO>();
await Task.Delay(100);
return ListRecords;
+5 -6
View File
@@ -38,21 +38,20 @@ namespace MagMan.UI.Controllers
/// <summary>
/// Controllo status Alive
/// GET: api/Machines/alive
/// GET: api/Projects/alive
/// </summary>
/// <returns></returns>
[HttpGet("alive")]
public string alive()
{
//Log.Debug("Chiamata alive");
return $"OK";
}
// GET api/Machines/5
// GET api/Projects/5
[HttpGet]
public async Task<List<MachineModel>> Get()
{
// se non ho chaive --> vuoto!
// se non ho chiave --> vuoto!
List<MachineModel> ListRecords = new List<MachineModel>();
await Task.Delay(100);
return ListRecords;
@@ -64,7 +63,7 @@ namespace MagMan.UI.Controllers
/// <param name="id">Rest Token cliente</param>
/// <param name="KeyNum">Chiave associata ai progetti</param>
/// <returns></returns>
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
// GET api/Projects/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("{id}")]
public async Task<List<ProjectDTO>> Get(string id, int KeyNum)
{
@@ -86,7 +85,7 @@ namespace MagMan.UI.Controllers
/// <param name="KeyNum">Chiave associata ai progetti</param>
/// <param name="ProjCloudId">Key del proj</param>
/// <returns></returns>
// GET api/Machines/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
// GET api/Projects/2cba60c7-7be4-40b1-aa0d-52e7c71fc1a7
[HttpGet("single/{id}")]
public async Task<ProjectDTO> GetSingle(string id, int ProjCloudId)
{
+158 -10
View File
@@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NLog;
using System.Linq;
namespace MagMan.UI.Controllers
{
@@ -16,13 +17,8 @@ namespace MagMan.UI.Controllers
[ApiController]
public class ResourcesController : ControllerBase
{
/// <summary>
/// Classe per logging
/// </summary>
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private MTAdminService MTAdmService { get; set; } = null!;
private static JsonSerializerSettings? JSSettings;
private TenantService TService { get; set; } = null!;
#region Public Constructors
public ResourcesController(MTAdminService MTDataService, TenantService TDataService)
{
MTAdmService = MTDataService;
@@ -35,6 +31,10 @@ namespace MagMan.UI.Controllers
Log.Info("Avviata classe ResourcesController");
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Controllo status Alive
/// GET: api/Resources/alive
@@ -47,18 +47,106 @@ namespace MagMan.UI.Controllers
return $"OK";
}
/// <summary>
/// Processa una chiamata POST per la verifica di un oggetto di TRACKING risorse progetto (RestPayload.Resources)
/// PUT: api/Resources/check/00000000-0000-0000-0000-000000000000
/// </summary>
/// <param name="id">token comunicazione</param>
/// <returns>
/// restituisce diversi valori secondo esito: ND/EQUAL/CHANGED, dove | ND = non definito /
/// non calcolato | EQUAL = il set inviato èidentico all'ultimo registrato (in termini di
/// numero barre impiegate complessivo e per singolo tipo, check da CloudId barre) | CHANGED
/// = il set inviato è differente (per tipo/numero/mix di barre)
/// </returns>
[HttpPost("check/{id}")]
public async Task<string> check(string id, [FromBody] RestPayload.Resources projectData)
{
string answ = "ND";
bool isEqual = false;
// verifico ci sia valore
if (!string.IsNullOrEmpty(id) && projectData != null)
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
if (nKey > 0)
{
// nel projData ho le info x gestire aggiornamento PER INTERO
int ProjCloudId = projectData.ProjCloudId;
// proseguo solo se ho un Id valido
if (ProjCloudId > 0)
{
// inizio dal num risorse DTO... se vuoto è sempre FALSE
int numResDTO = 0;
if (projectData.ResourceList == null || projectData.ResourceList.Count == 0)
{
// confermo che NON corrisponde
isEqual = false;
}
else
{
numResDTO = projectData.ResourceList.Count;
// recupero ultimo set ricevuto...
var lastRecPlan = TService.ReqPlanGetLast(nKey, ProjCloudId, Enums.ProjResState.Estimated);
// se non corrisponde ProjId --> false
if (lastRecPlan == null || lastRecPlan.ProjDbId != ProjCloudId)
{
// confermo che NON corrisponde
isEqual = false;
}
// altrimenti verifico contenuto come barre
else
{
// ora recupero risorse associate alla registrazione ricevuta...
var lastResList = await TService.ResourcesGetByProject(nKey, ProjCloudId, true, false);
// se lista vuota
if (lastResList == null || lastResList.Count == 0)
{
// confermo che NON corrisponde
isEqual = false;
}
else
{
//...o se num tot != numResDto --> false
if (lastResList.Count != numResDTO)
{
// confermo che NON corrisponde
isEqual = false;
}
else
{
// altrimenti check CloudId barre + quantità x equality...
// inizio convertendo
List<ResourceModel> listRes = projectData.ResourceList.Select(x => TService.ResourceFromDto(x, lastRecPlan.RequestId)).ToList();
// dato x scontato che ho stesso numero di barre -->
// confronto 1-1 per quantità... genero i 2 set
Dictionary<int, int> list2check = projectData.ResourceList.ToDictionary(x => x.RawItemCloudId, x => x.Qty);
Dictionary<int, int> listSaved = lastResList.ToDictionary(x => x.RawItemId, x => x.Qty);
// comparazione finale!
isEqual = DictComparer(list2check, listSaved);
//isEqual= list2check.Count == listSaved.Count && !list2check.Except(listSaved).Any();
}
}
}
}
}
}
answ = isEqual ? "EQUAL" : "CHANGED";
}
return answ;
}
// GET api/Resources/5
[HttpGet]
public async Task<List<ResourceModel>> Get()
{
// se non ho chaive --> vuoto!
// se non ho chiave --> vuoto!
List<ResourceModel> ListRecords = new List<ResourceModel>();
await Task.Delay(100);
return ListRecords;
}
/// <summary>
/// Elenco Macchine dato RestToken
/// Elenco Macchine dato RestToken
/// </summary>
/// <param name="id">Rest Token cliente</param>
/// <param name="projDbId">ID progetto</param>
@@ -147,5 +235,65 @@ namespace MagMan.UI.Controllers
answ = fatto ? "OK" : "NO";
return answ;
}
#endregion Public Methods
#region Private Fields
private static JsonSerializerSettings? JSSettings;
/// <summary>
/// Classe per logging
/// </summary>
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Properties
private MTAdminService MTAdmService { get; set; } = null!;
private TenantService TService { get; set; } = null!;
#endregion Private Properties
#region Private Methods
/// <summary>
/// Utility method comparatore dizionari
/// </summary>
/// <param name="dict1"></param>
/// <param name="dict2"></param>
/// <returns></returns>
private bool DictComparer(Dictionary<int, int> dict1, Dictionary<int, int> dict2)
{
// Test for equality.
bool isEqual = false;
if (dict1.Count == dict2.Count) // Require isEqual count.
{
isEqual = true;
foreach (var pair in dict1)
{
int value;
if (dict2.TryGetValue(pair.Key, out value))
{
// Require value be isEqual.
if (value != pair.Value)
{
isEqual = false;
break;
}
}
else
{
// Require key be present.
isEqual = false;
break;
}
}
}
return isEqual;
}
#endregion Private Methods
}
}
}
+14 -21
View File
@@ -53,32 +53,25 @@ namespace MagMan.UI.Health
}
}
public static async Task<HealthCheckResult> DbPlantTable(string dbName)
public static async Task<HealthCheckResult> CustomersCount()
{
using (var appDb = new MagManContext())
string description = "Try check CUSTOMERS table";
var healthCheckData = new Dictionary<string, object>();
using (MultiTenantContext localDbCtx = new MultiTenantContext())
{
string description = "Try check Table PlantLog";
var healthCheckData = new Dictionary<string, object>();
#if false
List<PlantDetailModel> recordList = new List<PlantDetailModel>();
try
var dbCount = localDbCtx
.DbSetCustomers
.Count();
if (dbCount > 0)
{
// provo a controllare se ho tab utenti
recordList = await Task.FromResult(appDb.DbSetPlant.ToList()).ConfigureAwait(false);
if (recordList.Count > 0)
{
description = $"Check PlantDetail table, found {recordList.Count} records";
return HealthCheckResult.Healthy(description, healthCheckData);
}
description = $"Check CUSTOMERS table, found {dbCount} records";
healthCheckData.Add("Count", dbCount);
return HealthCheckResult.Healthy(description, healthCheckData);
}
catch (Exception exc)
{
Log.Error(exc, "Errore in esecuzione PlantDetail Table");
}
#endif
return HealthCheckResult.Degraded(description + $" {dbName}", null, healthCheckData);
}
await Task.Delay(1);
return HealthCheckResult.Unhealthy(description + $" NO RECORD found", null, healthCheckData);
}
public static async Task<HealthCheckResult> DbUserRoot(string dbName)
+8 -5
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.0.2404.1208</Version>
<Version>1.0.2404.2711</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
@@ -34,10 +34,11 @@
<PackageReference Include="AspNetCore.HealthChecks.System" Version="6.0.5" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="6.0.5" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.5" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Core" Version="6.0.5" />
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="6.0.5" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2401.2209" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2401.1911" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2402.2411" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.5.2402.2411" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.25" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.25" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.23" />
@@ -46,10 +47,12 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.29" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="6.0.29" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.7" />
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="StackExchange.Redis" Version="2.7.33" />
</ItemGroup>
<ItemGroup>
+9 -6
View File
@@ -48,12 +48,15 @@
</AuthorizeView>
<AuthorizeView Roles="SuperAdmin, Admin, User">
<Authorized>
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Dati Macchine" href="MachineStatus">
<i class="fa-solid fa-screwdriver-wrench fa-2x mb-2" aria-hidden="true"></i>
<h4>Dati Macchine</h4>
</NavLink>
</div>
@if (isDebug)
{
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Dati Macchine" href="MachineStatus">
<i class="fa-solid fa-screwdriver-wrench fa-2x mb-2" aria-hidden="true"></i>
<h4>Dati Macchine</h4>
</NavLink>
</div>
}
<div class="col-6 col-md-4 col-lg-3 mb-3">
<NavLink type="button" class="btn btn-primary bg-gradient text-light p-3 w-100" title="Stato Impianti" href="ProjectsStatus">
<i class="fa-solid fa-chart-gantt fa-2x mb-2" aria-hidden="true"></i>
+12
View File
@@ -5,6 +5,16 @@ namespace MagMan.UI.Pages
{
public partial class Index
{
#region Protected Fields
#if DEBUG
protected bool isDebug = true;
#else
protected bool isDebug = false;
#endif
#endregion Protected Fields
#region Protected Properties
[Inject]
@@ -23,5 +33,7 @@ namespace MagMan.UI.Pages
}
#endregion Protected Methods
}
}
+3 -5
View File
@@ -52,13 +52,11 @@ builder.Services.AddHealthChecks()
.AddMySql(connStringDB, "MySql instance")
.AddAsyncCheck($"DB PING ({dbServerAddr})", () => MagMan.UI.Health.Checks.PingCheck(dbServerAddr))
.AddAsyncCheck($"Redis PING ({redisSrvAddr})", () => MagMan.UI.Health.Checks.PingCheck(redisSrvAddr))
.AddProcessAllocatedMemoryHealthCheck(512, "Max Process memory (<512MB)", failureStatus: HealthStatus.Degraded) // 512 MB max allocated memory
// 512 MB max allocated memory
.AddProcessAllocatedMemoryHealthCheck(512, "Max Process memory (<512MB)", failureStatus: HealthStatus.Degraded)
.AddRedis(builder.Configuration.GetConnectionString("Redis"), "Redis", failureStatus: HealthStatus.Degraded)
.AddAsyncCheck($"MySql Root User", () => MagMan.UI.Health.Checks.DbUserRoot("MySql"))
.AddAsyncCheck($"MySql Identity", () => MagMan.UI.Health.Checks.DbIdentity(MagMan.Data.Admin.DbConfig.DATABASE_NAME))
#if false
.AddAsyncCheck($"MySql PlantLog", () => MagMan.UI.Health.Checks.DbPlantTable(DbConfig.DATABASE_NAME))
#endif
.AddAsyncCheck($"MySql Customers", () => MagMan.UI.Health.Checks.CustomersCount())
;
builder.Services.AddHealthChecksUI(s =>
+8 -43
View File
@@ -28,7 +28,6 @@
</div>
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="SuperAdmin">
<Authorized>
<div class="nav-item px-2">
@@ -38,14 +37,16 @@
</div>
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="SuperAdmin, Admin, User">
<Authorized>
<div class="nav-item px-2">
<NavLink class="nav-link py-0 px-2 mb-0" href="MachineStatus">
<i class="fa-solid fa-screwdriver-wrench pe-2"></i> Dati Macchine
</NavLink>
</div>
@if (isDebug)
{
<div class="nav-item px-2">
<NavLink class="nav-link py-0 px-2 mb-0" href="MachineStatus">
<i class="fa-solid fa-screwdriver-wrench pe-2"></i> Dati Macchine
</NavLink>
</div>
}
<div class="nav-item px-2">
<NavLink class="nav-link py-0 px-2 mb-0" href="ProjectsStatus">
<i class="fa-solid fa-chart-gantt pe-2"></i> Progetti
@@ -81,40 +82,4 @@
</nav>
</div>
@code {
[CascadingParameter]
private Task<AuthenticationState> AuthenticationStateTask { get; set; }
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
protected bool showText { get; set; } = true;
private string userName = "";
protected override async Task OnInitializedAsync()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "Non Autenticato";
}
}
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
protected string hideText
{
get => showText ? "" : "invisible";
}
[Parameter]
public EventCallback<bool> EC_compressUpdated { get; set; }
}
+53
View File
@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
namespace MagMan.UI.Shared
{
public partial class NavMenu
{
[CascadingParameter]
private Task<AuthenticationState> AuthenticationStateTask { get; set; }
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
protected bool showText { get; set; } = true;
private string userName = "";
protected override async Task OnInitializedAsync()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
userName = $"{user.Identity.Name}";
}
else
{
userName = "Non Autenticato";
}
}
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
protected string hideText
{
get => showText ? "" : "invisible";
}
[Parameter]
public EventCallback<bool> EC_compressUpdated { get; set; }
#if DEBUG
protected bool isDebug = true;
#else
protected bool isDebug = false;
#endif
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"OptConf": {
"msRefresh": "4000",
"BaseAddr": "https://magman.ufficio/",
"BaseAppPath": "",
"QrRedirPage": "",
"jumpRedir": "~/../",
"CodModulo": "MagMan"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MagMan - Wood Warehouse Management System</i>
<h4>Versione: 1.0.2404.1208</h4>
<h4>Versione: 1.0.2404.2711</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.0.2404.1208
1.0.2404.2711
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.2404.1208</version>
<version>1.0.2404.2711</version>
<url>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+44 -3
View File
@@ -1,4 +1,5 @@
using EgwProxy.MagMan;
using EgwProxy.DataLayer.Controllers;
using EgwProxy.MagMan;
using EgwProxy.MagMan.DTO;
using System;
using System.Collections.Generic;
@@ -14,7 +15,12 @@ namespace DemoApp
static async Task Main(string[] args)
{
// num chiave
int keyNum = 470;
// id macchina cloud
int machCloudId = 4;
// id progetto cloud
int projCloud = 1;
#if DEBUG
// Indirizzo server (DEBUG)
string servAddr = "localhost:7207";
@@ -104,8 +110,9 @@ namespace DemoApp
Console.WriteLine("Enter to next step");
answ = Console.ReadLine();
// leggo projectList
var projList = commLib.ProjectGet(470);
var projList = commLib.ProjectGet(keyNum);
if (projList != null)
{
foreach (var itemProj in projList)
@@ -188,6 +195,40 @@ namespace DemoApp
alias2send.Add(new AliasDTO() { ValOrig = "Item02", ValAlias = "Gl24h", IsActive = true });
var resAliasSend = commLib.AliasSend(alias2send);
// carico dal DB primi 50 rec e li invio 10 alla volta...
LogMachineController lmc = new LogMachineController();
int num2send = 20;
int batchSize = 10;
int numSent = 0;
var recList = lmc.GetUnsentAsc(num2send);
// ciclo!
while (numSent < num2send)
{
var currList = recList
.Skip(numSent)
.Take(batchSize)
.ToList();
// converto il blocco
var listDto = currList
.Select(x => LogMachineController.ConvToItemDto(x, keyNum, machCloudId, projCloud))
.ToList();
// invio!
var res = commLib.LogMachineSend(listDto);
if (res)
{
// registro dati inviati...
lmc.SetDtSent(currList);
Console.WriteLine($"Inviati {batchSize}rec | {numSent} --> {numSent + batchSize}");
numSent += batchSize;
}
else
{
Console.WriteLine($"Errore in invio logMacchina");
}
}
Console.WriteLine(sep);
Console.WriteLine();
Console.WriteLine("Enter to close");
answ = Console.ReadLine();
}
+4
View File
@@ -88,6 +88,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EgwProxy.DataLayer\EgwProxy.DataLayer.csproj">
<Project>{87935fc9-c1bc-4984-83ca-a9edabbe2228}</Project>
<Name>EgwProxy.DataLayer</Name>
</ProjectReference>
<ProjectReference Include="..\EgwProxy.MagMan\EgwProxy.MagMan.csproj">
<Project>{1696d7a5-765a-4d25-8d29-ca7345023479}</Project>
<Name>EgwProxy.MagMan</Name>