FwUpdateBuilder: - Fw Update Sw taken from DB,- Configuration files taken from DB
This commit is contained in:
@@ -187,7 +187,6 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
/// </summary>
|
||||
private const Int32 DbConnectionTimeoutMs = 5000;
|
||||
private Int32 _dbAccessDelayCtrMs;
|
||||
private Boolean _dbAccessIsLocked;
|
||||
|
||||
/// <summary>
|
||||
/// Project name for the DLL to load:
|
||||
@@ -219,7 +218,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
ProgramConfig.NlogConfig);
|
||||
|
||||
/// <summary>
|
||||
/// Source folder of binaries
|
||||
/// Source folder of software package if taken from local [user]/downloads/ServiceFwUpdateSw
|
||||
/// </summary>
|
||||
private static readonly String FwUpdateSwSourcePath = Path.Combine(Environment.GetFolderPath(
|
||||
Environment.SpecialFolder.UserProfile), FwUpdateConfig.DefaultFwUpdateSwSourcePath);
|
||||
@@ -452,7 +451,6 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
private void infoToolStripMenuItem_Click(Object sender, EventArgs e)
|
||||
{
|
||||
_processState = ProcessState.UserRegistration;
|
||||
_dbAccessIsLocked = true;
|
||||
var frmRegister = new FrmRegister(_regUser);
|
||||
DisableAllControlsInvoked();
|
||||
frmRegister.Show();
|
||||
@@ -472,7 +470,6 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
Show();
|
||||
Update();
|
||||
CheckUserRegistration();
|
||||
_dbAccessIsLocked = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Exit the program
|
||||
@@ -692,7 +689,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
if (e.TabPage == tabPageFwPackageSelection)
|
||||
{
|
||||
// Load fw packages only if not selected indicated in count
|
||||
if (_fwUpdatePackages.Count > 0 ||
|
||||
if (_fwUpdatePackages.Count > 0 ||
|
||||
_cordonelFwPackageInfoSearch != null && _cordonelFwPackageInfoSearch.Count > 0) return;
|
||||
|
||||
DisableAllControlsInvoked();
|
||||
@@ -926,9 +923,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
if (File.Exists(nLogConfigSourcePathName) && !File.Exists(NLogConfigurationDestPathFile))
|
||||
SystemControl.CopyFile(nLogConfigSourcePathName, NLogConfigurationDestPathFile);
|
||||
|
||||
var rulerPathName = Path.Combine(fwUpdateBuilderLibraryPath,
|
||||
var rulerPathName = Path.Combine(fwUpdateBuilderLibraryPath,
|
||||
FwUpdateConfig.MeterFwUpdateRulerConfigFileName);
|
||||
if (!File.Exists(rulerPathName)) rulerPathName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
|
||||
if (!File.Exists(rulerPathName)) rulerPathName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
|
||||
FwUpdateConfig.MeterFwUpdateRulerConfigFileName);
|
||||
if (File.Exists(rulerPathName))
|
||||
{
|
||||
@@ -1129,8 +1126,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
}
|
||||
|
||||
GetFwUpdateSwLicenseFromDb(FwUpdateSwFullName, out fwUpdateSafe.License);
|
||||
|
||||
if (fwUpdateSafe.License == null)
|
||||
|
||||
if (fwUpdateSafe.License == null)
|
||||
{
|
||||
LogErrorText(Resources.StrSwLicenseMissing);
|
||||
MessageBoxShow(Resources.StrSwLicenseMissing, Resources.StrError, MessageBoxButtons.OK,
|
||||
@@ -1139,15 +1136,15 @@ if (fwUpdateSafe.License == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
// overwrite license as operator has decided for FW-Update Valid date
|
||||
// overwrite license validation date as operator has selected this
|
||||
fwUpdateSafe.License.ValidTo =
|
||||
DateTimeServer.GetDateTimeFromDateString(lblFwUpdateDutyDate.Text + " 23:59:59", _cultureInfo);
|
||||
|
||||
LogSuccessText($@"{Resources.StrSwLicenseLoadedSuccessfully} {FwUpdateProjectName}" +
|
||||
$" {fwUpdateSafe.License.Major}.{fwUpdateSafe.License.Minor}.{fwUpdateSafe.License.Build}");
|
||||
|
||||
//GetFwUpdateSwContainerFromDb();
|
||||
if (!BuildFwUpdateSwContainer(fwUpdateSafe.License) ||
|
||||
// local files: if (!BuildFwUpdateSwContainer(fwUpdateSafe.License) ||
|
||||
if (!BuildFwUpdateSwContainerFromDb(fwUpdateSafe.License) ||
|
||||
_fwUpdateSwContainer?.RegisterDefinitionFile == null ||
|
||||
_fwUpdateSwContainer.SoftwareSetupFile == null ||
|
||||
_fwUpdateSwContainer.MeterFilesEraseRestore == null ||
|
||||
@@ -1285,113 +1282,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Take user input to fill the FW-Update collection information.
|
||||
///// </summary>
|
||||
///// <remarks date="2021-Feb-02" author="Thomas Wiedebusch">
|
||||
///// - Initial.
|
||||
///// </remarks>
|
||||
///// <remarks date="2021-Mar-25" author="Thomas Wiedebusch">
|
||||
///// - Clear update info on entry.
|
||||
///// </remarks>
|
||||
///// <remarks date="2021-Apr-01" author="Thomas Wiedebusch">
|
||||
///// - Checkbox to enable DEBUG Cordonels for development.
|
||||
///// </remarks>
|
||||
///// <remarks date="2021-Apr-08" author="Thomas Wiedebusch">
|
||||
///// - Added DEBUG Cordonels to CordonelProductionInfos.
|
||||
///// </remarks>
|
||||
//public void DebugDeviceAndFwPackageSelection()
|
||||
//{
|
||||
// _cordonelProductionInfos.Clear();
|
||||
// if (!cbxAddDebugCordonels.Checked) return;
|
||||
|
||||
// var updateInfo = new CordonelDeviceInfo
|
||||
// {
|
||||
// PcbId = "182100041",
|
||||
// CustomerSerialNumber = @"Octopus 1",
|
||||
// RequiredRelease = "EMEA R106D 868MHz"
|
||||
// //RequiredRelease = "EMEA R106B TEST (it is R106D)"
|
||||
// //RequiredRelease = "EMEA R106B 433MHz"
|
||||
// };
|
||||
// if (_cordonelDeviceInfos.All(d => d.PcbId != updateInfo.PcbId)) _cordonelDeviceInfos.Add(updateInfo);
|
||||
|
||||
// updateInfo = new CordonelDeviceInfo
|
||||
// {
|
||||
// PcbId = "192000001",
|
||||
// CustomerSerialNumber = @"Octopus 2",
|
||||
// RequiredRelease = "EMEA R1066 433MHz"
|
||||
// };
|
||||
// if (_cordonelDeviceInfos.All(d => d.PcbId != updateInfo.PcbId)) _cordonelDeviceInfos.Add(updateInfo);
|
||||
|
||||
// updateInfo = new CordonelDeviceInfo
|
||||
// {
|
||||
// PcbId = "192000004",
|
||||
// CustomerSerialNumber = @"Octopus 3",
|
||||
// RequiredRelease = "EMEA R106D 868MHz"
|
||||
// };
|
||||
// if (_cordonelDeviceInfos.All(d => d.PcbId != updateInfo.PcbId)) _cordonelDeviceInfos.Add(updateInfo);
|
||||
|
||||
// updateInfo = new CordonelDeviceInfo
|
||||
// {
|
||||
// PcbId = "192000006",
|
||||
// CustomerSerialNumber = @"Octopus 4",
|
||||
// RequiredRelease = "EMEA R106D 868MHz"
|
||||
// };
|
||||
// if (_cordonelDeviceInfos.All(d => d.PcbId != updateInfo.PcbId)) _cordonelDeviceInfos.Add(updateInfo);
|
||||
|
||||
// updateInfo = new CordonelDeviceInfo
|
||||
// {
|
||||
// PcbId = "192000007",
|
||||
// CustomerSerialNumber = @"Octopus 5",
|
||||
// RequiredRelease = "EMEA R106D 868MHz"
|
||||
// };
|
||||
// if (_cordonelDeviceInfos.All(d => d.PcbId != updateInfo.PcbId)) _cordonelDeviceInfos.Add(updateInfo);
|
||||
|
||||
// updateInfo = new CordonelDeviceInfo
|
||||
// {
|
||||
// PcbId = "192000009",
|
||||
// CustomerSerialNumber = @"Octopus 6",
|
||||
// RequiredRelease = "EMEA R106D 868MHz"
|
||||
// };
|
||||
// if (_cordonelDeviceInfos.All(d => d.PcbId != updateInfo.PcbId)) _cordonelDeviceInfos.Add(updateInfo);
|
||||
|
||||
// foreach (var cordonelUpdateInfo in _cordonelDeviceInfos)
|
||||
// {
|
||||
// var cordonel = new CordonelProductionInfosDb
|
||||
// {
|
||||
// IsSelected = true,
|
||||
// CatalogNumber = "OCTOPUS",
|
||||
// CustomerOrderNumber = 999999,
|
||||
// CustomerOrderPos = 99,
|
||||
// Diameter = "0",
|
||||
// Length = "0",
|
||||
// PcbId = cordonelUpdateInfo.PcbId,
|
||||
// CustomerSerialNumber = cordonelUpdateInfo.CustomerSerialNumber,
|
||||
// SensusSerialNumber = @"Test-Cordonel",
|
||||
// RequiredReleaseNameVersion = cordonelUpdateInfo.RequiredRelease
|
||||
// };
|
||||
// if (_fwUpdateDbAccess != null &&
|
||||
// _fwUpdateDbAccess.DownloadCordonelAppVersionsFromDb(cordonel.PcbId, out var cordonelAppVersions))
|
||||
// {
|
||||
// foreach (var appVersion in cordonelAppVersions)
|
||||
// {
|
||||
// if (appVersion.Id == -1) cordonel.CoreRevision = appVersion.Version;
|
||||
// if (appVersion.Id == 0x0F)
|
||||
// {
|
||||
// cordonel.Metrology = appVersion.Version;
|
||||
// cordonel.MetrologyIsUpdateable = appVersion.IsUpdateable;
|
||||
// }
|
||||
|
||||
// if (appVersion.Id == 0x18)
|
||||
// cordonel.InstalledReleaseNameVersion = appVersion.Version;
|
||||
// }
|
||||
// }
|
||||
// if (_cordonelProductionInfos.All(d => d.PcbId != cordonel.PcbId))
|
||||
// _cordonelProductionInfos.Add(cordonel);
|
||||
// }
|
||||
|
||||
// _cordonelsPropertyChanged = true;
|
||||
//}
|
||||
|
||||
#endregion --------------------------------------- Build FW-Update Safe ---------------------------------------
|
||||
|
||||
@@ -1404,9 +1294,6 @@ if (fwUpdateSafe.License == null)
|
||||
/// </remarks>
|
||||
private void CheckUserRegistration()
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (_fwUpdateDbAccess == null || _regUser == null) return;
|
||||
_regUser.Domain = CryptInformation.GetSysDomain();
|
||||
_regUser.LogInName = CryptInformation.GetSysUserLoginName();
|
||||
@@ -1519,7 +1406,6 @@ if (fwUpdateSafe.License == null)
|
||||
if (_fwUpdateDbAccess.DbIsConnected)
|
||||
{
|
||||
// DB is free to use
|
||||
_dbAccessIsLocked = false;
|
||||
|
||||
if (_dbLicenseRefreshDelayCtrMs > DbLicenseRefreshTimeoutMs)
|
||||
{
|
||||
@@ -2373,7 +2259,6 @@ if (fwUpdateSafe.License == null)
|
||||
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
||||
try
|
||||
{
|
||||
_dbAccessIsLocked = true;
|
||||
// check DB connection in advance to overcome the timing issues for DB service startup
|
||||
_fwUpdateDbAccess.CheckDbConnection();
|
||||
}
|
||||
@@ -2383,7 +2268,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
_dbAccessIsLocked = false;
|
||||
_processState = ProcessState.Idle;
|
||||
});
|
||||
}
|
||||
@@ -2409,7 +2293,6 @@ if (fwUpdateSafe.License == null)
|
||||
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
||||
try
|
||||
{
|
||||
_dbAccessIsLocked = true;
|
||||
// check DB connection in advance to overcome the timing issues for DB service startup
|
||||
_fwUpdateDbAccess.CheckDbConnection();
|
||||
GetAllUpdateOperatorsFromDb();
|
||||
@@ -2420,7 +2303,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
_dbAccessIsLocked = false;
|
||||
_fwUpdateOperatorsPropertyChanged = true;
|
||||
_processState = ProcessState.Idle;
|
||||
});
|
||||
@@ -2441,7 +2323,6 @@ if (fwUpdateSafe.License == null)
|
||||
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
||||
try
|
||||
{
|
||||
_dbAccessIsLocked = true;
|
||||
// check DB connection in advance to overcome the timing issues for DB service startup
|
||||
_fwUpdateDbAccess.CheckDbConnection();
|
||||
GetLicenseFromDb();
|
||||
@@ -2452,7 +2333,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
_dbAccessIsLocked = false;
|
||||
if (_regUser.AccountActive)
|
||||
{
|
||||
_licenseValidDateTimeOffset = DateTimeServer.GetDateTimeTodayUntilMidnight();
|
||||
@@ -2468,6 +2348,12 @@ if (fwUpdateSafe.License == null)
|
||||
/// <remarks date="2021-Apr-08" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2021-Oct-26" author="Thomas Wiedebusch">
|
||||
/// - Load configuration files from DB as the latest MeterFwUpdateRuler.json is needed for the
|
||||
/// FwUpdateBuilder FW package check and validation routine! This step has to be done in advance
|
||||
/// to the FW package load, as the Builder uses the information of the MeterFwUpdateRuler to
|
||||
/// create the package information!
|
||||
/// </remarks>
|
||||
private void LoadDbCordonelFwPackagesTask()
|
||||
{
|
||||
_invokerProcessState = _processState;
|
||||
@@ -2477,9 +2363,11 @@ if (fwUpdateSafe.License == null)
|
||||
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
||||
try
|
||||
{
|
||||
_dbAccessIsLocked = true;
|
||||
// check DB connection in advance to overcome the timing issues for DB service startup
|
||||
_fwUpdateDbAccess.CheckDbConnection();
|
||||
// has to be done first to extract the MeterFwUpdateRuler
|
||||
GetFwUpdateConfigFilesFromDb();
|
||||
// load the packages and use the MeterFwUpdateRuler to assign the DN, EMEA, NA, 868, 433..
|
||||
GetCordonelFwPackagesFromDb();
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -2488,7 +2376,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
_dbAccessIsLocked = false;
|
||||
_fwPackagePropertyChanged = true;
|
||||
_processState = ProcessState.Idle;
|
||||
});
|
||||
@@ -2515,7 +2402,6 @@ if (fwUpdateSafe.License == null)
|
||||
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
||||
try
|
||||
{
|
||||
_dbAccessIsLocked = true;
|
||||
// check DB connection in advance to overcome the timing issues for DB service startup
|
||||
_fwUpdateDbAccess.CheckDbConnection();
|
||||
GetAllCordonelCustomersFromDb();
|
||||
@@ -2526,7 +2412,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
_dbAccessIsLocked = false;
|
||||
_customersPropertyChanged = true;
|
||||
_processState = ProcessState.Idle;
|
||||
});
|
||||
@@ -2553,7 +2438,6 @@ if (fwUpdateSafe.License == null)
|
||||
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
||||
try
|
||||
{
|
||||
_dbAccessIsLocked = true;
|
||||
// check DB connection in advance to overcome the timing issues for DB service startup
|
||||
_fwUpdateDbAccess.CheckDbConnection();
|
||||
GetAllCordonelSerialNumbersOfOrderFromDb();
|
||||
@@ -2564,7 +2448,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
_dbAccessIsLocked = false;
|
||||
_cordonelsPropertyChanged = true;
|
||||
_processState = ProcessState.Idle;
|
||||
});
|
||||
@@ -2588,7 +2471,6 @@ if (fwUpdateSafe.License == null)
|
||||
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
||||
try
|
||||
{
|
||||
_dbAccessIsLocked = true;
|
||||
// check DB connection in advance to overcome the timing issues for DB service startup
|
||||
_fwUpdateDbAccess.CheckDbConnection();
|
||||
GetAllCordonelOrdersOfCustomerFromDb();
|
||||
@@ -2599,7 +2481,6 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
}).ContinueWith(delegate
|
||||
{
|
||||
_dbAccessIsLocked = false;
|
||||
_cordonelsPropertyChanged = true;
|
||||
_processState = ProcessState.Idle;
|
||||
});
|
||||
@@ -3833,7 +3714,7 @@ if (fwUpdateSafe.License == null)
|
||||
}
|
||||
|
||||
var initialSortColumn = gridViewCustomerSelection.Columns[Resources.StrTableCustomerName];
|
||||
if (initialSortColumn != null)
|
||||
if (initialSortColumn != null)
|
||||
gridViewCustomerSelection.Sort(initialSortColumn, ListSortDirection.Ascending);
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -4000,6 +3881,9 @@ if (fwUpdateSafe.License == null)
|
||||
/// <remarks date="2021-Apr-29" author="Thomas Wiedebusch">
|
||||
/// - Meter FW update ruler.
|
||||
/// </remarks>
|
||||
/// <remarks date="2021-Oct-15" author="Thomas Wiedebusch">
|
||||
/// - Configuration files loading from DB: - MeterFwUpdateRuler, configuration.json and MeterEraseRestore.
|
||||
/// </remarks>
|
||||
private Boolean GetCordonelFwPackagesFromDb()
|
||||
{
|
||||
if (_fwUpdateDbAccess == null || !_fwUpdateDbAccess.GetAllCordonelFwInfoFilesFromDb() ||
|
||||
@@ -4007,6 +3891,10 @@ if (fwUpdateSafe.License == null)
|
||||
return false;
|
||||
|
||||
_cordonelFwPackageInfoSearch.Clear();
|
||||
// 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).
|
||||
// GetConfigurationFilesFromDb();
|
||||
|
||||
// Start with the last package, as this will be the latest
|
||||
for (var idx = _fwUpdateDbAccess.DbCordonelFwPackages.Count - 1;
|
||||
idx > _fwUpdateDbAccess.DbCordonelFwPackages.Count - 40; idx--)
|
||||
@@ -4055,10 +3943,10 @@ if (fwUpdateSafe.License == null)
|
||||
$"{rule.Release.Substring(3, 2)}";
|
||||
if (releaseVersion == fwPackInfo.ReleaseVersion)
|
||||
{
|
||||
Int32.TryParse(rule.CoreVersionMin, out var x);
|
||||
int.TryParse(rule.CoreVersionMin, out var x);
|
||||
fwPackInfo.CoreVersionMin = x;
|
||||
x = 0;
|
||||
Int32.TryParse(rule.CoreVersionMax, out x);
|
||||
int.TryParse(rule.CoreVersionMax, out x);
|
||||
fwPackInfo.CoreVersionMax = x;
|
||||
fwPackInfo.FwIsReleased = !string.IsNullOrEmpty(rule.ApproverName);
|
||||
}
|
||||
@@ -4216,6 +4104,135 @@ if (fwUpdateSafe.License == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Cordonel Fa update configuration files from DB.
|
||||
/// 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).
|
||||
/// Copies the MeterFwUpdateRuler.json to the [exe-root] or [exe-root]/Library of the FwUpdateBuilder.
|
||||
/// </summary>
|
||||
/// <returns>true if successful</returns>
|
||||
/// <remarks date="2021-Oct-27" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private Boolean GetFwUpdateConfigFilesFromDb()
|
||||
{
|
||||
if (_fwUpdateDbAccess == null ||
|
||||
!_fwUpdateDbAccess.DownloadFwUpdateConfigurationFilesFromDb() ||
|
||||
_fwUpdateDbAccess.DbFwUpdateConfigFiles.Count == 0)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
// extract the MeterFwUpdateRuler
|
||||
foreach (var f in _fwUpdateDbAccess.DbFwUpdateConfigFiles)
|
||||
{
|
||||
if (f.FileName == FwUpdateConfig.MeterFwUpdateRulerConfigFileName)
|
||||
{
|
||||
// Copy MeterFwUpdateRuler either to exe-path or if existing to Library-subfolder
|
||||
var fwUpdateBuilderExePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
var fwUpdateBuilderLibraryPath = Path.Combine(fwUpdateBuilderExePath,
|
||||
FwUpdateConfig.LibrarySubFolderName);
|
||||
|
||||
// check the Library path existence (will be used in Release build)
|
||||
var meterFwUpdateRulerPath = Directory.Exists(fwUpdateBuilderLibraryPath) ?
|
||||
fwUpdateBuilderLibraryPath : fwUpdateBuilderExePath;
|
||||
|
||||
var sourceFile = Path.Combine(meterFwUpdateRulerPath, f.FileName);
|
||||
var fs = File.Open(sourceFile, FileMode.Create);
|
||||
fs.Write(f.FileContent, 0, f.FileContent.Length);
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Cordonel SW and configuration files from DB.
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="fwUpdateSwLicense">license information of valid software</param>
|
||||
/// <returns>true if successful</returns>
|
||||
/// <remarks date="2021-Oct-27" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private Boolean BuildFwUpdateSwContainerFromDb(SoftwareLicense fwUpdateSwLicense)
|
||||
{
|
||||
if (_fwUpdateDbAccess?.DbFwUpdateConfigFiles == null ||
|
||||
!_fwUpdateDbAccess.DownloadFwUpdateSwContainerFromDb() ||
|
||||
_fwUpdateDbAccess.DbFwUpdateSwPackage.Count == 0 ||
|
||||
_fwUpdateDbAccess.DbFwUpdateConfigFiles.Count == 0)
|
||||
return false;
|
||||
|
||||
_fwUpdateSwContainer = new SoftwareContainer
|
||||
{
|
||||
Major = fwUpdateSwLicense.Major,
|
||||
Minor = fwUpdateSwLicense.Minor,
|
||||
Build = fwUpdateSwLicense.Build,
|
||||
Program = fwUpdateSwLicense.Program,
|
||||
SoftwareDynLinkLibs = new List<FilePart>(),
|
||||
RegisterDefinitionFile = new FilePart(),
|
||||
SoftwareSetupFile = new FilePart(),
|
||||
MeterFilesEraseRestore = new FilePart()
|
||||
};
|
||||
|
||||
foreach (var f in _fwUpdateDbAccess.DbFwUpdateConfigFiles)
|
||||
{
|
||||
// load the register definition
|
||||
if (f.FileName == ProgramConfig.RegisterDefinitionFileName)
|
||||
{
|
||||
f.FileContentLength = f.FileContent.Length;
|
||||
f.FileContentCrc16CcittMsb = Crc16Ccitt.CalculateMsb1021(f.FileContent);
|
||||
_fwUpdateSwContainer.RegisterDefinitionFile = f;
|
||||
}
|
||||
|
||||
// load the meter files to erase and restore
|
||||
if (f.FileName == FwUpdateConfig.MeterFilesEraseRestoreConfigFileName)
|
||||
{
|
||||
f.FileContentLength = f.FileContent.Length;
|
||||
f.FileContentCrc16CcittMsb = Crc16Ccitt.CalculateMsb1021(f.FileContent);
|
||||
_fwUpdateSwContainer.MeterFilesEraseRestore = f;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var f in _fwUpdateDbAccess.DbFwUpdateSwPackage)
|
||||
{
|
||||
// load the logging configuration
|
||||
if (f.FileName == ProgramConfig.NlogConfig)
|
||||
{
|
||||
f.FileContentLength = f.FileContent.Length;
|
||||
f.FileContentCrc16CcittMsb = Crc16Ccitt.CalculateMsb1021(f.FileContent);
|
||||
_fwUpdateSwContainer.SoftwareSetupFile = f;
|
||||
}
|
||||
// load the DLLs
|
||||
if (f.FileName.EndsWith(".dll"))
|
||||
{
|
||||
// extract sub-directory from file name in DB for sub-directory creation in FwUpdateLoader
|
||||
// supports only depth of one level
|
||||
if (f.FileName.Contains("\\"))
|
||||
{
|
||||
var fileName = f.FileName.Split('\\');
|
||||
var subDirectory = fileName[0];
|
||||
f.FileName = fileName[fileName.Length - 1];
|
||||
f.SubDirectory = subDirectory;
|
||||
}
|
||||
|
||||
f.FileContentLength = f.FileContent.Length;
|
||||
f.FileContentCrc16CcittMsb = Crc16Ccitt.CalculateMsb1021(f.FileContent);
|
||||
_fwUpdateSwContainer.SoftwareDynLinkLibs.Add(f);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build the FW-Update SW container
|
||||
/// </summary>
|
||||
@@ -4232,6 +4249,7 @@ if (fwUpdateSafe.License == null)
|
||||
/// <remarks date="2021-Apr-29" author="Thomas Wiedebusch">
|
||||
/// - Take license from DB.
|
||||
/// </remarks>
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
private Boolean BuildFwUpdateSwContainer(SoftwareLicense fwUpdateSwLicense)
|
||||
{
|
||||
_fwUpdateSwContainer = new SoftwareContainer
|
||||
@@ -4247,7 +4265,7 @@ if (fwUpdateSafe.License == null)
|
||||
};
|
||||
try
|
||||
{
|
||||
//TODO THW for debug purposes the locally values are taken
|
||||
// for debug purposes the locally stored files from download folder are taken
|
||||
// copy all elements of software release in the main directory
|
||||
var fileList = new List<String>();
|
||||
|
||||
@@ -4498,84 +4516,6 @@ if (fwUpdateSafe.License == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Load firmware package from local HDD.
|
||||
///// </summary>
|
||||
///// <param name="releaseNameVersion"></param>
|
||||
///// <returns>true if succeeded</returns>
|
||||
///// <remarks date="2020-Dec-14" author="Thomas Wiedebusch">
|
||||
///// - Initial.
|
||||
///// </remarks>
|
||||
///// <remarks date="2021-Feb-02" author="Thomas Wiedebusch">
|
||||
///// - Returns bool.
|
||||
///// </remarks>
|
||||
///// <remarks date="2021-Mar-26" author="Thomas Wiedebusch">
|
||||
///// - Logging added.
|
||||
///// </remarks>
|
||||
//private Boolean LoadFirmwarePackage(String releaseNameVersion)
|
||||
//{
|
||||
// // if this packages has already been loaded, exit immediately
|
||||
// if (_fwUpdatePackages.Any(version => version.ReleaseNameVersion == releaseNameVersion))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// var cordonelFwPackage = new CordonelFirmware
|
||||
// {
|
||||
// ReleaseNameVersion = releaseNameVersion,
|
||||
// PackageDescriptionFile = new FilePart(),
|
||||
// BinaryApplicationFiles = new List<FilePart>()
|
||||
// };
|
||||
|
||||
// try
|
||||
// {
|
||||
// // copy all firmware releases which later will be the "Cordonel Firmware" container
|
||||
// var files = Directory.GetFiles(FwUpdateFwSourceFolder + releaseNameVersion);
|
||||
// if (files.Length == 0)
|
||||
// {
|
||||
// var msg = Resources.StrFwPackageLoadFailed + @" " + releaseNameVersion;
|
||||
// LogErrorText(msg);
|
||||
// MessageBoxShow(msg, Resources.StrError, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// foreach (var f in files)
|
||||
// {
|
||||
// // extract the file name
|
||||
// var fileName = Path.GetFileName(f);
|
||||
// // load the ADF
|
||||
// if (f.Contains("product") && f.EndsWith(".txt"))
|
||||
// {
|
||||
// cordonelFwPackage.PackageDescriptionFile.FileName = fileName;
|
||||
// var file = File.ReadAllBytes(f);
|
||||
// cordonelFwPackage.PackageDescriptionFile.FileContent = new Byte[file.Length];
|
||||
// cordonelFwPackage.PackageDescriptionFile.FileContent = file;
|
||||
// }
|
||||
// // load the binaries
|
||||
// if (f.Contains("binfile") && f.EndsWith(".bin"))
|
||||
// {
|
||||
// var filePart = new FilePart { FileName = fileName };
|
||||
// var file = new List<Byte>(File.ReadAllBytes(f));
|
||||
// filePart.FileContent = new Byte[file.Count];
|
||||
// filePart.FileContent = file.ToArray();
|
||||
// cordonelFwPackage.BinaryApplicationFiles.Add(filePart);
|
||||
// }
|
||||
// }
|
||||
// _fwUpdatePackages.Add(cordonelFwPackage);
|
||||
// LogSuccessText(Resources.StrFwPackageLoadSuccess + " " + releaseNameVersion);
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// var msg = Resources.StrFwPackageLoadFailed + @" " + releaseNameVersion;
|
||||
// LogErrorText(msg);
|
||||
// MessageBoxShow(msg, Resources.StrError, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
// MessageBoxShow(e.ToString(), Resources.StrError, MessageBoxButtons.OK,
|
||||
// MessageBoxIcon.Error);
|
||||
// _processState = ProcessState.Error;
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
#endregion --------------------------------------- Load DB Contents -------------------------------------------
|
||||
|
||||
#region ------------------------------------------ Language ---------------------------------------------------
|
||||
|
||||
@@ -509,7 +509,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateLoader
|
||||
public FrmFwUpdateLoader()
|
||||
{
|
||||
var fwUpdateLoaderExePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
var fwUpdateLoaderConfigPath = Path.Combine(fwUpdateLoaderExePath, "Config");
|
||||
var fwUpdateLoaderConfigPath = Path.Combine(fwUpdateLoaderExePath, FwUpdateConfig.ConfigSubFolderName);
|
||||
|
||||
// Set the FW-Update SW destination folder to the FW-Update Loader exe path
|
||||
_fwUpdateSwDestinationPath = Path.Combine(fwUpdateLoaderExePath, FwUpdateProjectName);
|
||||
|
||||
Reference in New Issue
Block a user