From fd984940941a52ad1d6d873e0c3a13aa0e96db5c Mon Sep 17 00:00:00 2001 From: Luc Vandenbroucke Date: Tue, 8 Mar 2022 16:23:49 +0100 Subject: [PATCH] entry dispatchertimer --- EpdBase/EpdBase.cpp | 2 +- EpdBaseClr/EpdBaseClr.cpp | 9 ++++++--- eDosStation/DataInterface.cs | 6 ++++++ eDosStation/EntryBadge.xaml.cs | 14 ++++++++------ eDosStation/EpdExit.xaml.cs | 3 +-- eDosStation/User.cs | 3 +-- syncEdosLocal/Program.cs | 16 +++++++--------- 7 files changed, 30 insertions(+), 23 deletions(-) diff --git a/EpdBase/EpdBase.cpp b/EpdBase/EpdBase.cpp index 4921bc4..6282fab 100644 --- a/EpdBase/EpdBase.cpp +++ b/EpdBase/EpdBase.cpp @@ -126,7 +126,7 @@ int EpdBase::Epd2U::Open(DWORD DeviceID) void EpdBase::Epd2U::Close() { - if (port > 0) CloseDevice(); + if (port > 0) CloseDevice(); CurrentDeviceID = 0; } diff --git a/EpdBaseClr/EpdBaseClr.cpp b/EpdBaseClr/EpdBaseClr.cpp index ae3fa39..dd8a256 100644 --- a/EpdBaseClr/EpdBaseClr.cpp +++ b/EpdBaseClr/EpdBaseClr.cpp @@ -14,6 +14,7 @@ EpdBaseClr::Epd2::Epd2(int port) Hp07Name = gcnew String(tHp07); isTitleNG = false; } + EpdBaseClr::Epd2::~Epd2() { if (epd != nullptr) { @@ -31,6 +32,7 @@ EpdBaseClr::Epd2::~Epd2() EpdBaseClr::Epd2::!Epd2() { } + int EpdBaseClr::Epd2::SetFeedbackSound(byte sound, UINT16 sound3) { epd->EndSessionControl = sound; @@ -490,7 +492,6 @@ int EpdBaseClr::Epd2::ReadTresholds() return rv; } - int EpdBaseClr::Epd2::AfterReadTresholds(EpdBase::Epd2U* epd) { int rv = 0; @@ -738,16 +739,18 @@ int EpdBaseClr::Epd2::SwitchCon() int rv = 0; if (isMK3) { if (epd3->epdComsHandle == INVALID_HANDLE_VALUE) { - epd->EndCom(); rv=epd3->StartCom(); + epd->EndCom(); + Sleep(100); + rv=epd3->StartCom(); } } else { if (epd->CommsInitialized == 0) { epd3->EndCom(); + Sleep(100); rv = epd->StartCom(); //0=ok if (!rv) rv = epd->Open(EpdID); if (!rv) rv = epd->ReadStatus(); - } } return rv; diff --git a/eDosStation/DataInterface.cs b/eDosStation/DataInterface.cs index 9606c2f..cd5e053 100644 --- a/eDosStation/DataInterface.cs +++ b/eDosStation/DataInterface.cs @@ -378,7 +378,13 @@ namespace eDosStation u.UserComment = dr["Comment"].ToString(); if (tb.Columns.Contains("hasEPD")) u.hasEPD = (bool)dr["hasEPD"]; else u.hasEPD = false; + + if (u.hasEPD) u.ReasonNoAccess = "EPD in use"; + + u.activeVisit = dr["activeVisit"] as int?; + + u.AllOk = ( !CheckUser || (u.AccessAllow == true && u.VisitIDLocked == 0)); } else diff --git a/eDosStation/EntryBadge.xaml.cs b/eDosStation/EntryBadge.xaml.cs index aa4c989..6c4db4d 100644 --- a/eDosStation/EntryBadge.xaml.cs +++ b/eDosStation/EntryBadge.xaml.cs @@ -381,6 +381,7 @@ namespace eDosStation UserSeconds = 10; //UserScreen string ReasonNoAccess = string.Empty; + dispatcherTimer?.Stop(); dispatcherTimer = null; if (_User.PersID == 0) { @@ -398,7 +399,7 @@ namespace eDosStation if (_User.VisitIDLocked > 0 || _User.AccessAllow == false) ReasonNoAccess = _User.ReasonNoAccess; else if (_User.hasEPD) - ReasonNoAccess = "User has epd in use"; + ReasonNoAccess = "EPD in use"; else ReasonNoAccess = getCommentOnEvent(string.Empty, 3); } @@ -413,7 +414,6 @@ namespace eDosStation if (!string.IsNullOrWhiteSpace(ReasonNoAccess)) UserAccess.Text = ReasonNoAccess; - Username.Text = _User.FullUserName(); string msg = string.Empty; if (!_User.HasMessage() && string.IsNullOrEmpty(ReasonNoAccess)) @@ -439,7 +439,6 @@ namespace eDosStation dispatcherTimer.Start(); thisStation.splunkLog?.WriteSplunkLog(taskName, LSWLib.CLog.iseverity.info, "Timer"); } - } return ; @@ -453,6 +452,7 @@ namespace eDosStation } else { + dispatcherTimer?.Stop(); dispatcherTimer = null; if (_User.AllOk == true && !_User.hasEPD) Dispatcher.InvokeAsync(AskTask, DispatcherPriority.Normal); else Dispatcher.InvokeAsync(() => {endPage(); }); @@ -487,6 +487,9 @@ namespace eDosStation } public void endPage() { + + dispatcherTimer?.Stop(); + dispatcherTimer = null; this.Close(); } private void bClose_Click(object sender, RoutedEventArgs e) @@ -627,9 +630,8 @@ namespace eDosStation { dispatcherTimer.Stop(); dispatcherTimer.Tick -= SwitchToTask; - if (_User.AllOk == true) - AskTask(); - else Close(); + if (_User.AllOk == true && !_User.hasEPD) AskTask(); + else endPage(); } private void TaskCancel_Click(object sender, RoutedEventArgs e) { diff --git a/eDosStation/EpdExit.xaml.cs b/eDosStation/EpdExit.xaml.cs index 712114b..0d58906 100644 --- a/eDosStation/EpdExit.xaml.cs +++ b/eDosStation/EpdExit.xaml.cs @@ -5,7 +5,6 @@ using System.Windows.Threading; namespace eDosStation { - public partial class EpdExit : Window { DataInterface dataInterface; @@ -45,7 +44,7 @@ namespace eDosStation Progress.Value = v; else { - dispatcherTimer.Stop(); + dispatcherTimer?.Stop(); endPage(); } } diff --git a/eDosStation/User.cs b/eDosStation/User.cs index 4dc2785..be048c0 100644 --- a/eDosStation/User.cs +++ b/eDosStation/User.cs @@ -26,8 +26,7 @@ namespace eDosStation public int Error = 0; public string ErrorMessage; - - + internal int? activeVisit; public string FullUserName() { diff --git a/syncEdosLocal/Program.cs b/syncEdosLocal/Program.cs index 10f84ee..3c72df3 100644 --- a/syncEdosLocal/Program.cs +++ b/syncEdosLocal/Program.cs @@ -103,8 +103,6 @@ namespace syncEdosLocal static LSWLib.Bulker Bulker; static cResult Result; - - public static int? CreateStationID (SqlConnection eDosLocalCon, SqlConnection eDosCon ) { var c1 = eDosCon.State; @@ -121,7 +119,7 @@ namespace syncEdosLocal if (c1 != ConnectionState.Open) eDosCon.Close(); return StationID; } - public static bool DoorloopToDo(System.Data.SqlClient.SqlConnection fromConnection, string toConstr, System.Data.SqlClient.SqlInfoMessageEventHandler im, ref bool error, ref bool warning, ref StringBuilder messages) + public static bool DoorloopToDo(System.Data.SqlClient.SqlConnection fromConnection, string toConstr, System.Data.SqlClient.SqlInfoMessageEventHandler im, ref bool error, ref bool warning) { ds = new DataSet(); DataTable dtTables = new DataTable("Tables"); @@ -133,7 +131,7 @@ namespace syncEdosLocal { spLog.KvClear(); cmd.CommandType = CommandType.StoredProcedure; - spLog.kvAddCommand(spl.skeys.sqlQuery, cmd); + spLog.KvAddCommand(spl.skeys.sqlQuery, cmd); using (var ncta = new System.Data.SqlClient.SqlDataAdapter(cmd)) { try @@ -246,7 +244,7 @@ namespace syncEdosLocal int cnt = 0; qry = LSWLib.SqlCommands.getColumnsQry(fromConnection, src); SqlConnection[] curDests = new SqlConnection[] { toConnection }; - cnt = Bulker.Execute(Task, fromConnection, curDests, qry, CommandType.Text, dest, 0, ref error, ref messages); + cnt = Bulker.Execute(Task, fromConnection, curDests, qry, CommandType.Text, dest, 0, ref error); ucmd.Parameters["lastRecords"].Value = cnt; if (dest.Contains("PersonInfo")) Result.Persons = cnt; @@ -258,7 +256,7 @@ namespace syncEdosLocal { cmd.CommandType = CommandType.Text; spLog.KvClear(); - spLog.kvAddCommand(spl.skeys.sqlQuery, cmd); + spLog.KvAddCommand(spl.skeys.sqlQuery, cmd); try { spLog.SeverityReset(); @@ -288,7 +286,6 @@ namespace syncEdosLocal } static void Main(string[] args) { - spLog = new spl("SynceDosLocal"); Bulker = new LSWLib.Bulker(spLog, true); messages = Bulker.messages; @@ -317,6 +314,8 @@ namespace syncEdosLocal spLog.WriteSplunkLog("init", spLog.splunkSeverity, null, spLog.splunkError); messages.AppendLine($"Error reading reg key"); } + + messages.AppendLine($"Remote {SourceCoStr.DataSource} db {SourceCoStr.InitialCatalog} Logon= { SourceCoStr.UserID} alias:{ reDos }"); messages.AppendLine($"Local {LocalCoStr.DataSource} db {LocalCoStr.InitialCatalog} Logon= { LocalCoStr.UserID} alias:{ reDosLocal }"); @@ -327,7 +326,6 @@ namespace syncEdosLocal { eDosLocalCon.Open(); int? StationID = Bulker.SqlCommands.ExecProcScalar("Get Station ID", eDosLocalCon, "GetID_LocalStation", true, ref error) as int?; - if (!StationID.HasValue) { System.Console.WriteLine($"No stationID for this computer [{Environment.MachineName}]"); @@ -338,7 +336,7 @@ namespace syncEdosLocal using (System.Data.SqlClient.SqlConnection eDosCon = new SqlConnection(SourceCoStr.ConnectionString)) { eDosCon.InfoMessage += Connection_InfoMessage; - DoorloopToDo(eDosCon, LocalCoStr.ConnectionString, iMessage, ref error, ref warning, ref messages); + DoorloopToDo(eDosCon, LocalCoStr.ConnectionString, iMessage, ref error, ref warning); DoorloopVisits(eDosLocalCon, eDosCon, Bulker.spLog, ref error); } Result.Write();