Merge branch 'main' of https://slm.sms-esaap.com/la_operations/laa_production into main
This commit is contained in:
@@ -335,7 +335,7 @@ namespace ProductionUiCordonel
|
||||
CurrentProcess = "Cordonel verbunden";
|
||||
|
||||
|
||||
CurrentGenesisMeter.QuickLogin();
|
||||
CurrentGenesisMeter.ReLogin();
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
+25
-78
@@ -1,21 +1,19 @@
|
||||
using Newtonsoft.Json;
|
||||
using ProductionUiCordonel.ProductionProcesses.Enum;
|
||||
using ProductionUiCordonel.ProductionProcesses.Enum;
|
||||
using ProductionUiCordonel.UserControls.FinalTest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd;
|
||||
|
||||
namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
{
|
||||
public class ProductionProcessPasswordFile : BaseProductionProcess
|
||||
{
|
||||
private UcPasswordFile UserControl;
|
||||
private UcPasswordFile _userControl;
|
||||
private MeterPwdDb _pwdContainer = new MeterPwdDb();
|
||||
private MeterPwdFile _meterPwdFile;
|
||||
|
||||
public ProductionProcessPasswordFile()
|
||||
{
|
||||
@@ -25,16 +23,16 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
|
||||
public override void InitUserControl()
|
||||
{
|
||||
UserControl = new UcPasswordFile();
|
||||
_userControl = new UcPasswordFile();
|
||||
}
|
||||
|
||||
public override UserControl GetControl()
|
||||
{
|
||||
if (UserControl == null)
|
||||
if (_userControl == null)
|
||||
{
|
||||
throw new Exception($"UserControl {GetType()} not Ready");
|
||||
}
|
||||
return UserControl;
|
||||
return _userControl;
|
||||
}
|
||||
|
||||
private void updateImage(Image ctlImage, Boolean? success = null)
|
||||
@@ -49,15 +47,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
|
||||
public override void StartProcess()
|
||||
{
|
||||
Boolean ret = RequestPassword();
|
||||
updateImage(UserControl.RequestPassword, ret);
|
||||
var ret = MeterPwdHandlerDb.RequestPwdFileFromDb(Meter.PcbId, out _pwdContainer);
|
||||
updateImage(_userControl.RequestPassword, ret);
|
||||
Progress += 16;
|
||||
|
||||
//If the password file is written, the "Password" from pwContainer is overwritten from Skeleton-key
|
||||
//If the password file is written, the "Password" from _pwdContainer is overwritten from Skeleton-key
|
||||
//to the "level 8 password" form the LuDB server. The DB password column is the current login password
|
||||
//for production. Initially the "Password" is the Skeleton-key which can not be part of the list of
|
||||
//Passwords. The level 8 password is the last in the pwContainer list of passwords.
|
||||
if (Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last()) == pwContainer.Password)
|
||||
//Passwords. The level 8 password is the last in the _pwdContainer list of passwords.
|
||||
if (Encoding.UTF8.GetString(_pwdContainer.ListOfPasswords.Last()) == _pwdContainer.Password)
|
||||
{
|
||||
NewStatus("Passwörter schon geschrieben. Prozess wird übersprungen");
|
||||
currentProcessState = ProductionProcessState.Done;
|
||||
@@ -70,7 +68,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
ret = CreatePasswordFile();
|
||||
}
|
||||
|
||||
updateImage(UserControl.CreateFile, ret);
|
||||
updateImage(_userControl.CreateFile, ret);
|
||||
Progress += 16;
|
||||
|
||||
//Write the password file to the Cordonel, read it back and make a binary verification
|
||||
@@ -79,14 +77,14 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
ret = WriteAndVerifyPasswordFileToMeter();
|
||||
}
|
||||
|
||||
updateImage(UserControl.WriteToMeter, ret);
|
||||
updateImage(_userControl.WriteToMeter, ret);
|
||||
Progress += 16;
|
||||
|
||||
//Check if new password is in the meter ... even if the file write wasn't successful
|
||||
if (ret)
|
||||
{
|
||||
Meter.Logout();
|
||||
ret = Meter.Login(Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last()));
|
||||
ret = Meter.Login(Encoding.UTF8.GetString(_pwdContainer.ListOfPasswords.Last()));
|
||||
}
|
||||
|
||||
//Password in Production DB can be updated (overwrite Skeleton-key in Password column with
|
||||
@@ -94,16 +92,16 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
//this is the indicator, that the password file is valid.
|
||||
if (ret)
|
||||
{
|
||||
ret = UpdatePasswordinDb();
|
||||
ret = MeterPwdHandlerDb.SetPwdFromSkeletonToLvl8inDd(Meter.PcbId, _pwdContainer);
|
||||
}
|
||||
updateImage(UserControl.UpdatePassword, ret);
|
||||
updateImage(_userControl.UpdatePassword, ret);
|
||||
Progress += 16;
|
||||
|
||||
if (ret)
|
||||
{
|
||||
ret = Meter.Logout();
|
||||
}
|
||||
updateImage(UserControl.Logout, ret);
|
||||
updateImage(_userControl.Logout, ret);
|
||||
Progress += 16;
|
||||
|
||||
//test the production database password
|
||||
@@ -112,7 +110,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
Meter.ClearPassword();
|
||||
ret = Meter.Login();
|
||||
}
|
||||
updateImage(UserControl.CheckNewPassword, ret);
|
||||
updateImage(_userControl.CheckNewPassword, ret);
|
||||
Progress = 100;
|
||||
|
||||
if (!ret)
|
||||
@@ -130,73 +128,22 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
}
|
||||
|
||||
#region realWork
|
||||
public class MeterPasswordContainer
|
||||
{
|
||||
public Int64? orderNumber = null;
|
||||
public Int64? radioAdress = null;
|
||||
public String Skeleton = "";
|
||||
public String Password = "";
|
||||
public List<Byte[]> listOfHashes = new List<Byte[]>();
|
||||
public List<Byte[]> listOfPasswords = new List<Byte[]>();
|
||||
}
|
||||
|
||||
private MeterPasswordContainer pwContainer = new MeterPasswordContainer();
|
||||
private MeterPwdFile meterPwdFile;
|
||||
public Boolean RequestPassword()
|
||||
{
|
||||
NewStatus("Request Passwords");
|
||||
var url = ServiceUrls.GenesisGetPasswordContainerServiceUrl();
|
||||
//url = "http://localhost:56011/api/Password/GetPasswordHashFileContent?PcbId=";
|
||||
url = ($"{url}{Meter.PcbId}");
|
||||
|
||||
var header = new Dictionary<String, String>
|
||||
{
|
||||
{ "Cache-Control", "no-cache" },
|
||||
{ "X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616" }
|
||||
};
|
||||
var resp = LocalWebRequest.GetRequestWithError(url, out var errorCode, 20000, header, true);
|
||||
if (errorCode == HttpStatusCode.OK.GetHashCode())
|
||||
{
|
||||
pwContainer = JsonConvert.DeserializeObject<MeterPasswordContainer>(resp);
|
||||
NewStatus("Passwörter verfügbar");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public Boolean CreatePasswordFile()
|
||||
{
|
||||
|
||||
meterPwdFile = new MeterPwdFile(Meter);
|
||||
return meterPwdFile.BuildPwdFile(pwContainer.listOfPasswords, 1, pwContainer.Skeleton);
|
||||
_meterPwdFile = new MeterPwdFile(Meter);
|
||||
return _meterPwdFile.BuildPwdFile(_pwdContainer.ListOfPasswords, 1, _pwdContainer.Skeleton);
|
||||
}
|
||||
public Boolean WriteAndVerifyPasswordFileToMeter()
|
||||
{
|
||||
if (meterPwdFile.UnlockEraseWriteMeterPwdFile())
|
||||
if (_meterPwdFile.UnlockEraseWriteMeterPwdFile())
|
||||
{
|
||||
if (meterPwdFile.WriteMeterPwdFile())
|
||||
if (_meterPwdFile.WriteMeterPwdFile())
|
||||
{
|
||||
return meterPwdFile.VerifyMeterPwdFile();
|
||||
return _meterPwdFile.VerifyMeterPwdFile();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Boolean UpdatePasswordinDb()
|
||||
{
|
||||
|
||||
var newPs = Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last());
|
||||
var passwordSetServiceUrl = ServiceUrls.GenesisSetPasswordServiceUrl();
|
||||
|
||||
|
||||
var responseJson = LocalWebRequest.GetRequest(passwordSetServiceUrl + Meter.PcbId + "&Password=" + newPs, 8000);
|
||||
if (responseJson.ToLower().Contains("store"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -335,6 +335,10 @@
|
||||
<Project>{2C6378C6-6BA1-4CEE-8992-8404D8369A90}</Project>
|
||||
<Name>GenesisFile</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\GenesisPwd\GenesisPwd.csproj">
|
||||
<Project>{AC434B18-4D7B-49BA-9AD5-0527C79E8297}</Project>
|
||||
<Name>GenesisPwd</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Hardware\WaterMeter\Genesis\Registers\Registers.csproj">
|
||||
<Project>{F4AAF7E6-7333-4284-B735-E32DEB076C64}</Project>
|
||||
<Name>Registers</Name>
|
||||
|
||||
Reference in New Issue
Block a user