Aggiunto metodo check risorse (da testare)
This commit is contained in:
@@ -65,7 +65,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
ERR_AliasMatEmpty,
|
||||
ERR_CloudAliasNotSent,
|
||||
ERR_ProjIdNotFound,
|
||||
ERR_ProjNotSync
|
||||
ERR_ProjNotSync,
|
||||
RES_CheckChanged,
|
||||
RES_CheckEqual,
|
||||
RES_CheckND
|
||||
}
|
||||
|
||||
#endregion Public Enums
|
||||
@@ -1364,6 +1367,84 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Effettua verifica risorse
|
||||
/// </summary>
|
||||
/// <param name="ProjCloudId">DB Id del progetto x cui si inviano i dati</param>
|
||||
/// <param name="rec2send">Elenco RawPart come dizionario quantità consumate [nId, qty]</param>
|
||||
/// <param name="trackType">tipologia dato inviato</param>
|
||||
/// <param name="sign">segno da applicare alle quantità dsa inviare</param>
|
||||
/// <returns>Restitusice errore comunicazione oppure se le risorse siano uguali o cambiate</returns>
|
||||
private SyncResult ResourceCheckChanged(int ProjCloudId, Dictionary<int, int> rec2send, ProjResState trackType, int sign)
|
||||
{
|
||||
SyncResult answ = SyncResult.ERR_ND;
|
||||
using (RawItemsController dbContr = new RawItemsController())
|
||||
{
|
||||
List<ResourceDTO> list2send = new List<ResourceDTO>();
|
||||
// recupero elenco risorse da lista int delle chiavi...
|
||||
var allResources = dbContr.GetFiltModel(0);
|
||||
// ciclo tra risorse richieste...
|
||||
foreach (var item in rec2send)
|
||||
{
|
||||
var currRes = allResources.Find(x => x.RawItemId == item.Key);
|
||||
list2send.Add(new ResourceDTO() { RawItemLocalId = item.Key, RawItemCloudId = currRes.RawItemCloudId, Qty = sign * Math.Abs(item.Value) });
|
||||
}
|
||||
//if (list2send == null || list2send.Count == 0)
|
||||
if (list2send == null)
|
||||
{
|
||||
answ = SyncResult.ERR_Res2SendEmpty;
|
||||
}
|
||||
else
|
||||
{
|
||||
int syncId = 0;
|
||||
string payload = JsonConvert.SerializeObject(list2send);
|
||||
DateTime adesso = DateTime.Now;
|
||||
// registro su DB invio..
|
||||
MagmanSyncModel newRec = new MagmanSyncModel()
|
||||
{
|
||||
CloudId = ProjCloudId,
|
||||
SyncType = $"{trackType}",
|
||||
DtReq = adesso,
|
||||
Payload = payload
|
||||
};
|
||||
|
||||
// verifico server ok
|
||||
bool servOk = commLib.CheckRemote();
|
||||
if (!servOk)
|
||||
{
|
||||
answ = SyncResult.ERR_ServerKo;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// effettuo invio...
|
||||
int resChk = commLib.ResourceCheck(ProjCloudId, trackType, adesso, list2send);
|
||||
switch (resChk)
|
||||
{
|
||||
case 1:
|
||||
answ = SyncResult.RES_CheckEqual;
|
||||
break;
|
||||
case 2:
|
||||
answ = SyncResult.RES_CheckChanged;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
answ = SyncResult.RES_CheckND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
answ = SyncResult.ERR_ServerKo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua invio track risorse
|
||||
/// </summary>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<HintPath>..\ExtLibs\EgtWPFLib5.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EgwProxy.MagMan, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EgwProxy.MagMan.1.0.2404.1011\lib\EgwProxy.MagMan.dll</HintPath>
|
||||
<HintPath>..\packages\EgwProxy.MagMan.1.0.2404.1520\lib\EgwProxy.MagMan.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>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="BouncyCastle" version="1.8.5" targetFramework="net472" />
|
||||
<package id="DotNetZip" version="1.16.0" targetFramework="net472" />
|
||||
<package id="EgwProxy.MagMan" version="1.0.2404.1011" targetFramework="net472" />
|
||||
<package id="EgwProxy.MagMan" version="1.0.2404.1520" targetFramework="net472" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net452" />
|
||||
<package id="Google.Protobuf" version="3.21.9" targetFramework="net472" />
|
||||
<package id="K4os.Compression.LZ4" version="1.3.6" targetFramework="net472" />
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<HintPath>..\ExtLibs\EgtWPFLib5.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EgwProxy.MagMan, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EgwProxy.MagMan.1.0.2404.1011\lib\EgwProxy.MagMan.dll</HintPath>
|
||||
<HintPath>..\packages\EgwProxy.MagMan.1.0.2404.1520\lib\EgwProxy.MagMan.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>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="BouncyCastle" version="1.8.5" targetFramework="net472" />
|
||||
<package id="DotNetZip" version="1.16.0" targetFramework="net472" />
|
||||
<package id="EgwProxy.MagMan" version="1.0.2404.1011" targetFramework="net472" />
|
||||
<package id="EgwProxy.MagMan" version="1.0.2404.1520" targetFramework="net472" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net452" />
|
||||
<package id="Google.Protobuf" version="3.21.9" targetFramework="net472" />
|
||||
<package id="K4os.Compression.LZ4" version="1.3.5" targetFramework="net472" />
|
||||
|
||||
Reference in New Issue
Block a user