small stability
This commit is contained in:
parent
df90ac8073
commit
a0b5891dee
5 changed files with 53 additions and 27 deletions
|
|
@ -44,5 +44,6 @@
|
|||
<add key="Reader" value="HID Global OMNIKEY 5022 Smart Card Reader 0" />
|
||||
<add key="TestCSN" value=""/>
|
||||
<add key="TestCode" value=""/>
|
||||
<add key="sqlLogFolder" value="c:\logs"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
|
|
|
|||
|
|
@ -291,12 +291,11 @@ namespace eDosStation
|
|||
{
|
||||
User u = new User();
|
||||
object[] Values = null;
|
||||
if (int.TryParse(Code,out int PersID))
|
||||
using (var cmd = new SqlCommand("GetPersonInfo", localConnection))
|
||||
{
|
||||
cmd.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
cmd.Parameters.AddWithValue("csn", CSN);
|
||||
cmd.Parameters.AddWithValue("PersID", PersID);
|
||||
if (int.TryParse(Code, out int PersID) ) cmd.Parameters.AddWithValue("PersID", PersID);
|
||||
else cmd.Parameters.AddWithValue("csn", CSN);
|
||||
//if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code);
|
||||
checkCon(true);
|
||||
cmd.Connection = localConnection;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<telerik:RadButton Name="LeesCancel" Content="Cancel" Click="LeesCancel_Click" Width="300" Height="50" CornerRadius="10" TextBlock.FontSize="25" Margin="20,20,0,0" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock x:Name="CSN" />
|
||||
<TextBlock x:Name="Site" />
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@ using System.Windows.Threading;
|
|||
|
||||
namespace eDosStation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for EntryBadge.xaml
|
||||
/// </summary>
|
||||
public partial class EntryBadge : Window
|
||||
{
|
||||
const int PageTimeout = 10000;
|
||||
|
||||
bool initialising = true;
|
||||
Station thisStation;
|
||||
EpdBaseClr.Epd2 ep;
|
||||
|
|
@ -51,6 +49,7 @@ namespace eDosStation
|
|||
thisStation = curStation;
|
||||
_User = null;
|
||||
}
|
||||
|
||||
private bool LoadDoses()
|
||||
{
|
||||
bool rv = true;
|
||||
|
|
@ -131,7 +130,14 @@ namespace eDosStation
|
|||
private void DoEPD()
|
||||
{
|
||||
int? StationVisitID = null;
|
||||
int? ID_Visit= DataInterface.NextID();
|
||||
int? ID_Visit = null;
|
||||
try
|
||||
{
|
||||
ID_Visit = DataInterface.NextID();
|
||||
} catch (System.Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Error {ex.Message}");
|
||||
}
|
||||
if (ID_Visit.HasValue && LoadDoses())
|
||||
{
|
||||
bool isBG = (ep.epdType != 3); //3 = zwarte 0=grijs
|
||||
|
|
@ -145,7 +151,7 @@ namespace eDosStation
|
|||
dataInterface.VisitInitCommand.Parameters["EPD_InternalID"].Value = (int)ep.EpdID;
|
||||
dataInterface.VisitInitCommand.Parameters["isBG"].Value = isBG;
|
||||
dataInterface.VisitInitCommand.Parameters["ENTRY_EPD_CLOCK"].Value = ep.CountsClock;
|
||||
|
||||
|
||||
|
||||
using (var l = new SqlLog())
|
||||
try
|
||||
|
|
@ -369,7 +375,7 @@ namespace eDosStation
|
|||
void CheckBadge()
|
||||
{
|
||||
_User = dataInterface.GetUser(CSN.Text, Code.Text);
|
||||
ShowUserInfo(); //AskTask();
|
||||
if (!ShowUserInfo()) endPage();
|
||||
}
|
||||
public void showBadge(int persID, string csn)
|
||||
{
|
||||
|
|
@ -594,6 +600,11 @@ namespace eDosStation
|
|||
|
||||
}
|
||||
|
||||
private void LeesCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
endPage();
|
||||
}
|
||||
|
||||
private void DfReader_BadgeTO(LSWDesfirePublic.CCard Sender, EventArgs e)
|
||||
{
|
||||
this.Dispatcher.Invoke(new Action(() => endPage()));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -8,15 +9,23 @@ namespace eDosStation
|
|||
{
|
||||
public class SqlLog: IDisposable
|
||||
{
|
||||
private string sqlLogFolder;
|
||||
private string sqlLogFile;
|
||||
private bool disposed = false;
|
||||
System.IO.StreamWriter wr;
|
||||
System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.GetCultureInfo("en-US");
|
||||
|
||||
public SqlLog()
|
||||
{
|
||||
wr = null;
|
||||
try
|
||||
{
|
||||
wr = new System.IO.StreamWriter(@"c:\temp\sql.txt", true);
|
||||
sqlLogFolder = ConfigurationManager.AppSettings["sqlLogFolder"];
|
||||
if (System.IO.Directory.Exists(sqlLogFolder))
|
||||
{
|
||||
sqlLogFile = System.IO.Path.Combine(sqlLogFolder, "sql.txt");
|
||||
wr = new System.IO.StreamWriter(sqlLogFile, true);
|
||||
}
|
||||
} catch(System.Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex.Message);
|
||||
|
|
@ -35,7 +44,7 @@ namespace eDosStation
|
|||
if (disposing)
|
||||
{
|
||||
if (wr?.BaseStream != null) wr.Close();
|
||||
wr.Dispose();
|
||||
wr?.Dispose();
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
|
|
@ -47,7 +56,7 @@ namespace eDosStation
|
|||
|
||||
public void LogCommand(string ermsg)
|
||||
{
|
||||
if (wr.BaseStream.CanWrite)
|
||||
if (wr !=null && wr.BaseStream.CanWrite)
|
||||
{
|
||||
wr.WriteLine($"-- {System.DateTime.Now.ToString("yyyy-MM-dd HH:mm")} --- err {ermsg} ---");
|
||||
wr.Flush();
|
||||
|
|
@ -56,26 +65,29 @@ namespace eDosStation
|
|||
|
||||
public void LogCommand(System.Data.SqlClient.SqlCommand co )
|
||||
{
|
||||
wr.WriteLine($"-- {System.DateTime.Now.ToString("yyyy-MM-dd HH:mm")} ---");
|
||||
if (co.CommandType == System.Data.CommandType.StoredProcedure) wr.Write("exec ");
|
||||
wr.Write(co.CommandText);
|
||||
int paidx = 0;
|
||||
foreach (System.Data.SqlClient.SqlParameter pa in co.Parameters)
|
||||
if (wr != null)
|
||||
{
|
||||
if (paidx++ > 0) wr.Write(",");
|
||||
wr.Write($" @{pa.ParameterName}=");
|
||||
if (pa.Value == DBNull.Value) wr.Write("null");
|
||||
else if (pa.DbType == System.Data.DbType.String) wr.Write($"'{pa.Value}'");
|
||||
else if (pa.DbType == System.Data.DbType.DateTime) wr.Write($"'{pa.Value:yyyyMMdd HH:mm}'");
|
||||
else if (pa.DbType == System.Data.DbType.Double)
|
||||
wr.WriteLine($"-- {System.DateTime.Now.ToString("yyyy-MM-dd HH:mm")} ---");
|
||||
if (co.CommandType == System.Data.CommandType.StoredProcedure) wr.Write("exec ");
|
||||
wr.Write(co.CommandText);
|
||||
int paidx = 0;
|
||||
foreach (System.Data.SqlClient.SqlParameter pa in co.Parameters)
|
||||
{
|
||||
wr.Write(((double)pa.Value).ToString("0.0",ci));
|
||||
if (paidx++ > 0) wr.Write(",");
|
||||
wr.Write($" @{pa.ParameterName}=");
|
||||
if (pa.Value == DBNull.Value) wr.Write("null");
|
||||
else if (pa.DbType == System.Data.DbType.String) wr.Write($"'{pa.Value}'");
|
||||
else if (pa.DbType == System.Data.DbType.DateTime) wr.Write($"'{pa.Value:yyyyMMdd HH:mm}'");
|
||||
else if (pa.DbType == System.Data.DbType.Double)
|
||||
{
|
||||
wr.Write(((double)pa.Value).ToString("0.0", ci));
|
||||
}
|
||||
else wr.Write(pa.Value);
|
||||
}
|
||||
else wr.Write(pa.Value);
|
||||
wr.WriteLine();
|
||||
wr.WriteLine("----");
|
||||
wr.Flush();
|
||||
}
|
||||
wr.WriteLine();
|
||||
wr.WriteLine("----");
|
||||
wr.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue