1112 lines
48 KiB
C#
1112 lines
48 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Resources;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Media;
|
|
using System.Windows.Threading;
|
|
|
|
namespace eDosStation
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for EntryBadge.xaml
|
|
/// </summary>
|
|
///
|
|
|
|
public partial class EntryBadge : Window
|
|
{
|
|
private enum eEntryState { none, getuser, gettask, getepd, epdtimeout, epdError, epdOK, final, NotAllowed, Initial }
|
|
private eEntryState EntryState;
|
|
SolidColorBrush sckbLB;
|
|
bool taskLoading = false;
|
|
const int PageTimeout = 10000;
|
|
bool initialising = true;
|
|
Station thisStation;
|
|
EpdBaseClr.Epd2 ep;
|
|
DispatcherTimer dispatcherTimer;
|
|
int UserSeconds;
|
|
Boolean Inst1 = false, Inst2 = false;
|
|
private System.Threading.Tasks.Task ReaderTask = null;
|
|
private DataInterface dataInterface;
|
|
public LSWDesfirePublic.CCard dfReader = null;
|
|
static User _User;
|
|
DataSet1.GetTaskInfoRow CurTaskRow;
|
|
eDosStation.DataSet1 dataSet1;
|
|
private DateTime ResultTime;
|
|
private bool EpdReading=false;
|
|
private bool FinalTimeOut=false;
|
|
|
|
|
|
enum eCOE { quiz = 1 };
|
|
#if SimulateEPD
|
|
public SimulateData simulData = new SimulateData();
|
|
#endif
|
|
public EntryBadge(Station curStation)
|
|
{
|
|
InitializeComponent();
|
|
dataInterface = curStation.dataInterface;
|
|
thisStation = curStation;
|
|
_User = null;
|
|
taskLoading = false;
|
|
EpdReading = false;
|
|
EntryState = eEntryState.none;
|
|
}
|
|
private void Ep_EpdTO(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdTOEventArgs e)
|
|
{
|
|
EntryState = eEntryState.epdtimeout;
|
|
System.Diagnostics.Debug.WriteLine("TIME OUT");
|
|
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
|
}
|
|
private void Ep_EpdError(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdErrorEventArgs e)
|
|
{
|
|
EntryState = eEntryState.epdError;
|
|
System.Diagnostics.Debug.WriteLine("ERROR ");
|
|
Dispatcher.InvokeAsync(() => {
|
|
MessageBox.Show($"EPD Error {e.returnValue} {e.ErrorRV} {e.ErrorStep}");
|
|
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
|
});
|
|
}
|
|
private void StopProgress(string newmessage)
|
|
{
|
|
dispatcherTimer?.Stop();
|
|
statusEPD.Text = newmessage;
|
|
pWaitEpd.Visibility = Visibility.Collapsed;
|
|
|
|
}
|
|
private void Ep_EpdRead(EpdBaseClr.Epd2 Sender, EpdBaseClr.EpdEventArgs e)
|
|
{
|
|
EntryState = eEntryState.epdOK;
|
|
EpdReading = false;
|
|
//dispatcherTimer?.Stop();
|
|
Dispatcher.InvokeAsync(() => StopProgress("Writing config"));
|
|
DoEvents();
|
|
System.Threading.Thread.Sleep(100);
|
|
Dispatcher.InvokeAsync(() => GetEPD());
|
|
}
|
|
private bool LoadDoses()
|
|
{
|
|
bool rv = true;
|
|
|
|
#if SimulateEPD
|
|
ep.CountsClock = 12345;
|
|
ep.alarmStatus = 0;
|
|
ep.otherAlarms = 0;
|
|
#endif
|
|
//if (rva != 0)
|
|
//{
|
|
// MessageBox.Show($"Entry GetStatus error {rva} {ep.GetStatusError}");
|
|
//}
|
|
System.Diagnostics.Debug.WriteLine($"LoadDoses: EPD {ep.EpdID} Type:{ep.epdType}");
|
|
statusEPD.Text = $"EPD: {ep.EpdID}";
|
|
if (ep.EPDIssued)
|
|
{
|
|
TextBlock il = new TextBlock();
|
|
il.Inlines.Add(new Run("This EPD is currently issued") {FontSize = 36 }); ;
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new Run("Please take an other."));
|
|
il.HorizontalAlignment = HorizontalAlignment.Center;
|
|
il.TextAlignment = System.Windows.TextAlignment.Center;
|
|
(new InstMessage(il)).ShowDialog();
|
|
|
|
|
|
//MessageBox.Show("EPD is currently issued\nPlease take an other", "EDP", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
|
|
endPage();
|
|
return false;
|
|
}
|
|
|
|
|
|
var maybeFault = ep.EPDFaulty;
|
|
bool realFault = (ep.EPDDetFault>0) || (ep.EPDCalFault >0) || (ep.EPDComFault >0) || (ep.EPDEprFault >0) || (ep.EPDTrhFault>0);
|
|
|
|
|
|
|
|
|
|
if (ep.eDoshasAlarm || ep.OtherAlarmBatLow > 0 || realFault )
|
|
{
|
|
TextBlock il = new TextBlock();
|
|
il.Inlines.Add(new Run("EPD is in alarm status\n\n")
|
|
{
|
|
FontSize = 36
|
|
}); ;
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new LineBreak());
|
|
if (ep.alarmStatus > 0) il.Inlines.Add(new Run("* Dose alarm *"));
|
|
if (ep.OtherAlarmBatLow > 0) il.Inlines.Add(new Run("* Battery Low *"));
|
|
if (ep.EPDCalFault > 0) il.Inlines.Add(new Run("* EPDCalFault fault *"));
|
|
if (ep.EPDTimeFault >0 ) il.Inlines.Add(new Run("* Time fault *"));
|
|
if (ep.EPDComFault > 0) il.Inlines.Add(new Run("* Communication fault *"));
|
|
if (ep.EPDEprFault > 0) il.Inlines.Add(new Run("* Eprom fault *"));
|
|
if (ep.EPDTrhFault > 0) il.Inlines.Add(new Run("* Treshold fault *"));
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new Run("Please take an other."));
|
|
il.HorizontalAlignment = HorizontalAlignment.Center;
|
|
il.TextAlignment = System.Windows.TextAlignment.Center;
|
|
(new InstMessage(il)).ShowDialog();
|
|
endPage();
|
|
return false;
|
|
}
|
|
if (ep.isBG != CurTaskRow.EPDRad.Equals("BG"))
|
|
{
|
|
string curtype = null, needdtype = string.Empty;
|
|
if (ep.isBG) curtype = "BG Beta-Gamma"; else curtype = "NG (Neutron)";
|
|
if (CurTaskRow.EPDRad.Equals("BG")) needdtype = "BG (Beta-Gamma)"; else needdtype = "NG (Neutron)";
|
|
|
|
TextBlock il = new TextBlock();
|
|
il.Inlines.Add(new Run("This EPD is not the right type")
|
|
{
|
|
FontSize = 36
|
|
}); ;
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(InstMessage.GetFullWidthLine());
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new Run($"This task needs a {needdtype} EPD,\n this is a {curtype}")
|
|
{
|
|
Background = System.Windows.Media.Brushes.Yellow
|
|
}); ;
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(InstMessage.GetFullWidthLine());
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new LineBreak());
|
|
il.Inlines.Add(new Run("Please take an other."));
|
|
il.HorizontalAlignment = HorizontalAlignment.Center;
|
|
il.TextAlignment = System.Windows.TextAlignment.Center;
|
|
(new InstMessage(il)).ShowDialog();
|
|
endPage();
|
|
return false;
|
|
}
|
|
//rva = ep.ReadTresholds();
|
|
//if (rva != 0)
|
|
//{
|
|
// MessageBox.Show($"ReadTresholds error {ep.ReadTresholdsError}");
|
|
//}
|
|
return rv;
|
|
}
|
|
//private void DispatcherTimer_Tick(object sender, EventArgs e)
|
|
//{
|
|
// //Was timeout
|
|
// //voorlopig niet meer gebruikt
|
|
// EpdFound = false;
|
|
// dispatcherTimer.Stop();
|
|
// ep.Close();
|
|
// System.Threading.Thread.Sleep(200);
|
|
|
|
// int rv = ep.Connect(false,thisStation.EPDTimeOut);
|
|
// System.Diagnostics.Debug.WriteLine($"Connect {rv} error {ep.ConnectError}");
|
|
// if (ep.DeviceCount > 0 && ep.EpdID > 0)
|
|
// {
|
|
// System.Diagnostics.Debug.WriteLine($"Devices:{ep.DeviceCount} id:{ep.EpdID} {ep.ConnectError} ");
|
|
// EpdFound = true;
|
|
// DoEPD();
|
|
// }
|
|
// if (!EpdFound)
|
|
// {
|
|
// Search--;
|
|
// if (Search > 0)
|
|
// {
|
|
// statusEPD.Text = $"Searching EPD ... {Search} ({ep.ConnectError})";
|
|
// dispatcherTimer.Start();
|
|
// }
|
|
// else
|
|
// {
|
|
// statusEPD.Text = $"No EPD found";
|
|
// }
|
|
// }
|
|
//}
|
|
private void DoEPD()
|
|
{
|
|
const string module = "EntryBadge DoEpd";
|
|
string step = null;
|
|
int? StationVisitID = null;
|
|
int? ID_Visit = null;
|
|
|
|
if (LoadDoses())
|
|
{
|
|
tWaitFor.Text = "Writing alarms";
|
|
try
|
|
{
|
|
ID_Visit = DataInterface.NextID();
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show($"Error {ex.Message}");
|
|
}
|
|
if (ID_Visit.HasValue)
|
|
{
|
|
step = "SqlInitVisit";
|
|
bool isBG = ep.isBG; // (ep.epdType != 3); //3 = zwarte 0=grijs
|
|
var co = dataInterface.getCon(true);
|
|
dataInterface.VisitInitCommand.Connection = co;
|
|
dataInterface.VisitInitCommand.Parameters["ID_Station"].Value = thisStation.ID_Station;
|
|
dataInterface.VisitInitCommand.Parameters["ID_Visit"].Value = ID_Visit;
|
|
dataInterface.VisitInitCommand.Parameters["PersID"].Value = _User.PersID;
|
|
dataInterface.VisitInitCommand.Parameters["ID_Task"].Value = CurTaskRow.ID_Task;
|
|
dataInterface.VisitInitCommand.Parameters["Inst_CODE"].Value = CurTaskRow.Inst_CODE;
|
|
dataInterface.VisitInitCommand.Parameters["EPD_InternalID"].Value = (int)ep.EpdID;
|
|
dataInterface.VisitInitCommand.Parameters["isBG"].Value = isBG;
|
|
dataInterface.VisitInitCommand.Parameters["ENTRY_EPD_CLOCK"].Value = ep.CountsClock;
|
|
dataInterface.VisitInitCommand.Parameters["epdType"].Value = (byte)ep.epdType;
|
|
dataInterface.VisitInitCommand.Parameters["EPDVisitID"].Value = 0;
|
|
dataInterface.VisitInitCommand.Parameters["InitError"].Value = 0;
|
|
//using (var l = new SqlLog())
|
|
// try
|
|
// {
|
|
// dataInterface.VisitInitCommand.ExecuteNonQuery();
|
|
// l.LogCommand(dataInterface.VisitInitCommand);
|
|
// }
|
|
// catch (System.Exception ex)
|
|
// {
|
|
// l.LogCommand(ex.Message);
|
|
// MessageBox.Show(ex.Message);
|
|
// }
|
|
//StationVisitID = (int?)dataInterface.VisitInitCommand.Parameters["EPDVisitID"].Value;
|
|
StationVisitID = ID_Visit * 100 + thisStation.ID_Station;
|
|
//co.Close();
|
|
step = "EPD writing";
|
|
ep.WearerID = StationVisitID.ToString();
|
|
ep.WearerName = _User.PersID.ToString();
|
|
|
|
#if SimulateEPD
|
|
simulData.EdpType = ep.epdType;
|
|
simulData.WearerID = ep.WearerID;
|
|
simulData.WearerName = ep.WearerName;
|
|
#endif
|
|
|
|
ep.Hp07RateOn = CurTaskRow.HP07RateON;
|
|
ep.Hp07RateOff = CurTaskRow.HP07RateOFF;
|
|
|
|
ep.Hp10Rate1On = CurTaskRow.HP10Rate1ON;
|
|
ep.Hp10Rate1Off = CurTaskRow.HP10Rate1OFF;
|
|
|
|
ep.Hp10Rate2On = CurTaskRow.HP10Rate2ON;
|
|
ep.Hp10Rate2Off = CurTaskRow.HP10Rate2OFF;
|
|
|
|
ep.Hp10THDose1 = CurTaskRow.Hp10Dose1;
|
|
ep.Hp10THDose2 = CurTaskRow.Hp10Dose2;
|
|
ep.Hp07THDose = CurTaskRow.Hp07Dose;
|
|
|
|
////voor Neutron K3, K4
|
|
//int? kx = null;
|
|
//if (!CurTaskRow.IsFNGain_ANGainValueNull()) kx = (int)CurTaskRow.FNGain_ANGainValue;
|
|
//if (kx != null && (ep.K3 != kx || ep.K4 != kx))
|
|
// {
|
|
// ep.K3 = ep.K4 = kx.Value;
|
|
// if (!ep.isBG)
|
|
// {
|
|
// if (ep.K6 != 1310)
|
|
// {
|
|
// MessageBox.Show("Alarm");
|
|
// }
|
|
// else
|
|
// {
|
|
// ep.WriteCalibration();
|
|
// }
|
|
// }
|
|
// }
|
|
#if DummyData
|
|
ep.Hp07THDose = 70;
|
|
ep.Hp10THDose1 = 11;
|
|
ep.Hp10THDose2 = 12;
|
|
|
|
ep.Hp07RateOn = 80;
|
|
ep.Hp07RateOff = 9;
|
|
ep.Hp10Rate1On = 13;
|
|
ep.Hp10Rate1Off = 14;
|
|
ep.Hp10Rate2On = 15;
|
|
ep.Hp10Rate2Off = 16;
|
|
|
|
ep.K3 = 3; ep.K4 = 4;
|
|
if (!ep.isBG)
|
|
ep.WriteCalibration();
|
|
|
|
#endif
|
|
|
|
float gain = 100.0F;
|
|
float ChirpRate = 0F;
|
|
if (!CurTaskRow.IsFNGain_ANGainValueNull()) gain = (int)CurTaskRow.FNGain_ANGainValue;
|
|
if (!CurTaskRow.IsChirpRateNull()) ChirpRate = (int)CurTaskRow.ChirpRate;
|
|
|
|
//doing stuff on EPD
|
|
|
|
int rv = ep.IssueAndCheck(gain, ChirpRate, thisStation.WriteConfig);
|
|
|
|
if (rv != 0 || thisStation.LogAll || ep.HasStepError())
|
|
{
|
|
//MessageBox.Show($"GetDoses {rv} rv:{ep.ErrorRV} step:{ep.ErrorStep} er:{ep.GetDosesError}");
|
|
ep.GetSteps();
|
|
if (rv != 0) MessageBox.Show(DecodeResults.decodesteps(ep.StepReturnValues));
|
|
DecodeResults.logsteps(module, ep.StepReturnValues, thisStation.splunkLog);
|
|
}
|
|
lbHP07.Text = ep.Hp07Name;
|
|
lbHP10.Text = ep.Hp10Name;
|
|
|
|
if (ep.EPDIssued || !ep.isMK3)
|
|
{
|
|
using (var l = new SqlLog())
|
|
{
|
|
try
|
|
{
|
|
dataInterface.VisitInitCommand.Parameters["InitError"].Value = rv;
|
|
dataInterface.VisitInitCommand.ExecuteNonQuery();
|
|
l.LogCommand(dataInterface.VisitInitCommand);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
l.LogCommand(ex.Message);
|
|
thisStation.splunkLog.WriteException(module, step, ex);
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
|
|
//if (rv != 0)
|
|
//{
|
|
// MessageBox.Show($"SetIssued error {rv}");
|
|
// step = "SqlConfirmVisit";
|
|
// dataInterface.VisitInitConfirmCommand.Connection = co;
|
|
// dataInterface.VisitInitConfirmCommand.Parameters["ID_Station"].Value = thisStation.ID_Station;
|
|
// dataInterface.VisitInitConfirmCommand.Parameters["ID_Visit"].Value = ID_Visit;
|
|
// dataInterface.VisitInitConfirmCommand.Parameters["InitError"].Value = rv;
|
|
// try
|
|
// {
|
|
// dataInterface.VisitInitConfirmCommand.ExecuteNonQuery();
|
|
// //l.LogCommand(dataInterface.VisitInitCommand);
|
|
// }
|
|
// catch (System.Exception ex)
|
|
// {
|
|
// //l.LogCommand(ex.Message);
|
|
// MessageBox.Show(ex.Message);
|
|
// thisStation.splunkLog.WriteException(module, step, ex);
|
|
// l.LogCommand(ex.Message);
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
else
|
|
MessageBox.Show("No registration",string.Empty,MessageBoxButton.OK,MessageBoxImage.Error);
|
|
co.Close();
|
|
ShowFinal(rv);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
EntryState = eEntryState.epdError;
|
|
System.Diagnostics.Debug.WriteLine("Not loaded");
|
|
FinalTimeOut = false;
|
|
SetTimedOutAndEnd();
|
|
}
|
|
}
|
|
public static void DoEvents()
|
|
{
|
|
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background,
|
|
new Action(delegate { }));
|
|
}
|
|
private void ShowFinal(int ReturnValue)
|
|
{
|
|
|
|
FinalHeader.Inlines.Clear();
|
|
if (ReturnValue == 0) {
|
|
FinalHeader.Inlines.Add(Properties.Resources.FinalEpdOkHeader);
|
|
FinalHeader.Inlines.Add(new LineBreak());
|
|
FinalHeader.Inlines.Add(new Run(Properties.Resources.FinalEpdOkSecond)
|
|
{
|
|
Foreground = System.Windows.Media.Brushes.Green,
|
|
Background = sckbLB
|
|
});
|
|
|
|
|
|
} else {
|
|
FinalHeader.Inlines.Add(Properties.Resources.FinalEpdNotOkHeader);
|
|
FinalHeader.Inlines.Add(new LineBreak());
|
|
FinalHeader.Inlines.Add(new Run(Properties.Resources.FinalEpdNotOkSecond) {
|
|
Foreground = System.Windows.Media.Brushes.Red,
|
|
Background = System.Windows.Media.Brushes.Yellow
|
|
});
|
|
}
|
|
|
|
FinalTimeOut = false;
|
|
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
|
dispatcherTimer.Interval = thisStation.InfoProgressbarInterval;
|
|
dispatcherTimer.Tick += CountDown;
|
|
ResultTime = DateTime.Now.AddSeconds(thisStation.InfoScreenTimeout);
|
|
pWaitEpd.Value = pWaitEpd.Maximum = thisStation.InfoScreenTimeout;
|
|
pWaitEpd.Visibility = Visibility.Visible;
|
|
|
|
panelWait.Visibility = Visibility.Collapsed;
|
|
panelDone.Visibility = Visibility.Visible;
|
|
bEpdCancel.Content = "OK"; bEpdCancel.IsEnabled = true;
|
|
EntryState = eEntryState.final;
|
|
dispatcherTimer.Start(); //restart timer
|
|
}
|
|
private void GetEPD()
|
|
{
|
|
const string module = "EntryBadge.getEPD";
|
|
if (thisStation.LogAll || ep.HasStepError())
|
|
{
|
|
var s = ep.GetSteps();
|
|
DecodeResults.logsteps(module, ep.StepReturnValues, thisStation.splunkLog);
|
|
}
|
|
|
|
if (ep.DeviceCount == 1 && ep.EpdID > 0)
|
|
{
|
|
statusEPD.Text = "Found Device : writing config";
|
|
Dispatcher.InvokeAsync(() => { DoEPD(); });
|
|
}
|
|
else
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("Not loaded");
|
|
EntryState = eEntryState.epdtimeout;
|
|
System.Diagnostics.Debug.WriteLine("TIME OUT");
|
|
Dispatcher.InvokeAsync(() => { SetTimedOutAndEnd(); });
|
|
}
|
|
}
|
|
private void SetFilter(bool isAlara)
|
|
{
|
|
string module = "SetFilter";
|
|
string step = null;
|
|
dataInterface.stationLog?.WriteLine($"{module} Start {DateTime.Now.ToString("HH:mm:ss.fff")}");
|
|
taskLoading = true; TaskOK.IsEnabled = false;
|
|
Inst1 = (cbInst1.IsChecked == true) && thisStation.Inst_CODE1 > 0;
|
|
Inst2 = (cbInst2.IsChecked == true) && thisStation.Inst_CODE2 > 0;
|
|
StringBuilder fi = new StringBuilder();
|
|
if (!Inst1 && !Inst2)
|
|
{
|
|
fi.Append(" (1=2) ");
|
|
}
|
|
else
|
|
{
|
|
fi.Append(" ( Inst_CODE in (");
|
|
if (Inst1 == true) fi.Append(thisStation.Inst_CODE1.ToString());
|
|
if (Inst1 && Inst2) fi.Append(",");
|
|
if (Inst2 ) fi.Append(thisStation.Inst_CODE2.ToString());
|
|
fi.Append($") AND TaskType_CODE {(isAlara ? ">=" : "<")} '1000' ) ");
|
|
}
|
|
|
|
string filter = fi.ToString();
|
|
thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.sqlWhere, filter);
|
|
|
|
System.Windows.Data.CollectionViewSource getTaskListViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("getTaskListViewSource")));
|
|
step = "rowfilter";
|
|
try
|
|
{
|
|
var dv = getTaskListViewSource.View.SourceCollection as DataView;
|
|
dataInterface.stationLog?.WriteLine($"filter = {filter}");
|
|
dv.RowFilter = filter;
|
|
dv.Sort = "TaskType_CODE";
|
|
getTaskListViewSource.View.MoveCurrentTo(null);
|
|
} catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
thisStation.splunkLog?.WriteException(module, step, ex);
|
|
dataInterface.stationLog?.WriteLine($"{module} Error {ex.Message}");
|
|
}
|
|
taskLoading = false;
|
|
thisStation.splunkLog?.WriteSplunkLog(module,null, LSWLib.CLog.iseverity.info);
|
|
}
|
|
public string getCommentUnknown()
|
|
{
|
|
StringBuilder res = new StringBuilder();
|
|
var r = dataInterface.GetCommentOnEventRow(3);
|
|
res.AppendLine(r.Comment_NL).Replace("\\n", "\n");
|
|
res.AppendLine("---");
|
|
res.AppendLine(r.Comment_FR).Replace("\\n", "\n");
|
|
res.AppendLine("---");
|
|
res.AppendLine(r.Comment_EN).Replace("\\n", "\n");
|
|
res.AppendLine("---");
|
|
return res.ToString();
|
|
}
|
|
public string getCommentOnEvent(string prefix, int id)
|
|
{
|
|
string res = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(prefix)) res = prefix + "\n";
|
|
var r = dataInterface.GetCommentOnEventRow(id);
|
|
string l = _User?.Language ?? "E";
|
|
if (r != null)
|
|
switch (l)
|
|
{
|
|
case "N": res += r.Comment_NL; break;
|
|
case "F": res += r.Comment_FR; break;
|
|
default: res += r.Comment_EN; break;
|
|
}
|
|
return res.Replace("\\n", "\n");
|
|
}
|
|
/// <summary>
|
|
/// Get User data
|
|
/// </summary>
|
|
/// <returns>doCancel</returns>
|
|
void ShowUserInfo()
|
|
{
|
|
const string module = "ShowUserInfo";
|
|
string step = null;
|
|
dataInterface.stationLog?.WriteLine($"ShowUserInfo Start {DateTime.Now.ToString("HH:mm:ss.fff")}");
|
|
|
|
UserSeconds = 10;
|
|
//UserScreen
|
|
string ReasonNoAccess = string.Empty;
|
|
dispatcherTimer?.Stop();
|
|
dispatcherTimer = null;
|
|
if (_User.PersID == 0)
|
|
{
|
|
thisStation.splunkLog?.WriteSplunkLog(module, null, LSWLib.CLog.iseverity.info, lresultMessage: "PersID 0 no access");
|
|
tReasonNoAccess.Text = getCommentUnknown();
|
|
if (_User.Error > 0) tReasonNoAccess.Text = _User.ErrorMessage;
|
|
EntryState = eEntryState.NotAllowed;
|
|
tbNotAllowed.IsSelected = true;
|
|
Dispatcher.InvokeAsync(() => { endPage(); });
|
|
}
|
|
else
|
|
{
|
|
EntryState = eEntryState.getuser;
|
|
tbUser.IsSelected = true;
|
|
if (_User == null || _User.VisitIDLocked > 0 || _User.AccessAllow == false || _User.hasEPD)
|
|
{
|
|
if (_User.VisitIDLocked > 0 || _User.AccessAllow == false)
|
|
ReasonNoAccess = _User.ReasonNoAccess;
|
|
else if (_User.hasEPD)
|
|
ReasonNoAccess = User.ErrorEPDInUse;
|
|
else ReasonNoAccess = getCommentOnEvent(string.Empty, 3);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(_User.UserComment))
|
|
{
|
|
UserComment.Text = _User.UserComment;
|
|
boxComment.Visibility = Visibility.Visible;
|
|
}
|
|
else
|
|
boxComment.Visibility = Visibility.Hidden;
|
|
|
|
if (!string.IsNullOrWhiteSpace(ReasonNoAccess))
|
|
UserAccess.Text = ReasonNoAccess;
|
|
|
|
Username.Text = _User.FullUserName();
|
|
thisStation.splunkLog?.KvAdd(LSWLib.CLog.skeys.persID, _User.PersID);
|
|
thisStation.splunkLog?.KvAdd(LSWLib.CLog.skeys.name, _User.FullUserName());
|
|
string msg = string.Empty;
|
|
if (!_User.HasMessage() && string.IsNullOrEmpty(ReasonNoAccess) && _User.AllowShowTask())
|
|
{
|
|
thisStation.splunkLog?.WriteSplunkLog(module, step, LSWLib.CLog.iseverity.info);
|
|
step = "AskTask";
|
|
msg = $"ShowUserInfo to AskTask {DateTime.Now.ToString("HH:mm:ss.fff")}";
|
|
dataInterface.stationLog?.WriteLine(msg);
|
|
thisStation.splunkLog?.WriteSplunkLog(module,step, LSWLib.CLog.iseverity.info, lresultMessage: msg);
|
|
pUserSeconds.Visibility = Visibility.Collapsed;
|
|
pUserSeconds.Maximum = pUserSeconds.Value = 1;
|
|
Dispatcher.InvokeAsync(AskTask, DispatcherPriority.Normal);
|
|
}
|
|
else
|
|
{
|
|
|
|
thisStation.splunkLog?.WriteSplunkLog(module, step, LSWLib.CLog.iseverity.warning, lresultMessage: ReasonNoAccess);
|
|
step = "Add timer";
|
|
msg = $"ShowUserInfo {step} {DateTime.Now.ToString("HH:mm:ss.fff")}";
|
|
dataInterface.stationLog?.WriteLine(msg);
|
|
tReasonNoAccess.Text = ReasonNoAccess;
|
|
pUserSeconds.Visibility = Visibility.Visible;
|
|
pUserSeconds.Maximum = pUserSeconds.Value = UserSeconds;
|
|
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
|
dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
|
|
dispatcherTimer.Tick += SwitchToTask;
|
|
dispatcherTimer.Start();
|
|
}
|
|
}
|
|
|
|
return ;
|
|
}
|
|
private void SwitchToTask(object sender, EventArgs e)
|
|
{
|
|
if (--UserSeconds > 0 && (_User.AccessAllow != true || !string.IsNullOrEmpty(_User.UserComment) || !string.IsNullOrEmpty(_User.ReasonNoAccess)))
|
|
{
|
|
tUserSeconds.Text = UserSeconds.ToString();
|
|
pUserSeconds.Value = UserSeconds;
|
|
}
|
|
else
|
|
{
|
|
dispatcherTimer?.Stop();
|
|
dispatcherTimer = null;
|
|
if (_User.AllowShowTask()) Dispatcher.InvokeAsync(AskTask, DispatcherPriority.Normal);
|
|
else Dispatcher.InvokeAsync(() => {endPage(); });
|
|
}
|
|
}
|
|
void AskTask()
|
|
{
|
|
const string module = "AskTask";
|
|
EntryState = eEntryState.gettask;
|
|
tbTask.IsSelected = true;
|
|
thisStation.splunkLog?.WriteSplunkLog(module,null, LSWLib.CLog.iseverity.info);
|
|
Naam.Text = _User.FirstName + " " + _User.LastName;
|
|
dataSet1 = ((eDosStation.DataSet1)(this.FindResource("dataSet1")));
|
|
dataInterface.FillTaskInfo(_User, dataSet1);
|
|
bool isAlara = (cbAlara.IsChecked == true);
|
|
SetFilter(isAlara);
|
|
}
|
|
void CheckBadge()
|
|
{
|
|
const string module = "CheckBadge";
|
|
_User = dataInterface.GetUser(CSN.Text, Code.Text,true);
|
|
#if DEBUG
|
|
//_User.UserComment = "Hallo";
|
|
#endif
|
|
thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.persID, _User.PersID);
|
|
thisStation.splunkLog?.WriteSplunkLog(module,"getUser",LSWLib.CLog.iseverity.info);
|
|
Dispatcher.InvokeAsync(() => { ShowUserInfo(); });
|
|
}
|
|
public void showBadge(int persID, string csn)
|
|
{
|
|
const string module = "showBadge";
|
|
thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.persID, persID);
|
|
thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.CSN, csn);
|
|
thisStation.splunkLog?.WriteSplunkLog(module, "received", LSWLib.CLog.iseverity.info);
|
|
CSN.Text = csn;
|
|
Site.Text = string.Empty;
|
|
Code.Text = persID.ToString();
|
|
Dispatcher.InvokeAsync(CheckBadge,DispatcherPriority.Normal);
|
|
}
|
|
public void endPage()
|
|
{
|
|
if (EpdReading)
|
|
{
|
|
//MessageBox.Show("Fout bij initialiseren EPD! ");
|
|
}
|
|
EpdReading = false;
|
|
dispatcherTimer?.Stop();
|
|
|
|
dispatcherTimer = null;
|
|
this.Close();
|
|
}
|
|
private void bClose_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
endPage();
|
|
}
|
|
private void BClear_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
CSN.Text = string.Empty;
|
|
Site.Text = string.Empty;
|
|
Code.Text = string.Empty;
|
|
}
|
|
private void TaskOK_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
bool isOk = false;
|
|
switch (TaskOK.Tag)
|
|
{
|
|
case "A": //No access
|
|
break;
|
|
case "M": //Margin
|
|
break;
|
|
case "B": // Badge
|
|
break;
|
|
case "L": //Locked
|
|
break;
|
|
case "O": // OK
|
|
isOk = true;
|
|
break;
|
|
}
|
|
|
|
if (isOk)
|
|
{
|
|
System.Windows.Data.CollectionViewSource getTaskListViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("getTaskListViewSource")));
|
|
var rv = getTaskListViewSource.View.CurrentItem as DataRowView;
|
|
CurTaskRow = rv.Row as DataSet1.GetTaskInfoRow;
|
|
|
|
if (_User == null || CurTaskRow == null) return;
|
|
if (CurTaskRow.MinWorkerDosisMargin > _User.Margin)
|
|
{
|
|
MessageBox.Show("Margin exceeded");
|
|
endPage();
|
|
}
|
|
else
|
|
{
|
|
EntryState = eEntryState.getepd;
|
|
tb.SelectedItem = tbEPD;
|
|
panelDone.Visibility = Visibility.Collapsed;//1
|
|
panelWait.Visibility = Visibility.Visible;
|
|
statusEPD.Text = $"Waiting for EPD ({thisStation.ScreenEPDTimeout} seconds)";
|
|
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
|
dispatcherTimer.Interval = thisStation.ScreenProgressBarInterval;
|
|
dispatcherTimer.Tick += CountDown;
|
|
ResultTime = DateTime.Now.AddSeconds(thisStation.ScreenEPDTimeout);
|
|
pWaitEpd.Value = pWaitEpd.Maximum = thisStation.ScreenEPDTimeout;
|
|
pWaitEpd.Visibility = Visibility.Visible;
|
|
dispatcherTimer.Start();
|
|
startEPDRead();
|
|
}
|
|
}
|
|
}
|
|
private void startEPDRead()
|
|
{
|
|
EpdReading = true; bEpdCancel.IsEnabled = false;
|
|
|
|
Dispatcher.InvokeAsync(new Action(() => { ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries); }), DispatcherPriority.Background);
|
|
}
|
|
private void SetTimedOutAndEnd()
|
|
{
|
|
bool ShowExtraTime= true;
|
|
if (!FinalTimeOut)
|
|
{
|
|
bEpdCancel.IsEnabled = true;
|
|
FinalTimeOut = true;
|
|
dispatcherTimer?.Stop();
|
|
pWaitEpd.Value = 0;
|
|
switch (EntryState) {
|
|
case eEntryState.epdtimeout:
|
|
pWaitEpd.Background = System.Windows.Media.Brushes.Red;
|
|
statusEPD.Text = "Time out";
|
|
tWaitFor.Text = "Lezer niet gevonden !";
|
|
break;
|
|
case eEntryState.epdError:
|
|
pWaitEpd.Background = System.Windows.Media.Brushes.Red;
|
|
statusEPD.Text = "Error";
|
|
tWaitFor.Text = "Error with EPD!";
|
|
break;
|
|
default:
|
|
bEpdCancel.Content = "OK";
|
|
ShowExtraTime = false;
|
|
break;
|
|
}
|
|
if (ShowExtraTime)
|
|
{
|
|
dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background);
|
|
dispatcherTimer.Tick += ShowAndEnd;
|
|
dispatcherTimer.Interval = thisStation.ShowTimeoutTime;
|
|
dispatcherTimer.Start();
|
|
}
|
|
else ShowAndEnd(null,null);
|
|
}
|
|
}
|
|
private void ShowAndEnd(object sender, EventArgs e)
|
|
{
|
|
dispatcherTimer?.Stop();
|
|
dispatcherTimer = null;
|
|
endPage();
|
|
}
|
|
private void CountDown(object sender, EventArgs e)
|
|
{
|
|
double v = (ResultTime - DateTime.Now).TotalSeconds;
|
|
if (v > pWaitEpd.Minimum)
|
|
pWaitEpd.Value = v;
|
|
else
|
|
{
|
|
pWaitEpd.Value = pWaitEpd.Minimum;
|
|
SetTimedOutAndEnd();
|
|
}
|
|
}
|
|
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
const string module = "ListBox_SelectionChanged";
|
|
if (taskLoading ) return;
|
|
var lb = sender as ListBox;
|
|
if (lb == null || !lb.Name.Equals("LB1")) return;
|
|
|
|
bool exceeded = false;
|
|
e.Handled = true;
|
|
DataSet1.GetTaskInfoRow o = null;
|
|
if (e.AddedItems.Count > 0)
|
|
{
|
|
o = ((DataRowView) e.AddedItems[0]).Row as DataSet1.GetTaskInfoRow;
|
|
TaskOK.IsEnabled = true;
|
|
}
|
|
thisStation.splunkLog?.KvClear();
|
|
thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.persID, _User.PersID);
|
|
|
|
if (o != null)
|
|
{
|
|
exceeded = o.MarginExceeded;
|
|
thisStation.splunkLog?.KvSet(LSWLib.CLog.skeys.TaskCode, o.TaskType_CODE);
|
|
TaskOK.Content = "Task"; TaskOK.Tag = "B";
|
|
}
|
|
if (_User == null) { TaskOK.Content = "Badge"; TaskOK.Tag = "B"; }
|
|
else if (!_User.AllOk)
|
|
{
|
|
if (_User.AccessAllow != true) { TaskOK.Content = "No Access"; TaskOK.Tag = "A"; }
|
|
else if (_User.VisitIDLocked.HasValue && _User.VisitIDLocked> 0) { TaskOK.Content = "Locked"; TaskOK.Tag = "L"; }
|
|
else if (exceeded == true) { TaskOK.Content = "No Margin"; TaskOK.Tag = "M"; }
|
|
dataInterface.stationLog?.WriteLine($"User {_User.PersID} not ok ");
|
|
thisStation.splunkLog?.WriteSplunkLog(module,null, LSWLib.CLog.iseverity.warning, lresultMessage: TaskOK.Content.ToString());
|
|
}
|
|
else
|
|
{
|
|
TaskOK.Content = "OK"; TaskOK.Tag = "O";
|
|
thisStation.splunkLog?.WriteSplunkLog(module,null, LSWLib.CLog.iseverity.info);
|
|
}
|
|
}
|
|
private void CbInst1_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Inst1 = (cbInst1.IsChecked == true);
|
|
cbInst2.IsChecked = !Inst1;
|
|
bool isAlara = (cbAlara.IsChecked == true);
|
|
SetFilter(isAlara);
|
|
}
|
|
private void CbAlara_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!initialising)
|
|
{
|
|
bool isAlara = true;
|
|
cbAlara.IsChecked = true;
|
|
cbNormal.IsChecked = !isAlara;
|
|
SetFilter(isAlara);
|
|
}
|
|
}
|
|
private void CbNormal_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!initialising)
|
|
{
|
|
bool isAlara = false;
|
|
cbAlara.IsChecked = isAlara;
|
|
cbNormal.IsChecked = !isAlara;
|
|
SetFilter(isAlara);
|
|
}
|
|
}
|
|
private void BUserRead_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
dispatcherTimer.Stop();
|
|
dispatcherTimer.Tick -= SwitchToTask;
|
|
if (_User.AllOk == true && !_User.hasEPD && _User.AllowShowTask()) AskTask();
|
|
else endPage();
|
|
}
|
|
private void TaskCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
private void BTestPerson_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Button b = sender as Button;
|
|
string id = b.Tag.ToString().ToUpper();
|
|
if (id[0]=='P')
|
|
_User = dataInterface.GetUser(null, id.Substring(1),true);
|
|
else
|
|
_User = dataInterface.GetUser("TP" + b.Tag.ToString().ToUpper(), string.Empty,true);
|
|
Dispatcher.InvokeAsync(() => { ShowUserInfo(); });
|
|
dfReader?.WaitEnd();
|
|
|
|
}
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
FinalTimeOut = false;
|
|
try
|
|
{
|
|
if (ep != null)
|
|
{
|
|
ep.WaitEnd();
|
|
ep.Dispose();
|
|
ep = null;
|
|
}
|
|
if (dfReader != null)
|
|
{
|
|
dfReader.WaitEnd();
|
|
dfReader.Dispose();
|
|
dfReader = null;
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
System.Diagnostics.Debug.WriteLine(ex.Message);
|
|
}
|
|
}
|
|
private void CbInst2_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Inst2 = (cbInst2.IsChecked == true);
|
|
cbInst1.IsChecked = !Inst2;
|
|
bool isAlara = (cbAlara.IsChecked == true);
|
|
SetFilter(isAlara);
|
|
}
|
|
private void AddTestButtons()
|
|
{
|
|
StackPanel sp = pTestButtons;
|
|
Button b;
|
|
string id;
|
|
Thickness m = new Thickness(0, 0, 20, 0);
|
|
for (int i = 1; i < 15; i++)
|
|
{
|
|
b = new Button();
|
|
b.Click += BTestPerson_Click;
|
|
switch (i)
|
|
{
|
|
case 1: id = "P12103"; break;
|
|
case 2: id = "P52969"; break;
|
|
default: id = i.ToString(); break;
|
|
}
|
|
b.Tag = id;
|
|
b.Content = $"{id}";
|
|
b.FontSize = 10;
|
|
b.Height = 40; b.Width = 50;
|
|
b.Margin = m;
|
|
sp.Children.Add(b);
|
|
}
|
|
|
|
sp.Visibility = Visibility.Visible;
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
initialising = true;
|
|
EpdReading = false; FinalTimeOut = false; bEpdCancel.IsEnabled = true;
|
|
sckbLB = TryFindResource("sckbLB") as SolidColorBrush;
|
|
if (sckbLB==null) sckbLB=Brushes.WhiteSmoke;
|
|
EntryState = eEntryState.Initial;
|
|
tbEntry.IsSelected = true;
|
|
panelDone.Visibility= Visibility.Collapsed;
|
|
panelWait.Visibility = Visibility.Visible;
|
|
cbAlara.IsChecked = false;
|
|
cbInst1.Content = thisStation.Inst_Name1;
|
|
Inst1 = true;
|
|
cbInst1.IsChecked = Inst1;
|
|
if (thisStation.Inst_CODE2 > 0)
|
|
{
|
|
cbInst2.Content = thisStation.Inst_Name2;
|
|
cbInst2.Visibility = Visibility.Visible;
|
|
Inst2 = false;
|
|
cbInst2.IsChecked = Inst2;
|
|
}
|
|
dataInterface.FillComment();
|
|
initialising = false;
|
|
if (thisStation.useTestButtons) AddTestButtons();
|
|
taskLoading = false;
|
|
|
|
//StartEPD
|
|
if (ep==null)
|
|
try
|
|
{
|
|
ep = new EpdBaseClr.Epd2(thisStation.ComPort, thisStation.OnlyMK2);
|
|
ep.SetFeedbackSound(thisStation.useBeep, thisStation.useBeepMK3());
|
|
ep.EpdRead += Ep_EpdRead;
|
|
ep.EpdError += Ep_EpdError;
|
|
ep.EpdTO += Ep_EpdTO;
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
thisStation.splunkLog.WriteException(null, "StartEpd", ex);
|
|
MessageBox.Show($"{ex.Message}");
|
|
ep = null;
|
|
}
|
|
|
|
//StartBadge
|
|
if (thisStation.isElatec)
|
|
{
|
|
thisStation.ReceivedPersid = Pelatec_DataReceived;
|
|
} else
|
|
{
|
|
if (dfReader == null)
|
|
{
|
|
dfReader = new LSWDesfirePublic.CCard();
|
|
dfReader.GetReaderList();
|
|
if (dfReader.readersList.Contains(thisStation.Reader))
|
|
{
|
|
dfReader.SetReader(thisStation.Reader);
|
|
dfReader.Badged += DFReader_Badged;
|
|
dfReader.BadgeTO += DfReader_BadgeTO;
|
|
dfReader.BadgeError += DfReader_BadgeError;
|
|
ReaderTask = dfReader.Wait(PageTimeout, 10);
|
|
}
|
|
else
|
|
{
|
|
StringBuilder er = new StringBuilder($"Badgelezer \"{thisStation.Reader}\" niet gevonden!.\nDeze lezers zijn beschikbaar:\n");
|
|
dfReader.GetReaderList();
|
|
foreach (string r in dfReader.readersList) er.AppendLine($"-> {r}");
|
|
MessageBox.Show(er.ToString(), "Badge Lezer", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
dfReader.Dispose(); dfReader = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Pelatec_DataReceived(int PersID)
|
|
{
|
|
this.Dispatcher.InvokeAsync(new Action(() => showBadge(PersID, null)), DispatcherPriority.Background);
|
|
}
|
|
//private void Pelatec_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
|
|
//{
|
|
// var v = elatecReader.ReadLine();
|
|
// int PersID;
|
|
// if (!int.TryParse(v, out PersID)) PersID = 0;
|
|
// if (PersID > 0)
|
|
// this.Dispatcher.InvokeAsync(new Action(() => showBadge(PersID, null)), DispatcherPriority.Background);
|
|
// else
|
|
// {
|
|
// string msg = $"No PersID found on badge ";
|
|
// MessageBox.Show(msg, "Error", MessageBoxButton.OK);
|
|
// thisStation.splunkLog?.WriteSplunkLog("Badged", LSWLib.CLog.iseverity.warning, null, msg);
|
|
// }
|
|
//}
|
|
|
|
private void DfReader_BadgeError(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeErrorEventArgs e)
|
|
{
|
|
endPage();
|
|
}
|
|
private void LeesCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
endPage();
|
|
}
|
|
private void DfReader_BadgeTO(LSWDesfirePublic.CCard Sender, EventArgs e)
|
|
{
|
|
this.Dispatcher.InvokeAsync(new Action(() => endPage()),DispatcherPriority.Normal);
|
|
}
|
|
private bool SelectTask(string id_task)
|
|
{
|
|
System.Windows.Data.CollectionViewSource getTaskListViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("getTaskListViewSource")));
|
|
var dv = getTaskListViewSource.View.SourceCollection as DataView;
|
|
var r = dv.Find(id_task);
|
|
if (r >= 0)
|
|
{
|
|
getTaskListViewSource.View.MoveCurrentTo(dv[r]);
|
|
return true;
|
|
}
|
|
else return false;
|
|
}
|
|
private void numPanel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Button x = sender as Button;
|
|
string t = x.Tag as string;
|
|
if (t[0] <= '9' && t[0] >= '0')
|
|
{
|
|
if (numPanelDisplay.Text == "0") numPanelDisplay.Text = string.Empty;
|
|
numPanelDisplay.Text += t;
|
|
}
|
|
else
|
|
switch (t[0])
|
|
{
|
|
case 'B':
|
|
string d = numPanelDisplay.Text;
|
|
if (d.Length > 0) numPanelDisplay.Text = d.Substring(0, d.Length - 1);
|
|
break;
|
|
case 'C':
|
|
numPanelDisplay.Text = string.Empty;
|
|
break;
|
|
case 'E':
|
|
//TaskbarItemInfo = numPanelDisplay.Text;
|
|
SelectTask(numPanelDisplay.Text);
|
|
scrollTask.Visibility = Visibility.Visible;
|
|
numPanel.Visibility = Visibility.Collapsed;
|
|
break;
|
|
}
|
|
}
|
|
private void ShowNumpad_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (numPanel.Visibility != Visibility.Visible)
|
|
{
|
|
numPanelDisplay.Text = string.Empty;
|
|
numPanel.Visibility = Visibility.Visible;
|
|
scrollTask.Visibility = Visibility.Collapsed;
|
|
numPanel1.Focus();
|
|
}
|
|
else
|
|
{
|
|
scrollTask.Visibility = Visibility.Visible;
|
|
numPanel.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
private void DFReader_Badged(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeEventArgs e)
|
|
{
|
|
const string module = "DFReader_Badged";
|
|
if (e.PersID > 0)
|
|
this.Dispatcher.InvokeAsync(new Action(() => showBadge(e.PersID, e.UID)), DispatcherPriority.Background);
|
|
else
|
|
{
|
|
string msg = $"No PersID found on badge {e.UID}";
|
|
MessageBox.Show(msg, "Error",MessageBoxButton.OK);
|
|
thisStation.splunkLog?.WriteSplunkLog(module,null, LSWLib.CLog.iseverity.warning, lresultMessage: msg);
|
|
}
|
|
}
|
|
}
|
|
}
|