public async void GetAllLogsAsync_InsertedBothParameters_ReturnsSpecifiedEntries() { //Arrange var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase($"TechTaskTestDatabase {Guid.NewGuid()}") .Options; using (var context = new AppDbContext(options)) { context.UpdateLogs.Add(new UpdateLog { CreatedAt = DateTime.Now, Name = "Added new User", UpdatedAt = null, Value = "76bbdcdc-dd26-4b6e-b7c8-08d702c8f782" }); context.UpdateLogs.Add(new UpdateLog { CreatedAt = DateTime.Now, Name = "Added new team", UpdatedAt = null, Value = "5" }); context.UpdateLogs.Add(new UpdateLog { CreatedAt = DateTime.Parse("06 jul 19"), Name = "Updated Task", UpdatedAt = DateTime.Now, Value = "12" }); context.UpdateLogs.Add(new UpdateLog { CreatedAt = DateTime.Parse("07 jul 19"), Name = "Removed User from Task", UpdatedAt = DateTime.Now, Value = "12" }); context.SaveChanges(); } using (var context = new AppDbContext(options)) { var dbLogService = new DbLogService(context); //Act var logs = await dbLogService.GetAllLogsAsync(new DbLogQueryParameters { Name = "new", CreatedAt = "08" }); //Assert logs.Count().Should().Be(2); } }
public JobMigrateConnectDb(DbLogService logger, ConnectDbContext connectDb) { _connectDb = connectDb; _logger = logger; _logger.Category = "Jobs"; _logger.ResourceId = _jobName; }
public JobCountUsers(SecurityPoolManager poolManager, DbLogService logger) { _poolManager = poolManager; _logger = logger; _logger.Category = "Jobs"; _logger.ResourceId = "JobCountUsers"; }
public static void timer_Elapsed(object sender, ElapsedEventArgs e) { Console.WriteLine("### [ClearLog]:Timer Stopped ### \n"); timer.Stop(); Console.WriteLine("### Clearing ChatLogs... ### \n\n"); DbLogService.ResetLog(); Console.WriteLine("### [ClearLog]:Task Finished ### \n\n"); schedule_Timer(); }
public static IServiceCollection AddLogService(this IServiceCollection services) { return(services.AddSingleton <ILogger, DbLogService>(x => { var logStore = x.GetService <ITableStorageRepository <MessageLogEntity> >(); var mapper = x.GetService <ILogLevelMapper>(); var dbLogger = new DbLogService(logStore, mapper, "CasualEsportsAmateurLeague LLC."); return dbLogger; })); }
public NotificationProcessor(DbLogService logger, ConnectCoreOptions connectCoreOptions, IHostingEnvironment env) { _options = connectCoreOptions; _env = env; _logger = logger; _logger.Category = "Jobs"; _logger.ResourceId = nameof(NotificationProcessor); }
public void Configuration(IAppBuilder app) { app.MapSignalR(); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Login") }); DbLogService.ResetLog(); // For testing purposes, comment it if you want to clear messages using timer ResetLogsSheduler.schedule_Timer(); }
public async void LogOnUpdateOfEntity_UpdateTask_ShouldReturnUpdatedTaskLog() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase($"TechTaskTestDatabase {Guid.NewGuid()}") .Options; using (var context = new AppDbContext(options)) { var taskToAdd = new Tasks { AdminApprovalOfTaskCompletion = 0, Balance = 0, Description = "Test", Name = "Test name", EstimatedTimeToFinishInHours = 3, Id = 11, Status = 0, TaskPriorityId = 2, TotalHoursOfWork = 0 }; context.Tasks.Add(taskToAdd); await context.SaveChangesAsync(); var dbLog = new DbLogService(context); await dbLog.LogOnCreationOfEntityAsync(taskToAdd); var dto = new TaskForUpdateDto { AdminApprovalOfTaskCompletion = 0, Balance = 0, Description = "Test", Name = "Test name", EstimatedTimeToFinishInHours = 3, Status = 0, TaskPriorityId = 2 }; dbLog.LogOnUpdateOfAnEntity(taskToAdd); await context.SaveChangesAsync(); } using (var context = new AppDbContext(options)) { var logFromDb = await context.UpdateLogs .SingleAsync(u => u.Name == "Updated Task"); logFromDb.Value.Should().Be(("11").ToLowerInvariant()); } }
public async void LogOnUpdateOfEntity_UpdateUser_ShouldReturnUpdatedUserLog() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase($"TechTaskTestDatabase {Guid.NewGuid()}") .Options; using (var context = new AppDbContext(options)) { var userToAdd = new User { Id = Guid.Parse("F808DF8A-3BAA-4BD8-83CA-E03E6FCE0B20"), Email = "*****@*****.**", FirstName = "John", LastName = "Smith", DateOfBirth = DateTime.Parse("03 jun 87"), Password = "******", Role = Roles.User, TeamId = 1 }; context.Users.Add(userToAdd); await context.SaveChangesAsync(); var dbLog = new DbLogService(context); await dbLog.LogOnCreationOfEntityAsync(userToAdd); var userDto = new UserForUpdateDto { Role = Roles.Admin, TeamId = 2 }; userToAdd.Role = userDto.Role ?? userToAdd.Role; userToAdd.TeamId = userDto.TeamId; dbLog.LogOnUpdateOfAnEntity(userToAdd); await context.SaveChangesAsync(); } using (var context = new AppDbContext(options)) { var logFromDb = await context.UpdateLogs .SingleAsync(u => u.Name == "Updated User"); logFromDb.Value.Should().Be(("F808DF8A-3BAA-4BD8-83CA-E03E6FCE0B20").ToLowerInvariant()); } }
public DocumentPickerController( IFolderManager <FileDocument> folderManager, IDocumentService <FileDocument> documentService, IOptions <DriveOptions> driveOptions, TagManager tagManager, DbLoggerProvider log, DbLogService logFetcher, ILogger <DocumentPickerController> logger) : base() { _folderManager = folderManager; _documentService = documentService; _driveOptions = driveOptions.Value; _tagManager = tagManager; _log = log; _logFetcher = logFetcher; _logger = logger; }
public async void LogOnDeleteEntity_RemoveUserFromTask_ShouldReturnLogForTask() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase($"TechTaskTestDatabase {Guid.NewGuid()}") .Options; using (var context = new AppDbContext(options)) { var taskToAdd = new Tasks { AdminApprovalOfTaskCompletion = 0, Balance = 0, Description = "Test", Name = "Test name", EstimatedTimeToFinishInHours = 3, Id = 11, Status = 0, TaskPriorityId = 2, TotalHoursOfWork = 0, UserId = Guid.NewGuid() }; context.Tasks.Add(taskToAdd); await context.SaveChangesAsync(); var dbLog = new DbLogService(context); await dbLog.LogOnCreationOfEntityAsync(taskToAdd); taskToAdd.UserId = null; dbLog.LogOnEntityDelete(taskToAdd); await context.SaveChangesAsync(); } using (var context = new AppDbContext(options)) { var logFromDb = await context.UpdateLogs .SingleAsync(u => u.Name == "Removed User from Task"); logFromDb.Value.Should().Be("11"); } }
public async void LogOnUpdateOfEntity_UpdateComment_ShouldReturnUpdatedCommentLog() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase($"TechTaskTestDatabase {Guid.NewGuid()}") .Options; using (var context = new AppDbContext(options)) { var commentToAdd = new Comment { Id = 3, Description = "Description", TasksId = 3, UserId = Guid.NewGuid() }; context.Comments.Add(commentToAdd); await context.SaveChangesAsync(); var dbLog = new DbLogService(context); await dbLog.LogOnCreationOfEntityAsync(commentToAdd); var dto = new CommentForUpdateDto { Description = "New description" }; dbLog.LogOnUpdateOfAnEntity(commentToAdd); await context.SaveChangesAsync(); } using (var context = new AppDbContext(options)) { var logFromDb = await context.UpdateLogs .SingleAsync(u => u.Name == "Updated Comment"); logFromDb.Value.Should().Be(("3").ToLowerInvariant()); } }
public static async Task <LogSummary> GetLogSummaryAsync(this DbLogService logger, FileDocument document) { Ensure.NotNull(logger, $"{nameof(logger)} cannot be null."); Ensure.NotNull(document, $"{nameof(document)} cannot be null."); var logs = (await logger.GetDocumentEventsAsync(document.DocumentId)) ?? new DbLogEvent[0]; return(new LogSummary() { Created = DateTime.MinValue, Deleted = null, DocumentLog = null, DocumentLogId = null, LastRead = DateTime.MinValue, LastReadOther = DateTime.MinValue, LastReadUserId = null, LastWrite = DateTime.MinValue, ReadCount = 0, ReadCountOther = 0, WriteCount = 0 }); }
public async void GetLogAsync_InsertUnexistingId_ReturnsNull() { var options = new DbContextOptionsBuilder <AppDbContext>() .UseInMemoryDatabase($"TechTaskTestDatabase {Guid.NewGuid()}") .Options; using (var context = new AppDbContext(options)) { context.UpdateLogs.Add(new UpdateLog { Id = 1, CreatedAt = DateTime.Now, Name = "Added new User", UpdatedAt = null, Value = "76bbdcdc-dd26-4b6e-b7c8-08d702c8f782" }); context.UpdateLogs.Add(new UpdateLog { Id = 2, CreatedAt = DateTime.Now, Name = "Added new team", UpdatedAt = null, Value = "5" }); await context.SaveChangesAsync(); } using (var context = new AppDbContext(options)) { var dbLogService = new DbLogService(context); var log = await dbLogService.GetLogAsync(3); log.Should().BeNull(); } }
public LibraryManager( IFolderManager <FileDocument> folderManager, IDocumentService <FileDocument> documentService, IDocumentUploadService <FileDocument> uploadService, IDocumentThumbnailService <FileDocument> thumbnailService, LibraryZipService libraryZipService, DbLoggerProvider log, DbLogService logFetcher, IJobsManager jobsManager, TagManager tagManager, LibraryIOService libraryIOService, IEnumerable <IImagePostProcessor> imageProcessors, IHostingEnvironment env) { Ensure.NotNull(folderManager, $"{nameof(folderManager)} cannot be null."); Ensure.NotNull(documentService, $"{nameof(documentService)} cannot be null."); Ensure.NotNull(libraryIOService, $"{nameof(libraryIOService)} cannot be null."); Ensure.NotNull(uploadService, $"{nameof(uploadService)} cannot be null."); Ensure.NotNull(thumbnailService, $"{nameof(thumbnailService)} cannot be null."); Ensure.NotNull(libraryZipService, $"{nameof(libraryZipService)} cannot be null."); Ensure.NotNull(jobsManager, $"{nameof(jobsManager)} cannot be null."); Ensure.NotNull(log, $"{nameof(log)} cannot be null."); Ensure.NotNull(tagManager, $"{nameof(tagManager)} cannot be null."); _folderManager = folderManager; _documentService = documentService; _libraryIOService = libraryIOService; _uploadService = uploadService; _thumbnailService = thumbnailService; _libraryZipService = libraryZipService; _jobs = jobsManager; _log = log; _tagManager = tagManager; _imageProcessors = imageProcessors; _env = env; }
public SiteTemplateExporter ( ConnectDbContext connectDb, ConnectCoreOptions coreOptions, ContentManager contentManager, WidgetProvider widgetProvider, SiteManager siteManager, SiteTemplateManager templateManager, PageMasterManager masterPageManager, PageManager pageManger, DbLogService logger ) { _connectDb = connectDb; _coreOptions = coreOptions; _contentManager = contentManager; _siteManager = siteManager; _widgetProvider = widgetProvider; _templateManager = templateManager; _masterPageManager = masterPageManager; _pageManager = pageManger; _logger = logger; _exportRootFolder = Path.Combine(_coreOptions.FileSystemRoot, _coreOptions.TemplateExportPath.Replace("/", @"\")); _masterPageMap = new Dictionary <string, SiteTemplateMasterPage>(); _pageMap = new Dictionary <string, SiteTemplatePage>(); _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver(), ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, }; }
public void Send(string name, string message, string time) { Clients.All.broadcastMessage(name, message, time); DbLogService.LogData(name, message, time); }
public ManageController() { logService = new DbLogService(); }
public CorpJobsDataController(IJobsManager jobs, DbLogService logger, DbLogContext db) { _jobs = jobs; _logger = logger; _db = db; }
public UserRegistrationsController() { logService = new DbLogService(); db = new ApplicationDbContext(); }
public static async Task <IEnumerable <DbLogEvent> > GetDocumentEventsAsync(this DbLogService logger, string documentId) { return(await logger.GetEventsByResource(documentId)); }
public AccountController() { this.db = new ApplicationDbContext(); this.logService = new DbLogService(); }