public static string GetIndex() { DAL settings = new DAL(); string lastId = BLANK; try { // get file name from config string fileName = settings.INDEX_STORE_FILE_NAME; if (!File.Exists(fileName)) { // make file, set to zero FileStoreUtility.MakeFile(fileName); } // get the last id that was placed inside lastId = File.ReadAllText(fileName); } catch (Exception exception) { string parameters = lastId; Shields_Error_Logger.LogError(exception, "GetIndex()", parameters); return(lastId); } return(lastId); }
public static bool UpdateIndex(string lastId) { DAL settings = new DAL(); try { // get file name from config string fileName = settings.INDEX_STORE_FILE_NAME; // if there is no file make one if (!File.Exists(fileName)) { if (!FileStoreUtility.MakeFile(fileName)) { return(false); } } // write the last id File.WriteAllText(fileName, lastId); } catch (Exception exception) { string parameters = lastId; Shields_Error_Logger.LogError(exception, "UpdateIndex(string lastId)", parameters); return(false); } return(true); }
public static bool AppendLocalWebLog(string message) { DAL settings = new DAL(); try { string fileName = settings.LOCAL_WEB_LOG_FILE_NAME; if (!File.Exists(fileName)) { if (!FileStoreUtility.MakeFile(fileName)) { return(false); } } string output = LOG_TEMPLATE .Replace("[DATE_TIME]", DateTime.Now.ToShortDateString()) .Replace("[MESSAGE]", message) + Convert.ToChar(NEW_LINE); File.AppendAllText(fileName, output); } catch (Exception exception) { string parameters = message; Shields_Error_Logger.LogError(exception, "AppendLocalWebLog(string message)", parameters); return(false); } return(true); }
public static void handleDateOfBirth(Patient patient) { try { patient.dateOfBirth = Convert.ToDateTime(patient.dateOfBirth) .ToShortDateString(); } catch (Exception exception) { string parameters = patient.dateOfBirth; Shields_Error_Logger.LogError(exception, "handleDateOfBirth(Patient patient)", parameters); } }
public static T GetData <T>(IDataRecord reader, string columnName, bool ignoreException = true) { try { return((T)Convert.ChangeType(((reader[columnName] == DBNull.Value) ? default(T) : reader[columnName]), typeof(T))); } catch (Exception e) { if (ignoreException) { return(default(T)); } Shields_Error_Logger.LogError(e, "getData(IDataRecord reader, string columnName)", reader + "|" + columnName); throw e; } }
public static Identity GetLastIdentity() { // set up dal settings DAL settings = new DAL(); // init new identity object Identity identity = new Identity() { lastId = ZERO }; using (SqlConnection connection = new SqlConnection(DALUtility.BuildConnectionString())) { // open connection connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = settings.GET_LAST_PT; command.CommandType = CommandType.StoredProcedure; try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { identity = new Identity(reader, true); } } } catch (Exception exception) { string parameters = identity.lastId.ToString(); Shields_Error_Logger.LogError(exception, "GetAllIdentities(string lastId)", parameters); } } return(identity); }
public static List <Identity> GetAllIdentities() { // init dal settings DAL settings = new DAL(); // make new list of identities List <Identity> identities = new List <Identity>(); using (SqlConnection connection = new SqlConnection(DALUtility.BuildConnectionString())) { // open connection connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = settings.GET_ALL_PATIENTS; command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@LASTID", DBNull.Value); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { identities.Add(new Identity(reader)); } } } catch (Exception exception) { string parameters = "all patients"; Shields_Error_Logger.LogError(exception, "GetAllIdentities(string lastId)", parameters); } } return(identities); }
private static bool MakeFile(string fileName) { try { if (!File.Exists(fileName)) { // make new stream FileStream stream = File.Create(fileName); // force close the stream stream.Close(); // write to file File.WriteAllText(fileName, ZERO); } } catch (Exception exception) { string parameters = fileName; Shields_Error_Logger.LogError(exception, "MakeFile(string fileName)", parameters); return(false); } return(true); }