Update metodi x nuget (test letura DB + invio)

This commit is contained in:
Samuele Locatelli
2024-04-27 11:42:12 +02:00
parent df2e281744
commit 5eb34cef4e
19 changed files with 551 additions and 21 deletions
+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,85 @@
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;
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();
}
}
#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
+9 -2
View File
@@ -17,15 +17,22 @@ namespace MagMan.Core.DTO
/// </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; }
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;
public int ProjLocalId { get; set; } = 0;
#endif
/// <summary>
/// Stato da enum
+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
{
+14 -12
View File
@@ -59,21 +59,24 @@ namespace MagMan.UI.Controllers
/// </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 numVal)
public async Task<List<LogMachineModel>> Get(string id, int KeyNum, int machineId, int numRec)
{
List<LogMachineModel> ListRecords = new List<LogMachineModel>();
#if false
if (!string.IsNullOrEmpty(id))
{
// in primis recupero codice chiave da token...
int nKey = await MTAdmService.MainKeyByToken(id);
var rawList = await TService.ProjectGetAll(nKey);
ListRecords = rawList.Select(x => TService.ProjectToDto(x)).ToList();
}
#endif
var rawList = await TService.LogMacGetLast(nKey, machineId,numRec);
if(rawList!=null)
{
ListRecords.AddRange(rawList);
}
}
return ListRecords;
}
@@ -94,20 +97,19 @@ namespace MagMan.UI.Controllers
int nKey = await MTAdmService.MainKeyByToken(id);
if (nKey > 0)
{
#if false
// converto ProjDto --> DB
var currRec = TService.ProjectFromDto(rawData.Project);
// converto elenco da Dto --> DB
var listRec = rawData.LogList.Select(x=> TService.LogMacFromDto(x)).ToList();
try
{
answ = await TService.ProjectUpsert(nKey, currRec);
// upsert!
answ = await TService.LogMacUpdate(nKey, listRec);
}
catch (Exception exc)
{
Log.Error($"ProjectsController.upsert | Errore in fase salvataggio ProjectDTO{Environment.NewLine}{exc}");
Log.Error($"LogMachineController.upsert | Errore in fase salvataggio di {rawData.LogList.Count} LogMacDTO{Environment.NewLine}{exc}");
}
// resetto cache redis
await MTAdmService.FlushRedisCache();
#endif
}
}
return answ;
+1 -1
View File
@@ -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 -1
View File
@@ -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
View File
@@ -1 +1 @@
1.0.2404.2612
1.0.2404.2711
+1 -1
View File
@@ -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>
+42 -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,38 @@ 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 = 50;
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)
{
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>