Local/Remote
This commit is contained in:
parent
43ab98dfe4
commit
6adcf2798f
11 changed files with 404 additions and 394 deletions
|
|
@ -72,6 +72,7 @@ int OkReadBadge::BadgeUnmanaged::read()
|
|||
//const wchar_t *devicePath0 = L"\\\\?\\hid#vid_076b&pid_5128&mi_00#7&1ddf3054&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
|
||||
int rv = 0;
|
||||
//const wchar_t *devicePath1 = L"\\\\?\\hid#vid_076b&pid_5428&mi_00#7&95573f7&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
|
||||
if (DevicePath == nullptr) return 0;
|
||||
HANDLE HIDfile = CreateFile(DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL| FILE_FLAG_OVERLAPPED, nullptr); //FILE_FLAG_OVERLAPPED|
|
||||
DWORD err = GetLastError();
|
||||
completed = false;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace OkReadBadge
|
|||
|
||||
public:
|
||||
// TODO: Add your methods for this class here.
|
||||
wchar_t * DevicePath;
|
||||
wchar_t * DevicePath = nullptr;
|
||||
int DeviceType;
|
||||
BYTE buffer[100];
|
||||
DWORD bread;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
connectionString="Data Source=scksrv23;Initial Catalog=master;Integrated Security=True"
|
||||
providerName="System.Data.SqlClient" />
|
||||
<add name="eDosStation.Properties.Settings.eDosConnectionString"
|
||||
connectionString="Data Source=HPHDB;Initial Catalog=eDos;User ID=eDosStation;Password=Infopla+8"
|
||||
connectionString="Data Source=HPHDB;Initial Catalog=eDosx;User ID=eDosStation;Password=Infopla+8"
|
||||
providerName="System.Data.SqlClient" />
|
||||
<add name="eDosStation.Properties.Settings.localConnectionString"
|
||||
connectionString="Data Source=HPHDB;Initial Catalog=eDosLocal;User ID=eDosStation;Password=Infopla+8" />
|
||||
|
|
|
|||
620
eDosStation/DataSet1.Designer.cs
generated
620
eDosStation/DataSet1.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,11 +4,11 @@
|
|||
Changes to this file may cause incorrect behavior and will be lost if
|
||||
the code is regenerated.
|
||||
</autogenerated>-->
|
||||
<DiagramLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ex:showrelationlabel="False" ViewPortX="0" ViewPortY="18" xmlns:ex="urn:schemas-microsoft-com:xml-msdatasource-layout-extended" xmlns="urn:schemas-microsoft-com:xml-msdatasource-layout">
|
||||
<DiagramLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ex:showrelationlabel="False" ViewPortX="0" ViewPortY="45" xmlns:ex="urn:schemas-microsoft-com:xml-msdatasource-layout-extended" xmlns="urn:schemas-microsoft-com:xml-msdatasource-layout">
|
||||
<Shapes>
|
||||
<Shape ID="DesignTable:GetTaskInfo" ZOrder="3" X="784" Y="129" Height="305" Width="269" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="254" />
|
||||
<Shape ID="DesignTable:GetTaskList" ZOrder="2" X="407" Y="240" Height="191" Width="211" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="140" />
|
||||
<Shape ID="DesignTable:CommentOnEvent" ZOrder="1" X="630" Y="497" Height="210" Width="285" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="159" />
|
||||
<Shape ID="DesignTable:GetTaskInfo" ZOrder="3" X="285" Y="59" Height="305" Width="269" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="254" />
|
||||
<Shape ID="DesignTable:GetTaskList" ZOrder="2" X="58" Y="55" Height="191" Width="211" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="140" />
|
||||
<Shape ID="DesignTable:CommentOnEvent" ZOrder="1" X="592" Y="61" Height="210" Width="285" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="159" />
|
||||
</Shapes>
|
||||
<Connectors />
|
||||
</DiagramLayout>
|
||||
|
|
@ -126,12 +126,14 @@ namespace eDosStation
|
|||
}
|
||||
private void DoEPD()
|
||||
{
|
||||
if (LoadDoses())
|
||||
int? StationVisitID = null;
|
||||
int? ID_Visit= LocalRemote.NextID();
|
||||
if (ID_Visit.HasValue && LoadDoses())
|
||||
{
|
||||
bool isBG = (ep.epdType != 3); //3 = zwarte 0=grijs
|
||||
int? StationVisitID = null;
|
||||
var co = LocalRemote.getCon();
|
||||
var co = LocalRemote.getCon(true);
|
||||
LocalRemote.VisitInitCommand.Parameters["ID_Station"].Value = thisStation.ID_Station;
|
||||
LocalRemote.VisitInitCommand.Parameters["ID_Visit"].Value = ID_Visit;
|
||||
LocalRemote.VisitInitCommand.Parameters["PersID"].Value = _User.PersID;
|
||||
LocalRemote.VisitInitCommand.Parameters["ID_Task"].Value = CurTaskRow.ID_Task;
|
||||
LocalRemote.VisitInitCommand.Parameters["Inst_CODE"].Value = CurTaskRow.Inst_CODE;
|
||||
|
|
@ -140,7 +142,6 @@ namespace eDosStation
|
|||
LocalRemote.VisitInitCommand.ExecuteNonQuery();
|
||||
StationVisitID = (int?)LocalRemote.VisitInitCommand.Parameters["EPDVisitID"].Value;
|
||||
co.Close();
|
||||
|
||||
int rv = ep.PrepareForIssue();
|
||||
if (rv != 1)
|
||||
{
|
||||
|
|
@ -165,20 +166,6 @@ namespace eDosStation
|
|||
{
|
||||
ep.K3 = ep.K4 = kx.Value;
|
||||
|
||||
//ep.K1 = 903;
|
||||
//ep.K2 = 613;
|
||||
//ep.K3 = 90;
|
||||
//ep.K4 = 90;
|
||||
//ep.K5 = 13100;
|
||||
//ep.K6 = 1310;
|
||||
|
||||
//ep.K1 = 857;
|
||||
//ep.K2 = 595;
|
||||
//ep.K3 = 100;
|
||||
//ep.K4 = 100;
|
||||
//ep.K5 = 13100;
|
||||
//ep.K6 = 1310;
|
||||
|
||||
if (!isBG)
|
||||
{
|
||||
if (ep.K6 != 1310)
|
||||
|
|
@ -302,7 +289,6 @@ namespace eDosStation
|
|||
tbUser.IsSelected = true;
|
||||
if (_User == null || _User.VisitIDLocked >0 || _User.AccessAllow == false)
|
||||
{
|
||||
//tbNotAllowed.IsSelected = true;
|
||||
if (_User.VisitIDLocked > 0|| _User.AccessAllow == false)
|
||||
ReasonNoAccess = _User.ReasonNoAccess;
|
||||
else ReasonNoAccess = getCommentOnEvent(string.Empty, 3);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Data.SqlClient;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace eDosStation
|
||||
{
|
||||
|
|
@ -14,47 +15,61 @@ namespace eDosStation
|
|||
static public string serverConstr;
|
||||
static public string serverTestConstr;
|
||||
static public string localConstr;
|
||||
static public string conStr;
|
||||
static public string currentConStr;
|
||||
static public System.Data.SqlClient.SqlConnection Connection;
|
||||
static public System.Data.SqlClient.SqlConnection SequenceConnection;
|
||||
static public System.Data.SqlClient.SqlCommand VisitInitCommand;
|
||||
public static SqlCommand VisitExitCommand;
|
||||
public static SqlCommand NextIDCommand;
|
||||
|
||||
static public DataSet1.CommentOnEventDataTable dtCOE;
|
||||
|
||||
|
||||
public static int? NextID()
|
||||
{
|
||||
int? nxtValue = null;
|
||||
if (NextIDCommand.Connection.State == ConnectionState.Closed) NextIDCommand.Connection.Open();
|
||||
nxtValue = NextIDCommand.ExecuteScalar() as int?;
|
||||
return nxtValue;
|
||||
}
|
||||
static public bool checkCon(bool leaveOpen = false)
|
||||
{
|
||||
if (Connection != null && Connection.State == System.Data.ConnectionState.Open) return true;
|
||||
|
||||
bool rv = false;
|
||||
var co = new System.Data.SqlClient.SqlConnection(serverTestConstr);
|
||||
var cs = new System.Data.SqlClient.SqlConnectionStringBuilder(serverTestConstr);
|
||||
#if DEBUG
|
||||
cs.ConnectTimeout = 10;
|
||||
#endif
|
||||
Connection = new System.Data.SqlClient.SqlConnection(cs.ConnectionString);
|
||||
try
|
||||
{
|
||||
co.Open();
|
||||
Connection.Open();
|
||||
isLocal = false;
|
||||
}
|
||||
catch { }
|
||||
if (co.State != System.Data.ConnectionState.Open)
|
||||
if (Connection.State != System.Data.ConnectionState.Open)
|
||||
{
|
||||
switchLocal();
|
||||
co.ConnectionString = localConstr;
|
||||
switchLocal(); //wijzigt currentConStr
|
||||
}
|
||||
else
|
||||
{
|
||||
isLocal = false;
|
||||
conStr = serverConstr;
|
||||
currentConStr = serverConstr;
|
||||
rv = true;
|
||||
}
|
||||
if (!rv)
|
||||
try
|
||||
{
|
||||
co.Open();
|
||||
isLocal = true;
|
||||
conStr = localConstr;
|
||||
Connection.ConnectionString = currentConStr;
|
||||
Connection.Open();
|
||||
rv = true;
|
||||
}
|
||||
catch
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
co = null; co.Dispose();
|
||||
Connection.Dispose();
|
||||
Connection = null;
|
||||
}
|
||||
if (rv && !leaveOpen) co?.Close();
|
||||
if (rv && !leaveOpen) Connection?.Close();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
@ -75,12 +90,16 @@ namespace eDosStation
|
|||
static public void init()
|
||||
{
|
||||
first();
|
||||
|
||||
localConstr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.localConnectionString"].ConnectionString;
|
||||
SequenceConnection = new SqlConnection(localConstr);
|
||||
NextIDCommand = new SqlCommand("SELECT NEXT VALUE FOR VisitSequence as VisitID", SequenceConnection);
|
||||
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; //Start met remote
|
||||
checkCon(false);
|
||||
|
||||
MakeCommands();
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +108,7 @@ namespace eDosStation
|
|||
if (!isLocal)
|
||||
{
|
||||
isLocal = true;
|
||||
conStr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.localConnectionString"].ConnectionString;
|
||||
currentConStr = localConstr;
|
||||
}
|
||||
}
|
||||
static void switchServer()
|
||||
|
|
@ -97,34 +116,34 @@ namespace eDosStation
|
|||
if (isLocal)
|
||||
{
|
||||
isLocal = false;
|
||||
conStr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.eDosConnectionString"].ConnectionString;
|
||||
currentConStr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosStation.Properties.Settings.eDosConnectionString"].ConnectionString;
|
||||
}
|
||||
}
|
||||
|
||||
static DataSet1TableAdapters.GetTaskInfoTableAdapter TaskInfoTa()
|
||||
{
|
||||
var ta = new DataSet1TableAdapters.GetTaskInfoTableAdapter();
|
||||
ta.Connection.ConnectionString = conStr;
|
||||
ta.Connection.ConnectionString = currentConStr;
|
||||
return ta;
|
||||
}
|
||||
|
||||
static DataSet1TableAdapters.GetTaskListTableAdapter TaskListTA()
|
||||
{
|
||||
var ta = new DataSet1TableAdapters.GetTaskListTableAdapter();
|
||||
ta.Connection.ConnectionString = conStr;
|
||||
ta.Connection.ConnectionString = currentConStr;
|
||||
return ta;
|
||||
}
|
||||
|
||||
static DataSet1TableAdapters.CommentOnEventTableAdapter CommentTA()
|
||||
{
|
||||
var ta = new DataSet1TableAdapters.CommentOnEventTableAdapter();
|
||||
ta.Connection.ConnectionString = conStr;
|
||||
ta.Connection.ConnectionString = currentConStr;
|
||||
return ta;
|
||||
}
|
||||
|
||||
static public System.Data.SqlClient.SqlConnection getCon()
|
||||
static public System.Data.SqlClient.SqlConnection getCon(bool LeaveOpen)
|
||||
{
|
||||
checkCon(true);
|
||||
checkCon(LeaveOpen);
|
||||
return Connection;
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +153,7 @@ namespace eDosStation
|
|||
VisitInitCommand = new System.Data.SqlClient.SqlCommand("VisitInit", Connection);
|
||||
VisitInitCommand.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
var pa = new System.Data.SqlClient.SqlParameter("ID_Station", SqlDbType.Int, 4); VisitInitCommand.Parameters.Add(pa);
|
||||
pa = new System.Data.SqlClient.SqlParameter("ID_Visit", SqlDbType.Int, 4); pa.Direction = ParameterDirection.Input; 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);
|
||||
|
|
@ -232,7 +252,7 @@ namespace eDosStation
|
|||
if (dtCOE == null) dtCOE = new DataSet1.CommentOnEventDataTable();
|
||||
using (var dt = new DataSet1TableAdapters.CommentOnEventTableAdapter())
|
||||
{
|
||||
dt.Connection.ConnectionString = conStr;
|
||||
dt.Connection.ConnectionString = currentConStr;
|
||||
dt.Fill(dtCOE);
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +268,7 @@ namespace eDosStation
|
|||
{
|
||||
using (var dataSet1GetTaskInfoTableAdapter = new eDosStation.DataSet1TableAdapters.GetTaskInfoTableAdapter())
|
||||
{
|
||||
dataSet1GetTaskInfoTableAdapter.Connection.ConnectionString = conStr;
|
||||
dataSet1GetTaskInfoTableAdapter.Connection.ConnectionString = currentConStr;
|
||||
dataSet1GetTaskInfoTableAdapter.Fill(dataSet1.GetTaskInfo, null, _User.Margin);
|
||||
}
|
||||
}
|
||||
|
|
@ -263,6 +283,7 @@ namespace eDosStation
|
|||
cmd.Parameters.AddWithValue("csn", CSN);
|
||||
if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code);
|
||||
checkCon(true);
|
||||
cmd.Connection = Connection;
|
||||
var rs = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow);
|
||||
if (rs.HasRows && rs.Read())
|
||||
{
|
||||
|
|
@ -279,6 +300,7 @@ namespace eDosStation
|
|||
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);
|
||||
rs.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -295,6 +317,7 @@ namespace eDosStation
|
|||
u.UserComment = "";
|
||||
u.AllOk = (u.AccessAllow == true & u.VisitIDLocked == 0);
|
||||
}
|
||||
|
||||
}
|
||||
return u;
|
||||
}
|
||||
|
|
|
|||
4
eDosStation/Properties/Settings.Designer.cs
generated
4
eDosStation/Properties/Settings.Designer.cs
generated
|
|
@ -12,7 +12,7 @@ namespace eDosStation.Properties {
|
|||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
|
@ -120,7 +120,7 @@ namespace eDosStation.Properties {
|
|||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=HPHDB;Initial Catalog=eDos;User ID=eDosStation;Password=Infopla+8")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=HPHDB;Initial Catalog=eDosx;User ID=eDosStation;Password=Infopla+8")]
|
||||
public string eDosConnectionString {
|
||||
get {
|
||||
return ((string)(this["eDosConnectionString"]));
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
<Setting Name="eDosConnectionString" Type="(Connection string)" Scope="Application">
|
||||
<DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<ConnectionString>Data Source=HPHDB;Initial Catalog=eDos;User ID=eDosStation;Password=Infopla+8</ConnectionString>
|
||||
<ConnectionString>Data Source=HPHDB;Initial Catalog=eDosx;User ID=eDosStation;Password=Infopla+8</ConnectionString>
|
||||
<ProviderName>System.Data.SqlClient</ProviderName>
|
||||
</SerializableConnectionString></DesignTimeValue>
|
||||
<Value Profile="(Default)">Data Source=HPHDB;Initial Catalog=eDos;User ID=eDosStation;Password=Infopla+8</Value>
|
||||
<Value Profile="(Default)">Data Source=HPHDB;Initial Catalog=eDosx;User ID=eDosStation;Password=Infopla+8</Value>
|
||||
</Setting>
|
||||
<Setting Name="localConnectionString" Type="(Connection string)" Scope="Application">
|
||||
<DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
|
|
|
|||
|
|
@ -41,9 +41,8 @@ namespace eDosStation
|
|||
tbComments.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
|
||||
tbComments.TextAlignment = System.Windows.TextAlignment.Center;
|
||||
|
||||
using (var co = new SqlConnection(Properties.Settings.Default.eDosConnectionString))
|
||||
using (var co = LocalRemote.getCon(true))
|
||||
{
|
||||
co.Open();
|
||||
using (var cmd = new SqlCommand("StationSettingsSelect", co))
|
||||
{
|
||||
cmd.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
|
|
@ -61,7 +60,8 @@ namespace eDosStation
|
|||
Inst_Name1 = Values[rs.GetOrdinal("Inst_Name1")].ToString();
|
||||
Inst_Name2 = Values[rs.GetOrdinal("Inst_Name2")].ToString();
|
||||
TestCSN = Values[rs.GetOrdinal("TestCSN")].ToString();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
ID_Station = 0;
|
||||
ComPort = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue