From 814e4b32a026aa0a6e1e617c741b83514e2f56b2 Mon Sep 17 00:00:00 2001 From: Luc Vandenbroucke Date: Fri, 15 Apr 2022 16:00:35 +0200 Subject: [PATCH] clean --- eDosStation/DataInterface.cs | 57 ++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/eDosStation/DataInterface.cs b/eDosStation/DataInterface.cs index 0b9134b..c54c85f 100644 --- a/eDosStation/DataInterface.cs +++ b/eDosStation/DataInterface.cs @@ -11,7 +11,7 @@ namespace eDosStation public int ID_Station; public bool isLocal = false; private string currentConStr, ConCentralStr; - public System.IO.StreamWriter stationLog; + public System.IO.StreamWriter stationLog; public SqlConnection localConnection, centralConnection; internal CLog splunkLog; @@ -21,7 +21,7 @@ namespace eDosStation public static SqlCommand LastIDCommand; public static SqlCommand CheckStatus; public DataSet1.CommentOnEventDataTable dtCOE; - private bool CheckUser,AllowMultipleEPD; + private bool CheckUser, AllowMultipleEPD; private SqlCommand ReverseSyncCommand; public static string tnow() @@ -33,7 +33,7 @@ namespace eDosStation int? nxtValue = null; if (NextIDCommand.Connection.State == ConnectionState.Closed) NextIDCommand.Connection.Open(); nxtValue = NextIDCommand.ExecuteScalar() as int?; - return nxtValue; + return nxtValue; } public static int? LastID() { @@ -67,7 +67,7 @@ namespace eDosStation public bool checkConCentral(bool leaveOpen = false) { bool rv = false; - + if (centralConnection != null && centralConnection.State == System.Data.ConnectionState.Open) return true; try { @@ -137,7 +137,8 @@ namespace eDosStation isLocal = true; MakeCommands(); bool rv = checkCon(false); - } catch (Exception ex) + } + catch (Exception ex) { splunkLog?.WriteException(moduleName, taskName, ex); System.Windows.MessageBox.Show($"Init error {ex.Message} con={currentConStr}"); @@ -145,11 +146,11 @@ namespace eDosStation } stationLog?.WriteLine($"Datainterface.Init end {tnow()}"); } - public DataInterface( ) + public DataInterface() { init(); } - + // DataSet1TableAdapters.GetTaskInfoTableAdapter TaskInfoTa() //{ // return new DataSet1TableAdapters.GetTaskInfoTableAdapter(); @@ -169,7 +170,6 @@ namespace eDosStation { this.CheckUser = pCheckUser; } - internal void SetAllowMultipleEPD(bool pAllowMultipleEPD) { this.AllowMultipleEPD = pAllowMultipleEPD; @@ -180,18 +180,16 @@ namespace eDosStation // ta.Connection.ConnectionString = currentConStr; // return ta; //} - public System.Data.SqlClient.SqlConnection getCon(bool LeaveOpen) { - checkCon(LeaveOpen); - return localConnection; + checkCon(LeaveOpen); + return localConnection; } public System.Data.SqlClient.SqlConnection getConCentral(bool LeaveOpen) { checkConCentral(LeaveOpen); return centralConnection; } - void MakeCommands() { LastIDCommand = new SqlCommand("VisitIDLast", localConnection); @@ -201,7 +199,7 @@ namespace eDosStation CheckStatus = new SqlCommand("[syncLoc].[SyncStatusIsOK]", localConnection); CheckStatus.CommandType = CommandType.StoredProcedure; pa = new System.Data.SqlClient.SqlParameter("ID_Station", SqlDbType.Int, 4); CheckStatus.Parameters.Add(pa); - + VisitInitCommand = new System.Data.SqlClient.SqlCommand("[dbo].[VisitInit]", localConnection) { CommandType = System.Data.CommandType.StoredProcedure }; VisitInitCommand.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("PersID",SqlDbType.Int,0,System.Data.ParameterDirection.Input,false,0,0,null,System.Data.DataRowVersion.Default,null) @@ -259,9 +257,7 @@ namespace eDosStation ReverseSyncCommand = new System.Data.SqlClient.SqlCommand("syncLoc.UpdateRemoteReturns", localConnection) { CommandType = System.Data.CommandType.StoredProcedure }; } - - - public void VisitExit(int EpdVisitID, EpdBaseClr.Epd2 ep) + public void VisitExit(int EpdVisitID, EpdBaseClr.Epd2 ep) { const string taskName = "VisitExit"; VisitExitCommand.Parameters["EPDVisitID"].Value = EpdVisitID; @@ -312,7 +308,8 @@ namespace eDosStation else VisitExitCommand.Parameters["PersID"].Value = DBNull.Value; - VisitExitCommand.SetBoolParam("eDosBatteryWarning",ep.eDosBatteryWarning); + //ep.hasAlarm + VisitExitCommand.SetBoolParam("eDosBatteryWarning", ep.eDosBatteryWarning); VisitExitCommand.SetBoolParam("eDosDose07Warning", ep.eDosDose07Warning); VisitExitCommand.SetBoolParam("eDosDose07Alarm", ep.eDosDose07Alarm); VisitExitCommand.SetBoolParam("eDosRate07Warning", ep.eDosRate07Warning); @@ -327,26 +324,26 @@ namespace eDosStation try { VisitExitCommand.ExecuteNonQuery(); - } catch (System.Exception ex) + } + catch (System.Exception ex) { splunkLog?.WriteException(moduleName, taskName, ex); } localConnection.Close(); } - - public void FillComment() + public void FillComment() { - if (dtCOE == null) dtCOE = new DataSet1.CommentOnEventDataTable(); + if (dtCOE == null) dtCOE = new DataSet1.CommentOnEventDataTable(); using (var dt = new DataSet1TableAdapters.CommentOnEventTableAdapter()) { dt.Fill(dtCOE); } } - public DataSet1.CommentOnEventRow GetCommentOnEventRow(int id) + public DataSet1.CommentOnEventRow GetCommentOnEventRow(int id) { return dtCOE.FindByID_CommnentOnEvent(id); } - public void FillTaskInfo(User _User, DataSet1 dataSet1) + public void FillTaskInfo(User _User, DataSet1 dataSet1) { const string taskName = "FillTaskInfo"; try @@ -359,20 +356,20 @@ namespace eDosStation stationLog?.WriteLine($"dataSet1GetTaskInfoTableAdapter Filled {System.DateTime.Now}"); } } - catch (System.Exception ex) { + catch (System.Exception ex) + { splunkLog?.WriteException(moduleName, taskName, ex); if (stationLog != null) stationLog.WriteLine($"{taskName} error {ex.Message} {System.DateTime.Now}"); } } - - public User GetUser( string CSN, string Code, bool isEntry) + public User GetUser(string CSN, string Code, bool isEntry) { const string taskName = "GetUser"; User u = new User(); //object[] Values = null; try { - using (var cmd = new SqlCommand("GetPersonInfo", localConnection) { CommandType = System.Data.CommandType.StoredProcedure } ) + using (var cmd = new SqlCommand("GetPersonInfo", localConnection) { 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); @@ -400,14 +397,14 @@ namespace eDosStation u.ReasonNoAccess = dr["ReasonNoAccess"].ToString().Replace("\\n", "\n"); u.UserComment = dr["Comment"].ToString(); - if (isEntry && tb.Columns.Contains("hasEPD")) + 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)); + u.AllOk = (!CheckUser || (u.AccessAllow == true && u.VisitIDLocked == 0)); } else { @@ -436,8 +433,6 @@ namespace eDosStation } return u; } - - public bool ReverseSync() { const string taskName = "ReverseSync";