From 3c99fe56245304b8a06c24721fc03de6a70d0aa6 Mon Sep 17 00:00:00 2001 From: Luc Vandenbroucke Date: Wed, 5 Feb 2020 14:21:53 +0100 Subject: [PATCH] functionality testing --- EpdBase/EpdBase.cpp | 32 ++- EpdBaseClr/EpdBaseClr.cpp | 39 ++-- EpdBaseClr/EpdBaseClr.h | 6 + OkReadBadge/Badging.h | 1 - OkReadBadge/OkReadBadge.cpp | 9 +- OkReadBadge/OkReadBadge.h | 5 +- RegisterBAdge/App.config | 16 ++ RegisterBAdge/App.xaml | 9 + RegisterBAdge/App.xaml.cs | 17 ++ RegisterBAdge/MainWindow.xaml | 53 +++++ RegisterBAdge/MainWindow.xaml.cs | 184 ++++++++++++++++++ RegisterBAdge/Properties/AssemblyInfo.cs | 55 ++++++ .../Properties/Resources.Designer.cs | 71 +++++++ RegisterBAdge/Properties/Resources.resx | 117 +++++++++++ RegisterBAdge/Properties/Settings.Designer.cs | 46 +++++ RegisterBAdge/Properties/Settings.settings | 22 +++ RegisterBAdge/RegisterBAdge.csproj | 101 ++++++++++ eDosStation.sln | 22 +++ eDosStation/DataSet1.xsd | 4 +- eDosStation/EntryBadge.xaml | 21 +- eDosStation/EntryBadge.xaml.cs | 112 ++++++----- eDosStation/EpdExit.xaml.cs | 41 +++- eDosStation/MainWindow.xaml.cs | 2 + eDosStation/User.cs | 13 +- 24 files changed, 870 insertions(+), 128 deletions(-) create mode 100644 RegisterBAdge/App.config create mode 100644 RegisterBAdge/App.xaml create mode 100644 RegisterBAdge/App.xaml.cs create mode 100644 RegisterBAdge/MainWindow.xaml create mode 100644 RegisterBAdge/MainWindow.xaml.cs create mode 100644 RegisterBAdge/Properties/AssemblyInfo.cs create mode 100644 RegisterBAdge/Properties/Resources.Designer.cs create mode 100644 RegisterBAdge/Properties/Resources.resx create mode 100644 RegisterBAdge/Properties/Settings.Designer.cs create mode 100644 RegisterBAdge/Properties/Settings.settings create mode 100644 RegisterBAdge/RegisterBAdge.csproj diff --git a/EpdBase/EpdBase.cpp b/EpdBase/EpdBase.cpp index 4063465..87fe2e9 100644 --- a/EpdBase/EpdBase.cpp +++ b/EpdBase/EpdBase.cpp @@ -1,16 +1,15 @@ #include "stdafx.h" #include "EpdBase.h" +#define DiscoveryExpirationPeriod 1000 + EpdBase::Epd2U::Epd2U(int comport) { port = comport; CommsInitialized = 0; SetAutoCommit(0); Error = 123; - //SetTimeouts(port, 20, 1000, 1000); - - } DWORD EpdBase::Epd2U::StartCom() @@ -20,7 +19,7 @@ DWORD EpdBase::Epd2U::StartCom() if (InitRv == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); else { CommsInitialized = 1; - SetDiscoveryExpirationPeriod(port, 5000); + SetDiscoveryExpirationPeriod(port, DiscoveryExpirationPeriod); } return Error; } @@ -35,17 +34,18 @@ EpdBase::Epd2U::~Epd2U() int EpdBase::Epd2U::StartDiscover() { Error = 0; - FlushDiscoveryCache(port); + Sleep(200); DiscRV= Discover(port, DeviceIDs, MaxDevices, &DeviceCount); Commit(); if (DiscRV == 1 && DeviceCount == 0) { DeinitComms(port); - Sleep(100); + FlushDiscoveryCache(port); + Sleep(200); InitRv = InitComms(port, 9600, 8, 0, 0); if (InitRv == 1) { CommsInitialized = 1; - SetDiscoveryExpirationPeriod(port, 5000); + SetDiscoveryExpirationPeriod(port, DiscoveryExpirationPeriod); DiscRV = Discover(port, DeviceIDs, MaxDevices, &DeviceCount); Commit(); } @@ -54,10 +54,7 @@ int EpdBase::Epd2U::StartDiscover() Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); } } - - return DiscRV; - } void EpdBase::Epd2U::Open(DWORD DeviceID) @@ -119,6 +116,7 @@ void EpdBase::Epd2U::DecodeStatus() WORD EpdBase::Epd2U::ReadStatus() { + Error = 0; ReadStatusRV = 0; memset(WearerID, 0, WearerIDLength+1); memset(WearerName, 0, WearerNameLength+1); @@ -126,7 +124,6 @@ WORD EpdBase::Epd2U::ReadStatus() ErrorSource = ErrorReason = ErrorData = 0; EpdID = HardVersion = SoftVersion = FunctionFlags = 0; - CommitRV = ReadEpdStatus(&EpdClock, &RealTime, &IssueCount, &OffTime, &OperatingStatus, &ErrorStatus, &AlarmStatus, &OtherAlarms, &EEPROMBadSectors); if (CommitRV==1) CommitRV= ReadEpdID( &EpdID, @@ -136,7 +133,8 @@ WORD EpdBase::Epd2U::ReadStatus() if (CommitRV==1) CommitRV = Commit(); if(CommitRV == 0) { Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); - return ErrorReason; + ReadStatusRV= ErrorReason; + return 0; } else { if (CurrentDeviceID == 0) CurrentDeviceID = EpdID; @@ -156,15 +154,15 @@ WORD EpdBase::Epd2U::ReadStatus() if(CommitRV==1) CommitRV = Commit(); if (CommitRV == 0) { Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData); - return ErrorReason; + ReadStatusRV = ErrorReason; + return 0; } else { for (int i = 0; i < WearerIDLength; i++) if (WearerID[i] == 0xb) WearerID[i] = '0'; else WearerID[i] |= 0x30; } } - - return CommitRV; + return CommitRV; } WORD EpdBase::Epd2U::EPDReadExtraStatus() @@ -378,7 +376,6 @@ WORD EpdBase::Epd2U::DeIssue() } //DeinitComms(port); return CommitRV; - } @@ -386,7 +383,6 @@ WORD EpdBase::Epd2U::Issue() { IssueEpdRV = WriteAlarmDoseThresholdsRV = WriteAlarmRateThresholdsRV = WriteWearerNameRV = OnRV = CommitRV = 0; - DWORD OKRV = SetFailFlag(); // all actions have been completed if (OKRV) OKRV = Commit(); @@ -406,7 +402,7 @@ WORD EpdBase::Epd2U::Issue() Commit(); if (!DetectorsOn) { - OKRV = EpdOn(); OKRV=Commit(); Sleep(1000); + OKRV = EpdOn(); OKRV=Commit(); Sleep(1500); } if (OKRV) { diff --git a/EpdBaseClr/EpdBaseClr.cpp b/EpdBaseClr/EpdBaseClr.cpp index 851f9e3..e2197de 100644 --- a/EpdBaseClr/EpdBaseClr.cpp +++ b/EpdBaseClr/EpdBaseClr.cpp @@ -23,6 +23,8 @@ EpdBaseClr::Epd2::!Epd2() int EpdBaseClr::Epd2::Connect() { + + ConnectError = 0; epd->StartCom(); b->CurrentDeviceID = 0; @@ -32,6 +34,9 @@ int EpdBaseClr::Epd2::Connect() DeviceCount = epd->DeviceCount; if (epd->DeviceCount >= 0) b->CurrentDeviceID = epd->DeviceIDs[0]; } + else { + ConnectError = epd->Error; + } return DiscRV; } @@ -43,16 +48,13 @@ int EpdBaseClr::Epd2::Close() return 0; } - - int EpdBaseClr::Epd2::GetStatus() { - //ReadStatus - StatusRV = 0; Issued = false; + GetStatusError = 0; StatusRV = 0; Issued = false; WearerID = String::Empty; WearerName = String::Empty; - epd->ReadStatus(); - StatusRV= epd->ReadStatusRV; + StatusRV = epd->ReadStatus(); + if (StatusRV != 1 ) GetStatusError=epd->Error; Issued = epd->EPDIssued; WearerID = gcnew String((char *)epd->WearerID); WearerName = gcnew String((char *)epd->WearerName); @@ -77,6 +79,7 @@ int EpdBaseClr::Epd2::GetDoses() ReadDosesRV = epd->ReadDoses(); if (ReadDosesRV == 1) { + GetDosesError = 0; Hp10 = (double)epd->Hp10Dose / 64.0; Hp07 = (double)epd->Hp07Dose / 64.0; Hp07Peak = (double)epd->Hp07Peak / 64.0; @@ -84,7 +87,9 @@ int EpdBaseClr::Epd2::GetDoses() Hp07Total = epd->Hp07Total / 64.0; Hp10Total = epd->Hp10Total / 64.0; - + } + else { + GetDosesError = epd->Error; } if (epd->Hp10Time > 0) @@ -119,12 +124,15 @@ int EpdBaseClr::Epd2::SetDeIssued() int EpdBaseClr::Epd2::PrepareForIssue() { - return epd->PrepareForIssue(); + PrepareForIssueError = 0; + int rv= epd->PrepareForIssue(); + if (rv != 1) PrepareForIssueError = epd->Error; + return rv; } int EpdBaseClr::Epd2::SetIssued() { - + SetIssuedError = 0; epd->Hp07THDose = Hp07THDose*64; epd->Hp10THDose1 = Hp10THDose1*64; epd->Hp10THDose2 = Hp10THDose2*64; @@ -135,7 +143,6 @@ int EpdBaseClr::Epd2::SetIssued() epd->Hp10Rate1Off = Hp10Rate1Off; epd->Hp10Rate2Off = Hp10Rate2Off; epd->Hp07RateOff = Hp07RateOff; - memset(epd->WearerID, ' ', WearerIDLength); epd->WearerID[WearerIDLength] = 0; char* str1 = (char*)(void *)Runtime::InteropServices::Marshal::StringToHGlobalAnsi(WearerID); @@ -151,11 +158,11 @@ int EpdBaseClr::Epd2::SetIssued() _memccpy(epd->WearerName, str2, l, WearerNameLength); Runtime::InteropServices::Marshal::FreeHGlobal((IntPtr)str2); - epd->Issue(); - return 0; + int rv = epd->Issue(); + if (rv != 1) SetIssuedError = epd->Error; + return rv; } - int EpdBaseClr::Epd2::WriteCalibration() { @@ -180,7 +187,9 @@ int EpdBaseClr::Epd2::WriteCalibration() int EpdBaseClr::Epd2::ReadTresholds() { - epd->ReadTresHolds(); + ReadTresholdsError = 0; + int rv= epd->ReadTresHolds(); + if (rv != 0) ReadTresholdsError = epd->Error; Hp10THDose1 = (double)epd->Hp10THDose1 / 64.0; Hp10THDose2 = (double)epd->Hp10THDose2 / 64.0; @@ -207,7 +216,7 @@ int EpdBaseClr::Epd2::ReadTresholds() FB = epd->FB; HG = epd->HG; - return 0; + return rv; } int EpdBaseClr::Epd2::ReadExtraStatus() diff --git a/EpdBaseClr/EpdBaseClr.h b/EpdBaseClr/EpdBaseClr.h index 61c4df5..5f5c117 100644 --- a/EpdBaseClr/EpdBaseClr.h +++ b/EpdBaseClr/EpdBaseClr.h @@ -29,6 +29,12 @@ namespace EpdBaseClr { int InitRV; int DiscRV; int StatusRV; + int GetStatusError; + int GetDosesError; + int ReadTresholdsError; + int PrepareForIssueError; + int SetIssuedError; + int ConnectError; int ReadDosesRV; int DeviceCount = 0; diff --git a/OkReadBadge/Badging.h b/OkReadBadge/Badging.h index 7124bcc..80b5985 100644 --- a/OkReadBadge/Badging.h +++ b/OkReadBadge/Badging.h @@ -14,7 +14,6 @@ namespace OkReadBadge clr = gcnew OkReadBadge::BadgeMessageHandler(); clr->OnMessage = f; clrb = new OkReadBadge::BadgeUnmanaged(clr); - } void Start() diff --git a/OkReadBadge/OkReadBadge.cpp b/OkReadBadge/OkReadBadge.cpp index 22b990f..ce812b0 100644 --- a/OkReadBadge/OkReadBadge.cpp +++ b/OkReadBadge/OkReadBadge.cpp @@ -62,9 +62,6 @@ void OkReadBadge::BadgeUnmanaged::GetDeviceUSB(std::wstring vid, std::wstring pi } } - - - int OkReadBadge::BadgeUnmanaged::read() { //const string x ="USB\\VID_076B&PID_5128&MI_00\\6&13A62366&0&0000"; @@ -73,6 +70,7 @@ int OkReadBadge::BadgeUnmanaged::read() //const wchar_t *devicePath1 = L"\\\\?\\hid#vid_076b&pid_5428&mi_00#7&95573f7&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"; HANDLE HIDfile = CreateFile(DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL| FILE_FLAG_OVERLAPPED, nullptr); //FILE_FLAG_OVERLAPPED| DWORD err = GetLastError(); + completed = false; if (err != 0) { //_tprintf(TEXT("unable to obtain read permissions for the HID device, error:\n ")); } @@ -81,7 +79,7 @@ int OkReadBadge::BadgeUnmanaged::read() bread = 0; rv = 1; err = 0; - while (err==0) + while (err==0 && !completed) { rv = ReadFile(HIDfile, buffer, 100, &bread, Overlapped); if (rv == 0) @@ -117,16 +115,13 @@ int OkReadBadge::BadgeUnmanaged::read() return 0; } - OkReadBadge::BadgeUnmanaged::BadgeUnmanaged(BadgeMessageHandler^ clr) { m_clr = clr; - Overlapped = new OVERLAPPED(); memset(Overlapped, 0, sizeof(OVERLAPPED)); Overlapped->Offset = 0; Overlapped->hEvent = CreateEvent(nullptr, true, false, nullptr); - buffer[100]; memset(buffer, 0, sizeof(buffer)); buffer[0] = 0x00; // Feature report 0x0F diff --git a/OkReadBadge/OkReadBadge.h b/OkReadBadge/OkReadBadge.h index b4b1c34..4e9667f 100644 --- a/OkReadBadge/OkReadBadge.h +++ b/OkReadBadge/OkReadBadge.h @@ -30,8 +30,8 @@ namespace OkReadBadge bool nextSite = false; bool nextCode = false; bool nextFinish = false; + bool completed = false; char Res [100]; - static bool CALLBACK Message(int err, LPARAM param) { @@ -50,7 +50,7 @@ namespace OkReadBadge } else if (!strncmp("csn:", r, 4)) { memset(bu->Res, 0, sizeof(bu->Res)); - bu->nextCSN = true; bu->nextFinish = bu->nextCode = bu->nextSite = false ; + bu->nextCSN = true; bu->nextFinish = bu->nextCode = bu->nextSite = bu->completed = false ; } else if (!strncmp("site:", r, 5)) { bu->nextSite = true; } else if (!strncmp("code:", r, 5)) { bu->nextCode = true; } @@ -59,6 +59,7 @@ namespace OkReadBadge bu->nextCode = bu->nextSite = bu->nextCSN = false; if (bu->nextFinish) { bu->nextFinish = false; + bu->completed = true; } } bu->m_clr->Result = gcnew String(r); diff --git a/RegisterBAdge/App.config b/RegisterBAdge/App.config new file mode 100644 index 0000000..f2a54fb --- /dev/null +++ b/RegisterBAdge/App.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/RegisterBAdge/App.xaml b/RegisterBAdge/App.xaml new file mode 100644 index 0000000..a896ffb --- /dev/null +++ b/RegisterBAdge/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/RegisterBAdge/App.xaml.cs b/RegisterBAdge/App.xaml.cs new file mode 100644 index 0000000..52688e7 --- /dev/null +++ b/RegisterBAdge/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace RegisterBAdge +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/RegisterBAdge/MainWindow.xaml b/RegisterBAdge/MainWindow.xaml new file mode 100644 index 0000000..2f33219 --- /dev/null +++ b/RegisterBAdge/MainWindow.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RegisterBAdge/MainWindow.xaml.cs b/RegisterBAdge/MainWindow.xaml.cs new file mode 100644 index 0000000..944c829 --- /dev/null +++ b/RegisterBAdge/MainWindow.xaml.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace RegisterBAdge +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public static OkReadBadge.Badging a; + System.Threading.Thread t; + bool nextCSN = false; + bool nextSite = false; + bool nextCode = false; + bool nextFinish = false; + string csn, site, code; + System.Data.SqlClient.SqlCommand UpdPers; + + public MainWindow() + { + InitializeComponent(); + } + + void CheckBadge() + { + using (var t = new System.Data.DataTable()) { + using (var co = new System.Data.SqlClient.SqlConnection(Properties.Settings.Default.idpbwConnection)) + { + using (var co2 = new System.Data.SqlClient.SqlConnection(Properties.Settings.Default.RemsConnection)) + { + using (var cm = new System.Data.SqlClient.SqlCommand("rems.GetPerson", co)) + { + cm.CommandType = System.Data.CommandType.StoredProcedure; + cm.Parameters.AddWithValue("CSN", CSN.Text); + cm.Parameters.AddWithValue("Badge", Code.Text); + co.Open(); + var rs = cm.ExecuteReader(System.Data.CommandBehavior.SingleRow | System.Data.CommandBehavior.CloseConnection); + t.Load(rs); + co.Close(); + if (t.Rows.Count > 0) + { + co2.Open(); + DataRow r = t.Rows[0]; + + PersID.Text = r["persID"].ToString(); + Name.Text = r["LastName"].ToString(); + FirstName.Text = (string)r["NickName"]; + + UpdPers.Parameters["persID"].Value = (int)r["persID"]; + UpdPers.Parameters["TYPE"].Value = (string)r["TYPE"]; + UpdPers.Parameters["CSN"].Value = (string)r["CSN"]; + UpdPers.Parameters["Badge"].Value = (string)r["Badge"]; + UpdPers.Parameters["firstname"].Value = (string)r["firstname"]; + UpdPers.Parameters["LastName"].Value = (string)r["LastName"]; + UpdPers.Parameters["NickName"].Value = (string)r["NickName"]; + UpdPers.Parameters["birthDate"].Value = (DateTime)r["birthDate"]; + UpdPers.Parameters["conCode"].Value = (string)r["conCode"]; + UpdPers.Parameters["AccessAllow"].Value = (Boolean)r["AccessAllow"]; + UpdPers.Parameters["Language"].Value = (string)r["Language"]; + UpdPers.Parameters["VisitIdLocked"].Value = DBNull.Value; + UpdPers.Parameters["Deleted"].Value = (Boolean)r["Deleted"]; + UpdPers.Connection = co2; + UpdPers.ExecuteNonQuery(); + co2.Close(); + } + } + } + } + } + //_User = new User(CSN.Text, Code.Text); + //if (_User.Error == 0) + // AskTask(); + //else + //{ + // MessageBox.Show(_User.ErrorMessage); + // Close(); + //} + } + + public void showBadge() + { + CSN.Text = csn; + Site.Text = site; + Code.Text = code; + + Dispatcher.Invoke(CheckBadge); + } + + bool Msg(int err) + { + //decodeert verschillenden USB messages. (callback ) + if (err == 0) + { + if (a.clr.Result.StartsWith("csn:", StringComparison.InvariantCultureIgnoreCase) && a.clr.Result.EndsWith(";")) + { //GEn 2 + csn = string.Empty; + foreach (string ar in a.clr.Result.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) + { + if (ar.StartsWith("csn:")) csn = ar.Substring(4); + if (ar.StartsWith("site:")) site = ar.Substring(5); + if (ar.StartsWith("code:")) code = ar.Substring(5); + } + this.Dispatcher.Invoke(new Action(() => showBadge())); + } + else + { + if (a.clr.Result.Equals(";")) + { + if (nextSite) site = string.Empty; + if (nextCode) code = string.Empty; + if (nextFinish || nextCode) + { + this.Dispatcher.Invoke(new Action(() => showBadge())); + } + nextCSN = nextSite = nextCode = nextFinish = false; + } + else if (nextCSN) { csn = a.clr.Result; nextCSN = nextFinish = false; } + else if (nextSite) { site = a.clr.Result; nextSite = false; } + else if (nextCode) { code = a.clr.Result; nextCode = false; nextFinish = true; } + else if (a.clr.Result.Equals("csn:")) { nextCSN = true; nextCode = nextSite = false; } + else if (a.clr.Result.Equals("site:")) { nextSite = true; nextCSN = nextCode = false; } + else if (a.clr.Result.Equals("code:")) { nextCode = true; nextCSN = nextSite = false; } + else System.Diagnostics.Debug.WriteLine(a.clr.Result); + } + } + else + System.Diagnostics.Debug.WriteLine($"Error {err}"); + return false; + } + + private void Starter() + { + try + { + a = new OkReadBadge.Badging(Msg); + a.Start(); + } + catch (System.Exception ex) + { + MessageBox.Show($"Badgereader error {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); + } + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + UpdPers = new System.Data.SqlClient.SqlCommand("UpdatePerson"); + UpdPers.CommandType = System.Data.CommandType.StoredProcedure; + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("RETURN_VALUE", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.ReturnValue, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("persID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("TYPE", System.Data.SqlDbType.Char, 1, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("CSN", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("Badge", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("firstname", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("LastName", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("NickName", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("birthDate", System.Data.SqlDbType.Date, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("conCode", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("AccessAllow", System.Data.SqlDbType.Bit, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("Language", System.Data.SqlDbType.Char, 1, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("VisitIdLocked", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + UpdPers.Parameters.Add(new System.Data.SqlClient.SqlParameter("Deleted", System.Data.SqlDbType.Bit, 0, System.Data.ParameterDirection.Input, false, 0, 0, null, System.Data.DataRowVersion.Current, DBNull.Value)); + + + t = new System.Threading.Thread(() => Starter()); + t.Start(); + } + + + } +} diff --git a/RegisterBAdge/Properties/AssemblyInfo.cs b/RegisterBAdge/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..df11d0c --- /dev/null +++ b/RegisterBAdge/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RegisterBAdge")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RegisterBAdge")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RegisterBAdge/Properties/Resources.Designer.cs b/RegisterBAdge/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c5f5e62 --- /dev/null +++ b/RegisterBAdge/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RegisterBAdge.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RegisterBAdge.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/RegisterBAdge/Properties/Resources.resx b/RegisterBAdge/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/RegisterBAdge/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegisterBAdge/Properties/Settings.Designer.cs b/RegisterBAdge/Properties/Settings.Designer.cs new file mode 100644 index 0000000..4cfc227 --- /dev/null +++ b/RegisterBAdge/Properties/Settings.Designer.cs @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RegisterBAdge.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=sqlprdidpbw;Initial Catalog=idpbw;Integrated Security=True")] + public string idpbwConnection { + get { + return ((string)(this["idpbwConnection"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=sqlsrv3;Initial Catalog=HPH_REMS_new;Integrated Security=True")] + public string RemsConnection { + get { + return ((string)(this["RemsConnection"])); + } + } + } +} diff --git a/RegisterBAdge/Properties/Settings.settings b/RegisterBAdge/Properties/Settings.settings new file mode 100644 index 0000000..99207a2 --- /dev/null +++ b/RegisterBAdge/Properties/Settings.settings @@ -0,0 +1,22 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=sqlprdidpbw;Initial Catalog=idpbw;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=sqlprdidpbw;Initial Catalog=idpbw;Integrated Security=True + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=sqlsrv3;Initial Catalog=HPH_REMS_new;Integrated Security=True</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=sqlsrv3;Initial Catalog=HPH_REMS_new;Integrated Security=True + + + \ No newline at end of file diff --git a/RegisterBAdge/RegisterBAdge.csproj b/RegisterBAdge/RegisterBAdge.csproj new file mode 100644 index 0000000..d691483 --- /dev/null +++ b/RegisterBAdge/RegisterBAdge.csproj @@ -0,0 +1,101 @@ + + + + + Debug + AnyCPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B} + WinExe + RegisterBAdge + RegisterBAdge + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\Release\OkReadBadge.dll + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + \ No newline at end of file diff --git a/eDosStation.sln b/eDosStation.sln index e7bef59..6ac24b1 100644 --- a/eDosStation.sln +++ b/eDosStation.sln @@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EpdBaseClr", "EpdBaseClr\Ep EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OkReadBadge", "OkReadBadge\OkReadBadge.vcxproj", "{F98F3496-8A4C-4BDB-9F17-C7AF47A60739}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegisterBAdge", "RegisterBAdge\RegisterBAdge.csproj", "{6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -121,6 +123,26 @@ Global {F98F3496-8A4C-4BDB-9F17-C7AF47A60739}.Release|x64.Build.0 = Release|x64 {F98F3496-8A4C-4BDB-9F17-C7AF47A60739}.Release|x86.ActiveCfg = Release|Win32 {F98F3496-8A4C-4BDB-9F17-C7AF47A60739}.Release|x86.Build.0 = Release|Win32 + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|ARM.Build.0 = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|ARM64.Build.0 = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|x64.ActiveCfg = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|x64.Build.0 = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|x86.ActiveCfg = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Debug|x86.Build.0 = Debug|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|Any CPU.Build.0 = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|ARM.ActiveCfg = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|ARM.Build.0 = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|ARM64.ActiveCfg = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|ARM64.Build.0 = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|x64.ActiveCfg = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|x64.Build.0 = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|x86.ActiveCfg = Release|Any CPU + {6AC69ACE-3666-4A3D-A4B9-FFA24C424C1B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/eDosStation/DataSet1.xsd b/eDosStation/DataSet1.xsd index 776841e..2bc513f 100644 --- a/eDosStation/DataSet1.xsd +++ b/eDosStation/DataSet1.xsd @@ -83,7 +83,7 @@ - + @@ -113,7 +113,7 @@ - + diff --git a/eDosStation/EntryBadge.xaml b/eDosStation/EntryBadge.xaml index 1569765..adaae82 100644 --- a/eDosStation/EntryBadge.xaml +++ b/eDosStation/EntryBadge.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:eDosStation" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="eDosStation.EntryBadge" mc:Ignorable="d" - Title="EntryBadge" Height="980" Width="1820" Loaded="Window_Loaded" FontFamily="Comic Sans MS" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowState="Maximized" > + Title="EntryBadge" Height="980" Width="1820" Loaded="Window_Loaded" FontFamily="Comic Sans MS" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowState="Maximized" Closing="Window_Closing" > @@ -17,7 +17,7 @@ - + @@ -37,6 +37,7 @@ + @@ -46,8 +47,8 @@ - - + + @@ -57,7 +58,6 @@ - @@ -66,7 +66,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -156,11 +156,8 @@ - - - - + - + diff --git a/eDosStation/EntryBadge.xaml.cs b/eDosStation/EntryBadge.xaml.cs index 99db6b3..72f58be 100644 --- a/eDosStation/EntryBadge.xaml.cs +++ b/eDosStation/EntryBadge.xaml.cs @@ -42,7 +42,7 @@ namespace eDosStation static User _User; DataSet1.GetTaskInfoRow CurTaskRow; - + private bool StopReadBadge=true; public EntryBadge(EpdBaseClr.Epd2 curEP, Station curStation) { ep=curEP; @@ -50,12 +50,16 @@ namespace eDosStation InitializeComponent(); _User = null; } - private bool LoadDoses() { bool rv = true; - ep.GetStatus(); - + System.Diagnostics.Debug.WriteLine("LoadDoses: EPD GEt Status"); + int rva= ep.GetStatus(); + if (rva != 1) + { + MessageBox.Show($"Entry GetStatus error {rva} {ep.GetStatusError}"); + } + System.Diagnostics.Debug.WriteLine($"LoadDoses: EPD {ep.EpdID} Type:{ep.epdType}"); if (ep.Issued) { MessageBox.Show("EPD is currently issued\nPlease take an other", "EDP", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification); @@ -68,22 +72,28 @@ namespace eDosStation MessageBox.Show("Wrong EPD Type", "EDP", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification); this.Close(); return false; - } statusEPD.Text = $"EPD: {ep.EpdID}"; - ep.ReadTresholds(); + rva = ep.ReadTresholds(); + if (rva != 1) + { + MessageBox.Show($"ReadTresholds error {ep.ReadTresholdsError}"); + } return rv; //ep.Hp07THDose = } - private void DispatcherTimer_Tick(object sender, EventArgs e) { + EpdFound = false; dispatcherTimer.Stop(); ep.Close(); - ep.Connect(); - if (ep.DeviceCount == 1) + System.Threading.Thread.Sleep(200); + int rv= ep.Connect(); + System.Diagnostics.Debug.WriteLine($"Connect {rv} error {ep.ConnectError}"); + if (ep.DeviceCount >0 && ep.b.CurrentDeviceID>0) { + System.Diagnostics.Debug.WriteLine($"Devices:{ep.DeviceCount} id:{ep.b.CurrentDeviceID} {ep.ConnectError} "); EpdFound = true; DoEPD(); } @@ -92,7 +102,7 @@ namespace eDosStation Search--; if (Search > 0) { - statusEPD.Text = $"Search {Search}"; + statusEPD.Text = $"Search {Search} ({ep.ConnectError})"; dispatcherTimer.Start(); } else @@ -101,7 +111,6 @@ namespace eDosStation } } } - private void DoEPD() { if (LoadDoses()) @@ -127,7 +136,10 @@ namespace eDosStation } int rv= ep.PrepareForIssue(); - + if (rv != 1) + { + MessageBox.Show($"PrepareForIssue error {ep.PrepareForIssueError}"); + } ep.WearerID = VisitID.ToString(); ep.WearerName = _User.PersID.ToString(); @@ -174,17 +186,21 @@ namespace eDosStation } } - ep.SetIssued(); + rv = ep.SetIssued(); + if (rv != 1) + { + MessageBox.Show($"SetIssued error {ep.SetIssuedError}"); + } bEpdDone.Visibility = Visibility.Visible; } } - private void GetEPD() { if (_User == null || CurTaskRow == null) return; int ok = ep.Connect(); - if (ep.DeviceCount == 1) + if (ok != 1) System.Diagnostics.Debug.WriteLine($"GetEpd {ok} ConnectError: {ep.ConnectError}"); + if (ep.DeviceCount == 1 && ep.b.CurrentDeviceID>0) { EpdFound = true; DoEPD(); @@ -200,7 +216,6 @@ namespace eDosStation return; } } - private void SetFilter(bool isAlara) { Inst1 = (cbInst1.IsChecked ==true); @@ -240,12 +255,10 @@ namespace eDosStation } else { - if (!string.IsNullOrEmpty(_User.UserComment)) { MessageBox.Show(_User.UserComment, "Comment", MessageBoxButton.OK, MessageBoxImage.Asterisk); } - eDosStation.DataSet1 dataSet1 = ((eDosStation.DataSet1)(this.FindResource("dataSet1"))); using (var dataSet1GetTaskInfoTableAdapter = new eDosStation.DataSet1TableAdapters.GetTaskInfoTableAdapter()) { @@ -260,8 +273,11 @@ namespace eDosStation void CheckBadge() { _User = new User(CSN.Text, Code.Text); - if (_User.Error==0) + if (_User.Error == 0) + { + Naam.Text = string.Concat(_User.FirstName, " ", _User.LastName); AskTask(); + } else { MessageBox.Show(_User.ErrorMessage); @@ -273,16 +289,25 @@ namespace eDosStation CSN.Text = csn; Site.Text = site; Code.Text = code; + Dispatcher.Invoke(CheckBadge); } bool Msg(int err) { + //decodeert verschillende USB messages. (callback ) + if (StopReadBadge ) + { + System.Diagnostics.Debug.WriteLine("msg dropped:"); + if (err!=0) System.Diagnostics.Debug.WriteLine($"msg result={a.clr.Result}"); + return false; + } + if (err == 0) { + System.Diagnostics.Debug.WriteLine($"msg result={a.clr.Result}"); if (a.clr.Result.StartsWith("csn:", StringComparison.InvariantCultureIgnoreCase) && a.clr.Result.EndsWith(";")) { //GEn 2 csn = string.Empty; - foreach (string ar in a.clr.Result.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { if (ar.StartsWith("csn:")) csn = ar.Substring(4); @@ -290,6 +315,7 @@ namespace eDosStation if (ar.StartsWith("code:")) code = ar.Substring(5); } this.Dispatcher.Invoke(new Action(() => showBadge())); + StopReadBadge = true; } else { @@ -300,6 +326,7 @@ namespace eDosStation if (nextFinish || nextCode) { this.Dispatcher.Invoke(new Action(() => showBadge())); + StopReadBadge = true; } nextCSN = nextSite = nextCode = nextFinish = false; } @@ -314,9 +341,6 @@ namespace eDosStation } else System.Diagnostics.Debug.WriteLine($"Error {err}"); - - - return false; } @@ -324,9 +348,6 @@ namespace eDosStation { this.Close(); } - - - private void BClear_Click(object sender, RoutedEventArgs e) { CSN.Text = string.Empty; @@ -393,12 +414,6 @@ namespace eDosStation } - - - - - - private void CbInst1_Click(object sender, RoutedEventArgs e) { Inst1 = (cbInst1.IsChecked == true); @@ -427,7 +442,13 @@ namespace eDosStation cbNormal.IsChecked = !isAlara; SetFilter(isAlara); } + } + private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + t = null; + a = null; + //t.Abort(); } private void CbInst2_Click(object sender, RoutedEventArgs e) @@ -438,14 +459,16 @@ namespace eDosStation SetFilter(isAlara); } - - private void Starter() { try { - a = new OkReadBadge.Badging(Msg); - a.Start(); + if (a == null) + { + a = new OkReadBadge.Badging(Msg); + StopReadBadge = false; + a.Start(); + } } catch (System.Exception ex) { MessageBox.Show($"Badgereader error {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); @@ -453,6 +476,7 @@ namespace eDosStation } private void Window_Loaded(object sender, RoutedEventArgs e) { + EpdFound = false; initialising = true; tbEntry.IsSelected = true; bEpdDone.Visibility = Visibility.Hidden; @@ -468,28 +492,12 @@ namespace eDosStation Inst2 = false; cbInst2.IsChecked = Inst2; } - //eDosStation.DataSet1 dataSet1 = ((eDosStation.DataSet1)(this.FindResource("dataSet1"))); - ////using (eDosStation.DataSet1TableAdapters.GetTaskListTableAdapter dataSet1GetTaskListTableAdapter = new eDosStation.DataSet1TableAdapters.GetTaskListTableAdapter()) - ////{ - //// dataSet1GetTaskListTableAdapter.Fill(dataSet1.GetTaskList); - ////} - //using (var dataSet1GetTaskInfoTableAdapter = new eDosStation.DataSet1TableAdapters.GetTaskInfoTableAdapter()) - //{ - // dataSet1GetTaskInfoTableAdapter.Fill(dataSet1.GetTaskInfo, null, null); - //} - - - - //System.Windows.Data.CollectionViewSource getTaskListViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("getTaskListViewSource"))); - //getTaskListViewSource.View.MoveCurrentToFirst(); - string TestCSN = thisStation.TestCSN; initialising = false; if (string.IsNullOrWhiteSpace(TestCSN)) { - ////Real t = new System.Threading.Thread(() => Starter()); t.Start(); } diff --git a/eDosStation/EpdExit.xaml.cs b/eDosStation/EpdExit.xaml.cs index ebd4b73..ba85403 100644 --- a/eDosStation/EpdExit.xaml.cs +++ b/eDosStation/EpdExit.xaml.cs @@ -57,12 +57,21 @@ namespace eDosStation } dispatcherTimer.Tick += DispatcherTimer_TickTO; ; - ep.GetStatus(); + int rv= ep.GetStatus(); + if (rv != 1) + { + int er= ep.GetStatusError; + MessageBox.Show($"GetStatus {rv} error {er}"); + } + if (!ep.Issued) { MessageBox.Show("This EPD is not issued","EDP",MessageBoxButton.OK,MessageBoxImage.Hand,MessageBoxResult.OK,MessageBoxOptions.ServiceNotification); this.Close(); return; + } else if (ep.EpdID==0) + { + MessageBox.Show("This EPD is not read", "EDP", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification); } @@ -80,11 +89,19 @@ namespace eDosStation DosePanel.Background = GreenBrush; ok.IsSelected = true; } - int rv = ep.ReadExtraStatus(); //D1 BaseD1 ... - + rv = ep.ReadExtraStatus(); //D1 BaseD1 ... + if (rv != 1) + { + MessageBox.Show($"ReadExtraStatus {rv}"); + } + Wearer.Text = $"Wearer: {ep.WearerName}"; EpdVisit.Text = $"Visit: {ep.WearerID}"; - ep.GetDoses(); + rv = ep.GetDoses(); + if (rv != 1) + { + MessageBox.Show($"GetDoses {rv} er:{ep.GetDosesError}"); + } HpDose07.Text = $"Hp07: {ep.Hp07:0.00} µSv "; HpDose10.Text = $"Hp10: {ep.Hp10:0.00} µSv"; if (int.TryParse(ep.WearerID, out int VisitID)) { @@ -127,8 +144,6 @@ namespace eDosStation pa = new SqlParameter("D3", SqlDbType.Int); pa.Value = ep.D3; cmd1.Parameters.Add(pa); pa = new SqlParameter("D4", SqlDbType.Int); pa.Value = ep.D4; cmd1.Parameters.Add(pa); - - pa = new SqlParameter("alarmStatus", SqlDbType.Int); pa.Value = ep.alarmStatus; cmd1.Parameters.Add(pa); pa = new SqlParameter("otherAlarms", SqlDbType.Int); pa.Value = ep.otherAlarms; cmd1.Parameters.Add(pa); pa = new SqlParameter("errorStatus", SqlDbType.Int); pa.Value = ep.errorStatus; cmd1.Parameters.Add(pa); @@ -140,8 +155,12 @@ namespace eDosStation } } } - ep.SetDeIssued(); + rv= ep.SetDeIssued(); + if (rv!=1) + { + MessageBox.Show($"DeIssueerror {rv}"); + } dispatcherTimer.Start(); //Knop hide return; @@ -156,12 +175,14 @@ namespace eDosStation private void StartScan() { + EpdFound = false; //ep = new EpdBaseClr.Epd2(thisStation.ComPort); - ep.Connect(); + int rv = ep.Connect(); + System.Diagnostics.Debug.WriteLine($"Connect {rv} error {ep.ConnectError}"); if (ep.DeviceCount == 1) { EpdFound = true; - statusEPD.Content = $"EPD: {ep.b.CurrentDeviceID}"; + statusEPD.Content = $"StartScan : EPD: {ep.b.CurrentDeviceID}"; LoadDoses(); } if (!EpdFound) @@ -178,12 +199,12 @@ namespace eDosStation private void Window_Loaded(object sender, RoutedEventArgs e) { Wait.IsSelected = true; + EpdFound = false; Dispatcher.InvokeAsync(StartScan); } private void DispatcherTimer_Tick(object sender, EventArgs e) { - dispatcherTimer.Stop(); EpdFound = false; ep.Connect(); diff --git a/eDosStation/MainWindow.xaml.cs b/eDosStation/MainWindow.xaml.cs index 1ae5b3d..9d07f20 100644 --- a/eDosStation/MainWindow.xaml.cs +++ b/eDosStation/MainWindow.xaml.cs @@ -38,12 +38,14 @@ namespace eDosStation { var w = new EntryBadge(ep, thisStation); w.ShowDialog(); + w = null; } private void BExit_Click(object sender, RoutedEventArgs e) { var w = new EpdExit(ep, thisStation); w.ShowDialog(); + w = null; } private void MenuItem_Click(object sender, RoutedEventArgs e) diff --git a/eDosStation/User.cs b/eDosStation/User.cs index f65a938..ec82995 100644 --- a/eDosStation/User.cs +++ b/eDosStation/User.cs @@ -15,13 +15,9 @@ namespace eDosStation public string conCode { get; set; } public string Language { get; set; } public bool? AccessAllow { get; set; } - public double? Margin { get; set; } - - public bool? VisitIDLocked {get;set; } - + public bool? VisitIDLocked { get; set; } public string ReasonNoAccess { get; set; } - public string UserComment { get; set; } public bool AllOk = false; @@ -61,14 +57,13 @@ namespace eDosStation AllOk = (AccessAllow == true & VisitIDLocked == true); } rs.Close(); - } catch(System.Exception ex) + } + catch (System.Exception ex) { Error = 1; ErrorMessage = ex.Message; } - co.Close(); - - + co.Close(); } } }