Compare commits

...
59 changed files with 1482 additions and 327 deletions
+2 -2
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;MUNICH</DefineConstants>
<DefineConstants>TRACE;DEBUG;DEWA_300</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -30,7 +30,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MUNICH</DefineConstants>
<DefineConstants>TRACE;DEWA_300</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+15
View File
@@ -44,6 +44,11 @@ namespace Config.Entities
public virtual string AltProcName { get; set; } /// Alternative procedure name (null or string.Empty = no alt. procedure)
public virtual int AltProcPeriod { get; set; } /// Period of alternative procedures (0 = no alt. procedure)
public virtual float DN { get; set; } /// Not mapped to DB, valid in ProceduresCtrl for procedure filtering only
public virtual float Qn { get; set; } /// - ' ' -
public virtual string MClass { get; set; } /// - ' ' -
public virtual string Producer { get; set; } /// - ' ' -
public virtual IList<ComponentProcedure> MoreParams { get; set; }
public virtual IList<Test> Tests { get; set; }
@@ -65,6 +70,11 @@ namespace Config.Entities
Watermeters = string.Empty;
Description = string.Empty;
LongDescription = string.Empty;
DN = 0;
Qn = 0;
MClass = string.Empty;
Producer = string.Empty;
}
public Procedure(string name, int itemNr)
@@ -103,6 +113,11 @@ namespace Config.Entities
result.AltProcName = AltProcName;
result.AltProcPeriod = AltProcPeriod;
result.DN = DN;
result.Qn = Qn;
result.MClass = MClass;
result.Producer = Producer;
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone(result)); }
foreach (var test in Tests) { result.Tests.Add(test.Clone()); }
-2
View File
@@ -18,9 +18,7 @@ namespace Config.Mappings
Map(x => x.Publish);
Map(x => x.DoEvaluate)
.Column("Evaluate");
#if TEST_PROFILES
Map(x => x.Qtg);
#endif
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.Volume);
-5
View File
@@ -29,11 +29,6 @@ namespace Results.Entities
public virtual float DensityCorr { get; set; } /// Density correction in [kg/m3]
public virtual float Custom2 { get; set; }
public virtual float Custom3 { get; set; }
public virtual int Counter1 { get; set; }
public virtual int Counter2 { get; set; }
public virtual int Counter3 { get; set; }
public virtual int Counter4 { get; set; }
public virtual int Counter5 { get; set; }
public virtual int Counter6 { get; set; }
public virtual int Counter7 { get; set; }
public virtual int Counter8 { get; set; }
+14 -1
View File
@@ -131,7 +131,13 @@ namespace Results.Entities
public virtual float Custom8 { get; set; } /// [°C] T ref lo end
public virtual float Custom9 { get; set; } /// [°C] T ref lo min
public virtual float Custom10 { get; set; } /// [°C] T ref lo max
public virtual int Counter1 { get; set; }
public virtual int Counter2 { get; set; }
public virtual int Counter3 { get; set; }
public virtual int Counter4 { get; set; }
public virtual int Counter5 { get; set; }
/// Wrappers
public virtual string Name() { return Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
public virtual int Repeats() { return TestData.Repeats; }
@@ -322,6 +328,7 @@ namespace Results.Entities
FlowEnd = src.FlowEnd;
FlowMin = src.FlowMin;
FlowMax = src.FlowMax;
Custom1 = src.Custom1;
Custom2 = src.Custom2;
Custom3 = src.Custom3;
@@ -332,6 +339,12 @@ namespace Results.Entities
Custom8 = src.Custom8;
Custom9 = src.Custom9;
Custom10 = src.Custom10;
Counter1 = src.Counter1;
Counter2 = src.Counter2;
Counter3 = src.Counter3;
Counter4 = src.Counter4;
Counter5 = src.Counter5;
}
/// <summary> Wrapper </summary>
+2 -5
View File
@@ -26,16 +26,13 @@ namespace Results.Mappings
.Column("Custom1"); ;
Map(x => x.Custom2);
Map(x => x.Custom3);
Map(x => x.Counter1);
Map(x => x.Counter2);
Map(x => x.Counter3);
Map(x => x.Counter4);
Map(x => x.Counter5);
Map(x => x.Counter6);
Map(x => x.Counter7);
Map(x => x.Counter8);
Map(x => x.Counter9);
Map(x => x.Counter10);
Map(x => x.StartTime);
Map(x => x.EndTime);
Map(x => x.Dirty);
-2
View File
@@ -12,9 +12,7 @@ namespace Results.Mappings
{
Id(x => x.Id);
Map(x => x.Name);
#if TEST_PROFILES
Map(x => x.Qtg);
#endif
Map(x => x.Qfrom);
Map(x => x.Qto);
Map(x => x.TargetVolume);
+7 -1
View File
@@ -117,6 +117,12 @@ namespace Results.Mappings
Map(x => x.Custom6);
Map(x => x.Custom7);
Map(x => x.Custom8);
}
Map(x => x.Counter1);
Map(x => x.Counter2);
Map(x => x.Counter3);
Map(x => x.Counter4);
Map(x => x.Counter5);
}
}
}
+2 -2
View File
@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;MUNICH</DefineConstants>
<DefineConstants>TRACE;DEBUG;DEWA_300</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -29,7 +29,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MUNICH</DefineConstants>
<DefineConstants>TRACE;DEWA_300</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+11 -5
View File
@@ -91,16 +91,22 @@ namespace Results
#endif
}
public static void GetCounterStates(Results.Entities.TestRslt tstRslt, int[] counters)
{
if (tstRslt != null)
{
tstRslt.Counter1 = ((counters != null) && (counters.Length >= 1)) ? counters[0] : 0;
tstRslt.Counter2 = ((counters != null) && (counters.Length >= 2)) ? counters[1] : 0;
tstRslt.Counter3 = ((counters != null) && (counters.Length >= 3)) ? counters[2] : 0;
tstRslt.Counter4 = ((counters != null) && (counters.Length >= 4)) ? counters[3] : 0;
tstRslt.Counter5 = ((counters != null) && (counters.Length >= 5)) ? counters[4] : 0;
}
}
public static void GetCounterStates(Results.Entities.Batch batch, int[] counters)
{
if (batch != null)
{
batch.Counter1 = ((counters != null) && (counters.Length >= 1)) ? counters[0] : 0;
batch.Counter2 = ((counters != null) && (counters.Length >= 2)) ? counters[1] : 0;
batch.Counter3 = ((counters != null) && (counters.Length >= 3)) ? counters[2] : 0;
batch.Counter4 = ((counters != null) && (counters.Length >= 4)) ? counters[3] : 0;
batch.Counter5 = ((counters != null) && (counters.Length >= 5)) ? counters[4] : 0;
batch.Counter6 = ((counters != null) && (counters.Length >= 6)) ? counters[5] : 0;
batch.Counter7 = ((counters != null) && (counters.Length >= 7)) ? counters[6] : 0;
batch.Counter8 = ((counters != null) && (counters.Length >= 8)) ? counters[7] : 0;
+90 -11
View File
@@ -485,17 +485,96 @@ namespace Results
AllItems.Add(new WMeterRsltItemSpec(ItemID.Table_row_nr, "Table row #", Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? TableRowNr.ToString() : string.Format(f, TableRowNr)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Table_column_nr, "Table column #", Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? TableColumnNr.ToString() : string.Format(f, TableColumnNr)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.WMRemark, string.Format("{0} {1}", Strings.Water_Meter, Strings.Remark), Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => FormatStr(f, w.Remark)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter1, string.Format(Strings.Counter_0, 1), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter1)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter2, string.Format(Strings.Counter_0, 2), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter2)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter3, string.Format(Strings.Counter_0, 3), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter3)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter4, string.Format(Strings.Counter_0, 4), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter4)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter5, string.Format(Strings.Counter_0, 5), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter5)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter6, string.Format(Strings.Counter_0, 6), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter6)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter7, string.Format(Strings.Counter_0, 7), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter7)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter8, string.Format(Strings.Counter_0, 8), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter8)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter9, string.Format(Strings.Counter_0, 9), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter9)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter10, string.Format(Strings.Counter_0, 10), Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => FormatInt(f, w.Batch.Counter10)));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter1,
string.Format(Strings.Counter_0, 1),
Quantity.Number,
ItemCategory.Other,
(w, t, u, f, p) =>
{
return (w.GetTestRslt(t) != null) ? FormatInt(f, w.GetTestRslt(t).Counter1) : string.Empty;
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter2,
string.Format(Strings.Counter_0, 2),
Quantity.Number,
ItemCategory.Other,
(w, t, u, f, p) =>
{
return (w.GetTestRslt(t) != null) ? FormatInt(f, w.GetTestRslt(t).Counter2) : string.Empty;
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter3,
string.Format(Strings.Counter_0, 3),
Quantity.Number,
ItemCategory.Other,
(w, t, u, f, p) =>
{
return (w.GetTestRslt(t) != null) ? FormatInt(f, w.GetTestRslt(t).Counter3) : string.Empty;
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter4,
string.Format(Strings.Counter_0, 4),
Quantity.Number,
ItemCategory.Other,
(w, t, u, f, p) =>
{
return (w.GetTestRslt(t) != null) ? FormatInt(f, w.GetTestRslt(t).Counter4) : string.Empty;
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter5,
string.Format(Strings.Counter_0, 5),
Quantity.Number,
ItemCategory.Other,
(w, t, u, f, p) =>
{
return (w.GetTestRslt(t) != null) ? FormatInt(f, w.GetTestRslt(t).Counter5) : string.Empty;
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter6,
string.Format(Strings.Counter_0, 6),
Quantity.Number,
ItemCategory.TestResult,
(w, t, u, f, p) =>
{
return FormatInt(f, w.Batch.Counter6);
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter7,
string.Format(Strings.Counter_0, 7),
Quantity.Number,
ItemCategory.TestResult,
(w, t, u, f, p) =>
{
return FormatInt(f, w.Batch.Counter7);
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter8,
string.Format(Strings.Counter_0, 8),
Quantity.Number,
ItemCategory.TestResult,
(w, t, u, f, p) =>
{
return FormatInt(f, w.Batch.Counter8);
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter9,
string.Format(Strings.Counter_0, 9),
Quantity.Number,
ItemCategory.TestResult,
(w, t, u, f, p) =>
{
return FormatInt(f, w.Batch.Counter9);
}));
AllItems.Add(new WMeterRsltItemSpec(ItemID.Counter10,
string.Format(Strings.Counter_0, 10),
Quantity.Number,
ItemCategory.TestResult,
(w, t, u, f, p) =>
{
return FormatInt(f, w.Batch.Counter10);
}));
}
/// To be updated by Output.FileWriter or Output.Printer
+2 -2
View File
@@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;MUNICH</DefineConstants>
<DefineConstants>TRACE;DEBUG;DEWA_300</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -32,7 +32,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MUNICH</DefineConstants>
<DefineConstants>TRACE;DEWA_300</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+1
View File
@@ -5,6 +5,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TBF", "TBF\TBF.csproj", "{8
ProjectSection(ProjectDependencies) = postProject
{EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF} = {EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF}
{0C0A1F4D-1363-4544-A7C5-196C76D26CCA} = {0C0A1F4D-1363-4544-A7C5-196C76D26CCA}
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE} = {46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Results", "Results\Results.csproj", "{9D0DCC88-DC81-47EB-9FDD-4C3907871BFB}"
+21 -20
View File
@@ -375,23 +375,7 @@ namespace TBF.BenchControl.Elde
public void RunDeviceBefore()
{
if (DebugLevel == DebugMode.Simulate) return;
controlCom.RunDeviceBefore();
previousEmergencyStop = emergencyStop;
emergencyStop = (controlCom.StatusP & StatusP.EmgcyStopActive) != 0;
if (emergencyStop && !previousEmergencyStop)
{
Program.MainWnd.Invoke(new ShowEmergencyStopFormDlgt(ShowEmergencyStopForm));
/// Stop the cycle - Press 'STOP' button in the BenchControlPanel
TBF.UiBridge.Bridge.Ui2Bench(TBF.UiBridge.UI2BenchCmd.Stop);
}
else if (!emergencyStop && previousEmergencyStop)
{
UiBridge.Bridge.OnEmergencyStopChanged(this,UiBridge.EmergencyStopEventArgs.State.CloseForm);
}
}
///
@@ -410,15 +394,32 @@ namespace TBF.BenchControl.Elde
{
if (DebugLevel == DebugMode.Simulate) return;
UpdateWeights();
/// Modify queue in case of emergency stop
if (emergencyStop && !previousEmergencyStop)
previousEmergencyStop = emergencyStop;
emergencyStop = (controlCom.StatusP & StatusP.EmgcyStopActive) != 0;
///
if (emergencyStop)
{
/// SendCommand() arguments to clear the emergency stop state
/// Modify the queue in case of an emergency stop
cbCommandQueue.Clear();
cbCommandQueue.Enqueue(new SendCommandArgs(Command.Stop, 0, 0, 0, 0, StopDevs.All));
}
///
if (emergencyStop && !previousEmergencyStop)
{
/// Stop the cycle - Press 'STOP' button in the BenchControlPanel
TBF.UiBridge.Bridge.Ui2Bench(TBF.UiBridge.UI2BenchCmd.Stop);
Program.MainWnd.Invoke(new ShowEmergencyStopFormDlgt(ShowEmergencyStopForm));
}
else if (!emergencyStop && previousEmergencyStop)
{
UiBridge.Bridge.OnEmergencyStopChanged(this, UiBridge.EmergencyStopEventArgs.State.CloseForm);
}
UpdateWeights();
/// Prepare uintFilters array and evaluate changes
uint[] uintFilters = new uint[FiltersCount];
+1 -1
View File
@@ -343,7 +343,7 @@ namespace TBF.BenchControl.Elde
bool bit39 = (route & 0x00FC000000000000) != 0; /// true if any of bits 50 through 55 is set
route = route & 0xFF03FFFFFFFFFFFF;
if (bit39) route = route | 0x0000008000000000;
#elif PETERSBURG_200 || DEWA_300 || ROMA_200
#elif PETERSBURG_200 || ROMA_200
///
/// The following code deals with the situation that all pumps share bit #80.
/// In settings the bits of pumps should be sent as follows: P1=64, P2=65, P3=66, P4=67 and P5=68
@@ -1448,6 +1448,7 @@ namespace TBF.BenchControl.Sequences
string fullTestName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(fullTestName, part);
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
if (tstRslt == null) return; /// Prevent program crash in certain cases
@@ -392,6 +392,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -665,6 +665,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -37,7 +37,14 @@ namespace TBF.BenchControl.TestMethods.Counter
TBF.UiBridge.Bridge.OnSaveSettings(this, null);
/// Update results
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr), null));
var testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
var testResults = BatchRslts.GetTestRslt(testName, test.Part);
global::Results.Utils.GetCounterStates(testResults, Program.LocalSettings.Counters);
if (testResults != null)
{
testResults.TestDone = true;
}
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, testResults));
return new List<Event> { Event.Done };
}
@@ -682,7 +682,8 @@ namespace TBF.BenchControl.TestMethods.DiverterTest
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -352,6 +352,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -797,6 +797,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -567,7 +567,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -784,6 +784,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -929,6 +929,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -976,6 +976,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -706,6 +706,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -461,7 +461,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -736,7 +736,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -853,7 +853,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -732,7 +732,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
double totalPulses = Convert.ToDouble(cBrd.EtPulses(0));
@@ -726,7 +726,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -485,7 +485,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -354,7 +354,8 @@ namespace TBF.BenchControl.TestMethods.LeakTest
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
tstRslt.DensityDiv = 0;
@@ -53,6 +53,7 @@ namespace TBF.BenchControl.TestMethods.ManualEntry
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -190,7 +190,8 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
tstRslt.DensityDiv = 0;
@@ -390,7 +390,8 @@ namespace TBF.BenchControl.TestMethods.PulsesTest
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -392,7 +392,8 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -48,6 +48,8 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory
TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
tstRslt.StartTime = DateTime.Now;
tstRslt.EndTime = DateTime.Now;
tstRslt.TestDone = true;
@@ -460,7 +460,8 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest
Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part);
if (tstRslt != null)
{
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
UpdateTempPressDensAmb(tstRslt);
/// Main results
@@ -2599,6 +2599,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (tstRslt != null)
{
Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters);
/// Auxiliary results ... not required
/// Main results
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.25.1400.0")]
[assembly: AssemblyFileVersion("2.25.1400.0")]
[assembly: AssemblyVersion("2.25.1405.0")]
[assembly: AssemblyFileVersion("2.25.1405.0")]
+9
View File
@@ -321,6 +321,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to any.
/// </summary>
internal static string any {
get {
return ResourceManager.GetString("any", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Approval.
/// </summary>
+3
View File
@@ -2134,4 +2134,7 @@
<data name="Empty_the_tank" xml:space="preserve">
<value>Empty the tank</value>
</data>
<data name="any" xml:space="preserve">
<value>any</value>
</data>
</root>
+21 -7
View File
@@ -3,32 +3,42 @@
<Language>en</Language>
<TestBenches>
<DatabaseSettings>
<BenchName>Test Bench</BenchName>
<BenchName>DEWA PT300</BenchName>
<IsRealBench>true</IsRealBench>
<ProceduresDBSettings>
<DbType>MySql</DbType>
<ConnectionString>SERVER=localhost; DATABASE=testbench; UID=root; PASSWORD=; CHARSET=utf8;</ConnectionString>
<ConnectionString>SERVER=localhost; DATABASE=dewa300; UID=root; PASSWORD=; CHARSET=utf8;</ConnectionString>
</ProceduresDBSettings>
<WaterMetersDBSettings>
<DbType>MySql</DbType>
<ConnectionString>SERVER=localhost; DATABASE=testbench-r; UID=root; PASSWORD=; CHARSET=utf8;</ConnectionString>
<ConnectionString>SERVER=localhost; DATABASE=dewa300-r; UID=root; PASSWORD=; CHARSET=utf8;</ConnectionString>
</WaterMetersDBSettings>
<UsersDBSettings>
<DbType>MySql</DbType>
<ConnectionString />
</UsersDBSettings>
</DatabaseSettings>
</TestBenches>
<LastBench>Test Bench</LastBench>
<LoginMethod>UserName</LoginMethod>
<LastBench>DEWA PT300</LastBench>
<BatchNr>1</BatchNr>
<RealDensity>998.2008</RealDensity>
<AtTemperature>20</AtTemperature>
<RightPaneHorizSplitterDistance>25</RightPaneHorizSplitterDistance>
<MainWndLeft>75</MainWndLeft>
<MainWndTop>5</MainWndTop>
<TopPaneVerticalSplitterDistance>596</TopPaneVerticalSplitterDistance>
<MainWndLeft>76</MainWndLeft>
<MainWndTop>21</MainWndTop>
<MainWndWidth>1250</MainWndWidth>
<MainWndHeight>750</MainWndHeight>
<ManiWndMaximized>false</ManiWndMaximized>
<ManiWndMaximized>true</ManiWndMaximized>
<ComponentsDlgLeft>200</ComponentsDlgLeft>
<ComponentsDlgTop>100</ComponentsDlgTop>
<ComponentsDlgWidth>850</ComponentsDlgWidth>
<ComponentsDlgHeight>500</ComponentsDlgHeight>
<PopupResultsLeft>0</PopupResultsLeft>
<PopupResultsTop>0</PopupResultsTop>
<PopupResultsWidth>0</PopupResultsWidth>
<PopupResultsHeight>0</PopupResultsHeight>
<PathsDlgLeft>0</PathsDlgLeft>
<PathsDlgTop>0</PathsDlgTop>
<PathsDlgWidth>0</PathsDlgWidth>
@@ -53,6 +63,10 @@
<OneProcedureDlgHeight>0</OneProcedureDlgHeight>
<PrintOrderLeft>0</PrintOrderLeft>
<PrintOrderTop>0</PrintOrderTop>
<EnduranceDlgLeft>0</EnduranceDlgLeft>
<EnduranceDlgTop>0</EnduranceDlgTop>
<EnduranceDlgWidth>0</EnduranceDlgWidth>
<EnduranceDlgHeight>0</EnduranceDlgHeight>
<PrintOrderOnlyGoodResult>false</PrintOrderOnlyGoodResult>
<PrintOrderOnlyLastResult>false</PrintOrderOnlyLastResult>
<ResultsConfigMeters>Vertically</ResultsConfigMeters>
+2 -1
View File
@@ -60,10 +60,11 @@
<logger name="NHibernate"> <level value="ERROR" /> </logger>
<logger name="TBF.BenchControl.StateMachine"> <level value="INFO" /> </logger>
<logger name="TBF.BenchControl.State"> <level value="WARN" /> </logger>
<logger name="TBF.BenchControl.Elde.ControlComdWrap"> <level value="WARN" /> </logger>
<logger name="TBF.BenchControl.Elde.ControlComWrap"> <level value="WARN" /> </logger>
<logger name="TBF.BenchControl.Elde.Pump"> <level value="WARN" /> </logger>
<logger name="TBF.BenchControl.Elde.PumpWithFM"> <level value="WARN" /> </logger>
<logger name="TBF.BenchControl.MettlerToledo"> <level value="WARN" /> </logger>
<logger name="TBF.BenchControl.Fomulas"> <level value="FATAL" /> </logger>
<logger name="TBF.BenchControl.Elde.StartMeasurementOp"> <level value="WARN" /> </logger>
<logger name="TBF.BenchControl.Modbus"> <level value="DEBUG" /> </logger>
</log4net>
+14 -7
View File
@@ -39,7 +39,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;MUNICH;CAMERA</DefineConstants>
<DefineConstants>TRACE;DEBUG;DEWA_300;CAMERA;STABLE_MASS_EXTRAS;TEST_PROFILES</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -50,7 +50,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;MUNICH;CAMERA</DefineConstants>
<DefineConstants>TRACE;DEWA_300;CAMERA;STABLE_MASS_EXTRAS;TEST_PROFILES</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -60,7 +60,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;MUNICH;CAMERA</DefineConstants>
<DefineConstants>TRACE;DEBUG;DEWA_300;CAMERA;STABLE_MASS_EXTRAS;TEST_PROFILES</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
@@ -70,7 +70,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;MUNICH;CAMERA</DefineConstants>
<DefineConstants>TRACE;DEWA_300;CAMERA;STABLE_MASS_EXTRAS;TEST_PROFILES</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
@@ -101,8 +101,8 @@
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="ControlComponent3Munich">
<HintPath>..\packages\ControlBoard\Munich\ControlComponent3Munich.dll</HintPath>
<Reference Include="ControlComponent3U">
<HintPath>..\packages\ControlBoard\DEWA_300\ControlComponent3U.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate">
<HintPath>..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll</HintPath>
@@ -2244,7 +2244,10 @@
<DependentUpon>ProcedureParamsCtrl.cs</DependentUpon>
</Compile>
<Compile Include="UI\Procedures\ProceduresCtrl.cs">
<SubType>Component</SubType>
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UI\Procedures\ProceduresCtrl.Designer.cs">
<DependentUpon>ProceduresCtrl.cs</DependentUpon>
</Compile>
<Compile Include="UI\Procedures\ProceduresDlg.cs">
<SubType>Form</SubType>
@@ -2386,6 +2389,7 @@
<Compile Include="UI\Settings\DatabaseSettingsDlg.designer.cs">
<DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
</Compile>
<Compile Include="UI\Settings\GroupTableRow.cs" />
<Compile Include="UI\Settings\LanguageDlg.cs">
<SubType>Form</SubType>
</Compile>
@@ -3242,6 +3246,9 @@
<EmbeddedResource Include="UI\Procedures\ProcedureParamsCtrl.resx">
<DependentUpon>ProcedureParamsCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Procedures\ProceduresCtrl.resx">
<DependentUpon>ProceduresCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Procedures\ProceduresDlg.resx">
<DependentUpon>ProceduresDlg.cs</DependentUpon>
</EmbeddedResource>
@@ -557,6 +557,7 @@ namespace TBF.UI.Bench.Components
if (component == null) return;
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = string.Format("{0}.pro", component.Name);
if (dlg.ShowDialog() == DialogResult.OK)
{
component.Export(new StreamWriter(dlg.FileName, false, System.Text.Encoding.UTF8));
+2 -2
View File
@@ -54,9 +54,9 @@ namespace TBF.UI
this.horizontalSplitContainer = new System.Windows.Forms.SplitContainer();
this.mainTabControl = new System.Windows.Forms.TabControl();
this.homeTabPage = new System.Windows.Forms.TabPage();
this.ctrlBrdComponent = new ControlComponent3Munich.UserControl1();
this.ctrlBrdComponent = new ControlComponent_Torino2015.UserControl1();
this.processTabPage = new System.Windows.Forms.TabPage();
this.processTabPageCtrl = new TBF.UI.Process.ProcessTabPageCtrl6();
this.processTabPageCtrl = new TBF.UI.Process.ProcessTabPageCtrl24();
this.insertTabPage = new System.Windows.Forms.TabPage();
this.resultsTabPage = new System.Windows.Forms.TabPage();
this.resultsTabPageCtrl = new TBF.UI.ResultsMI.ResultsTabPageCtrl();
+23 -18
View File
@@ -114,10 +114,7 @@ namespace TBF.UI
graphsToolStripMenuItem.Text = Strings.Graphs;
#endif
usersTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.Administrators) ||
Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.HeadOfLab);
upgradeTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.Administrators) && Users.GlobalData.CurrentUser.IsPowerUser();
UpdateMenuItemsVisibility();
#if IPERL
iPerlHeadsToolStripMenuItem.Visible = true;
@@ -448,6 +445,20 @@ namespace TBF.UI
userInfoStatusLabel.Text = string.Format("{0}: {1}{2}, ", Strings.User, Users.GlobalData.CurrentUser.UserName,
(Users.GlobalData.AuthorizedAs == Users.Entities.AuthorizedAs.PowerUser) ? "(S)" :
((Users.GlobalData.AuthorizedAs == Users.Entities.AuthorizedAs.LocalUser) ? "(L)" : "(R)"));
UpdateMenuItemsVisibility();
}
void UpdateMenuItemsVisibility()
{
usersTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.Administrators) ||
Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.HeadOfLab);
databaseSettingsTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.Administrators) && Users.GlobalData.CurrentUser.IsPowerUser(); ;
upgradeTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.Administrators) && Users.GlobalData.CurrentUser.IsPowerUser();
clearCountersToolStripMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.Administrators) ||
Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.HeadOfLab) ||
Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.TestingSpecialists) ||
Users.GlobalData.CurrentUser.IsMemberOf(Users.Entities.GID.Metrologists);
}
public void UpdateStatusP(string statusPStr)
@@ -819,22 +830,16 @@ namespace TBF.UI
private void clearCountersToolStripMenuItem_Click(object sender, EventArgs e)
{
Users.Entities.GID[] reqGrpMembership = new Users.Entities.GID[]
{
Users.Entities.GID.TestingSpecialists,
Users.Entities.GID.Metrologists,
Users.Entities.GID.HeadOfLab,
Users.Entities.GID.Administrators,
};
if (new Users.Forms.LoginDlg(reqGrpMembership).ShowDialog() == DialogResult.OK)
if ((Program.LocalSettings != null) &&
(Program.LocalSettings.Counters != null) &&
MessageBox.Show("Do you really want to clear counter(s)?",
Strings.Confirmation,
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
if ((Program.LocalSettings != null) && (Program.LocalSettings.Counters != null))
for (int i = 0; i < Program.LocalSettings.Counters.Length; i++)
{
for (int i = 0; i < Program.LocalSettings.Counters.Length; i++)
{
Program.LocalSettings.Counters[i] = 0;
}
Program.LocalSettings.Counters[i] = 0;
}
}
}
+194
View File
@@ -0,0 +1,194 @@
namespace TBF.UI.Procedures
{
partial class ProceduresCtrl
{
/// <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 Component 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.filtersSplitContainer = new System.Windows.Forms.SplitContainer();
this.producerLabel = new System.Windows.Forms.Label();
this.mclassLabel = new System.Windows.Forms.Label();
this.q3Label = new System.Windows.Forms.Label();
this.dnLabel = new System.Windows.Forms.Label();
this.producerComboBox = new System.Windows.Forms.ComboBox();
this.mclassComboBox = new System.Windows.Forms.ComboBox();
this.q3ComboBox = new System.Windows.Forms.ComboBox();
this.dnComboBox = new System.Windows.Forms.ComboBox();
this.listViewEx = new Results.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.filtersSplitContainer)).BeginInit();
this.filtersSplitContainer.Panel1.SuspendLayout();
this.filtersSplitContainer.Panel2.SuspendLayout();
this.filtersSplitContainer.SuspendLayout();
this.SuspendLayout();
//
// filtersSplitContainer
//
this.filtersSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.filtersSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.filtersSplitContainer.Location = new System.Drawing.Point(0, 0);
this.filtersSplitContainer.Name = "filtersSplitContainer";
this.filtersSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// filtersSplitContainer.Panel1
//
this.filtersSplitContainer.Panel1.Controls.Add(this.producerLabel);
this.filtersSplitContainer.Panel1.Controls.Add(this.mclassLabel);
this.filtersSplitContainer.Panel1.Controls.Add(this.q3Label);
this.filtersSplitContainer.Panel1.Controls.Add(this.dnLabel);
this.filtersSplitContainer.Panel1.Controls.Add(this.producerComboBox);
this.filtersSplitContainer.Panel1.Controls.Add(this.mclassComboBox);
this.filtersSplitContainer.Panel1.Controls.Add(this.q3ComboBox);
this.filtersSplitContainer.Panel1.Controls.Add(this.dnComboBox);
//
// filtersSplitContainer.Panel2
//
this.filtersSplitContainer.Panel2.Controls.Add(this.listViewEx);
this.filtersSplitContainer.Size = new System.Drawing.Size(600, 400);
this.filtersSplitContainer.SplitterDistance = 40;
this.filtersSplitContainer.TabIndex = 2;
//
// producerLabel
//
this.producerLabel.AutoSize = true;
this.producerLabel.Location = new System.Drawing.Point(381, 15);
this.producerLabel.Name = "producerLabel";
this.producerLabel.Size = new System.Drawing.Size(50, 13);
this.producerLabel.TabIndex = 7;
this.producerLabel.Text = "Producer";
//
// mclassLabel
//
this.mclassLabel.AutoSize = true;
this.mclassLabel.Location = new System.Drawing.Point(257, 15);
this.mclassLabel.Name = "mclassLabel";
this.mclassLabel.Size = new System.Drawing.Size(32, 13);
this.mclassLabel.TabIndex = 6;
this.mclassLabel.Text = "Class";
//
// q3Label
//
this.q3Label.AutoSize = true;
this.q3Label.Location = new System.Drawing.Point(125, 15);
this.q3Label.Name = "q3Label";
this.q3Label.Size = new System.Drawing.Size(40, 13);
this.q3Label.TabIndex = 5;
this.q3Label.Text = "Q3/Qn";
//
// dnLabel
//
this.dnLabel.AutoSize = true;
this.dnLabel.Location = new System.Drawing.Point(12, 15);
this.dnLabel.Name = "dnLabel";
this.dnLabel.Size = new System.Drawing.Size(23, 13);
this.dnLabel.TabIndex = 4;
this.dnLabel.Text = "DN";
//
// producerComboBox
//
this.producerComboBox.FormattingEnabled = true;
this.producerComboBox.Location = new System.Drawing.Point(437, 12);
this.producerComboBox.Name = "producerComboBox";
this.producerComboBox.Size = new System.Drawing.Size(133, 21);
this.producerComboBox.TabIndex = 3;
this.producerComboBox.SelectedIndexChanged += new System.EventHandler(this.producerComboBox_SelectedIndexChanged);
this.producerComboBox.TextChanged += new System.EventHandler(this.producerComboBox_TextChanged);
//
// mclassComboBox
//
this.mclassComboBox.FormattingEnabled = true;
this.mclassComboBox.Location = new System.Drawing.Point(295, 12);
this.mclassComboBox.Name = "mclassComboBox";
this.mclassComboBox.Size = new System.Drawing.Size(72, 21);
this.mclassComboBox.TabIndex = 2;
this.mclassComboBox.SelectedIndexChanged += new System.EventHandler(this.mclassComboBox_SelectedIndexChanged);
this.mclassComboBox.TextChanged += new System.EventHandler(this.mclassComboBox_TextChanged);
//
// q3ComboBox
//
this.q3ComboBox.FormattingEnabled = true;
this.q3ComboBox.Location = new System.Drawing.Point(171, 12);
this.q3ComboBox.Name = "q3ComboBox";
this.q3ComboBox.Size = new System.Drawing.Size(72, 21);
this.q3ComboBox.TabIndex = 1;
this.q3ComboBox.SelectedIndexChanged += new System.EventHandler(this.q3ComboBox_SelectedIndexChanged);
this.q3ComboBox.TextChanged += new System.EventHandler(this.q3ComboBox_TextChanged);
//
// dnComboBox
//
this.dnComboBox.FormattingEnabled = true;
this.dnComboBox.Location = new System.Drawing.Point(41, 12);
this.dnComboBox.Name = "dnComboBox";
this.dnComboBox.Size = new System.Drawing.Size(72, 21);
this.dnComboBox.TabIndex = 0;
this.dnComboBox.SelectedIndexChanged += new System.EventHandler(this.dnComboBox_SelectedIndexChanged);
this.dnComboBox.TextChanged += new System.EventHandler(this.dnComboBox_TextChanged);
//
// listViewEx
//
this.listViewEx.AllowColumnReorder = true;
this.listViewEx.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewEx.DoubleClickActivation = false;
this.listViewEx.FullRowSelect = true;
this.listViewEx.GridLines = true;
this.listViewEx.Location = new System.Drawing.Point(0, 0);
this.listViewEx.Name = "listViewEx";
this.listViewEx.Size = new System.Drawing.Size(600, 356);
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
this.listViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewEx_MouseDoubleClick);
//
// ProceduresCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.filtersSplitContainer);
this.Name = "ProceduresCtrl";
this.Size = new System.Drawing.Size(600, 400);
this.filtersSplitContainer.Panel1.ResumeLayout(false);
this.filtersSplitContainer.Panel1.PerformLayout();
this.filtersSplitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.filtersSplitContainer)).EndInit();
this.filtersSplitContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer filtersSplitContainer;
private System.Windows.Forms.Label producerLabel;
private System.Windows.Forms.Label mclassLabel;
private System.Windows.Forms.Label q3Label;
private System.Windows.Forms.Label dnLabel;
private System.Windows.Forms.ComboBox producerComboBox;
private System.Windows.Forms.ComboBox mclassComboBox;
private System.Windows.Forms.ComboBox q3ComboBox;
private System.Windows.Forms.ComboBox dnComboBox;
private Results.Forms.ListViewEx listViewEx;
}
}
+454 -154
View File
@@ -1,27 +1,53 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Windows.Forms;
using NHibernate;
using log4net;
using Config.Entities;
using Results.Forms;
using TBF.BenchControl;
using TBF.BenchControl.GenericDevices;
using TBF.Resources;
using TBF.UI.Shared;
namespace TBF.UI.Procedures
{
public class ProceduresCtrl : BaseWithListViewEx<Procedure>, ITabWithListViewEx
{
public partial class ProceduresCtrl : UserControl
{
static readonly ILog log = LogManager.GetLogger(typeof(ProceduresCtrl));
/// <summary>
/// List of all active procedures
/// </summary>
public IList<Procedure> AllProcedures;
/// <summary>
/// List of procedures satisfying filter criteria
/// </summary>
public IList<Procedure> Procedures;
/// <summary>
/// List of removed items that have to be removed from the database
/// when completed with OK.
/// </summary>
public IList<Procedure> ToBeRemovedProcedures;
/// <summary>
/// true = editing was unlocked
/// </summary>
public bool Unlocked { get { return unlocked; } } /// read only
bool unlocked;
float selectedDN;
float selectedQ3;
string selectedMClass;
string selectedProducer;
/// <summary>
/// ListViewEx columns
/// </summary>
@@ -40,31 +66,51 @@ namespace TBF.UI.Procedures
Control[] editors;
ISession session;
IWaterMeter waterMeterCmpnt;
IErrorFlags errorFlagsCmpnt;
public ProceduresCtrl()
: base()
{
InitializeComponent();
session = null;
}
waterMeterCmpnt = null;
errorFlagsCmpnt = null;
ToBeRemovedProcedures = new List<Procedure>();
dnComboBox.Text = Strings.any;
dnComboBox.Items.Add(Strings.any);
selectedDN = 0;
q3ComboBox.Text = Strings.any;
q3ComboBox.Items.Add(Strings.any);
selectedQ3 = 0;
mclassComboBox.Text = Strings.any;
mclassComboBox.Items.Add(Strings.any);
selectedMClass = null;
producerComboBox.Text = Strings.any;
producerComboBox.Items.Add(Strings.any);
selectedProducer = null;
}
public void Initialize(ProceduresDlg parent, Control parentControl)
{
if (parent == null) return;
/// Create a DB session
session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
this.parent = parent;
this.parentControl = parentControl;
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
/// ListViewEx columns
TBF.LocalSettings ls = Program.LocalSettings;
Columns.Add(Strings.Nr, (ls.ProceduresColumnCount > 0) ? ls.ProceduresColumnWidths[0] : ( 30 * parent.Dpi / Constants.Dpi100pct));
Columns.Add(Strings.Name, (ls.ProceduresColumnCount > 1) ? ls.ProceduresColumnWidths[1] : (100 * parent.Dpi / Constants.Dpi100pct));
Columns.Add(Strings.DescriptionColHdr, (ls.ProceduresColumnCount > 2) ? ls.ProceduresColumnWidths[2] : (300 * parent.Dpi / Constants.Dpi100pct));
Columns.Add(Strings.More, (ls.ProceduresColumnCount > 3) ? ls.ProceduresColumnWidths[3] : (300 * parent.Dpi / Constants.Dpi100pct));
listViewEx.Columns.Add(Strings.Nr, (ls.ProceduresColumnCount > 0) ? ls.ProceduresColumnWidths[0] : (30 * parent.Dpi / Constants.Dpi100pct));
listViewEx.Columns.Add(Strings.Name, (ls.ProceduresColumnCount > 1) ? ls.ProceduresColumnWidths[1] : (100 * parent.Dpi / Constants.Dpi100pct));
listViewEx.Columns.Add(Strings.DescriptionColHdr, (ls.ProceduresColumnCount > 2) ? ls.ProceduresColumnWidths[2] : (300 * parent.Dpi / Constants.Dpi100pct));
listViewEx.Columns.Add(Strings.More, (ls.ProceduresColumnCount > 3) ? ls.ProceduresColumnWidths[3] : (300 * parent.Dpi / Constants.Dpi100pct));
editors = new Control[columnsCount];
///
@@ -85,82 +131,141 @@ namespace TBF.UI.Procedures
ReloadAndRedrawAll();
}
void ReloadAndRedrawAll()
{
public void Unlock()
{
unlocked = true;
if (listViewEx.SelectedItems.Count == 1)
{
int ix = listViewEx.SelectedIndices[0];
Focus();
listViewEx.Items[ix].Selected = true;
listViewEx.Items[ix].EnsureVisible();
}
}
bool ReloadProcedures()
{
bool isFirstTime = AllProcedures == null;
try
{
/// Find ErrorFlags component
foreach (var cmpnt in TBF.BenchControl.TbfComponents.LoadComponentsFromDB(session))
if (isFirstTime)
{
if (cmpnt is IErrorFlags)
/// Find WaterMeter and ErrorFlags components, this is done just once when AllProcedures == null
foreach (var cmpnt in TBF.BenchControl.TbfComponents.LoadComponentsFromDB(session))
{
errorFlagsCmpnt = cmpnt as IErrorFlags;
break;
if (waterMeterCmpnt == null && cmpnt is IWaterMeter) waterMeterCmpnt = cmpnt as IWaterMeter;
if (errorFlagsCmpnt == null && cmpnt is IErrorFlags) errorFlagsCmpnt = cmpnt as IErrorFlags;
}
}
/// Load the procedures
MyItems = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.OrderBy(x => x.ItemNr).Asc
.List();
/// (Re)Load all procedures unconditionally
AllProcedures = session.QueryOver<Procedure>()
.Where(x => (x.ProcedureState == ProcedureState.Active))
.OrderBy(x => x.ItemNr).Asc
.List();
if (waterMeterCmpnt != null)
{
foreach (var proc in AllProcedures)
{
IParamsProvider waterMeterParams = waterMeterCmpnt.Cfg.GetUIProcParamsProvider(proc);
TBF.BenchControl.WaterMeters.WaterMeter.ProcParams wmParams = waterMeterParams as TBF.BenchControl.WaterMeters.WaterMeter.ProcParams;
if (wmParams != null)
{
proc.DN = wmParams.DN;
proc.Qn = wmParams.Qn;
proc.MClass = wmParams.MetrologicalClass;
proc.Producer = wmParams.Producer;
if (isFirstTime)
{
if (!dnComboBox.Items.Contains(wmParams.DN.ToString())) dnComboBox.Items.Add(wmParams.DN.ToString());
if (!q3ComboBox.Items.Contains(wmParams.Qn.ToString())) q3ComboBox.Items.Add(wmParams.Qn.ToString());
if (!mclassComboBox.Items.Contains(wmParams.MetrologicalClass)) mclassComboBox.Items.Add(wmParams.MetrologicalClass);
if (!producerComboBox.Items.Contains(wmParams.Producer)) producerComboBox.Items.Add(wmParams.Producer);
}
}
}
}
return true; /// Reloading successful
}
catch (Exception exc)
{
log.ErrorFormat("Loading Procedures from DB failed: {0}", exc.Message);
MyItems = new List<Procedure>();
AllProcedures = new List<Procedure>();
return false;
}
}
void ReloadAndRedrawAll()
{
if (ReloadProcedures())
{
RedrawAll();
}
}
void RedrawAll()
{
Procedures = new List<Procedure>();
/// Select procedures satisfying filter criteria: AllProcedures -> Procedures
if (AllProcedures != null)
{
foreach (var proc in AllProcedures)
{
if ((selectedDN == 0 || selectedDN == proc.DN) &&
(selectedQ3 == 0 || selectedQ3 == proc.Qn) &&
((selectedMClass == null) || (selectedMClass == proc.MClass)) &&
((selectedProducer == null) || (selectedProducer == proc.Producer)))
{
Procedures.Add(proc);
}
}
}
base.RedrawAll();
}
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
{
}
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
{
}
public override void DrawOne(object myItem)
{
Procedure entity = (Procedure)myItem;
listViewEx.Items.Clear();
foreach (var procedure in Procedures) DrawOne(procedure);
}
void DrawOne(Procedure procedure)
{
StringBuilder tests = new StringBuilder();
foreach (var test in entity.Tests)
foreach (var test in procedure.Tests)
{
tests.Append(test.Name);
tests.Append(", ");
}
ListViewItem lvi = new ListViewItem((entity.ItemNr + 1).ToString());
lvi.SubItems.Add(entity.Name);
lvi.SubItems.Add(entity.Description);
ListViewItem lvi = new ListViewItem((procedure.ItemNr + 1).ToString());
lvi.SubItems.Add(procedure.Name);
lvi.SubItems.Add(procedure.Description);
lvi.SubItems.Add(tests.ToString());
lvi.Tag = entity;
lvi.Tag = procedure;
Items.Add(lvi);
}
listViewEx.Items.Add(lvi);
}
/// <summary>
/// Update the entities and save them to the database
/// </summary>
public new void OkBtnClicked()
public void OkBtnClicked()
{
base.OkBtnClicked();
using (ITransaction transaction = session.BeginTransaction())
{
try
{
foreach (var entity in ToBeRemovedItems) session.Delete(entity);
ToBeRemovedItems.Clear();
foreach (var entity in ToBeRemovedProcedures) session.Delete(entity);
ToBeRemovedProcedures.Clear();
int itemNr = 0;
foreach (var entity in MyItems)
foreach (var proc in AllProcedures)
{
(entity as Procedure).ItemNr = itemNr++;
session.SaveOrUpdate(entity);
(proc as Procedure).ItemNr = itemNr++;
session.SaveOrUpdate(proc);
}
transaction.Commit();
@@ -179,93 +284,91 @@ namespace TBF.UI.Procedures
Program.MainWnd.ReloadProcedureComboBoxItems();
}
void SaveUISettings()
public void CancelBtnClicked()
{
LocalSettings ls = Program.LocalSettings;
}
/// Compare list view column widths with the saved ones
bool anyColumnDiffers = false;
if (Columns.Count != ls.ProceduresColumnCount)
/// <summary>
/// 'Add' button was clicked.
/// </summary>
public void AddOne()
{
/// Find an unused procedure name
string newName;
for (int nameId = 1; true; nameId++)
{
anyColumnDiffers = true;
}
else
{
for (int i = 0; i < Columns.Count; i++)
{
if (Columns[i].Width != ls.ProceduresColumnWidths[i]) { anyColumnDiffers = true; break; }
}
newName = Strings.New_procedure_name + nameId.ToString();
bool notUsed = true;
foreach (var t in Procedures) if (t.Name.ToLower().Equals(newName.ToLower())) notUsed = false;
if (notUsed) break;
}
if (anyColumnDiffers)
{
/// Update column widths
ls.ProceduresColumnWidths = new int[Columns.Count];
for (int i = 0; i < Columns.Count; i++)
{
ls.ProceduresColumnWidths[i] = Columns[i].Width;
}
Procedure newProcedure = new Procedure(newName, Procedures.Count);
newProcedure.ItemNr = AllProcedures.Count;
newProcedure.ProcedureState = ProcedureState.Active;
newProcedure.Revision = 1;
newProcedure.PredecessorId = 0;
newProcedure.ObtainedByCopy = false;
newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.CreationTime = DateTime.Now;
ls.Save();
if (new ProcedureDlg(newProcedure, GetUsedNames(false), true).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
using (var transaction = session.BeginTransaction())
{
try
{
newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.LastChgTime = DateTime.Now;
DoAddOne(newProcedure);
session.SaveOrUpdate(newProcedure);
transaction.Commit();
MessageBox.Show(string.Format(Strings.Procedure_0_added, newProcedure.Name),
Strings.Confirmation,
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch (Exception exc)
{
transaction.Rollback();
log.ErrorFormat("Exception when saving Procedure '{0}' : {1}", newProcedure.Name, exc.Message);
}
}
}
}
public void AddOne()
{
/// Find an unused procedure name
string newName;
for (int nameId = 1; true; nameId++)
{
newName = Strings.New_procedure_name + nameId.ToString();
bool notUsed = true;
foreach (var t in MyItems) if (t.Name.ToLower().Equals(newName.ToLower())) notUsed = false;
if (notUsed) break;
}
/// <summary>
/// Adds an item to the ListView and at the end of the list.
/// Focuses onto the added item.
/// </summary>
public void DoAddOne(Procedure procedure)
{
Procedures.Add(procedure);
AllProcedures.Add(procedure);
DrawOne(procedure);
Procedure newProcedure = new Procedure(newName, MyItems.Count);
newProcedure.ProcedureState = ProcedureState.Active;
newProcedure.Revision = 1;
newProcedure.PredecessorId = 0;
newProcedure.ObtainedByCopy = false;
newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.CreationTime = DateTime.Now;
Focus();
listViewEx.SelectedItems.Clear();
listViewEx.Items[listViewEx.Items.Count - 1].Selected = true;
listViewEx.Items[listViewEx.Items.Count - 1].EnsureVisible();
}
if (new ProcedureDlg(newProcedure, GetUsedNames(false), true).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
using(var transaction = session.BeginTransaction())
{
try
{
newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.LastChgTime = DateTime.Now;
base.AddOne(newProcedure);
session.SaveOrUpdate(newProcedure);
transaction.Commit();
MessageBox.Show(string.Format(Strings.Procedure_0_added, newProcedure.Name),
Strings.Confirmation,
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch (Exception exc)
{
transaction.Rollback();
log.ErrorFormat("Exception when saving Procedure '{0}' : {1}", newProcedure.Name, exc.Message);
}
}
}
}
public new void RemoveSelected()
{
/// <summary>
/// 'Remove' button was clicked.
/// </summary>
public void RemoveSelected()
{
if (MessageBox.Show(Strings.Do_you_want_to_delete_the_procedure,
Strings.Question, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
bool lastOneRemoved = base.RemoveSelected();
bool lastOneRemoved = DoRemoveSelected();
if (lastOneRemoved && parent != null)
{
@@ -277,11 +380,11 @@ namespace TBF.UI.Procedures
{
try
{
foreach (var entity in ToBeRemovedItems) session.Delete(entity);
ToBeRemovedItems.Clear();
foreach (var entity in ToBeRemovedProcedures) session.Delete(entity);
ToBeRemovedProcedures.Clear();
int itemNr = 0;
foreach (var entity in MyItems)
foreach (var entity in Procedures)
{
(entity as Procedure).ItemNr = itemNr++;
session.SaveOrUpdate(entity);
@@ -300,11 +403,143 @@ namespace TBF.UI.Procedures
}
}
/// <summary>
/// Removes an item from the ListView and from the list itself.
/// Adds it on ToBeRemovedItems list.
/// Focuses on the next item.
/// </summary>
/// <returns>true when the last item was removed and 'Remove' button should be disabled</returns>
public bool DoRemoveSelected()
{
if (listViewEx.SelectedItems.Count != 1) return false;
int removeItemNr = listViewEx.SelectedIndices[0];
if (removeItemNr < 0) return false;
Procedure selectedItem = (Procedure)listViewEx.SelectedItems[0].Tag;
/// Add to ToBeRemovedProcedures if necessary
if (selectedItem.Id != 0)
{
/// Procedure to be removed was loaded from the DB (was not recenlu created)
ToBeRemovedProcedures.Add(selectedItem);
}
/// Remove from AllProcedures
AllProcedures.Remove(selectedItem);
/// Remove
Procedures.RemoveAt(removeItemNr);
for (int i = removeItemNr; i < Procedures.Count; i++)
{
Procedures[i].ItemNr--;
}
RedrawAll();
if (removeItemNr < listViewEx.Items.Count)
{
Focus();
listViewEx.Items[removeItemNr].Selected = true;
listViewEx.Items[removeItemNr].EnsureVisible();
return false;
}
else
{
return true;
}
}
public void MoveUpSelected()
{
if (listViewEx.SelectedItems.Count != 1) return;
if (Procedures.Count != AllProcedures.Count) return;
int ix = listViewEx.SelectedIndices[0];
if (ix <= 0 || ix >= Procedures.Count) return;
Procedure proc1 = (Procedure)(listViewEx.Items[ix - 1].Tag);
Procedure proc2 = (Procedure)(listViewEx.Items[ix].Tag);
proc1.ItemNr++;
proc2.ItemNr--;
Procedures.RemoveAt(ix);
Procedures.Insert(ix - 1, proc2);
AllProcedures.RemoveAt(ix);
AllProcedures.Insert(ix - 1, proc2);
RedrawAll();
listViewEx.Focus();
listViewEx.Items[ix - 1].Selected = true;
listViewEx.Items[ix - 1].EnsureVisible();
}
public void MoveDownSelected()
{
if (listViewEx.SelectedItems.Count != 1) return;
if (Procedures.Count != AllProcedures.Count) return;
int ix = listViewEx.SelectedIndices[0];
if (ix < 0 || ix >= Procedures.Count - 1) return;
Procedure proc1 = (Procedure)(listViewEx.Items[ix].Tag);
Procedure proc2 = (Procedure)(listViewEx.Items[ix + 1].Tag);
proc1.ItemNr++;
proc2.ItemNr--;
Procedures.RemoveAt(ix + 1);
Procedures.Insert(ix, proc2);
AllProcedures.RemoveAt(ix + 1);
AllProcedures.Insert(ix, proc2);
RedrawAll();
listViewEx.Focus();
listViewEx.Items[ix + 1].Selected = true;
listViewEx.Items[ix + 1].EnsureVisible();
}
void SaveUISettings()
{
LocalSettings ls = Program.LocalSettings;
/// Compare list view column widths with the saved ones
bool anyColumnDiffers = false;
if (listViewEx.Columns.Count != ls.ProceduresColumnCount)
{
anyColumnDiffers = true;
}
else
{
for (int i = 0; i < listViewEx.Columns.Count; i++)
{
if (listViewEx.Columns[i].Width != ls.ProceduresColumnWidths[i]) { anyColumnDiffers = true; break; }
}
}
if (anyColumnDiffers)
{
/// Update column widths
ls.ProceduresColumnWidths = new int[listViewEx.Columns.Count];
for (int i = 0; i < listViewEx.Columns.Count; i++)
{
ls.ProceduresColumnWidths[i] = listViewEx.Columns[i].Width;
}
ls.Save();
}
}
private void listViewEx_MouseDoubleClick(object sender, MouseEventArgs e)
{
editButton_Click(sender, e);
}
///
public void editButton_Click(object sender, EventArgs e)
{
if (SelectedItems.Count != 1) return;
if (listViewEx.SelectedItems.Count != 1) return;
Procedure originalProcedure = SelectedItems[0].Tag as Procedure;
Procedure originalProcedure = listViewEx.SelectedItems[0].Tag as Procedure;
Procedure modifiedProcedure = originalProcedure.Clone();
modifiedProcedure.Revision = originalProcedure.Revision + 1;
@@ -329,7 +564,7 @@ namespace TBF.UI.Procedures
session.SaveOrUpdate(modifiedProcedure);
transaction.Commit();
SelectedItems[0].Tag = modifiedProcedure;
listViewEx.SelectedItems[0].Tag = modifiedProcedure;
MessageBox.Show(string.Format(Strings.Procedure_0_modified, string.Format(" {0} '{1}' ", modifiedProcedure.ItemNr + 1, modifiedProcedure.Name)),
Strings.Confirmation,
MessageBoxButtons.OK,
@@ -349,15 +584,15 @@ namespace TBF.UI.Procedures
public void copyButton_Click(object sender, EventArgs e)
{
if (SelectedItems.Count != 1) return;
if (listViewEx.SelectedItems.Count != 1) return;
Procedure selectedProcedure = (Procedure)SelectedItems[0].Tag;
Procedure selectedProcedure = (Procedure)listViewEx.SelectedItems[0].Tag;
/// Make a copy of the selected procedure
Procedure newProcedure = selectedProcedure.Clone();
newProcedure.Name = selectedProcedure.Name + Strings.New_name_copy;
newProcedure.ItemNr = MyItems.Count;
newProcedure.ItemNr = AllProcedures.Count;
newProcedure.ProcedureState = ProcedureState.Active;
newProcedure.Revision = 1;
newProcedure.PredecessorId = selectedProcedure.Id;
@@ -376,7 +611,7 @@ namespace TBF.UI.Procedures
newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.LastChgTime = DateTime.Now;
base.AddOne(newProcedure);
DoAddOne(newProcedure);
session.SaveOrUpdate(newProcedure);
transaction.Commit();
@@ -390,9 +625,9 @@ namespace TBF.UI.Procedures
public void exportButton_Click(object sender, EventArgs e)
{
if (SelectedItems.Count != 1) return;
if (listViewEx.SelectedItems.Count != 1) return;
Procedure selectedProcedure = (Procedure)SelectedItems[0].Tag;
Procedure selectedProcedure = (Procedure)listViewEx.SelectedItems[0].Tag;
SaveFileDialog dlg = new SaveFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
@@ -411,7 +646,7 @@ namespace TBF.UI.Procedures
Procedure newProcedure = Procedure.Import(new StreamReader(dlg.FileName, System.Text.Encoding.UTF8));
newProcedure.Name = newProcedure.Name + " imported";
newProcedure.ItemNr = MyItems.Count;
newProcedure.ItemNr = Procedures.Count;
newProcedure.ProcedureState = ProcedureState.Active;
newProcedure.Revision = 1;
newProcedure.PredecessorId = 0;
@@ -429,7 +664,7 @@ namespace TBF.UI.Procedures
newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.LastChgTime = DateTime.Now;
base.AddOne(newProcedure);
DoAddOne(newProcedure);
session.SaveOrUpdate(newProcedure);
transaction.Commit();
@@ -443,9 +678,9 @@ namespace TBF.UI.Procedures
public void compareButton_Click(object sender, EventArgs e)
{
if (SelectedItems.Count != 1) return;
if (listViewEx.SelectedItems.Count != 1) return;
Procedure selectedProcedure = (Procedure)SelectedItems[0].Tag;
Procedure selectedProcedure = (Procedure)listViewEx.SelectedItems[0].Tag;
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
@@ -486,13 +721,13 @@ namespace TBF.UI.Procedures
{
newName = Strings.New_procedure_name + nameId.ToString();
bool notUsed = true;
foreach (var t in MyItems) if (t.Name.ToLower().Equals(newName.ToLower())) notUsed = false;
foreach (var t in Procedures) if (t.Name.ToLower().Equals(newName.ToLower())) notUsed = false;
if (notUsed) break;
}
ProfileType pt = dlg.SelectedProfile.ProfileType;
Procedure newProcedure = new Procedure(newName, MyItems.Count);
Procedure newProcedure = new Procedure(newName, Procedures.Count);
Medium medium = (pt == ProfileType.QnClassHotWater) ? Medium.HotWater : Medium.ColdWater;
IList<IParamsProvider> errorFlagsParamsOfCreatedTests = new List<IParamsProvider>();
IList<IParamsProvider> waterMeterParamsOfNewProcedure = new List<IParamsProvider>();
@@ -649,7 +884,7 @@ namespace TBF.UI.Procedures
newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.LastChgTime = DateTime.Now;
base.AddOne(newProcedure);
DoAddOne(newProcedure);
session.SaveOrUpdate(newProcedure);
foreach (var efp in errorFlagsParamsOfCreatedTests)
@@ -673,13 +908,78 @@ namespace TBF.UI.Procedures
}
}
public string GetWarningsBeforeSaving(ref Dictionary<string, string> renmInfo)
{
return string.Empty;
}
public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
public IList<string> GetUsedNames(bool caseSensitive = true)
{
IList<string> usedNames = new List<string>();
if (Procedures != null)
{
if (caseSensitive)
{
foreach (var procedure in Procedures)
{
usedNames.Add(procedure.Name);
}
}
else
{
foreach (var procedure in Procedures)
{
usedNames.Add(procedure.Name.ToLower());
}
}
}
return usedNames;
}
private void dnComboBox_SelectedIndexChanged(object sender, EventArgs e) { UpdateSelectedDN(); }
private void dnComboBox_TextChanged(object sender, EventArgs e) { UpdateSelectedDN(); }
///
void UpdateSelectedDN()
{
uint ival;
selectedDN = uint.TryParse(dnComboBox.Text, out ival) ? ival : 0;
RedrawAll();
listViewEx_SelectedIndexChanged(null, null);
}
private void q3ComboBox_SelectedIndexChanged(object sender, EventArgs e) { UpdateSelectedQn(); }
private void q3ComboBox_TextChanged(object sender, EventArgs e) { UpdateSelectedQn(); }
///
void UpdateSelectedQn()
{
float fval;
selectedQ3 = Utils.TryParseUFloat(q3ComboBox.Text, out fval) ? fval : 0;
RedrawAll();
listViewEx_SelectedIndexChanged(null, null);
}
private void mclassComboBox_SelectedIndexChanged(object sender, EventArgs e) { UpdateSelectedMClass(); }
private void mclassComboBox_TextChanged(object sender, EventArgs e) { UpdateSelectedMClass(); }
///
void UpdateSelectedMClass()
{
selectedMClass = (mclassComboBox.Text != Strings.any) ? mclassComboBox.Text : null;
RedrawAll();
listViewEx_SelectedIndexChanged(null, null);
}
private void producerComboBox_SelectedIndexChanged(object sender, EventArgs e) { UpdateSelectedProducer(); }
private void producerComboBox_TextChanged(object sender, EventArgs e) { UpdateSelectedProducer(); }
///
void UpdateSelectedProducer()
{
selectedProducer = (producerComboBox.Text != Strings.any) ? producerComboBox.Text : null;
RedrawAll();
listViewEx_SelectedIndexChanged(null, null);
}
private void listViewEx_SelectedIndexChanged(object sender, EventArgs e)
{
bool isFilterAny = (selectedDN == 0) && (selectedQ3 == 0) && (selectedMClass == null) && (selectedProducer == null);
if (parent != null) parent.SelectedIndexChanged(listViewEx, isFilterAny);
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+3 -9
View File
@@ -54,23 +54,17 @@ namespace TBF.UI.Procedures
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.sharedButtons);
this.splitContainer.Size = new System.Drawing.Size(517, 402);
this.splitContainer.SplitterDistance = 412;
this.splitContainer.Size = new System.Drawing.Size(711, 402);
this.splitContainer.SplitterDistance = 606;
this.splitContainer.TabIndex = 0;
//
// proceduresCtrl
//
this.proceduresCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.proceduresCtrl.DoubleClickActivation = false;
this.proceduresCtrl.FullRowSelect = true;
this.proceduresCtrl.GridLines = true;
this.proceduresCtrl.Location = new System.Drawing.Point(0, 0);
this.proceduresCtrl.Name = "proceduresCtrl";
this.proceduresCtrl.Size = new System.Drawing.Size(412, 402);
this.proceduresCtrl.TabIndex = 0;
this.proceduresCtrl.UseCompatibleStateImageBehavior = false;
this.proceduresCtrl.View = System.Windows.Forms.View.Details;
this.proceduresCtrl.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.proceduresCtrl_MouseDoubleClick);
//
// sharedButtons
//
@@ -83,7 +77,7 @@ namespace TBF.UI.Procedures
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(517, 402);
this.ClientSize = new System.Drawing.Size(711, 402);
this.Controls.Add(this.splitContainer);
this.Name = "ProceduresDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+36 -18
View File
@@ -1,13 +1,11 @@
///
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using TBF.Resources;
using TBF.UI.Shared;
using Config.Entities;
namespace TBF.UI.Procedures
{
@@ -179,16 +177,17 @@ namespace TBF.UI.Procedures
proceduresCtrl.MoveDownSelected();
}
private void proceduresCtrl_MouseDoubleClick(object sender, MouseEventArgs e)
{
proceduresCtrl.editButton_Click(sender, e);
}
private void custom1Button_Click(object sender, EventArgs e)
{
proceduresCtrl.CreateFromProfile();
}
/// <summary>
/// Common part for three xxxListViewEx_SelectedIndexChanged event handlers
/// </summary>
/// <param name="listViewEx"></param>
void SelectedIndexChanged(object sender, EventArgs e)
public void SelectedIndexChanged(ListView sender, bool isFilterAny)
{
Results.Forms.ListViewEx listViewEx = sender as Results.Forms.ListViewEx;
if (listViewEx.SelectedItems.Count != 1)
@@ -205,27 +204,46 @@ namespace TBF.UI.Procedures
else if (listViewEx.SelectedIndices[0] == 0)
{
/// The first of many items selected
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Down);
sharedButtons.DisableButtons(SharedButtons.Buttons.Up);
if (isFilterAny)
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Down);
sharedButtons.DisableButtons(SharedButtons.Buttons.Up);
}
else
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove);
sharedButtons.DisableButtons(SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
else if (listViewEx.SelectedIndices[0] == (listViewEx.Items.Count - 1))
{
/// The last of many items selected
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up);
sharedButtons.DisableButtons(SharedButtons.Buttons.Down);
if (isFilterAny)
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up);
sharedButtons.DisableButtons(SharedButtons.Buttons.Down);
}
else
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove);
sharedButtons.DisableButtons(SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
else
{
/// One of middle items selected
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
if (isFilterAny)
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
else
{
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove);
sharedButtons.DisableButtons(SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
}
private void custom1Button_Click(object sender, EventArgs e)
{
proceduresCtrl.CreateFromProfile();
}
public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos)
{
if (selectedItemPos == SharedButtons.SelectedItemPos.None)
+19
View File
@@ -0,0 +1,19 @@
///
/// Copyright (c) 2020 Sensus slovensko a.s.
///
namespace TBF.UI.Settings
{
public class GroupTableRow
{
public int GroupId;
public Users.Entities.GID Gid;
public int UserId;
public GroupTableRow(int groupId, Users.Entities.GID gid, int userId)
{
GroupId = groupId;
Gid = gid;
UserId = userId;
}
}
}
+55 -15
View File
@@ -44,6 +44,9 @@
this.upgradeDb_218_222_Button = new System.Windows.Forms.Button();
this.upgradeDb_NFC_button = new System.Windows.Forms.Button();
this.upgradeDb_222_224_Button = new System.Windows.Forms.Button();
this.upgradeDb_224_225_Button = new System.Windows.Forms.Button();
this.errorFlagsComponentsTextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// upgradeDb_215_216_Button
@@ -52,7 +55,7 @@
this.upgradeDb_215_216_Button.Name = "upgradeDb_215_216_Button";
this.upgradeDb_215_216_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_215_216_Button.TabIndex = 6;
this.upgradeDb_215_216_Button.Text = "Upgrade database from ver. 2.15 to ver. 2.16";
this.upgradeDb_215_216_Button.Text = "Upgrade DB from v.2.15 to v.2.16";
this.upgradeDb_215_216_Button.UseVisualStyleBackColor = true;
this.upgradeDb_215_216_Button.Click += new System.EventHandler(this.upgradeDb_215_216_Button_Click);
//
@@ -62,7 +65,7 @@
this.upgradeDb_216_217_Button.Name = "upgradeDb_216_217_Button";
this.upgradeDb_216_217_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_216_217_Button.TabIndex = 7;
this.upgradeDb_216_217_Button.Text = "Upgrade database from ver. 2.16 to ver. 2.17";
this.upgradeDb_216_217_Button.Text = "Upgrade DB from v.2.16 to v.2.17";
this.upgradeDb_216_217_Button.UseVisualStyleBackColor = true;
this.upgradeDb_216_217_Button.Click += new System.EventHandler(this.upgradeDb_216_217_Button_Click);
//
@@ -72,7 +75,7 @@
this.upgradeDb_212_215_Button.Name = "upgradeDb_212_215_Button";
this.upgradeDb_212_215_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_212_215_Button.TabIndex = 5;
this.upgradeDb_212_215_Button.Text = "Upgrade database from ver. 2.12 to ver. 2.15";
this.upgradeDb_212_215_Button.Text = "Upgrade DB from v.2.12 to v.2.15";
this.upgradeDb_212_215_Button.UseVisualStyleBackColor = true;
this.upgradeDb_212_215_Button.Click += new System.EventHandler(this.upgradeDb_212_215_Button_Click);
//
@@ -82,7 +85,7 @@
this.upgradeDb_217_218_Button.Name = "upgradeDb_217_218_Button";
this.upgradeDb_217_218_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_217_218_Button.TabIndex = 8;
this.upgradeDb_217_218_Button.Text = "Upgrade database from ver. 2.17 to ver. 2.18";
this.upgradeDb_217_218_Button.Text = "Upgrade DB from v.2.17 to v.2.18";
this.upgradeDb_217_218_Button.UseVisualStyleBackColor = true;
this.upgradeDb_217_218_Button.Click += new System.EventHandler(this.upgradeDb_217_218_Button_Click);
//
@@ -92,7 +95,7 @@
this.upgradeDb_29_212_Button.Name = "upgradeDb_29_212_Button";
this.upgradeDb_29_212_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_29_212_Button.TabIndex = 4;
this.upgradeDb_29_212_Button.Text = "Upgrade database from ver. 2.9 to ver. 2.12";
this.upgradeDb_29_212_Button.Text = "Upgrade DB from v.2.9 to v.2.12";
this.upgradeDb_29_212_Button.UseVisualStyleBackColor = true;
this.upgradeDb_29_212_Button.Click += new System.EventHandler(this.upgradeDb_29_212_Button_Click);
//
@@ -119,7 +122,8 @@
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.textBox1.Location = new System.Drawing.Point(94, 431);
this.textBox1.Enabled = false;
this.textBox1.Location = new System.Drawing.Point(94, 493);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 11;
@@ -127,7 +131,8 @@
// textBox2
//
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.textBox2.Location = new System.Drawing.Point(94, 457);
this.textBox2.Enabled = false;
this.textBox2.Location = new System.Drawing.Point(94, 519);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 13;
@@ -136,7 +141,8 @@
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 434);
this.label1.Enabled = false;
this.label1.Location = new System.Drawing.Point(12, 496);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(70, 13);
this.label1.TabIndex = 10;
@@ -146,7 +152,8 @@
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 460);
this.label2.Enabled = false;
this.label2.Location = new System.Drawing.Point(12, 522);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(60, 13);
this.label2.TabIndex = 12;
@@ -155,7 +162,8 @@
// pressureRepresentationButton
//
this.pressureRepresentationButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.pressureRepresentationButton.Location = new System.Drawing.Point(207, 431);
this.pressureRepresentationButton.Enabled = false;
this.pressureRepresentationButton.Location = new System.Drawing.Point(207, 493);
this.pressureRepresentationButton.Name = "pressureRepresentationButton";
this.pressureRepresentationButton.Size = new System.Drawing.Size(65, 42);
this.pressureRepresentationButton.TabIndex = 14;
@@ -169,7 +177,7 @@
this.upgradeDb_24_29_Button.Name = "upgradeDb_24_29_Button";
this.upgradeDb_24_29_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_24_29_Button.TabIndex = 3;
this.upgradeDb_24_29_Button.Text = "Upgrade database from ver. 2.4 to ver. 2.9";
this.upgradeDb_24_29_Button.Text = "Upgrade DB from v.2.4 to v.2.9";
this.upgradeDb_24_29_Button.UseVisualStyleBackColor = true;
this.upgradeDb_24_29_Button.Click += new System.EventHandler(this.upgradeDb_24_29_Button_Click);
//
@@ -179,7 +187,7 @@
this.upgradeDb_218_222_Button.Name = "upgradeDb_218_222_Button";
this.upgradeDb_218_222_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_218_222_Button.TabIndex = 9;
this.upgradeDb_218_222_Button.Text = "Upgrade database from ver. 2.18 to ver. 2.22";
this.upgradeDb_218_222_Button.Text = "Upgrade DB from v.2.18 to v.2.22";
this.upgradeDb_218_222_Button.UseVisualStyleBackColor = true;
this.upgradeDb_218_222_Button.Click += new System.EventHandler(this.upgradeDb_218_222_Button_Click);
//
@@ -195,19 +203,48 @@
//
// upgradeDb_222_224_Button
//
this.upgradeDb_222_224_Button.Location = new System.Drawing.Point(12, 377);
this.upgradeDb_222_224_Button.Location = new System.Drawing.Point(12, 404);
this.upgradeDb_222_224_Button.Name = "upgradeDb_222_224_Button";
this.upgradeDb_222_224_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_222_224_Button.TabIndex = 15;
this.upgradeDb_222_224_Button.Text = "Upgrade database from ver. 2.22 to ver. 2.24";
this.upgradeDb_222_224_Button.Text = "Upgrade DB from v.2.22 to v.2.24";
this.upgradeDb_222_224_Button.UseVisualStyleBackColor = true;
this.upgradeDb_222_224_Button.Click += new System.EventHandler(this.upgradeDb_222_224_Button_Click);
//
// upgradeDb_224_225_Button
//
this.upgradeDb_224_225_Button.Location = new System.Drawing.Point(12, 444);
this.upgradeDb_224_225_Button.Name = "upgradeDb_224_225_Button";
this.upgradeDb_224_225_Button.Size = new System.Drawing.Size(260, 34);
this.upgradeDb_224_225_Button.TabIndex = 16;
this.upgradeDb_224_225_Button.Text = "Upgrade DB from v.2.24 to v.2.25 (users)";
this.upgradeDb_224_225_Button.UseVisualStyleBackColor = true;
this.upgradeDb_224_225_Button.Click += new System.EventHandler(this.upgradeDb_224_225_Button_Click);
//
// errorFlagsComponentsTextBox
//
this.errorFlagsComponentsTextBox.Location = new System.Drawing.Point(94, 378);
this.errorFlagsComponentsTextBox.Name = "errorFlagsComponentsTextBox";
this.errorFlagsComponentsTextBox.Size = new System.Drawing.Size(178, 20);
this.errorFlagsComponentsTextBox.TabIndex = 17;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 381);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(71, 13);
this.label3.TabIndex = 18;
this.label3.Text = "ErrFlags1~E..";
//
// UpgradeSelectionDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 493);
this.ClientSize = new System.Drawing.Size(284, 555);
this.Controls.Add(this.label3);
this.Controls.Add(this.errorFlagsComponentsTextBox);
this.Controls.Add(this.upgradeDb_224_225_Button);
this.Controls.Add(this.upgradeDb_222_224_Button);
this.Controls.Add(this.upgradeDb_NFC_button);
this.Controls.Add(this.upgradeDb_218_222_Button);
@@ -249,6 +286,9 @@
private System.Windows.Forms.Button upgradeDb_218_222_Button;
private System.Windows.Forms.Button upgradeDb_NFC_button;
private System.Windows.Forms.Button upgradeDb_222_224_Button;
private System.Windows.Forms.Button upgradeDb_224_225_Button;
private System.Windows.Forms.TextBox errorFlagsComponentsTextBox;
private System.Windows.Forms.Label label3;
}
}
+287 -20
View File
@@ -1,4 +1,7 @@
using System;
///
/// Copyright (c) 2016-2020 Sensus slovensko a.s.
///
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
@@ -38,13 +41,13 @@ namespace TBF.UI.Settings
void ActivityStart()
{
form = new Shared.ModelessActivityForm()
{
Message = "Upgrading database",
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.Green,
};
{
Message = "Upgrading database",
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.Green,
};
formThread = new System.Threading.Thread(() => form.ShowDialog());
formThread.Start();
}
@@ -99,6 +102,63 @@ namespace TBF.UI.Settings
return success;
}
/// <summary>
/// Common part of database upgrade code
/// </summary>
/// <param name="dbConn">Database connection</param>
/// <param name="commands">Array of SQL commands to be executed</param>
/// <returns>true = successful</returns>
bool ChangeErrorFlags(string errorFlagsCmpntName)
{
bool success = false;
ISession session = null;
try
{
session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
var testParams = session.QueryOver<Config.Entities.ComponentTest>()
.Where(x => (x.CmpntName == errorFlagsCmpntName))
.List();
foreach (var tp in testParams)
{
string temp;
if (tp.Parameters.Contains("<Mode>Info</Mode>"))
{
temp = tp.Parameters.Replace("true", "1");
}
else if (tp.Parameters.Contains("<Mode>On</Mode>"))
{
temp = tp.Parameters.Replace("true", "2");
}
else
{
temp = tp.Parameters.Replace("true", "0");
}
tp.Parameters = temp.Replace("false", "0");
session.SaveOrUpdate(tp);
}
session.Flush();
success = true;
}
catch (Exception exc)
{
ActivityEnd();
MessageBox.Show(string.Format("Upgrade failed:\r\n{0}", exc.Message),
"Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
if (session != null) session.Close();
}
return success;
}
///---------------------------------------------------------------------
private void upgradeDb_NFC_button_Click(object sender, EventArgs e)
{
@@ -131,7 +191,7 @@ namespace TBF.UI.Settings
MessageBox.Show("No database selected");
return;
}
string[] configDbCommands = new string[]
{
/// 2.4 -> 2.5
@@ -182,7 +242,7 @@ namespace TBF.UI.Settings
MessageBox.Show("No database selected");
return;
}
string[] configDbCommands = new string[]
{
/// 2.9 -> 2.10
@@ -310,7 +370,7 @@ namespace TBF.UI.Settings
}
}
}
///---------------------------------------------------------------------
private void upgradeDb_212_215_Button_Click(object sender, EventArgs e)
{
@@ -486,8 +546,8 @@ namespace TBF.UI.Settings
}
}
///---------------------------------------------------------------------
private void upgradeDb_215_216_Button_Click(object sender, EventArgs e)
///---------------------------------------------------------------------
private void upgradeDb_215_216_Button_Click(object sender, EventArgs e)
{
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
{
@@ -510,8 +570,8 @@ namespace TBF.UI.Settings
}
}
///---------------------------------------------------------------------
private void upgradeDb_216_217_Button_Click(object sender, EventArgs e)
///---------------------------------------------------------------------
private void upgradeDb_216_217_Button_Click(object sender, EventArgs e)
{
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
{
@@ -596,7 +656,75 @@ namespace TBF.UI.Settings
string[] configDbCommands = new string[]
{
"ALTER TABLE `user` ADD `Password2` VARCHAR(255) NULL DEFAULT NULL AFTER `Password`, ADD `Password3` VARCHAR(255) NULL DEFAULT NULL AFTER `Password2`;",
/// Table profile
"CREATE TABLE IF NOT EXISTS `profile` (" +
"`Id` int(11) NOT NULL," +
" `ItemNr` int(11) DEFAULT NULL," +
" `Name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
" `Description` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
" `CreationUser` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
" `CreationTime` datetime DEFAULT NULL," +
" `LastChgUser` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
" `LastChgTime` datetime DEFAULT NULL," +
" `ProfileType` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
" `ErrorLimitType` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
" PRIMARY KEY (`Id`));",
/// Table ptest
"CREATE TABLE IF NOT EXISTS `ptest` (" +
"`Id` int(11) NOT NULL," +
" `ItemNr` int(11) DEFAULT NULL," +
" `Name` varchar(255) DEFAULT NULL," +
" `Part` int(11) NOT NULL DEFAULT '0'," +
" `CoefQfrom` double NOT NULL DEFAULT '0'," +
" `CoefQto` double NOT NULL DEFAULT '0'," +
" `ErrLimLo` double NOT NULL DEFAULT '0'," +
" `ErrLimHi` double NOT NULL DEFAULT '0'," +
" `TempLimLo` double NOT NULL DEFAULT '0'," +
" `TempLimHi` double NOT NULL DEFAULT '0'," +
" `PressLimLo` double NOT NULL DEFAULT '0'," +
" `PressLimHi` double NOT NULL DEFAULT '0'," +
" `Publish` tinyint(4) NOT NULL DEFAULT '1'," +
" `Evaluate` boolean NOT NULL DEFAULT TRUE," +
" `E1` tinyint(4) NOT NULL DEFAULT '0'," +
" `E2` tinyint(4) NOT NULL DEFAULT '0'," +
" `E3` tinyint(4) NOT NULL DEFAULT '0'," +
" `E4` tinyint(4) NOT NULL DEFAULT '0'," +
" `E5` tinyint(4) NOT NULL DEFAULT '0'," +
" `E6` tinyint(4) NOT NULL DEFAULT '0'," +
" `E7` tinyint(4) NOT NULL DEFAULT '0'," +
" `E8` tinyint(4) NOT NULL DEFAULT '0'," +
" `E9` tinyint(4) NOT NULL DEFAULT '0'," +
" `E10` tinyint(4) NOT NULL DEFAULT '0'," +
" `E11` tinyint(4) NOT NULL DEFAULT '0'," +
" `E12` tinyint(4) NOT NULL DEFAULT '0'," +
" `E13` tinyint(4) NOT NULL DEFAULT '0'," +
" `E14` tinyint(4) NOT NULL DEFAULT '0'," +
" `E15` tinyint(4) NOT NULL DEFAULT '0'," +
" `E16` tinyint(4) NOT NULL DEFAULT '0'," +
" `E21` tinyint(4) NOT NULL DEFAULT '0'," +
" `Delta_Q_pct` double NOT NULL DEFAULT '0'," +
" `Delta_T` double NOT NULL DEFAULT '0'," +
" `Delta_Tup_Tdn` double NOT NULL DEFAULT '0'," +
" `TestTime_min` double NOT NULL DEFAULT '0'," +
" `TestTime_max` double NOT NULL DEFAULT '0'," +
" `AmbTemp_min` double NOT NULL DEFAULT '0'," +
" `AmbTemp_max` double NOT NULL DEFAULT '0'," +
" `Coef_E9` double NOT NULL DEFAULT '0'," +
" `Coef_E10` double NOT NULL DEFAULT '0'," +
" `Coef_E11` double NOT NULL DEFAULT '0'," +
" `Coef_E12` double NOT NULL DEFAULT '0'," +
" `Offset_E9` double NOT NULL DEFAULT '0'," +
" `Offset_E12` double NOT NULL DEFAULT '0'," +
" `Profile_id` int(11) NOT NULL DEFAULT '0'," +
" PRIMARY KEY (`Id`));",
/// Table test
"ALTER TABLE `test` ADD `Qtg` FLOAT NULL DEFAULT NULL AFTER `Evaluate`;",
"ALTER TABLE `test` CHANGE `RelTransAfter` `Profile` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;",
"UPDATE `test` SET Profile = 'UserDefined';",
/// Table uncertainty
"CREATE TABLE IF NOT EXISTS `uncertainty` (" +
" `Id` int(11) NOT NULL AUTO_INCREMENT," +
" `Measurement` float NOT NULL DEFAULT '0'," +
@@ -608,19 +736,54 @@ namespace TBF.UI.Settings
" `Component_id` int(11) DEFAULT NULL," +
" PRIMARY KEY (`Id`)," +
" KEY `Component_id` (`Component_id`)" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;",
"UPDATE `test` SET `RelTransAfter`='UserDefined';",
");",
/// Table user
"ALTER TABLE `user` ADD `Password2` VARCHAR(255) NULL DEFAULT NULL AFTER `Password`, ADD `Password3` VARCHAR(255) NULL DEFAULT NULL AFTER `Password2`, ADD `Password4` VARCHAR(255) NULL DEFAULT NULL AFTER `Password3`;",
/// Tables watermeter and wmtype
"DROP TABLE `watermeter`",
"DROP TABLE `wmtype`",
//"ALTER TABLE `procedure` DROP `ProtocolTitle`",
};
string[] resultsDbCommands = new string[]
{
"ALTER TABLE `testdata` ADD `Qtg` DOUBLE NULL DEFAULT NULL AFTER `Name`;",
"ALTER TABLE `testrslt` ADD `Uncertnt` FLOAT NOT NULL DEFAULT '0' AFTER `FlowMax`, ADD `UncertntScale` FLOAT NOT NULL DEFAULT '0' AFTER `Uncertnt`, ADD `UncertntDensity` FLOAT NOT NULL DEFAULT '0' AFTER `UncertntScale`, ADD `UncertntTemp` FLOAT NOT NULL DEFAULT '0' AFTER `UncertntDensity`, ADD `UncertntPressure` FLOAT NOT NULL DEFAULT '0' AFTER `UncertntTemp`;",
"ALTER TABLE `testrslt` CHANGE `ErrorFlags` `ErrorFlags` BIGINT(20) NOT NULL DEFAULT '0', CHANGE `ErrorFlagsMd` `InfoFlags` BIGINT(20) NOT NULL DEFAULT '0';",
"ALTER TABLE `watermeter` CHANGE `ErrorFlags` `ErrorFlags` BIGINT(20) NOT NULL DEFAULT '0', ADD `InfoFlags` BIGINT NOT NULL DEFAULT '0' AFTER `ErrorFlags`;",
#if IPERL
"ALTER TABLE `watermeter` DROP `Q2CorrectionDone`, DROP `Q2Correction`;",
#endif
};
ActivityStart();
bool success = true;
if ((!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
(!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(DB.ConnectionString), resultsDbCommands)))
if (upgradeConfigDBCheckBox.Checked)
{
success = success && ExecuteCommands(new MySqlConnection(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands);
if (!string.IsNullOrEmpty(errorFlagsComponentsTextBox.Text))
{
string[] errorFlagsCmpnts = errorFlagsComponentsTextBox.Text.Split(new char[] { '~' });
foreach (var errFCmpnt in errorFlagsCmpnts)
{
success = success && ChangeErrorFlags(errFCmpnt);
}
}
}
if (upgradeResultsDBCheckBox.Checked)
{
success = success && ExecuteCommands(new MySqlConnection(DB.ConnectionString), resultsDbCommands);
}
if (success)
{
ActivityEnd();
MessageBox.Show("DB succesfully upgraded." + Environment.NewLine +
@@ -632,6 +795,110 @@ namespace TBF.UI.Settings
}
}
private void upgradeDb_224_225_Button_Click(object sender, EventArgs e)
{
MySqlConnection dbConn = null;
MySqlCommand cmd;
ActivityStart();
bool success = false;
try
{
dbConn = new MySqlConnection(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString);
dbConn.Open();
cmd = dbConn.CreateCommand();
cmd.CommandText = "CREATE TABLE IF NOT EXISTS `usersgroups` ( `Group_id` int(11) NOT NULL, `User_id` int(11) NOT NULL );";
cmd.ExecuteNonQuery();
cmd.Dispose();
cmd = dbConn.CreateCommand();
cmd.CommandText = "ALTER TABLE `usersgroups` ADD KEY `User_id` (`User_id`), ADD KEY `Group_id` (`Group_id`)," +
" ADD CONSTRAINT `FKEC3AF23393C4061C` FOREIGN KEY (`Group_id`) REFERENCES `group` (`Id`)," +
" ADD CONSTRAINT `FKEC3AF23373767C99` FOREIGN KEY (`User_id`) REFERENCES `user` (`Id`);";
cmd.ExecuteNonQuery();
cmd.Dispose();
int[] groupIdsToKeep = new int[(int)Users.Entities.GID.NrOfGroups];
IList<GroupTableRow> groupTable = new List<GroupTableRow>();
cmd = dbConn.CreateCommand();
cmd.CommandText = "SELECT `Id`, `Gid`, `User_id` FROM `group`;";
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int groupId = dr.GetInt32(0);
Users.Entities.GID gid = (Users.Entities.GID)dr.GetInt32(1);
int userId = dr.GetInt32(2);
groupTable.Add(new GroupTableRow(groupId, gid, userId));
if ((gid >= 0) && (gid < Users.Entities.GID.NrOfGroups) && (groupIdsToKeep[(int)gid] == 0))
{
groupIdsToKeep[(int)gid] = groupId;
}
}
dr.Close();
foreach (var groupTableRow in groupTable)
{
cmd = dbConn.CreateCommand();
cmd.CommandText = string.Format("INSERT INTO `usersgroups` (`Group_id`, `User_id`) VALUES ({0}, {1});",
groupIdsToKeep[(int)groupTableRow.Gid],
groupTableRow.UserId);
cmd.ExecuteNonQuery();
cmd.Dispose();
}
//foreach (var groupTableRow in groupTable)
//{
// bool deleteThisRow = true;
// for (int i = 0; i < groupIdsToKeep.Length; i++)
// {
// if (groupTableRow.GroupId == groupIdsToKeep[i])
// {
// deleteThisRow = false;
// break;
// }
// }
// if (deleteThisRow)
// {
// cmd = dbConn.CreateCommand();
// cmd.CommandText = string.Format("DELETE FROM `group` WHERE `Id` = {0}", groupTableRow.GroupId);
// cmd.ExecuteNonQuery();
// cmd.Dispose();
// }
//}
cmd = dbConn.CreateCommand();
cmd.CommandText = string.Format("ALTER TABLE `group` ADD `AccessFlags` BIGINT NOT NULL DEFAULT '0' AFTER `Name`;");
cmd.ExecuteNonQuery();
cmd.Dispose();
success = true;
}
catch (Exception exc)
{
log.ErrorFormat(string.Format("Exception when upgrading DB: {0}", exc.Message));
if (exc.InnerException != null) log.ErrorFormat(string.Format("Inner exception: {0}", exc.InnerException.Message));
ActivityEnd();
MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
finally
{
if (dbConn != null) dbConn.Close();
}
if (success)
{
ActivityEnd();
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
upgradeDb_224_225_Button.Enabled = false;
}
}
private void pressureRepresentationButton_Click(object sender, EventArgs e)
{
try
+21 -1
View File
@@ -48,7 +48,25 @@ namespace Users.Forms
try
{
displayedGroups = session.QueryOver<Group>().List();
IList<Group> allGroups = session.QueryOver<Group>().List();
///
/// Selects groups to be displayed (so that each GID is present only once)
///
Group[] dspGroups = new Group[(int)Users.Entities.GID.NrOfGroups];
foreach (var group in allGroups)
{
if ((group.GID >= 0) && (group.GID < Users.Entities.GID.NrOfGroups) && (dspGroups[(int)group.GID] == null))
{
dspGroups[(int)group.GID] = group;
}
}
displayedGroups = new List<Group>();
foreach (var group in dspGroups)
{
if (group != null) displayedGroups.Add(group);
}
listOfUsers = session.QueryOver<User>().List();
}
catch (Exception)
@@ -56,6 +74,8 @@ namespace Users.Forms
if (displayedGroups == null) displayedGroups = new List<Group>();
if (listOfUsers == null) listOfUsers = new List<User>();
}
}
private void UserManagementDlg_Load(object sender, EventArgs e)