public bool Insert(ApplicationLogEntity entity) { string query = @"INSERT INTO ApplicationLog (CategoryTypeId, MethodName, LogData) VALUES (@CategoryTypeId, @MethodName, @LogData);"; IConfigurationUtility utility = IocFactory.Resolve <IConfigurationUtility>(); using (DatabaseConnector databaseConnector = new DatabaseConnector(utility.DatabaseConnection)) { return(databaseConnector.ExecuteNonQuery(query, entity) > 0); } }
public bool Save(string methodName, string logData, CategoryType categoryType) { IApplicationLogRepository repository = IocFactory.Resolve <IApplicationLogRepository>(); ApplicationLogEntity entity = new ApplicationLogEntity(); entity.CategoryTypeId = (short)categoryType; entity.LogData = logData; entity.MethodName = methodName; return(repository.Insert(entity)); }
public void CreateFromLogEntryTest() { ApplicationLogEntity entity = ApplicationLogEntityManager.CreateFromLogEntry(new LogEntry { ApplicationName = "myApplication", TimeStamp = new DateTime(2015, 3, 2, 0, 0, 0), Message = "This is a log message" }, null); Assert.AreEqual("myApplication_201503", entity.PartitionKey); Assert.AreNotEqual(Guid.Empty.ToString(), entity.RowKey); Assert.AreEqual("This is a log message", entity.Message); }