8 oktober, voor afwerking

This commit is contained in:
Luc Vandenbroucke 2020-10-08 13:48:36 +02:00
parent a218732e81
commit 43ab98dfe4
16 changed files with 211 additions and 181 deletions

View file

@ -6,7 +6,7 @@
#define RxRetryCount 5
#define TxRetryCount 5
#pragma unmanaged
EpdBase::Epd2U::Epd2U(int comport)
{
port = comport;
@ -30,11 +30,11 @@ DWORD EpdBase::Epd2U::StartCom()
if (CommsInitialized==0)
do {
InitRv = InitComms(port, 9600, 8, 0, 0);
System::Diagnostics::Trace::WriteLine(System::String::Format("InitCOms RV={0} Port={1}", InitRv, port));
//System::Diagnostics::Trace::WriteLine(System::String::Format("InitCOms RV={0} Port={1}", InitRv, port));
if (InitRv == 0) {
rv= GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
System::Diagnostics::Trace::WriteLine(System::String::Format("InitCOms ErrorReason={0} ErrorData={1} Port={2}", ErrorReason, ErrorData, port));
//System::Diagnostics::Trace::WriteLine(System::String::Format("InitCOms ErrorReason={0} ErrorData={1} Port={2}", ErrorReason, ErrorData, port));
Sleep(300); DeinitComms(port);
}
else {
@ -58,7 +58,7 @@ EpdBase::Epd2U::~Epd2U()
int EpdBase::Epd2U::StartDiscover()
{
WORD rv;
System::Diagnostics::Trace::WriteLine("StartDiscover");
//System::Diagnostics::Trace::WriteLine("StartDiscover");
Error = 0;
//SetDiscoveryTimeslotCount(port, 2);
@ -75,13 +75,13 @@ int EpdBase::Epd2U::StartDiscover()
{
//memset(DeviceIDs, 0, sizeof(DeviceIDs));
DiscRV = Discover(port, DeviceIDs, MaxDevices, &DeviceCount);
System::Diagnostics::Trace::WriteLine(System::String::Format("Discover try: {0} RV={1}", tries, DiscRV));
//System::Diagnostics::Trace::WriteLine(System::String::Format("Discover try: {0} RV={1}", tries, DiscRV));
if (DiscRV ==0 ) {
Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
System::Diagnostics::Trace::WriteLine(System::String::Format("StartDiscover Error Connect Reason: {0} ErrorData {1}", ErrorReason, ErrorData));
//System::Diagnostics::Trace::WriteLine(System::String::Format("StartDiscover Error Connect Reason: {0} ErrorData {1}", ErrorReason, ErrorData));
}
}
System::Diagnostics::Trace::WriteLine(System::String::Format("Discover DeviceCount = {0}", DeviceCount));
//System::Diagnostics::Trace::WriteLine(System::String::Format("Discover DeviceCount = {0}", DeviceCount));
return DiscRV;
}
@ -379,16 +379,14 @@ WORD EpdBase::Epd2U::PrepareForIssue()
WORD EpdBase::Epd2U::DeIssue()
{
ClearDoseRV = ClearTotalDoseRV = ClearPeakRatesRV = DeIssueEpdRV = 0;
CommitRV = ClearFailFlag();
if (CommitRV) CommitRV = ClearFaultFlags();
if (CommitRV) CommitRV = ClearLatchedAlarms();
if (CommitRV) CommitRV = Commit();
if (CommitRV) CommitRV = ClearDose();
if (CommitRV) CommitRV = ClearTotalDose();
if (CommitRV) CommitRV = ClearPeakRates();
if (CommitRV) CommitRV = Commit();
if (CommitRV) CommitRV = ClearFaultFlags();
if (CommitRV) CommitRV = ClearLatchedAlarms();//Hp10Rate1; Hp10Rate2; Hp07Rate; ReturnForRead
if (CommitRV) CommitRV = Commit();
CommitRV = ClearFailFlag();
if (CommitRV) CommitRV = DeIssueEpd();
if (CommitRV) CommitRV = Commit();
if (CommitRV && DetectorsOn) {

View file

@ -24,34 +24,34 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>EpdBase</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "TimeFunctions.h"
#pragma unmanaged
TimeFunctions::TimeFunctions()
{

View file

@ -103,10 +103,6 @@ int EpdBaseClr::Epd2::GetStatus()
errorStatus = epd->ErrorStatus;
operatingStatus = epd->OperatingStatus;
EpdID = epd->EpdID;
HardVersion = epd->HardVersion;
SoftVersion = epd->SoftVersion;

View file

@ -24,34 +24,34 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>EpdBaseClr</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View file

@ -11,8 +11,7 @@
namespace OkReadBadge
{
public class BadgeUnmanaged
public class BadgeUnmanaged
{
private:
@ -35,7 +34,6 @@ namespace OkReadBadge
char CSN[50];
char Site[20];
char Badge[20];
int parse(char *rall)
{

View file

@ -23,35 +23,35 @@
<ProjectGuid>{F98F3496-8A4C-4BDB-9F17-C7AF47A60739}</ProjectGuid>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>OkReadBadge</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<TargetFrameworkVersion>4.7.2</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View file

@ -23,32 +23,32 @@
<ProjectGuid>{3655B312-F7C2-4825-BD5F-E087F6AF2D90}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>TestDirect</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View file

@ -23,32 +23,32 @@
<ProjectGuid>{7B3DD1C5-D8D0-408C-A272-FF5E4A30DF24}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>TestEdosBase</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View file

@ -20,11 +20,17 @@
<TabControl Name="tb" TabStripPlacement="Top" >
<TabItem Name="tbEntry" >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Border Background="AliceBlue" TextBlock.FontSize="24" TextBlock.LineHeight="30px" Padding="20,20,20,20" >
<Border Background="AliceBlue" TextBlock.FontSize="24" TextBlock.LineHeight="30px" Padding="20,20,20,20" CornerRadius="10" BorderThickness="2" BorderBrush="Blue" >
<StackPanel HorizontalAlignment="Center" >
<TextBlock Text="Welcome to eDOS" TextAlignment="Center" />
<TextBlock Text="Entry Process ready !" FontSize="30" TextAlignment="Center" Margin="0,20,0,20"/>
<TextBlock Text="Please scan your badge on the badge reader" TextAlignment="Center"/>
<TextBlock TextAlignment="Center" Padding="10,10,10,10" >
<LineBreak/>
<Run Foreground="Blue" FontSize="28" FontWeight="Bold">Welcome to eDOS</Run>
<LineBreak/><LineBreak/>
<Run Background="LightGreen">Entry Process is ready</Run>
<LineBreak/><LineBreak/>
<Run>Please scan your badge on the badge reader</Run>
<LineBreak/><LineBreak/>
</TextBlock>
</StackPanel>
</Border>
<StackPanel Orientation="Horizontal">

View file

@ -41,7 +41,6 @@ namespace eDosStation
string csn, site, code;
static User _User;
DataSet1.CommentOnEventDataTable dtCOE;
DataSet1.GetTaskInfoRow CurTaskRow;
enum eCOE { quiz=1} ;
private bool StopReadBadge=true;
@ -258,7 +257,7 @@ namespace eDosStation
public string getCommentUnknown()
{
StringBuilder res = new StringBuilder();
DataSet1.CommentOnEventRow r = dtCOE.FindByID_CommnentOnEvent(3);
var r = LocalRemote.GetCommentOnEventRow(3);
res.AppendLine(r.Comment_NL).Replace("\\n", "\n");
res.AppendLine("---");
res.AppendLine(r.Comment_FR).Replace("\\n", "\n");
@ -272,7 +271,7 @@ namespace eDosStation
{
string res=string.Empty;
if (!string.IsNullOrWhiteSpace(prefix)) res = prefix + "\n";
DataSet1.CommentOnEventRow r = dtCOE.FindByID_CommnentOnEvent(id);
var r = LocalRemote.GetCommentOnEventRow(id);
string l = _User?.Language ?? "E";
if (r!=null)
@ -351,17 +350,14 @@ namespace eDosStation
{
Naam.Text = _User.FirstName + " " + _User.LastName;
eDosStation.DataSet1 dataSet1 = ((eDosStation.DataSet1)(this.FindResource("dataSet1")));
using (var dataSet1GetTaskInfoTableAdapter = new eDosStation.DataSet1TableAdapters.GetTaskInfoTableAdapter())
{
dataSet1GetTaskInfoTableAdapter.Fill(dataSet1.GetTaskInfo, null, _User.Margin);
}
LocalRemote.FillTaskInfo(_User, dataSet1);
tbTask.IsSelected = true;
bool isAlara = (cbAlara.IsChecked == true);
SetFilter(isAlara);
}
void CheckBadge()
{
_User = new User(CSN.Text, Code.Text);
_User = LocalRemote.GetUser(CSN.Text, Code.Text);
ShowUserInfo(); //AskTask();
}
public void showBadge()
@ -516,7 +512,7 @@ namespace eDosStation
private void BTestPerson_Click(object sender, RoutedEventArgs e)
{
Button b = sender as Button;
_User = new User("TP"+b.Tag, "");
_User = LocalRemote.GetUser("TP"+b.Tag.ToString().ToUpper(), "");
ShowUserInfo(); //AskTask();
}
@ -573,6 +569,7 @@ namespace eDosStation
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
LocalRemote.checkCon();
EpdFound = false;
initialising = true;
tbEntry.IsSelected = true;
@ -590,7 +587,7 @@ namespace eDosStation
cbInst2.IsChecked = Inst2;
}
LocalRemote.FillComment(dtCOE);
LocalRemote.FillComment();
string TestCSN = thisStation.TestCSN;
initialising = false;
@ -606,7 +603,7 @@ namespace eDosStation
else
{
////Debug
_User = new User(TestCSN, string.Empty);
_User = LocalRemote.GetUser(TestCSN, string.Empty);
if (_User.Error > 0)
{
MessageBox.Show(_User.ErrorMessage, "DB Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);

View file

@ -45,14 +45,15 @@
</TabItem>
<TabItem Name="Alarm" Header="Alarm">
<StackPanel>
<Border Background="LightYellow" TextBlock.FontSize="24" TextBlock.LineHeight="30px" Padding="20,20,20,20" >
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" >
<Border Background="LightYellow" TextBlock.FontSize="22" TextBlock.LineHeight="30px" Padding="20,20,20,20" >
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" >
<LineBreak/>
<Run>Your dose and/or doserate has been above the alarmlevel</Run>
<Run>during your visit !</Run>
<LineBreak/>
<Run>Please contact the Radioprotection officer of the building.</Run>>
<LineBreak/>
<Run>Please contact</Run><LineBreak/><Run> the Radioprotection officer of the building.</Run>
<LineBreak/><LineBreak/>
<Run>He needs to validate and clear your alarm(s).</Run>
<LineBreak/>
</TextBlock>
@ -65,11 +66,12 @@
<Border Background="LightYellow" TextBlock.FontSize="24" TextBlock.LineHeight="30px" Padding="20,20,20,20" >
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" >
<LineBreak/>
<Run>Your EPD has encounterd a problem.</Run>
<Run>Your EPD has encountered a problem.</Run>
<LineBreak/><LineBreak/>
<Run>Please contact</Run><LineBreak/><Run>the Radioprotection officer of the building.</Run>
<LineBreak/>
<Run>Please contact the Radioprotection officer of the building.</Run>
<LineBreak/>
<Run> He needs to investigate it.</Run>
<LineBreak/>
<Run> He needs to investigate the alarm.</Run>
</TextBlock>
</Border>
<Button Content="OK" Height="40" Width="200" Name="bConfirmAlarm2" Click="BConfirmAlarm_Click" />

View file

@ -52,10 +52,10 @@ namespace eDosStation
dispatcherTimer.Interval = new TimeSpan(0, 0, 5);
} else
{
dispatcherTimer.Tick -= DispatcherTimer_Tick;
dispatcherTimer.Tick -= DispatcherTimer_IsEPDFound;
dispatcherTimer.Stop();
}
dispatcherTimer.Tick += DispatcherTimer_TickTimeOut; ;
dispatcherTimer.Tick += DispatcherTimer_WindowTimeoutAndClose; ;
int rv= ep.GetStatus();
if (rv != 1)
@ -74,16 +74,19 @@ namespace eDosStation
MessageBox.Show("This EPD is not read", "EDP", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
}
bool NoTimeout = false;
if (ep.alarmStatus != 0)
{
DosePanel.Background = AlarmBrush;
Alarm.IsSelected = true;
NoTimeout = true;
}
else if ((ep.otherAlarms & 0x7f) != 0)
{
DosePanel.Background = AlarmBrush;
OtherAlarm.IsSelected = true;
NoTimeout = true;
} else
{
DosePanel.Background = GreenBrush;
@ -128,11 +131,11 @@ namespace eDosStation
}
l.Dispose();
}
dispatcherTimer.Start(); //Knop hide
if (!NoTimeout) dispatcherTimer.Start(); //Knop hide
return;
}
private void DispatcherTimer_TickTimeOut(object sender, EventArgs e)
private void DispatcherTimer_WindowTimeoutAndClose(object sender, EventArgs e)
{
dispatcherTimer.Stop();
this.Close();
@ -156,7 +159,7 @@ namespace eDosStation
statusEPD.Content = $"EPD: Wait ";
Search = 100;
dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += DispatcherTimer_Tick;
dispatcherTimer.Tick += DispatcherTimer_IsEPDFound;
dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
dispatcherTimer.Start();
}
@ -169,7 +172,7 @@ namespace eDosStation
Dispatcher.InvokeAsync(StartScan);
}
private void DispatcherTimer_Tick(object sender, EventArgs e)
private void DispatcherTimer_IsEPDFound(object sender, EventArgs e)
{
dispatcherTimer.Stop();
EpdFound = false;

View file

@ -17,9 +17,11 @@ namespace eDosStation
static public string conStr;
static public System.Data.SqlClient.SqlConnection Connection;
static public System.Data.SqlClient.SqlCommand VisitInitCommand;
public static SqlCommand VisitExitCommand;
public static SqlCommand VisitExitCommand;
static bool checkCon(bool leaveOpen=false)
static public DataSet1.CommentOnEventDataTable dtCOE;
static public bool checkCon(bool leaveOpen = false)
{
if (Connection != null && Connection.State == System.Data.ConnectionState.Open) return true;
bool rv = false;
@ -41,30 +43,47 @@ namespace eDosStation
rv = true;
}
if (!rv)
try
{
co.Open();
try
{
co.Open();
isLocal = true;
conStr = localConstr;
rv = true;
}
catch
{
co = null; co.Dispose();
}
}
catch
{
co = null; co.Dispose();
}
if (rv && !leaveOpen) co?.Close();
return rv;
}
static void init()
static public void first()
{
var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(Properties.Settings.Default.eDosConnectionString);
if (string.IsNullOrEmpty(cb.Password))
{
var f = new AskPwd();
f.ShowDialog();
string pwd = f.ResponseText;
string cfg = System.IO.Path.Combine(Environment.CurrentDirectory, System.AppDomain.CurrentDomain.FriendlyName);
Config.ToggleConfigEncryption(cfg, pwd);
System.Windows.Application.Current.Shutdown();
}
}
static public void init()
{
first();
serverConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.eDosConnectionString"].ConnectionString;
var cb = new System.Data.SqlClient.SqlConnectionStringBuilder(serverConstr);
cb.ConnectTimeout = 5;
serverTestConstr = cb.ConnectionString;
localConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.eDosConnectionString"].ConnectionString;
localConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.eDosConnectionString"].ConnectionString; //Start met remote
checkCon(false);
MakeCommands();
}
static void switchLocal()
{
if (!isLocal)
@ -107,57 +126,56 @@ namespace eDosStation
{
checkCon(true);
return Connection;
}
}
static void MakeCommands ()
static void MakeCommands()
{
VisitInitCommand = new System.Data.SqlClient.SqlCommand("VisitInit", Connection);
VisitInitCommand.CommandType = System.Data.CommandType.StoredProcedure;
var VisitExitCommand.Parameters["ID_Station", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["PersID", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["ID_Task", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["Inst_CODE", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["EPD_InternalID", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["isBG", SqlDbType.Bit, 4); VisitInitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["EPDVisitID", SqlDbType.Int, 4); pa.Direction = ParameterDirection.Output; VisitInitCommand.Parameters.Add(pa);
var pa = new System.Data.SqlClient.SqlParameter("ID_Station", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("PersID", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("ID_Task", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("Inst_CODE", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("EPD_InternalID", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("isBG", SqlDbType.Bit, 4); VisitInitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("EPDVisitID", SqlDbType.Int, 4); pa.Direction = ParameterDirection.Output; VisitInitCommand.Parameters.Add(pa);
VisitExitCommand = new SqlCommand("VisitExit", Connection);
VisitExitCommand.CommandType = CommandType.StoredProcedure;
VisitExitCommand.Parameters["EPDVisitID", SqlDbType.Int, 4); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["HP07", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["HP10", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("EPDVisitID", SqlDbType.Int, 4); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("HP07", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("HP10", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["Hp07Total", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["Hp10Total", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("Hp07Total", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("Hp10Total", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["Hp07Peak", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["Hp10Peak", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["HP07PeakTime", SqlDbType.DateTime); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["HP10PeakTime", SqlDbType.DateTime); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["K1", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["K2", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["K3", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["K4", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["K5", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["K6", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["SG", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["BC", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["FB", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["HG", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("Hp07Peak", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("Hp10Peak", SqlDbType.Float); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("HP07PeakTime", SqlDbType.DateTime); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("HP10PeakTime", SqlDbType.DateTime); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("K1", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("K2", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("K3", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("K4", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("K5", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("K6", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("SG", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("BC", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("FB", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("HG", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["QualityData", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("QualityData", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["D1", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["D2", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["D3", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["D4", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("D1", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("D2", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("D3", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("D4", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["alarmStatus", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["otherAlarms", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["errorStatus", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
VisitExitCommand.Parameters["operatingStatus", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("alarmStatus", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("otherAlarms", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("errorStatus", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
pa = new System.Data.SqlClient.SqlParameter("operatingStatus", SqlDbType.Int); VisitExitCommand.Parameters.Add(pa);
}
@ -209,7 +227,7 @@ namespace eDosStation
Connection.Close();
}
static public void FillComment(DataSet1.CommentOnEventDataTable dtCOE)
static public void FillComment()
{
if (dtCOE == null) dtCOE = new DataSet1.CommentOnEventDataTable();
using (var dt = new DataSet1TableAdapters.CommentOnEventTableAdapter())
@ -217,9 +235,70 @@ namespace eDosStation
dt.Connection.ConnectionString = conStr;
dt.Fill(dtCOE);
}
}
}
static public DataSet1.CommentOnEventRow GetCommentOnEventRow(int id)
{
return dtCOE.FindByID_CommnentOnEvent(id);
}
static public void FillTaskInfo(User _User, DataSet1 dataSet1)
{
using (var dataSet1GetTaskInfoTableAdapter = new eDosStation.DataSet1TableAdapters.GetTaskInfoTableAdapter())
{
dataSet1GetTaskInfoTableAdapter.Connection.ConnectionString = conStr;
dataSet1GetTaskInfoTableAdapter.Fill(dataSet1.GetTaskInfo, null, _User.Margin);
}
}
static public User GetUser(string CSN, string Code)
{
User u = new User();
object[] Values = null;
using (var cmd = new SqlCommand("GetPersonInfo", Connection))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("csn", CSN);
if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code);
checkCon(true);
var rs = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow);
if (rs.HasRows && rs.Read())
{
Values = new object[rs.FieldCount];
int rv = rs.GetValues(Values);
u.PersID = (int)Values[rs.GetOrdinal("PersID")];
u.LastName = Values[rs.GetOrdinal("LastName")].ToString();
u.FirstName = Values[rs.GetOrdinal("FirstName")].ToString();
u.conCode = Values[rs.GetOrdinal("conCode")].ToString();
u.Language = Values[rs.GetOrdinal("Language")].ToString();
u.AccessAllow = Values[rs.GetOrdinal("AccessAllow")] as bool?;
u.Margin = Values[rs.GetOrdinal("AccessAllow")] as double?;
u.VisitIDLocked = Values[rs.GetOrdinal("VisitIDLocked")] as int?;
u.ReasonNoAccess = Values[rs.GetOrdinal("ReasonNoAccess")].ToString().Replace("\\n", "\n");
u.UserComment = Values[rs.GetOrdinal("Comment")].ToString();
u.AllOk = (u.AccessAllow == true && u.VisitIDLocked == 0);
}
else
{
// Not found
u.PersID = 0;
u.LastName = "Not Found";
u.FirstName = "Not Found";
u.conCode = "A1";
u.Language = "N";
u.AccessAllow = false;
u.Margin = 0;
u.VisitIDLocked = 0;
u.ReasonNoAccess = "Not found";
u.UserComment = "";
u.AllOk = (u.AccessAllow == true & u.VisitIDLocked == 0);
}
}
return u;
}
}
}

View file

@ -69,6 +69,7 @@ namespace eDosStation
else
{
bool ok = true;
LocalRemote.init();
try
{
thisStation = new Station(string.Empty);

View file

@ -25,61 +25,10 @@ namespace eDosStation
public int Error = 0;
public string ErrorMessage;
public User(string CSN, string Code)
public User()
{
LastName = FirstName = conCode = Language = string.Empty;
AccessAllow = null; ;
using (var co = new SqlConnection(Properties.Settings.Default.eDosConnectionString))
{
using (var cmd = new SqlCommand("GetPersonInfo", co))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("csn", CSN);
if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code);
co.Open();
try
{
var rs = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow);
if (rs.HasRows && rs.Read())
{
object[] Values = new object[rs.FieldCount];
int rv = rs.GetValues(Values);
PersID = (int)Values[rs.GetOrdinal("PersID")];
LastName = Values[rs.GetOrdinal("LastName")].ToString();
FirstName = Values[rs.GetOrdinal("FirstName")].ToString();
conCode = Values[rs.GetOrdinal("conCode")].ToString();
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 int?;
ReasonNoAccess = Values[rs.GetOrdinal("ReasonNoAccess")].ToString().Replace("\\n","\n");
UserComment = Values[rs.GetOrdinal("Comment")].ToString();
AllOk = (AccessAllow == true && VisitIDLocked == 0 );
} else
{
// Not found
PersID = 0;
LastName = "Not Found";
FirstName = "Not Found";
conCode = "A1";
Language = "N";
AccessAllow = false;
Margin = 0;
VisitIDLocked = 0;
ReasonNoAccess = "Not found";
UserComment = "";
AllOk = (AccessAllow == true & VisitIDLocked == 0);
}
rs.Close();
}
catch (System.Exception ex)
{
Error = 1;
ErrorMessage = ex.Message;
}
co.Close();
}
}
AccessAllow = null;
}
}
}