From 4fc7c92ba19b14248b956b8b3d4a1b18899b6e69 Mon Sep 17 00:00:00 2001 From: Roland Drabesch Date: Thu, 11 Aug 2022 16:30:01 +0200 Subject: [PATCH] need to movie this to pc and check after publish webserver --- Common/.vs/config/applicationhost.config | 2 +- .../Genesis/GenesisFile/MeterLutUpdate.cs | 23 +++ ...erRegisters.csproj.CoreCompileInputs.cache | 2 +- .../Cordonel/CordonelMetrologyLut.cs | 6 + .../Controllers/FileUpToDateController.cs | 21 +-- ...ToXlsHelper.csproj.CoreCompileInputs.cache | 2 +- .../FrmLutManagement.Designer.cs | 125 ++++++++++++- Common/Ui/GenesisToolBox/FrmLutManagement.cs | 22 ++- .../GenesisToolBox/FrmLutUpdate.Designer.cs | 166 ++++++++++++++---- Common/Ui/GenesisToolBox/FrmLutUpdate.cs | 136 +++++++++++++- .../Ui/GenesisToolBox/frmMainForm.Designer.cs | 26 +-- 11 files changed, 450 insertions(+), 81 deletions(-) diff --git a/Common/.vs/config/applicationhost.config b/Common/.vs/config/applicationhost.config index 40cde372..ebc79eca 100644 --- a/Common/.vs/config/applicationhost.config +++ b/Common/.vs/config/applicationhost.config @@ -155,7 +155,7 @@ - + diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs index d1b4c120..7e60094e 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisFile/MeterLutUpdate.cs @@ -965,6 +965,29 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile // validate the file return ValidateLutFile(); } + + /// + /// Load file from memory + /// + /// origin Name + /// /// list of bytes of the file strean + /// + /// + /// - Initial + /// + public Boolean LoadLutFromStream(String Name, List StreamData ) + { + + + LutFile = null; + LutFile = new MeterLutFile(Name) + { + BinData = StreamData + }; + + // validate the file + return ValidateLutFile(); + } #endregion } } \ No newline at end of file diff --git a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache index f22623aa..b81d5f66 100644 --- a/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache +++ b/Common/Hardware/WaterMeter/WaterMeterCore/WaterMeterRegisters/obj/Debug/WaterMeterRegisters.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3 +46bd00889699f5a20a4981a22f62b66368323855 diff --git a/Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs b/Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs index 17850db0..119b8044 100644 --- a/Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs +++ b/Common/Logic.PrdoctionToProductMapper/Cordonel/CordonelMetrologyLut.cs @@ -17,5 +17,11 @@ namespace Logic.ProductionToProductMapper.Cordonel public string Version { get; set; } public byte[] FileContent { get; set; } + public override string ToString() + { + return FileName; + } + + } } diff --git a/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs b/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs index b4584208..42318341 100644 --- a/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs +++ b/Common/Service/MeterProcessState/Controllers/FileUpToDateController.cs @@ -252,11 +252,11 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers public async Task GetLutFiles(int? Metersize = null, string Region = null, bool? ForProd = null) { - - return await Task.Run(() => + try { - try - { + return await Task.Run(() => + { + using (var dataacces = new SqlDataAccess(GlobalConfig.connectionString.Value)) { @@ -282,14 +282,15 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers return Request.CreateResponse(HttpStatusCode.OK, retDT); } - } - catch (Exception ex) - { - throw new ApplicationException($"file was not uploaded {ex.Message}"); - } - throw new ApplicationException("file was not uploaded"); }); + } + catch (Exception ex) + { + throw new ApplicationException($"file was not uploaded {ex.Message}"); + } + + throw new ApplicationException("file was not uploaded"); } diff --git a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache index 0028f628..2634cdb8 100644 --- a/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache +++ b/Common/Tools/Tools.JsonToXlsHelper/obj/Debug/Tools.JsonToXlsHelper.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -f64d563def603c89cafafa61a3219ba97e1e344c +81d60b90addc793525740e9993e19bf6665bd401 diff --git a/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs b/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs index f2239937..0fbec6ae 100644 --- a/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs +++ b/Common/Ui/GenesisToolBox/FrmLutManagement.Designer.cs @@ -1,4 +1,6 @@ -namespace Xylem.Common.Ui.GenesisToolBox +using Logic.ProductionToProductMapper.Cordonel; + +namespace Xylem.Common.Ui.GenesisToolBox { partial class FrmLutManagement { @@ -45,12 +47,22 @@ this.btnOpenLutFile = new System.Windows.Forms.Button(); this.btnStore = new System.Windows.Forms.Button(); this.dgvLuts = new System.Windows.Forms.DataGridView(); - this.cordonelMetrologyLutBindingSource = new System.Windows.Forms.BindingSource(this.components); this.btnLoad = new System.Windows.Forms.Button(); this.tbxVersion = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.tbxDataLengt = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); + this.cordonelMetrologyLutBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.fileIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.fileNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.meterSizeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.regionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.fileCrcDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.currentVerionForProdDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.dataLengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.versionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.fileContentDataGridViewImageColumn = new System.Windows.Forms.DataGridViewImageColumn(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvLuts)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cordonelMetrologyLutBindingSource)).BeginInit(); @@ -179,6 +191,17 @@ this.dgvLuts.AllowUserToDeleteRows = false; this.dgvLuts.AutoGenerateColumns = false; this.dgvLuts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvLuts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.idDataGridViewTextBoxColumn, + this.fileIdDataGridViewTextBoxColumn, + this.fileNameDataGridViewTextBoxColumn, + this.meterSizeDataGridViewTextBoxColumn, + this.regionDataGridViewTextBoxColumn, + this.fileCrcDataGridViewTextBoxColumn, + this.currentVerionForProdDataGridViewCheckBoxColumn, + this.dataLengthDataGridViewTextBoxColumn, + this.versionDataGridViewTextBoxColumn, + this.fileContentDataGridViewImageColumn}); this.dgvLuts.DataSource = this.cordonelMetrologyLutBindingSource; this.dgvLuts.Location = new System.Drawing.Point(3, 378); this.dgvLuts.Name = "dgvLuts"; @@ -231,6 +254,82 @@ this.label2.TabIndex = 62; this.label2.Text = "Data Length"; // + // cordonelMetrologyLutBindingSource + // + this.cordonelMetrologyLutBindingSource.DataSource = typeof(CordonelMetrologyLut); + // + // idDataGridViewTextBoxColumn + // + this.idDataGridViewTextBoxColumn.DataPropertyName = "Id"; + this.idDataGridViewTextBoxColumn.HeaderText = "Id"; + this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn"; + this.idDataGridViewTextBoxColumn.ReadOnly = true; + this.idDataGridViewTextBoxColumn.Visible = false; + // + // fileIdDataGridViewTextBoxColumn + // + this.fileIdDataGridViewTextBoxColumn.DataPropertyName = "FileId"; + this.fileIdDataGridViewTextBoxColumn.HeaderText = "FileId"; + this.fileIdDataGridViewTextBoxColumn.Name = "fileIdDataGridViewTextBoxColumn"; + this.fileIdDataGridViewTextBoxColumn.ReadOnly = true; + // + // fileNameDataGridViewTextBoxColumn + // + this.fileNameDataGridViewTextBoxColumn.DataPropertyName = "FileName"; + this.fileNameDataGridViewTextBoxColumn.HeaderText = "FileName"; + this.fileNameDataGridViewTextBoxColumn.Name = "fileNameDataGridViewTextBoxColumn"; + this.fileNameDataGridViewTextBoxColumn.ReadOnly = true; + // + // meterSizeDataGridViewTextBoxColumn + // + this.meterSizeDataGridViewTextBoxColumn.DataPropertyName = "MeterSize"; + this.meterSizeDataGridViewTextBoxColumn.HeaderText = "MeterSize"; + this.meterSizeDataGridViewTextBoxColumn.Name = "meterSizeDataGridViewTextBoxColumn"; + this.meterSizeDataGridViewTextBoxColumn.ReadOnly = true; + // + // regionDataGridViewTextBoxColumn + // + this.regionDataGridViewTextBoxColumn.DataPropertyName = "Region"; + this.regionDataGridViewTextBoxColumn.HeaderText = "Region"; + this.regionDataGridViewTextBoxColumn.Name = "regionDataGridViewTextBoxColumn"; + this.regionDataGridViewTextBoxColumn.ReadOnly = true; + // + // fileCrcDataGridViewTextBoxColumn + // + this.fileCrcDataGridViewTextBoxColumn.DataPropertyName = "FileCrc"; + this.fileCrcDataGridViewTextBoxColumn.HeaderText = "FileCrc"; + this.fileCrcDataGridViewTextBoxColumn.Name = "fileCrcDataGridViewTextBoxColumn"; + this.fileCrcDataGridViewTextBoxColumn.ReadOnly = true; + // + // currentVerionForProdDataGridViewCheckBoxColumn + // + this.currentVerionForProdDataGridViewCheckBoxColumn.DataPropertyName = "CurrentVerionForProd"; + this.currentVerionForProdDataGridViewCheckBoxColumn.HeaderText = "CurrentVerionForProd"; + this.currentVerionForProdDataGridViewCheckBoxColumn.Name = "currentVerionForProdDataGridViewCheckBoxColumn"; + this.currentVerionForProdDataGridViewCheckBoxColumn.ReadOnly = true; + // + // dataLengthDataGridViewTextBoxColumn + // + this.dataLengthDataGridViewTextBoxColumn.DataPropertyName = "DataLength"; + this.dataLengthDataGridViewTextBoxColumn.HeaderText = "DataLength"; + this.dataLengthDataGridViewTextBoxColumn.Name = "dataLengthDataGridViewTextBoxColumn"; + this.dataLengthDataGridViewTextBoxColumn.ReadOnly = true; + // + // versionDataGridViewTextBoxColumn + // + this.versionDataGridViewTextBoxColumn.DataPropertyName = "Version"; + this.versionDataGridViewTextBoxColumn.HeaderText = "Version"; + this.versionDataGridViewTextBoxColumn.Name = "versionDataGridViewTextBoxColumn"; + this.versionDataGridViewTextBoxColumn.ReadOnly = true; + // + // fileContentDataGridViewImageColumn + // + this.fileContentDataGridViewImageColumn.DataPropertyName = "FileContent"; + this.fileContentDataGridViewImageColumn.HeaderText = "FileContent"; + this.fileContentDataGridViewImageColumn.Name = "fileContentDataGridViewImageColumn"; + this.fileContentDataGridViewImageColumn.ReadOnly = true; + this.fileContentDataGridViewImageColumn.Visible = false; + // // FrmLutManagement // this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound; @@ -292,21 +391,31 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox tbxDataLengt; private System.Windows.Forms.Label label2; - private System.Windows.Forms.DataGridViewTextBoxColumn fileIdDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn fileNameDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn meterSizeDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn regionDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn cRCDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewCheckBoxColumn forProductionDataGridViewCheckBoxColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn5; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn6; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn9; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn10; + private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn11; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn12; + private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn1; + private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn fileIdDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn fileNameDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn meterSizeDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn regionDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn fileCrcDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn currentVerionForProdDataGridViewCheckBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn dataLengthDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn versionDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridViewCheckBoxColumn currentVerionForProdDataGridViewCheckBoxColumn; private System.Windows.Forms.DataGridViewImageColumn fileContentDataGridViewImageColumn; private System.Windows.Forms.BindingSource cordonelMetrologyLutBindingSource; } diff --git a/Common/Ui/GenesisToolBox/FrmLutManagement.cs b/Common/Ui/GenesisToolBox/FrmLutManagement.cs index bfc76ab3..ffd63b23 100644 --- a/Common/Ui/GenesisToolBox/FrmLutManagement.cs +++ b/Common/Ui/GenesisToolBox/FrmLutManagement.cs @@ -90,10 +90,7 @@ namespace Xylem.Common.Ui.GenesisToolBox public FrmLutManagement() { InitializeComponent(); - // - // cordonelMetrologyLutBindingSource - // - this.cordonelMetrologyLutBindingSource.DataSource = typeof(CordonelMetrologyLut); + var cultureInfo = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentUICulture = cultureInfo; @@ -239,13 +236,20 @@ namespace Xylem.Common.Ui.GenesisToolBox //sbUrl.Append($"&crc={_FileCrc}"); //sbUrl.Append($"&Metersize={_MeterSize.GetHashCode()}"); //sbUrl.Append($"&Region={_StrLutRegion}"); - - var ret = LocalWebRequest.GetRequest(sbUrl.ToString()); - + try + { + var ret = LocalWebRequest.GetRequest(sbUrl.ToString(), 80000); + + + var a = JsonConvert.DeserializeObject>(ret); + dgvLuts.DataSource = a; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } - var a = JsonConvert.DeserializeObject>(ret); - dgvLuts.DataSource = a; } diff --git a/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs b/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs index 2b3172c8..8273e9e1 100644 --- a/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs +++ b/Common/Ui/GenesisToolBox/FrmLutUpdate.Designer.cs @@ -56,17 +56,24 @@ this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.label4 = new System.Windows.Forms.Label(); + this.rbtProd = new System.Windows.Forms.RadioButton(); + this.cbxDbLuts = new System.Windows.Forms.ComboBox(); + this.rbtDb = new System.Windows.Forms.RadioButton(); + this.rbtFile = new System.Windows.Forms.RadioButton(); + this.lblSelectDb = new System.Windows.Forms.Label(); this.tbxFileMeterSize = new System.Windows.Forms.TextBox(); this.tbxFileCrc = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.lblLutFileLoadedInfo = new System.Windows.Forms.Label(); this.tbxLutFilePathName = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); + this.lvlSelechtFile = new System.Windows.Forms.Label(); this.btnOpenLutFile = new System.Windows.Forms.Button(); this.label9 = new System.Windows.Forms.Label(); this.lblUpdateTime = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); + this.btnLoadfromDb = new System.Windows.Forms.Button(); this.grpSetup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.groupBox1.SuspendLayout(); @@ -87,9 +94,9 @@ this.grpSetup.Controls.Add(this.lblConnectPcb); this.grpSetup.Controls.Add(this.label2); this.grpSetup.Controls.Add(this.cbComSlot); - this.grpSetup.Location = new System.Drawing.Point(12, 56); + this.grpSetup.Location = new System.Drawing.Point(12, 69); this.grpSetup.Name = "grpSetup"; - this.grpSetup.Size = new System.Drawing.Size(248, 212); + this.grpSetup.Size = new System.Drawing.Size(248, 250); this.grpSetup.TabIndex = 24; this.grpSetup.TabStop = false; this.grpSetup.Text = "Cordonel"; @@ -233,7 +240,7 @@ // this.lblWaitingForMeterResponse.AutoSize = true; this.lblWaitingForMeterResponse.ForeColor = System.Drawing.Color.Red; - this.lblWaitingForMeterResponse.Location = new System.Drawing.Point(532, 280); + this.lblWaitingForMeterResponse.Location = new System.Drawing.Point(529, 331); this.lblWaitingForMeterResponse.Name = "lblWaitingForMeterResponse"; this.lblWaitingForMeterResponse.Size = new System.Drawing.Size(182, 13); this.lblWaitingForMeterResponse.TabIndex = 18; @@ -241,7 +248,7 @@ // // btnStopFwUpdate // - this.btnStopFwUpdate.Location = new System.Drawing.Point(310, 181); + this.btnStopFwUpdate.Location = new System.Drawing.Point(310, 219); this.btnStopFwUpdate.Name = "btnStopFwUpdate"; this.btnStopFwUpdate.Size = new System.Drawing.Size(116, 25); this.btnStopFwUpdate.TabIndex = 8; @@ -251,7 +258,7 @@ // // btnDownloadLutFile // - this.btnDownloadLutFile.Location = new System.Drawing.Point(310, 147); + this.btnDownloadLutFile.Location = new System.Drawing.Point(310, 188); this.btnDownloadLutFile.Name = "btnDownloadLutFile"; this.btnDownloadLutFile.Size = new System.Drawing.Size(116, 25); this.btnDownloadLutFile.TabIndex = 0; @@ -262,7 +269,7 @@ // lblOverall // this.lblOverall.AutoSize = true; - this.lblOverall.Location = new System.Drawing.Point(21, 317); + this.lblOverall.Location = new System.Drawing.Point(18, 368); this.lblOverall.Name = "lblOverall"; this.lblOverall.Size = new System.Drawing.Size(80, 13); this.lblOverall.TabIndex = 7; @@ -270,7 +277,7 @@ // // barSingleProgressUpdate // - this.barSingleProgressUpdate.Location = new System.Drawing.Point(12, 296); + this.barSingleProgressUpdate.Location = new System.Drawing.Point(9, 347); this.barSingleProgressUpdate.Name = "barSingleProgressUpdate"; this.barSingleProgressUpdate.Size = new System.Drawing.Size(702, 18); this.barSingleProgressUpdate.TabIndex = 6; @@ -279,7 +286,7 @@ // lblActualProcess // this.lblActualProcess.AutoSize = true; - this.lblActualProcess.Location = new System.Drawing.Point(21, 280); + this.lblActualProcess.Location = new System.Drawing.Point(18, 331); this.lblActualProcess.Name = "lblActualProcess"; this.lblActualProcess.Size = new System.Drawing.Size(76, 13); this.lblActualProcess.TabIndex = 4; @@ -287,7 +294,7 @@ // // barOverallProgressUpdate // - this.barOverallProgressUpdate.Location = new System.Drawing.Point(12, 333); + this.barOverallProgressUpdate.Location = new System.Drawing.Point(9, 384); this.barOverallProgressUpdate.Name = "barOverallProgressUpdate"; this.barOverallProgressUpdate.Size = new System.Drawing.Size(702, 18); this.barOverallProgressUpdate.TabIndex = 3; @@ -315,7 +322,7 @@ // pictureBox1 // this.pictureBox1.Image = global::Xylem.Common.Ui.GenesisToolBox.Properties.Resources.SensusLogoXylem; - this.pictureBox1.Location = new System.Drawing.Point(611, 3); + this.pictureBox1.Location = new System.Drawing.Point(609, 9); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(102, 54); this.pictureBox1.TabIndex = 29; @@ -327,6 +334,13 @@ // // groupBox1 // + this.groupBox1.Controls.Add(this.btnLoadfromDb); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.rbtProd); + this.groupBox1.Controls.Add(this.cbxDbLuts); + this.groupBox1.Controls.Add(this.rbtDb); + this.groupBox1.Controls.Add(this.rbtFile); + this.groupBox1.Controls.Add(this.lblSelectDb); this.groupBox1.Controls.Add(this.tbxFileMeterSize); this.groupBox1.Controls.Add(this.tbxFileCrc); this.groupBox1.Controls.Add(this.label3); @@ -334,19 +348,84 @@ this.groupBox1.Controls.Add(this.lblLutFileLoadedInfo); this.groupBox1.Controls.Add(this.btnDownloadLutFile); this.groupBox1.Controls.Add(this.tbxLutFilePathName); - this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.lvlSelechtFile); this.groupBox1.Controls.Add(this.btnStopFwUpdate); this.groupBox1.Controls.Add(this.btnOpenLutFile); - this.groupBox1.Location = new System.Drawing.Point(278, 56); + this.groupBox1.Location = new System.Drawing.Point(275, 69); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(436, 212); + this.groupBox1.Size = new System.Drawing.Size(436, 250); this.groupBox1.TabIndex = 28; this.groupBox1.TabStop = false; this.groupBox1.Text = "Lookup Table File"; // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(12, 28); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(68, 13); + this.label4.TabIndex = 19; + this.label4.Text = "LUT Source:"; + // + // rbtProd + // + this.rbtProd.AutoSize = true; + this.rbtProd.Location = new System.Drawing.Point(270, 24); + this.rbtProd.Name = "rbtProd"; + this.rbtProd.Size = new System.Drawing.Size(96, 17); + this.rbtProd.TabIndex = 18; + this.rbtProd.TabStop = true; + this.rbtProd.Text = "Prod Database"; + this.rbtProd.UseVisualStyleBackColor = true; + this.rbtProd.Click += new System.EventHandler(this.SwitchView); + // + // cbxDbLuts + // + this.cbxDbLuts.FormattingEnabled = true; + this.cbxDbLuts.Location = new System.Drawing.Point(82, 53); + this.cbxDbLuts.Name = "cbxDbLuts"; + this.cbxDbLuts.Size = new System.Drawing.Size(333, 21); + this.cbxDbLuts.TabIndex = 17; + this.cbxDbLuts.Visible = false; + this.cbxDbLuts.SelectedIndexChanged += new System.EventHandler(this.cbxDbLuts_SelectedIndexChanged); + // + // rbtDb + // + this.rbtDb.AutoSize = true; + this.rbtDb.Location = new System.Drawing.Point(150, 24); + this.rbtDb.Name = "rbtDb"; + this.rbtDb.Size = new System.Drawing.Size(120, 17); + this.rbtDb.TabIndex = 16; + this.rbtDb.TabStop = true; + this.rbtDb.Text = "Research Database"; + this.rbtDb.UseVisualStyleBackColor = true; + this.rbtDb.Click += new System.EventHandler(this.SwitchView); + // + // rbtFile + // + this.rbtFile.AutoSize = true; + this.rbtFile.Location = new System.Drawing.Point(103, 24); + this.rbtFile.Name = "rbtFile"; + this.rbtFile.Size = new System.Drawing.Size(41, 17); + this.rbtFile.TabIndex = 15; + this.rbtFile.TabStop = true; + this.rbtFile.Text = "File"; + this.rbtFile.UseVisualStyleBackColor = true; + this.rbtFile.Click += new System.EventHandler(this.SwitchView); + // + // lblSelectDb + // + this.lblSelectDb.AutoSize = true; + this.lblSelectDb.Location = new System.Drawing.Point(12, 58); + this.lblSelectDb.Name = "lblSelectDb"; + this.lblSelectDb.Size = new System.Drawing.Size(64, 13); + this.lblSelectDb.TabIndex = 14; + this.lblSelectDb.Text = "Select LUT:"; + this.lblSelectDb.Visible = false; + // // tbxFileMeterSize // - this.tbxFileMeterSize.Location = new System.Drawing.Point(104, 148); + this.tbxFileMeterSize.Location = new System.Drawing.Point(104, 223); this.tbxFileMeterSize.Name = "tbxFileMeterSize"; this.tbxFileMeterSize.ReadOnly = true; this.tbxFileMeterSize.Size = new System.Drawing.Size(68, 20); @@ -354,7 +433,7 @@ // // tbxFileCrc // - this.tbxFileCrc.Location = new System.Drawing.Point(104, 118); + this.tbxFileCrc.Location = new System.Drawing.Point(104, 193); this.tbxFileCrc.Name = "tbxFileCrc"; this.tbxFileCrc.ReadOnly = true; this.tbxFileCrc.Size = new System.Drawing.Size(68, 20); @@ -363,7 +442,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(10, 152); + this.label3.Location = new System.Drawing.Point(10, 227); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(79, 13); this.label3.TabIndex = 11; @@ -372,7 +451,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(10, 122); + this.label1.Location = new System.Drawing.Point(10, 197); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(75, 13); this.label1.TabIndex = 10; @@ -381,7 +460,7 @@ // lblLutFileLoadedInfo // this.lblLutFileLoadedInfo.AutoSize = true; - this.lblLutFileLoadedInfo.Location = new System.Drawing.Point(10, 60); + this.lblLutFileLoadedInfo.Location = new System.Drawing.Point(6, 107); this.lblLutFileLoadedInfo.Name = "lblLutFileLoadedInfo"; this.lblLutFileLoadedInfo.Size = new System.Drawing.Size(97, 13); this.lblLutFileLoadedInfo.TabIndex = 9; @@ -389,24 +468,26 @@ // // tbxLutFilePathName // - this.tbxLutFilePathName.Location = new System.Drawing.Point(104, 27); + this.tbxLutFilePathName.Location = new System.Drawing.Point(82, 76); this.tbxLutFilePathName.Name = "tbxLutFilePathName"; this.tbxLutFilePathName.ReadOnly = true; - this.tbxLutFilePathName.Size = new System.Drawing.Size(322, 20); + this.tbxLutFilePathName.Size = new System.Drawing.Size(333, 20); this.tbxLutFilePathName.TabIndex = 2; + this.tbxLutFilePathName.Visible = false; // - // label4 + // lvlSelechtFile // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(10, 30); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(63, 13); - this.label4.TabIndex = 1; - this.label4.Text = "Path Name:"; + this.lvlSelechtFile.AutoSize = true; + this.lvlSelechtFile.Location = new System.Drawing.Point(10, 79); + this.lvlSelechtFile.Name = "lvlSelechtFile"; + this.lvlSelechtFile.Size = new System.Drawing.Size(63, 13); + this.lvlSelechtFile.TabIndex = 1; + this.lvlSelechtFile.Text = "Path Name:"; + this.lvlSelechtFile.Visible = false; // // btnOpenLutFile // - this.btnOpenLutFile.Location = new System.Drawing.Point(310, 112); + this.btnOpenLutFile.Location = new System.Drawing.Point(310, 156); this.btnOpenLutFile.Name = "btnOpenLutFile"; this.btnOpenLutFile.Size = new System.Drawing.Size(116, 26); this.btnOpenLutFile.TabIndex = 0; @@ -417,7 +498,7 @@ // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(250, 280); + this.label9.Location = new System.Drawing.Point(247, 331); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(101, 13); this.label9.TabIndex = 30; @@ -426,7 +507,7 @@ // lblUpdateTime // this.lblUpdateTime.AutoSize = true; - this.lblUpdateTime.Location = new System.Drawing.Point(357, 280); + this.lblUpdateTime.Location = new System.Drawing.Point(354, 331); this.lblUpdateTime.Name = "lblUpdateTime"; this.lblUpdateTime.Size = new System.Drawing.Size(28, 13); this.lblUpdateTime.TabIndex = 31; @@ -442,12 +523,22 @@ this.label7.TabIndex = 32; this.label7.Text = "Cordonel LUT Update"; // + // btnLoadfromDb + // + this.btnLoadfromDb.Location = new System.Drawing.Point(310, 124); + this.btnLoadfromDb.Name = "btnLoadfromDb"; + this.btnLoadfromDb.Size = new System.Drawing.Size(116, 26); + this.btnLoadfromDb.TabIndex = 20; + this.btnLoadfromDb.Text = "Load from Db"; + this.btnLoadfromDb.UseVisualStyleBackColor = true; + this.btnLoadfromDb.Click += new System.EventHandler(this.btnLoadfromDb_Click); + // // FrmLutUpdate // this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(723, 366); + this.ClientSize = new System.Drawing.Size(723, 461); this.Controls.Add(this.label7); this.Controls.Add(this.lblUpdateTime); this.Controls.Add(this.label9); @@ -461,7 +552,7 @@ this.Controls.Add(this.grpSetup); this.Controls.Add(this.barOverallProgressUpdate); this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(739, 405); + this.MaximumSize = new System.Drawing.Size(739, 500); this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(739, 405); this.Name = "FrmLutUpdate"; @@ -500,7 +591,7 @@ private System.Windows.Forms.Label lblFwVersion; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.TextBox tbxLutFilePathName; - private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label lvlSelechtFile; private System.Windows.Forms.Button btnOpenLutFile; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label lblUpdateTime; @@ -518,5 +609,12 @@ private System.Windows.Forms.Label label7; private System.Windows.Forms.TextBox tbxRegionRadio; private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label lblSelectDb; + private System.Windows.Forms.RadioButton rbtDb; + private System.Windows.Forms.RadioButton rbtFile; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.RadioButton rbtProd; + private System.Windows.Forms.ComboBox cbxDbLuts; + private System.Windows.Forms.Button btnLoadfromDb; } } \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/FrmLutUpdate.cs b/Common/Ui/GenesisToolBox/FrmLutUpdate.cs index 6606cdc1..1c2a8102 100644 --- a/Common/Ui/GenesisToolBox/FrmLutUpdate.cs +++ b/Common/Ui/GenesisToolBox/FrmLutUpdate.cs @@ -1,14 +1,19 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Globalization; +using System.Linq; using System.Reflection; +using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Logic.ProductionToProductMapper.Cordonel; +using Newtonsoft.Json; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile; using Xylem.Common.Hardware.WaterMeter.WaterMeterCore; +using Xylem.Common.Logic.SoftwareAccessHelper; using Xylem.Common.Utils.ProcessExec.EventArguments; @@ -158,7 +163,7 @@ namespace Xylem.Common.Ui.GenesisToolBox btnStopFwUpdate.Enabled = false; } #endregion - + #region BoardControls private void Connect() { @@ -463,7 +468,7 @@ namespace Xylem.Common.Ui.GenesisToolBox })); } #endregion - + #region Checks private void CheckUpdateEnabled() { @@ -589,7 +594,7 @@ namespace Xylem.Common.Ui.GenesisToolBox LogText("File Meter Size: " + tbxFileMeterSize.Text); LogText("File LUT CRC: " + tbxFileCrc.Text); LogText(StrSeparator); - + } else { @@ -681,6 +686,129 @@ namespace Xylem.Common.Ui.GenesisToolBox } #endregion + + + private void SwitchView(object sender, EventArgs e) + { + btnLoadfromDb.Enabled = false; + bool File = rbtFile.Checked; + cbxDbLuts.Visible = !File; + lblSelectDb.Visible = !File; + btnLoadfromDb.Visible = !File; + + lvlSelechtFile.Visible = File; + tbxLutFilePathName.Visible = File; + btnOpenLutFile.Visible = File; + if (!File) + { + LoadDbLuts(rbtProd.Checked); + } + + } + + private void LoadDbLuts(bool Prod) + { + + StringBuilder sbUrl = new StringBuilder(); + // sbUrl.Append("http://10.49.40.25/MeterProcessState/api/FileUpToDate/GetLutFiles"); + sbUrl.Append("http://localhost:56011/api/FileUpToDate/GetLutFiles"); + //sbUrl.Append($"?DataLength={_DataLength}"); + //sbUrl.Append($"&version={_Version}"); + //sbUrl.Append($"&crc={_FileCrc}"); + //sbUrl.Append($"&Metersize={_MeterSize.GetHashCode()}"); + //sbUrl.Append($"&Region={_StrLutRegion}"); + try + { + + var ret = LocalWebRequest.GetRequest(sbUrl.ToString(), 80000); + + + var a = JsonConvert.DeserializeObject>(ret); + cbxDbLuts.Items.Clear(); + + foreach (var item in a) + { + if (!Prod || item.CurrentVerionForProd) + { + cbxDbLuts.Items.Add(item); + } + + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + + + } + + private void cbxDbLuts_SelectedIndexChanged(object sender, EventArgs e) + { + if (cbxDbLuts.SelectedItem is CordonelMetrologyLut lut) + { + btnLoadfromDb.Enabled = true; + } + else + { + btnLoadfromDb.Enabled = false; + } + } + + private void btnLoadfromDb_Click(object sender, EventArgs e) + { + if (cbxDbLuts.SelectedItem is CordonelMetrologyLut lut) + { + lblLutFileLoadedInfo.Text = ""; + tbxLutFilePathName.Text = $"fromDB{lut.FileName}"; + if (_meterLutUpdate == null) + { + _meterLutUpdate = new MeterLutUpdate(_currentGenesis); + _meterLutUpdate.OnProcessUpdate += ProcessUpdate_Event; + } + + if (_meterLutUpdate == null) + { + return; + } + + if (_meterLutUpdate.LoadLutFromStream(lut.FileName, lut.FileContent.ToList())) + { + lblLutFileLoadedInfo.ForeColor = Color.Green; + lblLutFileLoadedInfo.Text = StrLutFileValid; + tbxFileCrc.Text = $@"0x{_meterLutUpdate.LutFile.FileCrc:X4}"; + tbxFileMeterSize.Text = MeterSizeConverter.ConvertMeterSizeEnumToSizeName(_meterLutUpdate.LutFile.MeterSize); + _lutFileValid = true; + + LogText("File Meter Size: " + tbxFileMeterSize.Text); + LogText("File LUT CRC: " + tbxFileCrc.Text); + LogText(StrSeparator); + + } + else + { + var txt = ""; + if (!string.IsNullOrEmpty(_meterLutUpdate?.ErrorMessage)) + { + txt += _meterLutUpdate?.ErrorMessage; + } + else + { + txt = StrLutFileInvalid; + } + + LogErrorText(txt); + lblLutFileLoadedInfo.ForeColor = Color.Red; + lblLutFileLoadedInfo.Text = txt; + tbxFileCrc.Text = @" --- "; + tbxFileMeterSize.Text = @" --- "; + _lutFileValid = false; + } + + CheckUpdateEnabled(); + _resetTimeMeasurement = true; + } + } } -} + } diff --git a/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs b/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs index f5414780..d9830c22 100644 --- a/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs +++ b/Common/Ui/GenesisToolBox/frmMainForm.Designer.cs @@ -42,6 +42,7 @@ this.btnAlarm = new System.Windows.Forms.Button(); this.btnSetup = new System.Windows.Forms.Button(); this.gpLAA = new System.Windows.Forms.GroupBox(); + this.button5 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.btnPara = new System.Windows.Forms.Button(); this.btnRegHistory = new System.Windows.Forms.Button(); @@ -53,7 +54,6 @@ this.BtnFileSplit = new System.Windows.Forms.Button(); this.btnFiles = new System.Windows.Forms.Button(); this.btnLegacyTestApp = new System.Windows.Forms.Button(); - this.button5 = new System.Windows.Forms.Button(); this.gpGerneral.SuspendLayout(); this.gpLAA.SuspendLayout(); this.gbDeveloper.SuspendLayout(); @@ -123,7 +123,7 @@ // // btnConfiguration // - this.btnConfiguration.Location = new System.Drawing.Point(7, 365); + this.btnConfiguration.Location = new System.Drawing.Point(112, 363); this.btnConfiguration.Name = "btnConfiguration"; this.btnConfiguration.Size = new System.Drawing.Size(152, 40); this.btnConfiguration.TabIndex = 14; @@ -219,6 +219,17 @@ this.gpLAA.TabStop = false; this.gpLAA.Text = "Production LAA"; // + // button5 + // + this.button5.Location = new System.Drawing.Point(6, 290); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(152, 40); + this.button5.TabIndex = 21; + this.button5.Text = "Mapping NA"; + this.button5.UseMnemonic = false; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // // button2 // this.button2.Location = new System.Drawing.Point(6, 244); @@ -338,17 +349,6 @@ this.btnLegacyTestApp.UseVisualStyleBackColor = true; this.btnLegacyTestApp.Click += new System.EventHandler(this.btnLegacyTestApp_Click); // - // button5 - // - this.button5.Location = new System.Drawing.Point(6, 290); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(152, 40); - this.button5.TabIndex = 21; - this.button5.Text = "Mapping NA"; - this.button5.UseMnemonic = false; - this.button5.UseVisualStyleBackColor = true; - this.button5.Click += new System.EventHandler(this.button5_Click); - // // FrmMainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);