Commit 458c2f5a authored by Omar Fantazi's avatar Omar Fantazi

Modifications suite aux changements des spécifications suivantes :

1)Le format du code de retour n’est pas au format XML comme cela est indiqué dans le fichier Excel (spécification du client) mais plutôt au format JSON.
2)La structure du code retour de l’appel du Webservice « Scrap Conveyr » et la même structure code retour que les autres Webservices
Utiliser Json à la place de XML pour traiter le code retour
parent 2b4c6664
......@@ -10,22 +10,23 @@ namespace InterfaceScadaToIN4RM.Caller.Callers
public interface ISCADACaller
{
InvocationResults WorkOrderCreation(WorkOrder workOrder);
string WorkOrderCreation(WorkOrder workOrder);
InvocationResults LineStatusCreation(LineStatus lineStatus);
string LineStatusCreation(LineStatus lineStatus);
InvocationResults SpeedChangeDetailCreation(SpeedChangeDetail speedchangeDetail);
string SpeedChangeDetailCreation(SpeedChangeDetail speedchangeDetail);
ArrayOfInterface_ScrapConveyorCreationResultDC ScrapConveyorDetailCreation(ScrapsConveyorDetails scrapconveyorDetails);
string ScrapConveyorDetailCreation(ScrapsConveyorDetails scrapconveyorDetails);
InvocationResults HandlingUnitsCreation(HandlingUnitDetails handlingUnitdetails);
string HandlingUnitsCreation(HandlingUnitDetails handlingUnitdetails);
......
......@@ -36,6 +36,9 @@
<AssemblyOriginatorKeyFile>keyScada.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.6.5\lib\net45\NLog.dll</HintPath>
</Reference>
......@@ -60,8 +63,7 @@
<ItemGroup>
<Compile Include="Callers\ISCADACaller.cs" />
<Compile Include="Callers\SCADACaller.cs" />
<Compile Include="Models\ArrayOfInterface_ScrapConveyorCreationResultDC.cs" />
<Compile Include="Models\InvocationResults.cs" />
<Compile Include="Models\Result.cs" />
<Compile Include="Models\HandlingUnitDetails.cs" />
<Compile Include="Models\LineStatus.cs" />
<Compile Include="Models\ScrapConveyorDetails.cs" />
......
......@@ -7,36 +7,21 @@
using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace InterfaceScadaToIN4RM.Caller.Models
{
[XmlRoot(ElementName = "result")]
public class Result
{
[XmlElement(ElementName = "Code")]
[JsonProperty("Code")]
public string Code { get; set; }
[XmlElement(ElementName = "Message")]
public string Message { get; set; }
}
[XmlRoot(ElementName = "InvocationResults", Namespace = "http://schemas.datacontract.org/2004/07/InterfaceWCF.DataContracts.Workshop")]
public class InvocationResults
{
[XmlElement(ElementName = "result")]
public Result Result { get; set; }
[XmlAttribute(AttributeName = "xmlns")]
public string Xmlns { get; set; }
[XmlAttribute(AttributeName = "i", Namespace = "http://www.w3.org/2000/xmlns/")]
public string I { get; set; }
}
[JsonProperty("Message")]
public string Message { get; set; }
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="NLog" version="4.6.5" targetFramework="net461" />
<package id="RestSharp" version="106.6.9" targetFramework="net461" />
</packages>
\ No newline at end of file
......@@ -37,6 +37,9 @@
<AssemblyOriginatorKeyFile>keyScada.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.6.5\lib\net45\NLog.dll</HintPath>
</Reference>
......
......@@ -75,19 +75,15 @@ namespace InterfaceScadaToIN4RM
/// <param name="woPosts"></param>
public string WorkOrderCreation(string woLine, string woHeader, string woPosts)
{
logger.Info("Call WorkOrderCreation :: woLine : {0}, woHeader : {1}, woPosts : {2}", woLine, woHeader, woPosts);
logger.Info("Call WorkOrderCreation :: woLine : {0}, woHeader : {1}, woPosts : {2}", woLine, woHeader, woPosts);
string invocResutlCode = string.Empty;
InvocationResults invocationResult;
string resutlCode = string.Empty;
if (scadaCaller != null)
{
WorkOrder workOrder = new WorkOrder(woLine, woHeader, woPosts);
invocationResult = scadaCaller.WorkOrderCreation(workOrder);
invocResutlCode = getInvocationResultCode("WorkOrderCreation", invocationResult);
resutlCode = scadaCaller.WorkOrderCreation(workOrder);
}
else
......@@ -95,7 +91,7 @@ namespace InterfaceScadaToIN4RM
logger.Error("scadaCaller is Null");
}
return invocResutlCode;
return resutlCode;
}
......@@ -120,17 +116,13 @@ namespace InterfaceScadaToIN4RM
{
logger.Info("Call LineStatusCreation :: slLine : {0}, statuses : {1}", slLine, statuses);
string invocResutlCode = string.Empty;
InvocationResults invocationResult;
string resutlCode = string.Empty;
if (scadaCaller != null)
{
LineStatus lineStatus = new LineStatus(slLine, statuses);
invocationResult = scadaCaller.LineStatusCreation(lineStatus);
invocResutlCode = getInvocationResultCode("LineStatusCreation", invocationResult);
resutlCode = scadaCaller.LineStatusCreation(lineStatus);
}
......@@ -139,7 +131,7 @@ namespace InterfaceScadaToIN4RM
logger.Error("scadaCaller is Null");
}
return invocResutlCode;
return resutlCode;
}
......@@ -158,18 +150,14 @@ namespace InterfaceScadaToIN4RM
{
logger.Info("Call SpeedChangeDetailCreation :: speedChangeCodeLine : {0}, speedChanges : {1}", speedChangeCodeLine, speedChanges);
string invocResutlCode = string.Empty;
InvocationResults invocationResult;
string resutlCode = string.Empty;
if (scadaCaller != null)
{
SpeedChangeDetail speedChangeDetail = new SpeedChangeDetail(speedChangeCodeLine, speedChanges);
invocationResult = scadaCaller.SpeedChangeDetailCreation(speedChangeDetail);
invocResutlCode = getInvocationResultCode("SpeedChangeDetailCreation", invocationResult);
resutlCode = scadaCaller.SpeedChangeDetailCreation(speedChangeDetail);
}
else
......@@ -177,7 +165,7 @@ namespace InterfaceScadaToIN4RM
logger.Error("scadaCaller is Null");
}
return invocResutlCode;
return resutlCode;
}
......@@ -194,17 +182,15 @@ namespace InterfaceScadaToIN4RM
{
logger.Info("Call ScrapConveyorDetailCreation :: scrapConveyorCodeLine : {0}, scrapConveyorPositions : {1}", scrapConveyorCodeLine, scrapConveyorPositions);
string invocResutlCode = string.Empty;
ArrayOfInterface_ScrapConveyorCreationResultDC scrapConveyorCreationResult;
string resutlCode = string.Empty;
if (scadaCaller != null)
{
ScrapsConveyorDetails scrapConveyorDetail = new ScrapsConveyorDetails(scrapConveyorCodeLine, scrapConveyorPositions);
scrapConveyorCreationResult = scadaCaller.ScrapConveyorDetailCreation(scrapConveyorDetail);
invocResutlCode = getScrapConveyorCreationResultCode("ScrapConveyorDetailCreation", scrapConveyorCreationResult);
resutlCode = scadaCaller.ScrapConveyorDetailCreation(scrapConveyorDetail);
//récupérer la réponse et l'affichée
//invocationResult.Result.Code
......@@ -224,7 +210,7 @@ namespace InterfaceScadaToIN4RM
logger.Error("scadaCaller is Null");
}
return invocResutlCode;
return resutlCode;
}
......@@ -244,17 +230,13 @@ namespace InterfaceScadaToIN4RM
{
logger.Info("Call HandlingUnitsCreation :: handlingUnitCodeLine : {0}, handlingUnits : {1}", handlingUnitCodeLine, handlingUnits);
string invocResutlCode = string.Empty;
InvocationResults invocationResult;
string resutlCode = string.Empty;
if (scadaCaller != null)
{
HandlingUnitDetails handlingUnitDetails = new HandlingUnitDetails(handlingUnitCodeLine, handlingUnits);
invocationResult = scadaCaller.HandlingUnitsCreation(handlingUnitDetails);
invocResutlCode = getInvocationResultCode("HandlingUnitsCreation", invocationResult);
resutlCode = scadaCaller.HandlingUnitsCreation(handlingUnitDetails);
}
......@@ -263,7 +245,7 @@ namespace InterfaceScadaToIN4RM
logger.Error("scadaCaller is Null");
}
return invocResutlCode;
return resutlCode;
}
......@@ -310,85 +292,7 @@ namespace InterfaceScadaToIN4RM
}
//Exemple
//< Code > 500 </ Code >
//< Message > Workorder successfully created. Internal ID : 62925 </ Message >
//invocationResult.Result.Code
//invocationResult.Result.Message
/// <summary>
/// Retour le code reponse du WebService
/// </summary>
/// <param name="serviceCaller"></param>
/// <param name="scrapConveyorCreationResult"></param>
/// <returns></returns>
private string getScrapConveyorCreationResultCode(string serviceCaller, ArrayOfInterface_ScrapConveyorCreationResultDC scrapConveyorCreationResult)
{
logger.Info("getScrapConveyorCreationResultCode : {0}", serviceCaller);
string invocResutlCode = string.Empty;
if (scrapConveyorCreationResult != null)
{
if (scrapConveyorCreationResult.Interface_ScrapConveyorCreationResultDC != null)
{
logger.Info("Result Interface_ScrapConveyorCreationResultDC :: Code : {0}, Message : {1}", scrapConveyorCreationResult.Interface_ScrapConveyorCreationResultDC.Code, scrapConveyorCreationResult.Interface_ScrapConveyorCreationResultDC.Message);
invocResutlCode = scrapConveyorCreationResult.Interface_ScrapConveyorCreationResultDC.Code;
}
else
{
invocResutlCode = "scrapConveyorCreationResult.Interface_ScrapConveyorCreationResultDC is Null";
logger.Info("getScrapConveyorCreationResultCode :: scrapConveyorCreationResult.Interface_ScrapConveyorCreationResultDC is Null");
}
}
else
{
invocResutlCode = "scrapConveyorCreationResult is Null";
logger.Info("getScrapConveyorCreationResultCode :: scrapConveyorCreationResult is Null");
}
return invocResutlCode;
}
private string getInvocationResultCode(string serviceCaller, InvocationResults invocationResult)
{
logger.Info("getInvocationResultCode : {0}", serviceCaller);
string invocResutlCode = string.Empty;
if (invocationResult != null)
{
if (invocationResult.Result != null)
{
logger.Info("Result invocationResult :: Code : {0}, Message : {1}", invocationResult.Result.Code, invocationResult.Result.Message);
invocResutlCode = invocationResult.Result.Code;
}
else
{
invocResutlCode = "invocationResult.Result is Null";
logger.Info("getInvocationResultCode :: invocationResult.Result is Null");
}
}
else
{
invocResutlCode = "invocationResult is Null";
logger.Info("getInvocationResultCode :: invocationResult is Null");
}
return invocResutlCode;
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="NLog" version="4.6.5" targetFramework="net461" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment