diff --git a/OkReadBadge/OkReadBadge.cpp b/OkReadBadge/OkReadBadge.cpp
index ce812b0..06611ff 100644
--- a/OkReadBadge/OkReadBadge.cpp
+++ b/OkReadBadge/OkReadBadge.cpp
@@ -37,11 +37,15 @@ void OkReadBadge::BadgeUnmanaged::GetDeviceUSB(std::wstring vid, std::wstring pi
auto x = sDeviceID.find(vid);
auto y = sDeviceID.find(pid);
auto z = sDeviceID.find(pid2);
+ if (x < 100)
+ {
+ System::Diagnostics::Trace::WriteLine( gcnew System::String(sDeviceID.c_str()));
+ }
if (x < 100 && (y < 100 || z < 100))
{
DWORD deviceInterfaceIndex = 0;
deviceInterfaceData.cbSize = sizeof(deviceInterfaceData);
-
+ System::Diagnostics::Trace::WriteLine(String::Format("x {0}", x));
if (SetupDiEnumDeviceInterfaces(deviceInterfaceSet, &deviceInfoData, &hid, deviceInterfaceIndex, &deviceInterfaceData))
{
deviceInterfaceData.cbSize = sizeof(deviceInterfaceData);
diff --git a/OkReadBadge/OkReadBadge.h b/OkReadBadge/OkReadBadge.h
index 4e9667f..34ed36f 100644
--- a/OkReadBadge/OkReadBadge.h
+++ b/OkReadBadge/OkReadBadge.h
@@ -32,7 +32,51 @@ namespace OkReadBadge
bool nextFinish = false;
bool completed = false;
char Res [100];
+ char CSN[50];
+ char Site[20];
+ char Badge[20];
+
+ int parse(char *rall)
+ {
+ int items;
+ char *source;
+ int sourcelen;
+ char *dest;
+ int destlen;
+ char *r = rall;
+ char *mx = r + strlen(rall);
+ items = 0;
+ Res[0] = 0;
+ while (r < mx && items<3) {
+ if (!strncmp("csn:", r, 4)) {
+ items++;
+ dest = CSN; destlen = sizeof(CSN);
+ source = r + 4; //na csn:
+ }
+ else if (!strncmp("site:", r, 4)) {
+ items++;
+ dest = Site; destlen = sizeof(Site);
+ source = r + 5; //na site:
+ }
+ else if (!strncmp("code:", r, 4)) {
+ items++;
+ dest = Badge; destlen = sizeof(Badge);
+ source = r + 5; //na code:
+ }
+ else {
+ dest = NULL; destlen = 0;
+ }
+ char *x = strchr(source, ';');
+ *x = 0; sourcelen = strlen(source);
+ if (dest != NULL) {
+ memcpy_s(dest, destlen, source, sourcelen + 1);
+ }
+ r = x + 1;
+ }
+ return items;
+ }
+
static bool CALLBACK Message(int err, LPARAM param)
{
//m_clr.Result = gcnew buffer
@@ -42,15 +86,43 @@ namespace OkReadBadge
char *r = (char *)&bu->buffer[4];
r[l] = 0;
if (bu->nextCSN) {
- memcpy_s(bu->Res, 100, r, l + 1); bu->nextCSN = false; }
+ memcpy_s(bu->CSN, sizeof(bu->CSN), r, l + 1);
+ memcpy_s(bu->Res, sizeof(bu->Res), r, l + 1);
+ bu->nextCSN = false;
+ }
else if (bu->nextSite) {
+ memcpy_s(bu->Site, 20, r, l + 1);
strncat_s(bu->Res, (const char *)r, l); bu->nextSite = false; }
else if (bu->nextCode) {
+ memcpy_s(bu->Badge, sizeof(bu->Badge), r, l + 1);
strncat_s(bu->Res, (const char *)r, l); bu->nextCode = false; bu->nextFinish = true;
}
else if (!strncmp("csn:", r, 4)) {
- memset(bu->Res, 0, sizeof(bu->Res));
- bu->nextCSN = true; bu->nextFinish = bu->nextCode = bu->nextSite = bu->completed = false ;
+ bu->nextCSN = true; bu->nextFinish = bu->nextCode = bu->nextSite = bu->completed = false;
+ if (strstr(r, "code:") != NULL) {
+ int it = bu->parse(r);
+ //char *s = r + 4; //na csn:
+ //char *x = strchr(r, ';');
+ //*x = 0; l = strlen(s);
+ //memcpy_s(bu->CSN, sizeof(bu->CSN), s, l + 1);
+ ////x+1 should be "site:"
+ //s = x + 6; // n a site:v
+ //x = strchr(s, ';'); *x = 0; l = strlen(s);
+ ////x+1 should be "code:"
+ //memcpy_s(bu->Site, sizeof(bu->Site), s, l + 1);
+ //s = x + 6; // no code:
+ //x = strchr(s, ';'); *x = 0; l = strlen(s);
+ //memcpy_s(bu->Badge, sizeof(bu->Badge), s, l + 1);
+ bu->completed = true;
+ }
+ else {
+ memset(bu->Res, 0, sizeof(bu->Res));
+ memset(bu->CSN, 0, sizeof(bu->CSN));
+ memset(bu->Site, 0, sizeof(bu->Site));
+ memset(bu->Badge, 0, sizeof(bu->Badge));
+ bu->completed = false;
+ bu->m_clr->Final = false;
+ }
}
else if (!strncmp("site:", r, 5)) { bu->nextSite = true; }
else if (!strncmp("code:", r, 5)) { bu->nextCode = true; }
@@ -62,13 +134,23 @@ namespace OkReadBadge
bu->completed = true;
}
}
+ if (bu->completed)
+ {
+ bu->m_clr->Final = true;
+ bu->m_clr->CSN= gcnew String(bu->CSN);
+ bu->m_clr->Site = gcnew String(bu->Site);
+ bu->m_clr->Badge= gcnew String(bu->Badge);
+ }
+ else
bu->m_clr->Result = gcnew String(r);
}
else {
if (bu->nextCSN | bu->nextFinish | bu->nextCode | bu->nextSite | bu->nextCSN )
bu->m_clr->Result = gcnew String(bu->Res);
- else
- bu->m_clr->Result = String::Empty;
+ else {
+ bu->m_clr->Result = String::Empty;
+ bu->m_clr->Final = false;
+ }
}
return bu->m_clr->OnMessage((int)err);
}
diff --git a/OkReadBadge/OkReadBadge.vcxproj b/OkReadBadge/OkReadBadge.vcxproj
index 7430c63..f81c810 100644
--- a/OkReadBadge/OkReadBadge.vcxproj
+++ b/OkReadBadge/OkReadBadge.vcxproj
@@ -21,10 +21,10 @@
15.0
{F98F3496-8A4C-4BDB-9F17-C7AF47A60739}
- v4.7.2
ManagedCProj
OkReadBadge
10.0.16299.0
+ 4.7.2
diff --git a/OkReadBadge/okClr.h b/OkReadBadge/okClr.h
index 08d70bf..1c3b499 100644
--- a/OkReadBadge/okClr.h
+++ b/OkReadBadge/okClr.h
@@ -13,6 +13,10 @@ namespace OkReadBadge
delegate bool delMessage(int err);
delMessage^ OnMessage;
String^ Result;
+ String^ CSN;
+ String^ Site;
+ String^ Badge;
+ bool Final;
bool Message(int err)
{
System::Diagnostics::Debug::WriteLine(err.ToString());
@@ -20,6 +24,8 @@ namespace OkReadBadge
}
BadgeMessageHandler()
{
+ Final = false;
+ Result = CSN= Site = Badge = String::Empty;
OnMessage = gcnew delMessage(this, &BadgeMessageHandler::Message);
}
};
diff --git a/eDosStation/App.config b/eDosStation/App.config
index 099cd55..47240a0 100644
--- a/eDosStation/App.config
+++ b/eDosStation/App.config
@@ -32,6 +32,9 @@
0428790A0B4E80
+
+ True
+
\ No newline at end of file
diff --git a/eDosStation/EntryBadge.xaml b/eDosStation/EntryBadge.xaml
index bd539f7..8039e48 100644
--- a/eDosStation/EntryBadge.xaml
+++ b/eDosStation/EntryBadge.xaml
@@ -32,7 +32,10 @@
+
+
+
diff --git a/eDosStation/EntryBadge.xaml.cs b/eDosStation/EntryBadge.xaml.cs
index 581de26..f07ba73 100644
--- a/eDosStation/EntryBadge.xaml.cs
+++ b/eDosStation/EntryBadge.xaml.cs
@@ -293,10 +293,10 @@ namespace eDosStation
else
{
tbUser.IsSelected = true;
- if (_User == null || _User.VisitIDLocked == true || _User.AccessAllow == false)
+ if (_User == null || _User.VisitIDLocked >0 || _User.AccessAllow == false)
{
//tbNotAllowed.IsSelected = true;
- if (_User.VisitIDLocked == true || _User.AccessAllow == false)
+ if (_User.VisitIDLocked > 0|| _User.AccessAllow == false)
ReasonNoAccess = _User.ReasonNoAccess;
else ReasonNoAccess = getCommentOnEvent(string.Empty, 3);
}
@@ -376,40 +376,48 @@ namespace eDosStation
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);
- if (ar.StartsWith("site:")) site = ar.Substring(5);
- if (ar.StartsWith("code:")) code = ar.Substring(5);
- }
+ System.Diagnostics.Debug.WriteLine($"msg result={a.clr.Result} {a.clr.Final}");
+ if (a.clr.Final)
+ {
+ csn = a.clr.CSN;
+ site = a.clr.Site;
+ code = a.clr.Badge;
this.Dispatcher.Invoke(new Action(() => showBadge()));
StopReadBadge = true;
}
- 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()));
- StopReadBadge = true;
- }
- 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);
- }
+ // 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()));
+ // StopReadBadge = true;
+ // }
+ // 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()));
+ // StopReadBadge = true;
+ // }
+ // 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}");
@@ -477,7 +485,7 @@ namespace eDosStation
}
if (_User == null) { TaskOK.Content = "Badge"; TaskOK.Tag = "B"; }
else if (_User.AccessAllow != true) { TaskOK.Content = "No Access"; TaskOK.Tag = "A"; }
- else if (_User.VisitIDLocked == true) { TaskOK.Content = "Locked"; TaskOK.Tag = "L"; }
+ else if (_User.VisitIDLocked >0 ) { TaskOK.Content = "Locked"; TaskOK.Tag = "L"; }
else if (exceeded == true) { TaskOK.Content = "No Margin"; TaskOK.Tag = "M"; }
else
{
@@ -530,6 +538,13 @@ namespace eDosStation
Close();
}
+ private void BTestPerson_Click(object sender, RoutedEventArgs e)
+ {
+ Button b = sender as Button;
+ _User = new User("TP"+b.Tag, "");
+ ShowUserInfo(); //AskTask();
+ }
+
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
t = null;
@@ -560,6 +575,26 @@ namespace eDosStation
MessageBox.Show($"Badgereader error {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
+
+
+ private void AddTestButtons()
+ {
+ //pTestButtons
+ //
+ StackPanel sp = pTestButtons;
+ Button b;
+ Thickness m = new Thickness(0, 0, 20, 0);
+ for (int i = 1; i < 15; i++)
+ {
+ b = new Button();
+ b.Click += BTestPerson_Click;
+ b.Tag = i.ToString();
+ b.Content = $"* TP {i} *";
+ b.Height = 30;
+ b.Margin = m;
+ sp.Children.Add(b);
+ }
+ }
private void Window_Loaded(object sender, RoutedEventArgs e)
{
EpdFound = false;
@@ -586,6 +621,9 @@ namespace eDosStation
string TestCSN = thisStation.TestCSN;
initialising = false;
+ if (Properties.Settings.Default.useTestButtons)
+ AddTestButtons();
+
if (string.IsNullOrWhiteSpace(TestCSN))
{
t = new System.Threading.Thread(() => Starter());
diff --git a/eDosStation/Properties/Settings.Designer.cs b/eDosStation/Properties/Settings.Designer.cs
index 85c19f3..36d4394 100644
--- a/eDosStation/Properties/Settings.Designer.cs
+++ b/eDosStation/Properties/Settings.Designer.cs
@@ -104,5 +104,17 @@ namespace eDosStation.Properties {
this["TestCSN"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool useTestButtons {
+ get {
+ return ((bool)(this["useTestButtons"]));
+ }
+ set {
+ this["useTestButtons"] = value;
+ }
+ }
}
}
diff --git a/eDosStation/Properties/Settings.settings b/eDosStation/Properties/Settings.settings
index 71e5025..b0fba73 100644
--- a/eDosStation/Properties/Settings.settings
+++ b/eDosStation/Properties/Settings.settings
@@ -28,5 +28,8 @@
0428790A0B4E80
+
+ True
+
\ No newline at end of file
diff --git a/eDosStation/User.cs b/eDosStation/User.cs
index 4566b8d..b6337b3 100644
--- a/eDosStation/User.cs
+++ b/eDosStation/User.cs
@@ -16,7 +16,7 @@ namespace eDosStation
public string Language { get; set; }
public bool? AccessAllow { get; set; }
public double? Margin { get; set; }
- public bool? VisitIDLocked { get; set; }
+ public int? VisitIDLocked { get; set; }
public string ReasonNoAccess { get; set; }
public string UserComment { get; set; }
@@ -51,10 +51,10 @@ namespace eDosStation
Language = Values[rs.GetOrdinal("Language")].ToString();
AccessAllow = Values[rs.GetOrdinal("AccessAllow")] as bool?;
Margin = Values[rs.GetOrdinal("AccessAllow")] as double?;
- VisitIDLocked = Values[rs.GetOrdinal("VisitIDLocked")] as bool?;
+ VisitIDLocked = Values[rs.GetOrdinal("VisitIDLocked")] as int?;
ReasonNoAccess = Values[rs.GetOrdinal("ReasonNoAccess")].ToString().Replace("\\n","\n");
UserComment = Values[rs.GetOrdinal("Comment")].ToString();
- AllOk = (AccessAllow == true & VisitIDLocked == true);
+ AllOk = (AccessAllow == true && VisitIDLocked == 0 );
} else
{
// Not found
@@ -65,10 +65,10 @@ namespace eDosStation
Language = "N";
AccessAllow = false;
Margin = 0;
- VisitIDLocked = false;
+ VisitIDLocked = 0;
ReasonNoAccess = "Not found";
UserComment = "";
- AllOk = (AccessAllow == true & VisitIDLocked == true);
+ AllOk = (AccessAllow == true & VisitIDLocked == 0);
}
rs.Close();
}