More Common.CurrentUser related changes (IPERL/ORACLE)

This commit is contained in:
Milan Hanajik 2022-05-30 15:33:32 +02:00
parent f1f662a419
commit 33f5274a6d
10 changed files with 106 additions and 40 deletions

View File

@ -135,7 +135,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
///
SharedDatabase.TracingDB.RegisterWorkplaceObsolete(session,
workplace,
GlobalData.GetCurrentUserName(),
CurrentUser.UserName(),
GetIPAddress(),
"<multiple>",
WorkstepName,

View File

@ -990,7 +990,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
if (tr == null) tr = b.GetTestRslt(testName, 1); /// TODO: Remove this workaround for large watermeters with multiple parts at Q3
if (tr == null) continue;
double Q_ist = (tr.VolumeMaster != 0) ? (tr.FlowVolume * tr.VolumeCTV / tr.VolumeMaster) : (double)tr.FlowVolume;
double Q_ist = tr.Flow;
///
if (dbCfg.DebugLevel == DebugMode.Normal)
{
@ -1041,7 +1041,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = Units.ConvertTo(Unit.lph, tr.FlowMax) }); ///:8
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = Units.ConvertTo(Unit.lph, Q_ist) }); ///:9
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = tr.ConstMaster }); ///:10
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = Units.ConvertTo(Unit.lph, tr.FlowVolume) }); ///:11
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = Units.ConvertTo(Unit.lph, tr.Flow) }); ///:11
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = tr.ErrorMaster }); ///:12
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = (double)tr.FlowSetTime }); ///:13
cmd2.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 0 /* TODO */ }); ///:14
@ -1057,13 +1057,13 @@ namespace TBF.Rig.Output.DB.SensusOracle
///
cmd2.ExecuteNonQuery(); /// Returns nr. of updated rows
log.InfoFormat("VT_PRUEFDURCHFLUSS_PD inserted ({0}, {1}, {2}, {3}, {4} ...)",
ProducerAnbid, dbCfg.TestBenchGroupId + b.TestBenchId, b.BatchNr, pruefungsnr, Q_ist);
ProducerAnbid, dbCfg.TestBenchGroupId + b.TestBenchId, b.BatchNr, pruefungsnr, tr.Flow);
#endif
}
else
{
log.WarnFormat("SIM: VT_PRUEFDURCHFLUSS_PD inserted ({0}, {1}, {2}, {3}, {4} ...)",
ProducerAnbid, dbCfg.TestBenchGroupId + b.TestBenchId, b.BatchNr, pruefungsnr, Q_ist);
ProducerAnbid, dbCfg.TestBenchGroupId + b.TestBenchId, b.BatchNr, pruefungsnr, tr.Flow);
}
}
}
@ -1517,9 +1517,7 @@ namespace TBF.Rig.Output.DB.SensusOracle
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32,
Value = (record != null) ? record.RevWztyp : wmTypeRevision }); /// :6 rev_wztyp
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 1 }); /// :7 rev_wzpruefpunkt
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double,
Value = (mtr.VolumeRef > float.Epsilon) ? 1000 * mtr.TestRslt.FlowVolume * mtr.VolumeMeter / mtr.VolumeRef
: 0 }); /// :8 q_wz
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = 1000 * mtr.TestRslt.Flow }); /// :8 q_wz
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Double, Value = Math.Min(100.0, Math.Max(-100.0, mtr.Error)) }); /// :9 q_fehler
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = mtr.Passed ? 1 : 0 }); /// :10 q_best
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 0 }); /// :11 niz

View File

@ -2216,6 +2216,12 @@
<DependentUpon>PicturesTabPageCtrl.cs</DependentUpon>
</Compile>
<Compile Include="UI\Constants.cs" />
<Compile Include="UI\DummyDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\DummyDlg.Designer.cs">
<DependentUpon>DummyDlg.cs</DependentUpon>
</Compile>
<Compile Include="UI\Item\EditDouble.cs" />
<Compile Include="UI\Item\EditEnum.cs" />
<Compile Include="UI\Item\EditFloat.cs" />

38
TBF/UI/DummyDlg.Designer.cs generated Normal file
View File

@ -0,0 +1,38 @@
namespace TBF.UI
{
partial class DummyDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "DummyDlg";
}
#endregion
}
}

15
TBF/UI/DummyDlg.cs Normal file
View File

@ -0,0 +1,15 @@
///
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
using System.Windows.Forms;
namespace TBF.UI
{
public partial class DummyDlg : Form
{
public DummyDlg()
{
InitializeComponent();
}
}
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
/// Copyright (c) 2016-2022 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
@ -23,7 +23,7 @@ namespace TBF.UI.ResultsMI
public int FailedCount;
public bool Sent;
protected PreviousResultCtrl()
PreviousResultCtrl()
{
InitializeComponent();
}
@ -109,11 +109,13 @@ namespace TBF.UI.ResultsMI
/// Access only to thise who manage production tracing
GID[] rqrdGroupMembership = new GID[] { GID.TraceabilityManagement };
if ((new SharedDatabase.Forms.LoginDlg(GlobalData.GetCurrentUserName(), rqrdGroupMembership)).ShowDialog() != DialogResult.OK)
if ((new SharedDatabase.Forms.LoginDlg(CurrentUser.UserName(), rqrdGroupMembership, parent)).ShowDialog() != DialogResult.OK)
{
return;
}
Program.MainWnd.UpdateUser();
parent.OnReloadAndFix(this, new PreviousResultIdEventArgs(BatchNr));
}
#endif

View File

@ -35,13 +35,13 @@
this.vertSplitContainer = new System.Windows.Forms.SplitContainer();
this.horizSplitContainer = new System.Windows.Forms.SplitContainer();
this.filterGroupBox = new System.Windows.Forms.GroupBox();
this.reloadButton = new System.Windows.Forms.Button();
this.procedureTextBox = new System.Windows.Forms.TextBox();
this.procedureLabel = new System.Windows.Forms.Label();
this.toLabel = new System.Windows.Forms.Label();
this.fromLabel = new System.Windows.Forms.Label();
this.toDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.fromDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.reloadButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.vertSplitContainer)).BeginInit();
this.vertSplitContainer.Panel1.SuspendLayout();
this.vertSplitContainer.Panel2.SuspendLayout();
@ -154,6 +154,16 @@
this.filterGroupBox.TabStop = false;
this.filterGroupBox.Text = "Filter";
//
// reloadButton
//
this.reloadButton.Location = new System.Drawing.Point(1005, 23);
this.reloadButton.Name = "reloadButton";
this.reloadButton.Size = new System.Drawing.Size(37, 23);
this.reloadButton.TabIndex = 0;
this.reloadButton.Text = "@";
this.reloadButton.UseVisualStyleBackColor = true;
this.reloadButton.Click += new System.EventHandler(this.reloadButton_Click);
//
// procedureTextBox
//
this.procedureTextBox.Location = new System.Drawing.Point(460, 25);
@ -206,16 +216,6 @@
this.fromDateTimePicker.Size = new System.Drawing.Size(82, 20);
this.fromDateTimePicker.TabIndex = 17;
//
// reloadButton
//
this.reloadButton.Location = new System.Drawing.Point(1005, 23);
this.reloadButton.Name = "reloadButton";
this.reloadButton.Size = new System.Drawing.Size(37, 23);
this.reloadButton.TabIndex = 0;
this.reloadButton.Text = "@";
this.reloadButton.UseVisualStyleBackColor = true;
this.reloadButton.Click += new System.EventHandler(this.reloadButton_Click);
//
// PreviousResultsDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -228,6 +228,7 @@
this.Name = "PreviousResultsDlg";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Previous results";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PreviousResultsDlg_FormClosing);
this.Load += new System.EventHandler(this.PreviousResultsDlg_Load);
this.vertSplitContainer.Panel1.ResumeLayout(false);
this.vertSplitContainer.Panel2.ResumeLayout(false);

View File

@ -392,5 +392,10 @@ namespace TBF.UI.ResultsMI
UpdateButtons();
Redraw();
}
private void PreviousResultsDlg_FormClosing(object sender, FormClosingEventArgs e)
{
if (CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
}
}
}

View File

@ -283,13 +283,13 @@ namespace TBF.UI.Shared
{
#if TURA_IPERL || TURA_IPERL_NEW
/// Prevent 'Stop draining' by password
if (drain1Highlighted && !GlobalData.IsMemberOf(GID.TestingSpecialists))
if (drain1Highlighted && !CurrentUser.IsMemberOf(GID.TestingSpecialists))
{
if ((new SharedDatabase.Forms.LoginDlg(new GID[] { GID.TestingSpecialists })).ShowDialog() != DialogResult.OK)
var dlg = new DummyDlg();
if ((new SharedDatabase.Forms.LoginDlg(new GID[] { GID.TestingSpecialists }, dlg)).ShowDialog() != DialogResult.OK)
return;
if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
Bridge.Ui2Bench(UI2BenchCmd.StopDrainingTank1);
CurrentUser.Restore(dlg);
return;
}
#endif
@ -300,13 +300,13 @@ namespace TBF.UI.Shared
{
#if TURA_IPERL || TURA_IPERL_NEW
/// Prevent 'Stop draining' by password
if (drain1Highlighted && !GlobalData.IsMemberOf(GID.TestingSpecialists))
if (drain1Highlighted && !CurrentUser.IsMemberOf(GID.TestingSpecialists))
{
if ((new SharedDatabase.Forms.LoginDlg(new GID[] { GID.TestingSpecialists })).ShowDialog() != DialogResult.OK)
var dlg = new DummyDlg();
if ((new SharedDatabase.Forms.LoginDlg(new GID[] { GID.TestingSpecialists }, dlg)).ShowDialog() != DialogResult.OK)
return;
if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
Bridge.Ui2Bench(UI2BenchCmd.StopDrainingTank2);
CurrentUser.Restore(dlg);
return;
}
#endif
@ -317,13 +317,13 @@ namespace TBF.UI.Shared
{
#if TURA_IPERL || TURA_IPERL_NEW
/// Prevent 'Stop draining' by password
if (drain1Highlighted && !GlobalData.IsMemberOf(GID.TestingSpecialists))
if (drain1Highlighted && !CurrentUser.IsMemberOf(GID.TestingSpecialists))
{
if ((new SharedDatabase.Forms.LoginDlg(new GID[] { GID.TestingSpecialists })).ShowDialog() != DialogResult.OK)
var dlg = new DummyDlg();
if ((new SharedDatabase.Forms.LoginDlg(new GID[] { GID.TestingSpecialists }, dlg)).ShowDialog() != DialogResult.OK)
return;
if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
Bridge.Ui2Bench(UI2BenchCmd.StopDrainingTank3);
CurrentUser.Restore(dlg);
return;
}
#endif

View File

@ -47,12 +47,13 @@ namespace TBF.UI.Shared
public string Custom2Caption { set { customButton2.Text = value; } }
public string Custom3Caption { set { customButton3.Text = value; } }
public enum LockState
public enum LState
{
Locked, /// 'Unlock', 'Close' (=OK) are shown, all the othere are hidden
Unlocked, /// Unlock, Ok, Cancel, Add,Remove and all optional buttons are shown
}
LockState lockState;
LState lockState;
public LState LockState { get { return lockState; } }
bool buttonsRepositionsed;
@ -82,7 +83,7 @@ namespace TBF.UI.Shared
public SharedButtons()
{
InitializeComponent();
lockState = LockState.Locked;
lockState = LState.Locked;
MoreActive = false;
RequiredGroupMembership = null;
buttonCtrls = new System.Windows.Forms.Button[]
@ -179,7 +180,7 @@ namespace TBF.UI.Shared
okButton.Text = Strings.OkBtnText;
cancelButton.Visible = true;
ShowOrHideButtons(OptionalButtons, true);
lockState = LockState.Unlocked;
lockState = LState.Unlocked;
}
/// <summary>
@ -228,7 +229,7 @@ namespace TBF.UI.Shared
/// <param name="e"></param>
public void unlockBtn_Click(object sender, EventArgs e)
{
if (lockState == LockState.Locked)
if (lockState == LState.Locked)
{
if (!CurrentUser.IsMemberOf(RequiredGroupMembership))
{
@ -254,7 +255,7 @@ namespace TBF.UI.Shared
/// </summary>
private void okBtn_Click(object sender, EventArgs e)
{
if (lockState == LockState.Locked)
if (lockState == LState.Locked)
{
if (CancelClicked != null) CancelClicked(sender, e);
}