optimalisaties
This commit is contained in:
parent
fb28ccefad
commit
eaf1732fca
14 changed files with 219 additions and 134 deletions
|
|
@ -637,7 +637,6 @@ void Epd3Base::Epd3U::encodeTreshold(Mk3AlarmThresholds_t* th)
|
|||
th->Thresholds[3].Id = (uint16_t)ThresholdId::Thres_RateWarning;
|
||||
th->Thresholds[3].Value = *pTHRateWarning;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HG, SG, BC, FB, BC, FB
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ UINT32 UnixTimeNow() {
|
|||
return FileTime_to_POSIX(ft);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filetime is 100nS since 1601 01 01 UTC Unix = seconds since 1970
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <param name="pft"></param>
|
||||
void TimeFunctions::UnixTimeToFileTime(time_t t, LPFILETIME pft)
|
||||
{
|
||||
ULONG64 ll = ((ULONG64)t * (ULONG64)10000000) + (ULONG64)116444736000000000;
|
||||
|
|
@ -42,35 +47,43 @@ void TimeFunctions::UnixTimeToFileTime(time_t t, LPFILETIME pft)
|
|||
FileTimeToSystemTime(&ft, pst);
|
||||
}
|
||||
|
||||
|
||||
void TimeFunctions::EpdTimeToFileTime(INT32 t, LPFILETIME pft, bool isMK2) //MK3
|
||||
|
||||
/// <summary>
|
||||
/// converts MK2/MK3 time to FileTime
|
||||
/// </summary>
|
||||
/// <param name="epdTime">UTC</param>
|
||||
/// <param name="pft">UTC</param>
|
||||
/// <param name="isMK2"></param>
|
||||
void TimeFunctions::EpdTimeToFileTime(UINT32 epdTime, LPFILETIME epdFileTime, bool isMK2) //MK3
|
||||
{
|
||||
ULONG64 ll = (ULONG64)t * (ULONG64)10000000;
|
||||
ULONG64 ll = (ULONG64)epdTime * (ULONG64)10000000;
|
||||
if (isMK2) ll += (ULONG64) 116444736000000000; else ll += (ULONG64)125911584000000000; // 2000 base - 1601-1-1 (FT) Base
|
||||
pft->dwLowDateTime = (DWORD)(ll & 0xffffffff);
|
||||
pft->dwHighDateTime = ll >> 32;
|
||||
epdFileTime->dwLowDateTime = (DWORD)(ll & 0xffffffff);
|
||||
epdFileTime->dwHighDateTime = ll >> 32;
|
||||
}
|
||||
|
||||
void TimeFunctions::FileTimeToEpdTime(FILETIME pft, INT32* t, bool isMK2)
|
||||
{
|
||||
LONGLONG offset;
|
||||
if (isMK2) offset = 116444736000000000; else offset = 125911584000000000;
|
||||
ULONG64 offset;
|
||||
if (isMK2) offset = (ULONG64)116444736000000000; else offset = (ULONG64)125911584000000000;
|
||||
LONGLONG ll = ((((LONGLONG)pft.dwHighDateTime << 32) + pft.dwLowDateTime) - offset) / 10000000;
|
||||
*t = (DWORD)ll;
|
||||
}
|
||||
|
||||
UINT32 TimeFunctions::NowToEpdTime(bool isMK2)
|
||||
{
|
||||
LONGLONG offset;
|
||||
if (isMK2) offset = 116444736000000000; else offset = 125911584000000000;
|
||||
ULONG64 offset;
|
||||
if (isMK2) offset = (ULONG64)116444736000000000; else offset = (ULONG64)125911584000000000;
|
||||
SYSTEMTIME t;
|
||||
GetSystemTime(&t);
|
||||
GetSystemTime(&t); // is UTC !!
|
||||
FILETIME ft;
|
||||
SystemTimeToFileTime((const SYSTEMTIME*)&t, &ft);
|
||||
LONGLONG ll = ((((LONGLONG)ft.dwHighDateTime << 32U) + ft.dwLowDateTime) - offset) / 10000000;
|
||||
return (DWORD)ll;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TimeFunctions::EPD2PeakTimeToFiletime(DWORD EpdClock, DWORD EpdPeakTime, FILETIME* PeakFileTime) {
|
||||
if (EpdPeakTime != 0xCDCDCDCD) {
|
||||
UINT32 tm = EpdClock - EpdPeakTime;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public:
|
|||
|
||||
|
||||
TimeFunctions();
|
||||
static void EpdTimeToFileTime(INT32 t, LPFILETIME pft, bool isMK2);
|
||||
static void EpdTimeToFileTime(UINT32 epdTime, LPFILETIME epdFileTime, bool isMK2);
|
||||
void FileTimeToEpdTime(FILETIME pft, INT32* t, bool isMK2);
|
||||
static UINT32 NowToEpdTime(bool isMK2);
|
||||
static void UnixTimeToFileTime(time_t t, LPFILETIME pft);
|
||||
|
|
|
|||
|
|
@ -8,17 +8,18 @@ GO
|
|||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
|
||||
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosBatteryWarning BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose07Warning BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose07Alarm BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate07Warning BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate07Alarm BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose10Warning BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose10Alarm BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate10Warning BIT;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate10Alarm BIT;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM sys.columns WHERE OBJECT_ID=OBJECT_ID('dbo.visit') AND name='eDosBatteryWarning')
|
||||
begin
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosBatteryWarning BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose07Warning BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose07Alarm BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate07Warning BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate07Alarm BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose10Warning BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosDose10Alarm BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate10Warning BIT null;
|
||||
ALTER TABLE [dbo].[Visit] ADD eDosRate10Alarm BIT null;
|
||||
END
|
||||
GO
|
||||
|
||||
ALTER PROCEDURE [dbo].[VisitExit]
|
||||
|
|
|
|||
|
|
@ -282,9 +282,17 @@ namespace eDosStation
|
|||
});
|
||||
}
|
||||
|
||||
public void SetBoolParam(SqlCommand c , string pa, bool value)
|
||||
public bool SetBoolParam(SqlCommand c, string pa, bool value)
|
||||
{
|
||||
if (c.Parameters.Contains(pa))c.Parameters[pa].Value = value;
|
||||
bool found = true;
|
||||
if (c.Parameters.Contains(pa)) c.Parameters[pa].Value = value;
|
||||
else
|
||||
{
|
||||
if (pa[0] != '@') pa = "@" + pa; else pa = pa.Substring(1);
|
||||
if (c.Parameters.Contains(pa)) c.Parameters[pa].Value = value;
|
||||
else found = false;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public void VisitExit(int EpdVisitID, EpdBaseClr.Epd2 ep)
|
||||
|
|
@ -337,7 +345,6 @@ namespace eDosStation
|
|||
else
|
||||
VisitExitCommand.Parameters["PersID"].Value = DBNull.Value;
|
||||
|
||||
|
||||
SetBoolParam(VisitExitCommand,"eDosBatteryWarning",ep.eDosBatteryWarning);
|
||||
SetBoolParam(VisitExitCommand, "eDosDose07Warning", ep.eDosDose07Warning);
|
||||
SetBoolParam(VisitExitCommand, "eDosDose07Alarm", ep.eDosDose07Alarm);
|
||||
|
|
@ -385,20 +392,17 @@ namespace eDosStation
|
|||
}
|
||||
}
|
||||
|
||||
public User GetUser( string CSN, string Code)
|
||||
public User GetUser( string CSN, string Code, bool isEntry)
|
||||
{
|
||||
User u = new User();
|
||||
//object[] Values = null;
|
||||
try
|
||||
{
|
||||
using (var cmd = new SqlCommand("GetPersonInfo", localConnection))
|
||||
using (var cmd = new SqlCommand("GetPersonInfo", localConnection) { CommandType = System.Data.CommandType.StoredProcedure } )
|
||||
{
|
||||
cmd.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
if (int.TryParse(Code, out int PersID)) cmd.Parameters.AddWithValue("PersID", PersID);
|
||||
if (!string.IsNullOrEmpty(CSN)) cmd.Parameters.AddWithValue("csn", CSN);
|
||||
else cmd.Parameters.AddWithValue("csn", DBNull.Value);
|
||||
|
||||
//if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code);
|
||||
checkCon(true);
|
||||
var rs = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow);
|
||||
using (var tb = new DataTable())
|
||||
|
|
@ -421,15 +425,14 @@ namespace eDosStation
|
|||
u.VisitIDLocked = dr["VisitIDLocked"] as int?;
|
||||
u.ReasonNoAccess = dr["ReasonNoAccess"].ToString().Replace("\\n", "\n");
|
||||
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";
|
||||
|
||||
if (isEntry && tb.Columns.Contains("hasEPD"))
|
||||
{
|
||||
u.hasEPD = (bool)dr["hasEPD"];
|
||||
if (u.hasEPD) u.ReasonNoAccess = "You have an EPD in use"; //!!! not for return !!!!
|
||||
}
|
||||
else u.hasEPD = false;
|
||||
u.activeVisit = dr["activeVisit"] as int?;
|
||||
|
||||
|
||||
u.AllOk = ( !CheckUser || (u.AccessAllow == true && u.VisitIDLocked == 0));
|
||||
}
|
||||
else
|
||||
|
|
@ -444,7 +447,8 @@ namespace eDosStation
|
|||
u.Margin = 0;
|
||||
u.VisitIDLocked = 0;
|
||||
u.ReasonNoAccess = "Not found";
|
||||
u.UserComment = "";
|
||||
u.UserComment = string.Empty;
|
||||
u.hasEPD = false;
|
||||
u.AllOk = !CheckUser || (u.AccessAllow == true && u.VisitIDLocked == 0);
|
||||
}
|
||||
rs.Close();
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ namespace eDosStation
|
|||
}
|
||||
void CheckBadge()
|
||||
{
|
||||
_User = dataInterface.GetUser(CSN.Text, Code.Text);
|
||||
_User = dataInterface.GetUser(CSN.Text, Code.Text,true);
|
||||
#if DEBUG
|
||||
//_User.UserComment = "Hallo";
|
||||
#endif
|
||||
|
|
@ -643,9 +643,9 @@ namespace eDosStation
|
|||
Button b = sender as Button;
|
||||
string id = b.Tag.ToString().ToUpper();
|
||||
if (id[0]=='P')
|
||||
_User = dataInterface.GetUser(null, id.Substring(1));
|
||||
_User = dataInterface.GetUser(null, id.Substring(1),true);
|
||||
else
|
||||
_User = dataInterface.GetUser("TP" + b.Tag.ToString().ToUpper(), string.Empty);
|
||||
_User = dataInterface.GetUser("TP" + b.Tag.ToString().ToUpper(), string.Empty,true);
|
||||
Dispatcher.InvokeAsync(() => { ShowUserInfo(); });
|
||||
dfReader?.WaitEnd();
|
||||
|
||||
|
|
|
|||
|
|
@ -101,13 +101,13 @@ namespace eDosStation
|
|||
return;
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
|
||||
if (int.TryParse(ep.WearerID, out EpdVisitID) && EpdVisitID % 100 != thisStation.ID_Station)
|
||||
{
|
||||
endWithMessage($"This EPD was issued on another station (ID:{EpdVisitID % 100})");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//bool NoTimeout = false;
|
||||
|
||||
|
|
@ -181,8 +181,8 @@ namespace eDosStation
|
|||
MessageBox.Show($"{ex.Message}");
|
||||
ep = null;
|
||||
}
|
||||
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries, thisStation.OnlyMK2), DispatcherPriority.Background);
|
||||
if (ep!=null)
|
||||
Dispatcher.InvokeAsync(() => ep.Wait(thisStation.EPDTimeOut, thisStation.EPDRetries, thisStation.OnlyMK2), DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void BCloseExit_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -51,5 +51,5 @@ using System.Windows;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.5.14.0")]
|
||||
[assembly: AssemblyFileVersion("2.5.14.0")]
|
||||
[assembly: AssemblyVersion("2.6.0.1")]
|
||||
[assembly: AssemblyFileVersion("2.6.0.1")]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
xmlns:local="clr-namespace:eDosStation"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
mc:Ignorable="d"
|
||||
Title="Settings" Height="464.627" Width="617.009"
|
||||
Title="Settings" Height="448.033" Width="702.744"
|
||||
FontFamily="Segoe UI" FontSize="20"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid >
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace eDosStation
|
|||
{
|
||||
try
|
||||
{
|
||||
thisUser = thisStation.dataInterface.GetUser(string.Empty, sPersID);
|
||||
thisUser = thisStation.dataInterface.GetUser(string.Empty, sPersID,false);
|
||||
epdUserMargin.Text = thisUser.Margin.ToString();
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
|
|
@ -90,77 +90,96 @@ namespace eDosStation
|
|||
int rv = rs.GetValues(Values);
|
||||
ID_Station = (int)Values[rs.GetOrdinal("ID_Station")];
|
||||
ComPort = (int)Values[rs.GetOrdinal("ComPort")];
|
||||
int c = rs.GetOrdinal("Inst_CODE1");
|
||||
if (rs.IsDBNull(c)) Inst_CODE1 = 0; else Inst_CODE1 = (int)Values[c];
|
||||
c = rs.GetOrdinal("Inst_CODE2");
|
||||
if (rs.IsDBNull(c)) Inst_CODE2 = 0; else Inst_CODE2 = (int)Values[c];
|
||||
c = rs.GetOrdinal("Inst_Name1");
|
||||
if (rs.IsDBNull(c)) Inst_Name1=string.Empty; else Inst_Name1 = Values[c].ToString();
|
||||
c = rs.GetOrdinal("Inst_Name2");
|
||||
if (rs.IsDBNull(c)) Inst_Name2 = string.Empty; else Inst_Name2 = Values[c].ToString();
|
||||
c = rs.GetOrdinal("TestCSN");
|
||||
if (rs.IsDBNull(c)) TestCSN = string.Empty; else TestCSN = Values[c].ToString();
|
||||
c = rs.GetOrdinal("Reader");
|
||||
if (rs.IsDBNull(c)) Reader = string.Empty; else Reader = Values[c].ToString();
|
||||
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("useTestButtons");
|
||||
if (rs.IsDBNull(c)) useTestButtons = false; else useTestButtons = (bool)Values[c];
|
||||
}
|
||||
catch { useTestButtons = false; }
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("useBeep");
|
||||
if (rs.IsDBNull(c)) useBeep = 0b00010110; else useBeep = (byte)Values[c];
|
||||
}
|
||||
catch { useBeep = 0b00010110; }
|
||||
Inst_CODE1 = rs.IntOrDefault("Inst_CODE1", 0);
|
||||
//int c = rs.GetOrdinal("Inst_CODE1");
|
||||
//if (rs.IsDBNull(c)) Inst_CODE1 = 0; else Inst_CODE1 = (int)Values[c];
|
||||
Inst_CODE2 = rs.IntOrDefault("Inst_CODE2", 0);
|
||||
//c = rs.GetOrdinal("Inst_CODE2");
|
||||
//if (rs.IsDBNull(c)) Inst_CODE2 = 0; else Inst_CODE2 = (int)Values[c];
|
||||
Inst_Name1 = rs.StringOrDefault("Inst_Name1", string.Empty);
|
||||
//c = rs.GetOrdinal("Inst_Name1");
|
||||
//if (rs.IsDBNull(c)) Inst_Name1=string.Empty; else Inst_Name1 = Values[c].ToString();
|
||||
Inst_Name2 = rs.StringOrDefault("Inst_Name2", string.Empty);
|
||||
//c = rs.GetOrdinal("Inst_Name2");
|
||||
//if (rs.IsDBNull(c)) Inst_Name2 = string.Empty; else Inst_Name2 = Values[c].ToString();
|
||||
TestCSN = rs.StringOrDefault("TestCSN", string.Empty);
|
||||
//c = rs.GetOrdinal("TestCSN");
|
||||
//if (rs.IsDBNull(c)) TestCSN = string.Empty; else TestCSN = Values[c].ToString();
|
||||
Reader = rs.StringOrDefault("Reader", string.Empty);
|
||||
//c = rs.GetOrdinal("Reader");
|
||||
//if (rs.IsDBNull(c)) Reader = string.Empty; else Reader = Values[c].ToString();
|
||||
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("doLog");
|
||||
if (rs.IsDBNull(c)) doLog = false; else doLog = (bool)Values[c];
|
||||
}
|
||||
catch { useBeep = 0b00010110; }
|
||||
useTestButtons = rs.BoolOrDefault("useTestButtons", false);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("useTestButtons");
|
||||
// if (rs.IsDBNull(c)) useTestButtons = false; else useTestButtons = (bool)Values[c];
|
||||
//}
|
||||
//catch { useTestButtons = false; }
|
||||
useBeep = rs.ByteOrDefault("useBeep", 0b00010110);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("useBeep");
|
||||
// if (rs.IsDBNull(c)) useBeep = 0b00010110; else useBeep = (byte)Values[c];
|
||||
//}
|
||||
//catch { useBeep = 0b00010110; }
|
||||
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("checkUser");
|
||||
if (rs.IsDBNull(c)) checkUser = false; else checkUser= (bool)Values[c];
|
||||
}
|
||||
catch { checkUser=false; }
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("EPDTimeout");
|
||||
if (rs.IsDBNull(c)) EPDTimeOut = 10000; else EPDTimeOut= (int)Values[c];
|
||||
}
|
||||
catch { EPDTimeOut= 10000; }
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("EPDRetries");
|
||||
if (rs.IsDBNull(c)) EPDRetries = 2; else EPDRetries = (int)Values[c];
|
||||
}
|
||||
catch { EPDRetries = 2; }
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("RestartCom");
|
||||
if (rs.IsDBNull(c)) RestartCom= false; else RestartCom = (bool)Values[c];
|
||||
}
|
||||
catch { EPDRetries = 2; }
|
||||
doLog = rs.BoolOrDefault("doLog", false);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("doLog");
|
||||
// if (rs.IsDBNull(c)) doLog = false; else doLog = (bool)Values[c];
|
||||
//}
|
||||
//catch { doLog = false; }
|
||||
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("RestartComFirst");
|
||||
if (rs.IsDBNull(c)) RestartComFirst = false; else RestartComFirst = (bool)Values[c];
|
||||
}
|
||||
catch { RestartComFirst = false; }
|
||||
checkUser = rs.BoolOrDefault("checkUser", false);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("checkUser");
|
||||
// if (rs.IsDBNull(c)) checkUser = false; else checkUser= (bool)Values[c];
|
||||
//}
|
||||
//catch { checkUser=false; }
|
||||
|
||||
try
|
||||
{
|
||||
c = rs.GetOrdinal("OnlyMK2");
|
||||
if (rs.IsDBNull(c)) OnlyMK2 = false; else OnlyMK2= (bool)Values[c];
|
||||
}
|
||||
catch { OnlyMK2 = false; }
|
||||
EPDTimeOut = rs.IntOrDefault("EPDTimeout", 10000);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("EPDTimeout");
|
||||
// if (rs.IsDBNull(c)) EPDTimeOut = 10000; else EPDTimeOut= (int)Values[c];
|
||||
//}
|
||||
//catch { EPDTimeOut= 10000; }
|
||||
|
||||
EPDRetries = rs.IntOrDefault("EPDRetries", 2);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("EPDRetries");
|
||||
// if (rs.IsDBNull(c)) EPDRetries = 2; else EPDRetries = (int)Values[c];
|
||||
//}
|
||||
//catch { EPDRetries = 2; }
|
||||
|
||||
RestartCom = rs.BoolOrDefault("RestartCom", false);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("RestartCom");
|
||||
// if (rs.IsDBNull(c)) RestartCom= false; else RestartCom = (bool)Values[c];
|
||||
//}
|
||||
//catch { EPDRetries = 2; }
|
||||
|
||||
RestartComFirst = rs.BoolOrDefault("RestartComFirst", false);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("RestartComFirst");
|
||||
// if (rs.IsDBNull(c)) RestartComFirst = false; else RestartComFirst = (bool)Values[c];
|
||||
//}
|
||||
//catch { RestartComFirst = false; }
|
||||
|
||||
OnlyMK2 = rs.BoolOrDefault("OnlyMK2", false);
|
||||
//try
|
||||
//{
|
||||
// c = rs.GetOrdinal("OnlyMK2");
|
||||
// if (rs.IsDBNull(c)) OnlyMK2 = false; else OnlyMK2= (bool)Values[c];
|
||||
//}
|
||||
//catch { OnlyMK2 = false; }
|
||||
|
||||
}
|
||||
else
|
||||
|
|
@ -259,6 +278,7 @@ namespace eDosStation
|
|||
cmd.SetIfExists("RestartCom", RestartCom);
|
||||
cmd.SetIfExists("RestartComFirst", RestartComFirst);
|
||||
cmd.SetIfExists("OnlyMK2", OnlyMK2);
|
||||
cmd.SetIfExists("useTestButtons", useTestButtons);
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
static public class extensions
|
||||
{
|
||||
|
||||
static public bool SetIfExists(this System.Data.SqlClient.SqlCommand cmd, string paramname, object value)
|
||||
{
|
||||
bool rv = true;
|
||||
if (value == null) value = DBNull.Value;
|
||||
string p1 = "@" + paramname;
|
||||
string p1;
|
||||
if (paramname[0] != '@') p1 = "@" + paramname; else {p1 = paramname; paramname = paramname.Substring(1); }
|
||||
if (cmd.Parameters.Contains(p1))
|
||||
cmd.Parameters[p1].Value = value;
|
||||
else if (cmd.Parameters.Contains(paramname))
|
||||
|
|
@ -16,5 +16,52 @@ static public class extensions
|
|||
else rv = false;
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static bool BoolOrDefault( this System.Data.SqlClient.SqlDataReader rs, string colName, bool defaultValue)
|
||||
{
|
||||
bool rv = defaultValue;
|
||||
try
|
||||
{
|
||||
int c = rs.GetOrdinal(colName);
|
||||
if (!rs.IsDBNull(c)) rv = rs.GetBoolean(c);
|
||||
}
|
||||
catch { rv = defaultValue; }
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static byte ByteOrDefault(this System.Data.SqlClient.SqlDataReader rs, string colName, byte defaultValue)
|
||||
{
|
||||
byte rv = defaultValue;
|
||||
try
|
||||
{
|
||||
int c = rs.GetOrdinal(colName);
|
||||
if (!rs.IsDBNull(c)) rv = rs.GetByte(c);
|
||||
}
|
||||
catch { rv = defaultValue; }
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static int IntOrDefault(this System.Data.SqlClient.SqlDataReader rs, string colName, int defaultValue)
|
||||
{
|
||||
int rv = defaultValue;
|
||||
try
|
||||
{
|
||||
int c = rs.GetOrdinal(colName);
|
||||
if (!rs.IsDBNull(c)) rv = rs.GetInt32(c);
|
||||
}
|
||||
catch { rv = defaultValue; }
|
||||
return rv;
|
||||
}
|
||||
public static string StringOrDefault(this System.Data.SqlClient.SqlDataReader rs, string colName, string defaultValue)
|
||||
{
|
||||
string rv = defaultValue;
|
||||
try
|
||||
{
|
||||
int c = rs.GetOrdinal(colName);
|
||||
if (!rs.IsDBNull(c)) rv = rs.GetString(c);
|
||||
}
|
||||
catch { rv = defaultValue; }
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,20 +35,20 @@ namespace syncEdosLocal
|
|||
|
||||
private void MakeCmd(SqlConnection co)
|
||||
{
|
||||
cmd = new SqlCommand("syncLoc.SyncStatusUpdate",co);
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
SqlParameter pa = new SqlParameter("ID_Station", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("TimeStamp", SqlDbType.DateTime, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("New", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("Entries", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("Exits", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("Skipped", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("ErrorMessage", SqlDbType.VarChar, 512); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("ID_Visit_Min", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("ID_Visit_Max", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("Persons", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
pa = new SqlParameter("Tasks", SqlDbType.Int, 4); cmd.Parameters.Add(pa);
|
||||
|
||||
cmd = new System.Data.SqlClient.SqlCommand("[syncLoc].[SyncStatusUpdate]", co) { CommandType = System.Data.CommandType.StoredProcedure };
|
||||
cmd.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
|
||||
new System.Data.SqlClient.SqlParameter("ID_Station",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("TimeStamp",SqlDbType.DateTime,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("New",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("Entries",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("Exits",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("Skipped",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("ErrorMessage",SqlDbType.VarChar,512,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("ID_Visit_Min",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("ID_Visit_Max",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("Persons",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
,new System.Data.SqlClient.SqlParameter("Tasks",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null)
|
||||
});
|
||||
}
|
||||
|
||||
public void Write( )
|
||||
|
|
@ -397,7 +397,6 @@ namespace syncEdosLocal
|
|||
if (cr == null)
|
||||
{
|
||||
Result.VisitsNew++;
|
||||
|
||||
copyrow(lr, ds.CentralVisits);
|
||||
if ((lr.VisitStatus & 1) > 0) { lr.syncedEntry = true; Result.VisitsAddedEntries++;}
|
||||
if ((lr.VisitStatus & 2) > 0) { lr.syncedExit = true; Result.VisitsAddedExits++; }
|
||||
|
|
@ -470,7 +469,8 @@ namespace syncEdosLocal
|
|||
private static DataSet1.CentralVisitsRow copyrow(DataSet1.LocalVisitsRow lr, DataSet1.CentralVisitsDataTable centralVisits)
|
||||
{
|
||||
DataSet1.CentralVisitsRow cr = centralVisits.NewCentralVisitsRow();
|
||||
foreach (DataColumn sc in lr.Table.Columns) cr[sc.ColumnName] = lr[sc.ColumnName];
|
||||
foreach (DataColumn sc in lr.Table.Columns)
|
||||
if (lr.Table.Columns.Contains(sc.ColumnName) ) cr[sc.ColumnName] = lr[sc.ColumnName];
|
||||
centralVisits.AddCentralVisitsRow(cr);
|
||||
return cr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue