private LogBase _buildKVP(string key, string value, string prop_name, string comments) { DictionaryLog _result = new DictionaryLog(); _result.Name = prop_name; _result.Message = comments ?? string.Empty; _result.Key = key; _result.Value = value; _result.TimeStamp = DateTime.UtcNow; _result.MessageType = MessageType.property; return(_result); }
public async Task GetAllUserSecretsAsync(HttpContext Context) { try { SqlConnection.Open(); SqlCommand command = new SqlCommand() { Connection = SqlConnection, CommandType = CommandType.StoredProcedure, CommandText = "[Store].[ReturnAllUserSecrets]" }; if (Context.Request.Query.TryGetValue("StoreUsername", out var StoreUsername)) { command.Parameters.AddWithValue("@StoreUsername", StoreUsername.ToString()); } SqlDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false); if (reader.HasRows) { ResultTable.Load(reader); } await reader.CloseAsync().ConfigureAwait(false); await reader.DisposeAsync().ConfigureAwait(false); await command.DisposeAsync().ConfigureAwait(false); await SqlConnection.CloseAsync().ConfigureAwait(false); } catch (Exception exception) { if (SqlConnection.State.Equals("Open")) { SqlConnection.Close(); } DictionaryLog.Add("Exception", exception.HResult); DictionaryLog.Add("Exception Message", exception.Message); } }
public async Task DeleteStoreSecretAsync(EntryTypes EntryType, HttpContext Context) { try { SqlConnection.Open(); SqlCommand command = new SqlCommand() { Connection = SqlConnection, CommandType = CommandType.StoredProcedure, CommandText = "[Store].[DeleteStoreSecret]" }; command.Parameters.AddWithValue("@EntryType", EntryType.GetHashCode()); command.Parameters.AddRange(QueryParameters(Context)); SqlDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false); if (reader.HasRows) { ResultTable.Load(reader); } await reader.CloseAsync().ConfigureAwait(false); await reader.DisposeAsync().ConfigureAwait(false); await command.DisposeAsync().ConfigureAwait(false); await SqlConnection.CloseAsync().ConfigureAwait(false); } catch (Exception exception) { if (SqlConnection.State.Equals("Open")) { await SqlConnection.CloseAsync(); } DictionaryLog.Add("Exception", exception.HResult); DictionaryLog.Add("Exception Message", exception.Message); } }
public override object convert(LogBase data, bool is_sub = false) { StringBuilder sbuilder = new StringBuilder(); if (is_sub) { sbuilder.AppendLine("#####*****---- BEGIN SUB LOG ----*****#####"); } else { sbuilder.AppendLine("---- BEGIN LOG ----"); } //Get timestamp sbuilder.AppendLine(nameof(data.TimeStamp) + " : " + data.TimeStamp.ToString(timeformat)); //Get PropertyName if (!string.IsNullOrEmpty(data.Name)) { sbuilder.AppendLine(nameof(data.Name) + " : " + data.Name); } //Get the main message if present if (!string.IsNullOrEmpty(data.Message)) { sbuilder.AppendLine(nameof(data.Message) + " : " + data.Message); } //Get the Info Type sbuilder.AppendLine(nameof(data.MessageType) + " : " + data.MessageType.ToString()); //Get Further Data if it is exception type if (data.GetType() == typeof(ExceptionLog)) { ExceptionLog _excplog = (ExceptionLog)data; if (!string.IsNullOrEmpty(_excplog.ExceptionMessage)) { sbuilder.AppendLine(nameof(_excplog.ExceptionMessage) + " : " + _excplog.ExceptionMessage); } if (!string.IsNullOrEmpty(_excplog.Trace)) { sbuilder.AppendLine(nameof(_excplog.Trace) + " : " + _excplog.Trace); } } //Get data if it is property type if (data.GetType() == typeof(DictionaryLog)) { DictionaryLog _dicLog = (DictionaryLog)data; if (!string.IsNullOrEmpty(_dicLog.Key)) { sbuilder.AppendLine(nameof(_dicLog.Key) + " : " + _dicLog.Key); } if (!string.IsNullOrEmpty(_dicLog.Value)) { sbuilder.AppendLine(nameof(_dicLog.Value) + " : " + _dicLog.Value); } } if (is_sub) { sbuilder.AppendLine("#####*****---- END SUB LOG ----*****#####"); } else { sbuilder.AppendLine("---- END LOG ----"); } return(sbuilder.ToString()); }