FwUpdateBuilder:

- special characters from FwUpdateSafe removed,
- customer name limited to 45 characters for FwUpdateFile.
FwUpdateSw:
- Release display soon FW-update succeeded,
- new IrDA, BaseSerialPort and TransmittProtocol from common 2.2.8.
FwUpdateLoader:
- Registration repaired if UserInformation.register does not exists.
Common:
- ReLogin skipped if already logged in,
- NA2WALARMS removed from read back of store configuration to support NA versions below 1.2.x.
This commit is contained in:
Thomas Wiedebusch
2022-07-22 09:40:10 +02:00
parent f819392e7e
commit baf39d1df0
5 changed files with 52 additions and 22 deletions
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
{
@@ -1091,7 +1091,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
btnLicenseFwUpdateBuilder.Enabled = false;
tbxCustomerName.Text = "";
lblCustomerNumber.Text = "";
tbxOrderNumber.Text = @"1234567890";
tbxOrderNumber.Text = @"0001";
tbxOrderPosition.Text = @"10";
var tabControlImages = new ImageList { ColorDepth = ColorDepth.Depth24Bit };
@@ -1177,6 +1177,11 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// <remarks date="2021-Oct-29" author="Thomas Wiedebusch">
/// - Skip loading of FW update SW if already done in preceding run.
/// </remarks>
/// <remarks date="2022-Jul-2" author="Thomas Wiedebusch">
/// - Removed special characters (e.g. characters from other language like "Umlaute") from file name,
/// as DB problems may ocure on FwUpdateSafe load, limit customer name length to 45 characters to
/// keep the file name small.
/// </remarks>
public Boolean BuildFwUpdateSafe()
{
if (string.IsNullOrEmpty(lblUpdateOperator.Text))
@@ -1312,7 +1317,15 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
// first replace the underlines as these are used for the file name and later to separate for customer and order number
var fileName = tbxCustomerName.Text.Replace(FwUpdateConfig.FwUpdateFileFieldSeparator.ToString(), "");
// leave all word characters (including the umlaut in for multilingual support), numbers the "-" and the white space in
fileName = Regex.Replace(fileName, @"[^\w\d\-\s]", "");
// fileName = Regex.Replace(fileName, @"[^\w\d\-\s]", "");
// remove special multilingual characters as they cause problems in DB, leave numbers, the "-", the "&", the "."
// and the white space in.
fileName = Regex.Replace(fileName, @"[^a-zA-Z0-9\-\s\&\.]", "");
// limit customer name length to 45
if (fileName.Length > 45)
{
fileName = fileName.Substring(0, 45);
}
// The safe shall look like "Thames Water_01234567890-10.safe"
_fwUpdateSafeName = $@"{fileName}{FwUpdateConfig.FwUpdateFileFieldSeparator}" +
@@ -4986,7 +4999,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// The software is a container of dll files, language packages and logging setups.
/// The configuration files contain the latest MeterFwUpdateRuler.json (needed for the FwUpdateBuilder),
/// the latest configuration.json and the latest MeterEraseRestore.json (needed for the FwUpdateSw).
/// Creates License, FileCrc, FileLength and SubDiractories.
/// Creates License, FileCrc, FileLength and SubDirectories.
/// </summary>
/// <param name="fwUpdateSwLicense">license information of valid software</param>
/// <returns>true if successful</returns>
@@ -75,6 +75,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateLoader
/// <remarks date="2021-Mar-25" author="Thomas Wiedebusch">
/// - DB object passed by to get result back to caller.
/// </remarks>
/// <remarks date="2022-Jul-22" author="Thomas Wiedebusch">
/// - Preset domain and loginName on unknown user.
/// </remarks>
public FrmRegister(String userRegistrationPathFileFile, Boolean fwUpdateSafesAvailable,
UserInformation regUser, FwUpdateDb fwUpdateDb)
{
@@ -95,6 +98,11 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateLoader
tbxDomain.Text = _regUser.Domain;
tbxLogInName.Text = _regUser.LogInName;
}
else
{
tbxDomain.Text = CryptInformation.GetSysDomain();
tbxLogInName.Text = CryptInformation.GetSysUserLoginName();
}
// Only one full name can be used for a specific user,if this is already set in the
// registration file, it has to remain as is (delete the registration file to set a new name)!
@@ -116,12 +124,6 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateLoader
tbxFullName.Text = _regUser.FullName;
}
//if (_regUser != null)
//{
// tbxDomain.Text = _regUser.Domain;
// tbxLogInName.Text = _regUser.LogInName;
//}
// Read initial DB users, compare DB content with given sys user
ReadDbUsers();
CheckUserRegistration();
@@ -356,11 +358,21 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateLoader
/// <remarks date="2021-Apr-08" author="Thomas Wiedebusch">
/// - Write registration to file after update of all information in DB.
/// </remarks>
/// <remarks date="2022-Jul-22" author="Thomas Wiedebusch">
/// - Initial user information set.
/// </remarks>
private void btnRegisterToDb_Click(Object sender, EventArgs e)
{
if (_regUser == null || string.IsNullOrEmpty(_regUser.FullName) || _fwUpdateDb == null) return;
btnRegisterToDb.Enabled = false;
if (!File.Exists(_userRegistrationPathFile))
{
// register anyway, as safes are not of interest if user isn't registered
if (!_fwUpdateDb.RefreshUserValidation(_regUser, false)) return;
}
if (!_fwUpdateDb.RefreshUserValidation(_regUser, _fwUpdateSafesAvailable)) return;
// The FullName has to be set in advance before searching it in fully registered users!
@@ -229,6 +229,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2022-Mai-10" author="Thomas Wiedebusch">
/// - Release display on idle entry.
/// </remarks>
/// <remarks date="2022-Jul-22" author="Thomas Wiedebusch">
/// - Release display on success entry.
/// </remarks>
private void FwUpdateSwStateMachine()
{
while (!_processToken.IsCancellationRequested)
@@ -367,6 +370,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
break;
case ProcessState.FirmwareUpdateSuccess:
ReleaseDisplay();
FwUpdateSuccessMessage();
_processState = ProcessState.Idle;
break;
@@ -1405,8 +1409,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2022-Apr-27" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
/// <remarks date="2022-Mai-10" author="Thomas Wiedebusch">
/// - Store all configurations after display release.
/// <remarks date="2022-Jul-22" author="Thomas Wiedebusch">
/// - Store configuration genesisflow after display release.
/// </remarks>
private void ReleaseDisplay()
{
@@ -1419,6 +1423,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// deactivate LED, not needed to get measurements during the update or on repeated start after system
// failure. This overwrites the settings in _meterFwUpdate.
_currentGenesis.WriteRegister(Register.Genesisflow.LedMode, new[] { (Byte)LedMode.Off });
_currentGenesis.WriteRegister(Register.Genesisflow.StoreConfiguration, 1);
LogText(Resources.StrDisplayReleased);
_currentGenesis.Logout();
}