Merge branch 'release/AddLogMachineSync'
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,7 @@ 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;
|
||||
|
||||
@@ -523,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>
|
||||
|
||||
@@ -24,21 +24,26 @@ namespace MagMan.Data.Tenant.DbModels
|
||||
[Key, Column("DbId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int LogDbId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id macchina (diMagMan)
|
||||
/// </summary>
|
||||
public int MachineID { get; set; } = 0;
|
||||
|
||||
/// <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>
|
||||
/// Progetto di riferimento (CloudId)
|
||||
/// </summary>
|
||||
public int ProjDbId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data Registrazione
|
||||
/// </summary>
|
||||
[Column("DtEvent")]
|
||||
public DateTime DtRif { get; set; } = DateTime.Now;
|
||||
public DateTime DtEvent { get; set; } = DateTime.Now;
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
@@ -107,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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -496,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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace MagMan.UI.Controllers
|
||||
[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;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>1.0.2404.2612</Version>
|
||||
<Version>1.0.2404.2711</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MagMan - Wood Warehouse Management System</i>
|
||||
<h4>Versione: 1.0.2404.2612</h4>
|
||||
<h4>Versione: 1.0.2404.2711</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2404.2612
|
||||
1.0.2404.2711
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2404.2612</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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user