test persons
This commit is contained in:
parent
df163e6727
commit
e29970b7a9
10 changed files with 197 additions and 46 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,50 @@ 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)
|
||||
{
|
||||
|
|
@ -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)) {
|
||||
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));
|
||||
bu->nextCSN = true; bu->nextFinish = bu->nextCode = bu->nextSite = bu->completed = false ;
|
||||
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
|
||||
else {
|
||||
bu->m_clr->Result = String::Empty;
|
||||
bu->m_clr->Final = false;
|
||||
}
|
||||
}
|
||||
return bu->m_clr->OnMessage((int)err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{F98F3496-8A4C-4BDB-9F17-C7AF47A60739}</ProjectGuid>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>OkReadBadge</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
<TargetFrameworkVersion>4.7.2</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
<setting name="TestCSN" serializeAs="String">
|
||||
<value>0428790A0B4E80</value>
|
||||
</setting>
|
||||
<setting name="useTestButtons" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
</eDosStation.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
|
@ -32,7 +32,10 @@
|
|||
<TextBlock x:Name="Site" />
|
||||
<TextBlock x:Name="Code" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,50,0,0" Name="pTestButtons">
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
</TabItem>
|
||||
<TabItem Name="tbUser" >
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
System.Diagnostics.Debug.WriteLine($"msg result={a.clr.Result} {a.clr.Final}");
|
||||
if (a.clr.Final)
|
||||
{
|
||||
if (ar.StartsWith("csn:")) csn = ar.Substring(4);
|
||||
if (ar.StartsWith("site:")) site = ar.Substring(5);
|
||||
if (ar.StartsWith("code:")) code = ar.Substring(5);
|
||||
}
|
||||
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
|
||||
//<Button Height="30" Content="*TP 1*" Tag="1" Name="bTestPerson1" Click="BTestPerson_Click" Margin="0,0,20,0"/>
|
||||
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());
|
||||
|
|
|
|||
12
eDosStation/Properties/Settings.Designer.cs
generated
12
eDosStation/Properties/Settings.Designer.cs
generated
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,5 +28,8 @@
|
|||
<Setting Name="TestCSN" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">0428790A0B4E80</Value>
|
||||
</Setting>
|
||||
<Setting Name="useTestButtons" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue