refinement

This commit is contained in:
Luc Vandenbroucke 2022-02-28 16:44:47 +01:00
parent e2ea06cda6
commit 8b4769520a
30 changed files with 145 additions and 89 deletions

Binary file not shown.

View file

@ -1,12 +1,7 @@
 stdafx.cpp  stdafx.cpp
AssemblyInfo.cpp AssemblyInfo.cpp
EpdBase.cpp EpdBase.cpp
c:\l\src\cs\edos\epdbase\timefunctions.h(12): warning C4091: 'static ': ignored on left of 'TimeFunctions' when no variable is declared
c:\l\src\cs\edos\epdbase\epdbase.cpp(95): warning C4244: '=': conversion from 'DWORD' to 'WORD', possible loss of data
TimeFunctions.cpp TimeFunctions.cpp
c:\l\src\cs\edos\epdbase\timefunctions.h(12): warning C4091: 'static ': ignored on left of 'TimeFunctions' when no variable is declared
Generating Code... Generating Code...
.NETFramework,Version=v4.7.2.AssemblyAttributes.cpp .NETFramework,Version=v4.8.AssemblyAttributes.cpp
.NETFramework,Version=v4.7.2.AssemblyAttributes.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library EpdBase.vcxproj -> D:\l\src\cs\eDosStation\x64\Debug\EpdBase.lib
AssemblyInfo.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
EpdBase.vcxproj -> C:\l\src\cs\eDos\x64\Debug\EpdBase.lib

Binary file not shown.

Binary file not shown.

View file

@ -1,2 +1,2 @@
#TargetFrameworkVersion=v4.7.2:PlatformToolSet=v141:EnableManagedIncrementalBuild=true:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:TargetPlatformVersion=10.0.19041.0:TargetFrameworkVersion=v4.8::EnableManagedIncrementalBuild=true:
Debug|x64|C:\l\src\cs\eDos\| Debug|x64|D:\l\src\cs\eDosStation\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -23,7 +23,7 @@ void OkReadBadge::BadgeUnmanaged::GetDeviceUSB(std::wstring vid, std::wstring pi
DWORD DeviceInstanceIdSize = 500; DWORD DeviceInstanceIdSize = 500;
DWORD RequiredSize = 0; DWORD RequiredSize = 0;
WCHAR * DeviceInstanceId = new WCHAR(DeviceInstanceIdSize); WCHAR * DeviceInstanceId = new WCHAR[DeviceInstanceIdSize];
DeviceType = 0; DeviceType = 0;
while (DeviceType == 0 && SetupDiEnumDeviceInfo(deviceInterfaceSet, deviceIndex, &deviceInfoData)) while (DeviceType == 0 && SetupDiEnumDeviceInfo(deviceInterfaceSet, deviceIndex, &deviceInfoData))

View file

@ -4,10 +4,13 @@
xmlns:local="clr-namespace:eDosStation" xmlns:local="clr-namespace:eDosStation"
StartupUri="MainWindow.xaml" Startup="Application_Startup" > StartupUri="MainWindow.xaml" Startup="Application_Startup" >
<Application.Resources> <Application.Resources>
<ResourceDictionary>
<ResourceDictionary x:Key="rd1">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="eDosDict.xaml"/> <ResourceDictionary Source="eDosDict.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

View file

@ -356,23 +356,30 @@ namespace eDosStation
//if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code); //if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code);
checkCon(true); checkCon(true);
var rs = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow); var rs = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow);
if (rs.HasRows && rs.Read()) using (var tb = new DataTable())
{ {
Values = new object[rs.FieldCount]; tb.Load(rs);
int rv = rs.GetValues(Values); if (tb.Rows.Count > 0)
u.PersID = (int)Values[rs.GetOrdinal("PersID")]; {
u.LastName = Values[rs.GetOrdinal("LastName")].ToString(); DataRow dr = tb.Rows[0];
u.FirstName = Values[rs.GetOrdinal("FirstName")].ToString(); //Values = new object[rs.FieldCount];
//int rv = rs.GetValues(Values);
u.PersID = (int)dr["PersID"];
u.LastName = dr["LastName"].ToString();
u.FirstName = dr["FirstName"].ToString();
//u.conCode = Values[rs.GetOrdinal("conCode")].ToString(); //u.conCode = Values[rs.GetOrdinal("conCode")].ToString();
u.Language = Values[rs.GetOrdinal("Language")].ToString(); u.Language = dr["Language"].ToString();
u.AccessAllow = Values[rs.GetOrdinal("AccessAllow")] as bool?; u.AccessAllow = dr["AccessAllow"] as bool?;
decimal? m = Values[rs.GetOrdinal("Margin")] as decimal?; decimal? m = dr["Margin"] as decimal?;
if (m.HasValue) u.Margin = (double)m.Value; else u.Margin = null; if (m.HasValue) u.Margin = (double)m.Value; else u.Margin = null;
//u.Margin = (double ?)Values[rs.GetOrdinal("Margin")] ; //u.Margin = (double ?)Values[rs.GetOrdinal("Margin")] ;
u.VisitIDLocked = Values[rs.GetOrdinal("VisitIDLocked")] as int?; u.VisitIDLocked = dr["VisitIDLocked"] as int?;
u.ReasonNoAccess = Values[rs.GetOrdinal("ReasonNoAccess")].ToString().Replace("\\n", "\n"); u.ReasonNoAccess = dr["ReasonNoAccess"].ToString().Replace("\\n", "\n");
u.UserComment = Values[rs.GetOrdinal("Comment")].ToString(); u.UserComment = dr["Comment"].ToString();
u.AllOk = !CheckUser || (u.AccessAllow == true && u.VisitIDLocked == 0); if (tb.Columns.Contains("hasEPD"))
u.hasEPD = (bool)dr["hasEPD"]; else u.hasEPD = false;
if (u.hasEPD) u.ReasonNoAccess = "EPD in use";
u.AllOk = ( !CheckUser || (u.AccessAllow == true && u.VisitIDLocked == 0));
} }
else else
{ {
@ -392,6 +399,7 @@ namespace eDosStation
rs.Close(); rs.Close();
} }
} }
}
catch (System.Exception ex) catch (System.Exception ex)
{ {
if (stationLog != null) stationLog.WriteLine($"GetUser error {ex.Message} {System.DateTime.Now.ToString("HH:mm:ss:nnn")}"); if (stationLog != null) stationLog.WriteLine($"GetUser error {ex.Message} {System.DateTime.Now.ToString("HH:mm:ss:nnn")}");

View file

@ -124,9 +124,9 @@
</Grid> </Grid>
</Border> </Border>
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Stretch" > <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Stretch" >
<Border MaxHeight="700"> <Border MaxHeight="700" HorizontalAlignment="Left" VerticalAlignment="Top">
<ScrollViewer VerticalScrollBarVisibility="Visible" Name="scrollTask" Visibility="Visible" > <ScrollViewer VerticalScrollBarVisibility="Visible" Name="scrollTask" Visibility="Visible" HorizontalAlignment="Stretch" VerticalAlignment="Top" >
<ListBox ItemsSource="{Binding Mode=OneWay}" SelectedValuePath="ID_Task" SelectionChanged="ListBox_SelectionChanged" ScrollViewer.CanContentScroll="False" > <ListBox ItemsSource="{Binding Mode=OneWay}" SelectedValuePath="ID_Task" SelectionChanged="ListBox_SelectionChanged" ScrollViewer.CanContentScroll="False" Name="LB1" >
<ListBox.ItemContainerStyle> <ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}"> <Style TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Left"/> <Setter Property="HorizontalContentAlignment" Value="Left"/>
@ -135,12 +135,12 @@
</ListBox.ItemContainerStyle> </ListBox.ItemContainerStyle>
<ListBox.ItemsPanel> <ListBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<telerik:RadUniformGrid Columns="3" IsItemsHost="True" /> <telerik:RadUniformGrid Columns="3" IsItemsHost="True" HorizontalAlignment="Left" VerticalAlignment="Center" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ListBox.ItemsPanel> </ListBox.ItemsPanel>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal" TextBlock.FontSize="20" Margin="5,5,5,5" Height="20" > <StackPanel Orientation="Horizontal" TextBlock.FontSize="20" Margin="5,5,5,5" Height="20" HorizontalAlignment="Left" VerticalAlignment="Center" >
<TextBlock Text="{Binding TaskType_CODE}" Width="60" TextWrapping="NoWrap" FontSize="18" HorizontalAlignment="Left" > <TextBlock Text="{Binding TaskType_CODE}" Width="60" TextWrapping="NoWrap" FontSize="18" HorizontalAlignment="Left" >
<TextBlock.Style> <TextBlock.Style>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
@ -255,9 +255,9 @@
</TextBlock> </TextBlock>
<TextBlock Grid.Row="2" Grid.Column="2" > <TextBlock Grid.Row="2" Grid.Column="2" >
<Run FontWeight="Bold" Text="Hp10Rate Off: "/> <Run FontWeight="Bold" Text="Hp10Rate Off: "/>
<Run Text="{Binding HP10RateOFF,StringFormat={}{0:0.00} µSv/h}" /> <Run Text="{Binding HP10Rate1OFF,StringFormat={}{0:0.00} µSv/h}" />
<Run FontWeight="Bold" Text=" On: "/> <Run FontWeight="Bold" Text=" On: "/>
<Run Text="{Binding HP10RateON,StringFormat={}{0:0.00} µSv/h}" /> <Run Text="{Binding HP10Rate1ON,StringFormat={}{0:0.00} µSv/h}" />
</TextBlock> </TextBlock>
<TextBlock Grid.Row="3" Grid.Column="1" > <TextBlock Grid.Row="3" Grid.Column="1" >
<Run FontWeight="Bold" Text="Type : "/> <Run FontWeight="Bold" Text="Type : "/>

View file

@ -29,8 +29,6 @@ namespace eDosStation
private DateTime ResultTime; private DateTime ResultTime;
enum eCOE { quiz = 1 }; enum eCOE { quiz = 1 };
#if SimulateEPD #if SimulateEPD
public SimulateData simulData = new SimulateData(); public SimulateData simulData = new SimulateData();
#endif #endif
@ -54,7 +52,6 @@ namespace eDosStation
thisStation = curStation; thisStation = curStation;
_User = null; _User = null;
taskLoading = false; taskLoading = false;
} }
private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e) private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e)
@ -324,8 +321,7 @@ namespace eDosStation
private void SetFilter(bool isAlara) private void SetFilter(bool isAlara)
{ {
dataInterface.stationLog?.WriteLine($"SetFilter Start {DateTime.Now.ToString("HH:mm:ss.fff")}"); dataInterface.stationLog?.WriteLine($"SetFilter Start {DateTime.Now.ToString("HH:mm:ss.fff")}");
taskLoading = true; taskLoading = true; TaskOK.IsEnabled = false;
TaskOK.IsEnabled = false;
Inst1 = (cbInst1.IsChecked == true) && thisStation.Inst_CODE1 > 0; Inst1 = (cbInst1.IsChecked == true) && thisStation.Inst_CODE1 > 0;
Inst2 = (cbInst2.IsChecked == true) && thisStation.Inst_CODE2 > 0; Inst2 = (cbInst2.IsChecked == true) && thisStation.Inst_CODE2 > 0;
StringBuilder fi = new StringBuilder(); StringBuilder fi = new StringBuilder();
@ -360,7 +356,6 @@ namespace eDosStation
taskLoading = false; taskLoading = false;
dataInterface.stationLog?.WriteLine($"SetFilter Stop {DateTime.Now.ToString("HH:mm:ss.fff")}"); dataInterface.stationLog?.WriteLine($"SetFilter Stop {DateTime.Now.ToString("HH:mm:ss.fff")}");
} }
public string getCommentUnknown() public string getCommentUnknown()
{ {
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
@ -414,10 +409,12 @@ namespace eDosStation
{ {
doCancel = false; doCancel = false;
tbUser.IsSelected = true; tbUser.IsSelected = true;
if (_User == null || _User.VisitIDLocked > 0 || _User.AccessAllow == false) if (_User == null || _User.VisitIDLocked > 0 || _User.AccessAllow == false || _User.hasEPD)
{ {
if (_User.VisitIDLocked > 0 || _User.AccessAllow == false) if (_User.VisitIDLocked > 0 || _User.AccessAllow == false)
ReasonNoAccess = _User.ReasonNoAccess; ReasonNoAccess = _User.ReasonNoAccess;
else if (_User.hasEPD)
ReasonNoAccess = "User has epd in use";
else ReasonNoAccess = getCommentOnEvent(string.Empty, 3); else ReasonNoAccess = getCommentOnEvent(string.Empty, 3);
} }
@ -479,16 +476,12 @@ namespace eDosStation
} }
void AskTask() void AskTask()
{ {
dataInterface.stationLog?.WriteLine($"AskTask Start {DateTime.Now.ToString("HH:mm:ss.fff")}");
tbTask.IsSelected = true; tbTask.IsSelected = true;
Naam.Text = _User.FirstName + " " + _User.LastName; Naam.Text = _User.FirstName + " " + _User.LastName;
eDosStation.DataSet1 dataSet1 = ((eDosStation.DataSet1)(this.FindResource("dataSet1"))); eDosStation.DataSet1 dataSet1 = ((eDosStation.DataSet1)(this.FindResource("dataSet1")));
dataInterface.stationLog?.WriteLine($"AskTask Before fill {DateTime.Now.ToString("HH:mm:ss.fff")}");
dataInterface.FillTaskInfo(_User, dataSet1); dataInterface.FillTaskInfo(_User, dataSet1);
dataInterface.stationLog?.WriteLine($"AskTask After fill {DateTime.Now.ToString("HH:mm:ss.fff")}");
bool isAlara = (cbAlara.IsChecked == true); bool isAlara = (cbAlara.IsChecked == true);
Dispatcher.InvokeAsync(() => { SetFilter(isAlara); }); Dispatcher.InvokeAsync(() => { SetFilter(isAlara); });
dataInterface.stationLog?.WriteLine($"AskTask Stop {DateTime.Now.ToString("HH:mm:ss.fff")}");
} }
void CheckBadge() void CheckBadge()
{ {
@ -768,6 +761,7 @@ namespace eDosStation
dfReader.Dispose(); dfReader = null; dfReader.Dispose(); dfReader = null;
} }
} }
taskLoading = false;
} }
private void DfReader_BadgeError(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeErrorEventArgs e) private void DfReader_BadgeError(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeErrorEventArgs e)

View file

@ -208,11 +208,54 @@ namespace eDosStation
} }
private void CmdSetParams(SqlCommand cmd)
{
//for (int ix = 0; ix < cmd.Parameters.Count; ix++)
// System.Diagnostics.Debug.WriteLine(cmd.Parameters[ix].ParameterName);
try
{
cmd.SetIfExists("ComPort", ComPort);
if (!string.IsNullOrEmpty(Inst_Name1) && Inst_CODE1 > 0)
{
cmd.SetIfExists("Inst_CODE1", Inst_CODE1);
cmd.SetIfExists("Inst_Name1", Inst_Name1);
}
if (!string.IsNullOrEmpty(Inst_Name2) && Inst_CODE2 > 0)
{
cmd.SetIfExists("Inst_CODE2", Inst_CODE2);
cmd.SetIfExists("Inst_Name2", Inst_Name2);
}
//if (!string.IsNullOrEmpty(TestCSN))
// cmd.Parameters.AddWithValue("TestCSN", TestCSN);
//Reader
if (!string.IsNullOrEmpty(Reader)) cmd.SetIfExists("Reader", Reader);
cmd.SetIfExists("checkUser", checkUser);
cmd.SetIfExists("useBeep", useBeep);
cmd.SetIfExists("EPDTimeout", EPDTimeOut);
cmd.SetIfExists("EPDRetries", EPDRetries);
}
catch (System.Exception ex)
{
}
}
private void UpdateToDb(SqlConnection co, SqlCommand cmd) private void UpdateToDb(SqlConnection co, SqlCommand cmd)
{ {
cmd.Connection = co; cmd.Connection = co;
try try
{ {
cmd.Parameters.Clear();
SqlCommandBuilder.DeriveParameters(cmd);
CmdSetParams(cmd);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
catch (System.Exception ex) { catch (System.Exception ex) {
@ -225,29 +268,6 @@ namespace eDosStation
using (var cmd = new SqlCommand("StationSettingsUpdate")) using (var cmd = new SqlCommand("StationSettingsUpdate"))
{ {
cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ComPort", ComPort);
if (!string.IsNullOrEmpty(Inst_Name1) && Inst_CODE1 > 0)
{
cmd.Parameters.AddWithValue("Inst_CODE1", Inst_CODE1);
cmd.Parameters.AddWithValue("Inst_Name1", Inst_Name1);
}
if (!string.IsNullOrEmpty(Inst_Name2) && Inst_CODE2 > 0)
{
cmd.Parameters.AddWithValue("Inst_CODE2", Inst_CODE2);
cmd.Parameters.AddWithValue("Inst_Name2", Inst_Name2);
}
//if (!string.IsNullOrEmpty(TestCSN))
// cmd.Parameters.AddWithValue("TestCSN", TestCSN);
if (!string.IsNullOrEmpty(Reader))
cmd.Parameters.AddWithValue("Reader", Reader);
cmd.Parameters.AddWithValue("checkUser", checkUser);
cmd.Parameters.AddWithValue("useBeep", useBeep);
cmd.Parameters.AddWithValue("EPDTimeout", EPDTimeOut);
cmd.Parameters.AddWithValue("EPDRetries", EPDRetries);
try try
{ {

View file

@ -22,10 +22,13 @@ namespace eDosStation
public bool AllOk = false; public bool AllOk = false;
public bool hasEPD { get; set; }
public int Error = 0; public int Error = 0;
public string ErrorMessage; public string ErrorMessage;
public string FullUserName() public string FullUserName()
{ {
return string.Concat(FirstName, " ", LastName); return string.Concat(FirstName, " ", LastName);

View file

@ -7,6 +7,11 @@
<BitmapImage x:Key="iNG" UriSource="Images/EPD-N2.png" /> <BitmapImage x:Key="iNG" UriSource="Images/EPD-N2.png" />
<BitmapImage x:Key="iRD" UriSource="Images/Mk2OnReader.jpg" /> <BitmapImage x:Key="iRD" UriSource="Images/Mk2OnReader.jpg" />
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
</Style>
<Style x:Key="ScrollBarPageButton" <Style x:Key="ScrollBarPageButton"
TargetType="{x:Type RepeatButton}"> TargetType="{x:Type RepeatButton}">
<Setter Property="SnapsToDevicePixels" <Setter Property="SnapsToDevicePixels"

View file

@ -163,6 +163,7 @@
<Compile Include="EpdExit.xaml.cs"> <Compile Include="EpdExit.xaml.cs">
<DependentUpon>EpdExit.xaml</DependentUpon> <DependentUpon>EpdExit.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="extensions.cs" />
<Compile Include="InstMessage.xaml.cs"> <Compile Include="InstMessage.xaml.cs">
<DependentUpon>InstMessage.xaml</DependentUpon> <DependentUpon>InstMessage.xaml</DependentUpon>
</Compile> </Compile>
@ -292,6 +293,7 @@
<Content Include="Reader3.dll"> <Content Include="Reader3.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Resource Include="todo.txt" />
<Resource Include="Images\EPD-MK3.png" /> <Resource Include="Images\EPD-MK3.png" />
<Resource Include="Images\logo500.png" /> <Resource Include="Images\logo500.png" />
<Resource Include="Images\logoh120.png" /> <Resource Include="Images\logoh120.png" />
@ -324,6 +326,10 @@
<Project>{f1f47b79-9930-48b0-8dde-56e2c4bed2a2}</Project> <Project>{f1f47b79-9930-48b0-8dde-56e2c4bed2a2}</Project>
<Name>EpdBaseClr</Name> <Name>EpdBaseClr</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\OkReadBadge\OkReadBadge.vcxproj">
<Project>{f98f3496-8a4c-4bdb-9f17-c7af47a60739}</Project>
<Name>OkReadBadge</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

20
eDosStation/extensions.cs Normal file
View file

@ -0,0 +1,20 @@
using System;
static public class extensions
{
static public bool SetIfExists(this System.Data.SqlClient.SqlCommand cmd, string paramname, object value)
{
bool rv = true;
if (value == null) value = DBNull.Value;
string p1 = "@" + paramname;
if (cmd.Parameters.Contains(p1))
cmd.Parameters[p1].Value = value;
else if (cmd.Parameters.Contains(paramname))
cmd.Parameters[paramname].Value = value;
else rv = false;
return rv;
}
}

2
eDosStation/todo.txt Normal file
View file

@ -0,0 +1,2 @@
check existing user
devcon restart "USB\VID_0EBB&PID_0340&MI_00"