public void Audit_log_checks_provider_type_audit_is_as_expected(int currentOrganisationTypeId, int newOrganisationTypeId, int currentProviderTypeId, int newProviderType, int currentOrganisationStatus, string currentStartDate, int numberOfFieldsChanged, bool providerTypeAudit, bool organisationTypeAudit, bool organisationStatusAudit, bool startDateAudit) { var startDate = DateTime.MinValue; if (currentStartDate == "yesterday") { startDate = DateTime.Today.AddDays(-1); } if (currentStartDate == "today") { startDate = DateTime.Today; } _organisationRepository.Setup(x => x.GetOrganisationType(It.IsAny <Guid>())).ReturnsAsync(currentOrganisationTypeId); _organisationRepository.Setup(x => x.GetProviderType(It.IsAny <Guid>())).ReturnsAsync(currentProviderTypeId); _organisationRepository.Setup(x => x.GetOrganisationStatus(It.IsAny <Guid>())).ReturnsAsync(currentOrganisationStatus); _organisationRepository.Setup(x => x.GetStartDate(It.IsAny <Guid>())).ReturnsAsync(startDate); var auditLogService = new AuditLogService(_settings, _organisationRepository.Object, _lookupDataRepository.Object, new OrganisationStatusManager()); var auditData = auditLogService.AuditProviderType(Guid.NewGuid(), "system", newProviderType, newOrganisationTypeId); Assert.AreEqual(numberOfFieldsChanged, auditData.FieldChanges.Count); Assert.AreEqual(providerTypeAudit, auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.ProviderType)); Assert.AreEqual(organisationTypeAudit, auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.OrganisationType)); Assert.AreEqual(organisationStatusAudit, auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.OrganisationStatus)); Assert.AreEqual(startDateAudit, auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.StartDate)); }
public BureauController(OrganizationService organizationService, AuditLogService auditLog, IMapper mapper, ILogger <BureauController> logger) { _organizationService = organizationService; _auditLog = auditLog; _mapper = mapper; _logger = logger; }
public FailureReportController(IConfiguration configuration) { failurereportRepo = new FailureReportRepo(configuration); _configuration = configuration; fileUploadService = new FileUploadService(configuration); auditLogService = new AuditLogService(HttpContext, configuration); }
public JobController(IConfiguration configuration) { _configuration = configuration; scheduleRepo = new ScheduleRepo(configuration); jobRepo = new JobRepo(configuration); auditLogService = new AuditLogService(HttpContext, configuration); }
public void Comparison_returns_empty_list_for_identical_organisations() { var comparison = new AuditLogService(_settings, null, null, null); var results = comparison.BuildListOfFieldsChanged(_firstOrganisation, _secondOrganisation).Result.FieldChanges.ToList(); results.Should().BeEmpty(); }
public ClientSiteController(IConfiguration configuration) { clientSiteRepo = new ClientSiteRepo(configuration); fileUploadService = new FileUploadService(configuration); _configuration = configuration; auditLogService = new AuditLogService(HttpContext, configuration); }
public FormController(FormService formService, SystemService systemService, AuditLogService auditLog, ILogger <FormController> logger) { _formService = formService; _systemService = systemService; _auditLog = auditLog; _logger = logger; }
public LogoutModel(SignInManager <IdentityUser> signInManager, ILogger <LogoutModel> logger, IConfiguration configuration) { _configuration = configuration; auditLogService = new AuditLogService(HttpContext, configuration); _signInManager = signInManager; _logger = logger; }
public void Audit_log_checks_ukprn_audit_is_as_expected(long currentUkprn, long newUkprn, bool auditChangesMade) { _organisationRepository.Setup(x => x.GetUkprn(It.IsAny <Guid>())).ReturnsAsync(currentUkprn); var auditLogService = new AuditLogService(_settings, _organisationRepository.Object, null, null); var auditData = auditLogService.AuditUkprn(Guid.NewGuid(), "system", newUkprn); Assert.AreEqual(auditChangesMade, auditData.ChangesMade); }
public ReportFeederController(IConfiguration configuration) { _configuration = configuration; jobRepo = new JobRepo(configuration); reportFeederRepo = new ReportFeederRepo(configuration); fileUploadService = new FileUploadService(configuration); auditLogService = new AuditLogService(HttpContext, configuration); }
public void Audit_log_checks_financial_track_record_audit_is_as_expected(bool currentFinancialTrackRecord, bool newFinancialTrackRecord, bool auditChangesMade) { _organisationRepository.Setup(x => x.GetFinancialTrackRecord(It.IsAny <Guid>())).ReturnsAsync(currentFinancialTrackRecord); var auditLogService = new AuditLogService(_settings, _organisationRepository.Object, null, null); var auditData = auditLogService.AuditFinancialTrackRecord(Guid.NewGuid(), "system", newFinancialTrackRecord); Assert.AreEqual(auditChangesMade, auditData.ChangesMade); }
public void Audit_log_checks_organisation_type_audit_is_as_expected(int currentOrganisationTypeId, int newOrganisationTypeId, bool auditChangesMade) { _organisationRepository.Setup(x => x.GetOrganisationType(It.IsAny <Guid>())).ReturnsAsync(currentOrganisationTypeId); var auditLogService = new AuditLogService(_settings, _organisationRepository.Object, _lookupDataRepository.Object, null); var auditData = auditLogService.AuditOrganisationType(Guid.NewGuid(), "system", newOrganisationTypeId); Assert.AreEqual(auditChangesMade, auditData.ChangesMade); }
public void Audit_log_checks_parent_company_guarantee_audit_is_as_expected(bool currentGuarantee, bool newGuarantee, bool auditChangesMade) { _organisationRepository.Setup(x => x.GetParentCompanyGuarantee(It.IsAny <Guid>())).ReturnsAsync(currentGuarantee); var auditLogService = new AuditLogService(_settings, _organisationRepository.Object, null, null); var auditData = auditLogService.AuditParentCompanyGuarantee(Guid.NewGuid(), "system", newGuarantee); Assert.AreEqual(auditChangesMade, auditData.ChangesMade); }
public void Audit_log_checks_trading_name_audit_is_as_expected(string currentName, string newName, bool auditChangesMade) { _organisationRepository.Setup(x => x.GetTradingName(It.IsAny <Guid>())).ReturnsAsync(currentName); var auditLogService = new AuditLogService(_settings, _organisationRepository.Object, null, null); var auditData = auditLogService.AuditTradingName(Guid.NewGuid(), "system", newName); Assert.AreEqual(auditChangesMade, auditData.ChangesMade); }
public SystemController(SystemService systemService, FormService formService, OrganizationService organizationService, AuditLogService auditLog, ILogger <SystemController> logger) { _systemService = systemService; _formService = formService; _organizationService = organizationService; _auditLog = auditLog; _logger = logger; }
public WebApiController(UserService userService, FormService formService, SystemService systemService, OrganizationService organizationService, AuditLogService auditLog) { _userService = userService; _formService = formService; _systemService = systemService; _organizationSevice = organizationService; _auditLog = auditLog; }
public EquipmentController(IConfiguration configuration) { equipmentRepo = new EquipmentRepo(configuration); _configuration = configuration; lookupRepo = new LookupsRepo(configuration); appConfigRepo = new ApplicationConfigurationRepo(configuration); fileUploadService = new FileUploadService(configuration); auditLogService = new AuditLogService(HttpContext, configuration); }
public EmployeeController(UserService userService, SystemService systemSerivce, IADService adService, AuditLogService auditLog, IMapper mapper, ILogger <EmployeeController> logger) { _userService = userService; _systemService = systemSerivce; _adService = adService; _auditLog = auditLog; _mapper = mapper; _logger = logger; }
public SupportUnitController(UserService userService, SystemService systemSerivce, OrganizationService organizationService, AuditLogService auditLog, IMapper mapper, ILogger <SupportUnitController> logger) { _userService = userService; _systemService = systemSerivce; _organizationService = organizationService; _auditLog = auditLog; _mapper = mapper; _logger = logger; }
public UnitController(OrganizationService organizationService, SystemService systemService, TreeViewService treeViewService, AuditLogService auditLog, IMapper mapper, ILogger <UnitController> logger) { _organizationService = organizationService; _systemService = systemService; _treeViewService = treeViewService; _auditLog = auditLog; _mapper = mapper; _logger = logger; }
protected virtual Response DoGet(dynamic parameters) { Guid id = parameters.id; using (var context = new TDataContext()) { var entity = context.Set <TEntity>().Find(id); if (entity == null) { return(this.AsFailedResponse(string.Format(Beesightsoft.Web.Nancy.Infrastructure.Constants.STRING_FORMAT_FOR_NOT_ENTITY_NOT_FOUND, id), HttpStatusCode.NotFound)); } string[] contexts = this.BuildEmbedContext(); var dto = FromEntity(entity, contexts); #region Audit if (Request.Headers["screenName"].ElementAtOrDefault(0) != null) { string tableName = context.GetTableName <TEntity>(); string identityUserID = Context.GetMSOwinUser().Identity.GetUserId(); List <AuditLog> auditLogs = new List <AuditLog>(); List <string> columnNames = AuditLogService.AuditableColumns(tableName); if (columnNames.Count > 0) { AuditLog log = new AuditLog() { Id = Guid.NewGuid(), OperationType = "VIEW", TableName = tableName, PrimaryKey = id.ToString(), FieldName = string.Empty, NewValue = string.Empty, UserID = Guid.Parse(identityUserID), IsDeleted = false, IsLuminX = false, ScreenName = Request.Headers["screenName"].ElementAtOrDefault(0), UserIPAddress = Request.UserHostAddress }; auditLogs.Add(log); } AuditLogService.LogActivityIntoDB(context, auditLogs); context.SaveChanges(); } #endregion return(this.AsSuccessResponse((object)dto)); } }
public ProcessingController(UserService userService, RequestService requestService, SystemService systemService, OrganizationService organizationService, AuditLogService auditLog, IFluentEmail email, EmailHelper emailHelper, ILogger <ProcessingController> logger) { _userService = userService; _requestService = requestService; _systemService = systemService; _organizationService = organizationService; _auditLog = auditLog; _email = email; _emailHelper = emailHelper; _logger = logger; }
public void Comparison_returns_empty_list_if_only_altered_fields_are_in_ignored_list() { var comparison = new AuditLogService(_settings, null, null, null); _secondOrganisation.CreatedAt = DateTime.Now.AddDays(-10); _secondOrganisation.CreatedBy = "Unit test"; _secondOrganisation.UpdatedAt = DateTime.Now; _secondOrganisation.UpdatedBy = "Unit test"; var results = comparison.BuildListOfFieldsChanged(_firstOrganisation, _secondOrganisation).Result.FieldChanges.ToList(); results.Should().BeEmpty(); }
protected virtual void OnAdd(DbContext context, TEntity entity, TAddOrUpdateDto dto) { context.Set <TEntity>().Add(entity); #region Audit string tableName = context.GetTableName <TEntity>(); List <string> columnNames = AuditLogService.AuditableColumns(tableName); if (columnNames.Count > 0) { var dictionary = dto as IDictionary <string, object>; string identityUserID = Context.GetMSOwinUser().Identity.GetUserId(); List <AuditLog> auditLogs = new List <AuditLog>(); List <string> serializableTypeNames = dto.GetType().GetProperties().Where(q => q.PropertyType.BaseType.Name.Contains("EntitySerializable")).Select(data => data.PropertyType.Name).ToList(); foreach (var item in dictionary) { if ((columnNames.Contains(item.Key.ToPascalCase())) && (item.Value != null) && (!string.IsNullOrEmpty(item.Value.ToString()))) { AuditLog log = new AuditLog() { Id = Guid.NewGuid(), OperationType = "CREATE", TableName = tableName, PrimaryKey = entity.Id.ToString(), FieldName = ((item.Value.GetType().BaseType.Name.Contains("EntitySerializable")) ? (item.Key.ToPascalCase() + "Serialized") : item.Key.ToPascalCase()), NewValue = ((item.Value.GetType().BaseType.Name.Contains("EntitySerializable")) ? item.Value.GetType().GetProperty("Serialized").GetValue(item.Value, null).ToString() : item.Value.ToString()), UserID = Guid.Parse(identityUserID), IsDeleted = false, IsLuminX = false, ScreenName = Request.Headers["screenName"].ElementAtOrDefault(0), UserIPAddress = Request.UserHostAddress }; auditLogs.Add(log); } } AuditLogService.LogActivityIntoDB(context, auditLogs); } #endregion context.SaveChanges(); }
private void LogModuleSelected() { App.Current.ModuleCreated += (o, e) => { //日志 var title = e.Window.Title; AuditLogService.LogAsync(new AuditLogItem() { Title = "打开模块:" + title, ModuleName = title, Type = AuditLogType.OpenModule }); }; }
// // GET: /Account/LogOff public ActionResult LogOff() { using (AuditLogService aservice = new AuditLogService()) { aservice.Create(ActivityTypes.Logout, CurrentUser, null, CurrentUser?.Id ?? 0); } FormsAuthentication.SignOut(); this.HttpContext.Cache.Remove(User.Identity.Name); ContextExtensions.RemoveCachedUserData(); return(RedirectToAction("Login")); }
public ReviewController(IADService adService, UserService userService, RequestService requestService, SystemService systemService, OrganizationService organizationService, AuditLogService auditLog, IAuthorizationService authService, IFluentEmail email, EmailHelper emailHelper, ILogger <ReviewController> logger) { _adService = adService; _userService = userService; _requestService = requestService; _systemService = systemService; _organizationService = organizationService; _auditLog = auditLog; _authService = authService; _email = email; _emailHelper = emailHelper; _logger = logger; }
public override void OnActionExecuting(ActionExecutingContext filterContext) { bool checkIsIgnore = filterContext.ActionDescriptor.IsDefined(typeof(AuditLogIgnore), true); if (checkIsIgnore) { return; } string controllerName = string.Empty; string actionName = string.Empty; var sessionId = filterContext.HttpContext.Session.SessionID; var routeData = filterContext.RouteData.Values; if (routeData != null && routeData.Any()) { actionName = routeData["action"].ToString(); controllerName = routeData["controller"].ToString(); } DateTime logTime = filterContext.HttpContext.Timestamp; if (filterContext.HttpContext.User.Identity.IsAuthenticated) { var userData = ((FormsIdentity)filterContext.HttpContext.User.Identity).Ticket?.UserData; var userVMObj = JsonConvert.DeserializeObject <UserVM>(userData); #if DEBUG // debug stuff goes here #else // Log yazdım Task.Run(() => { AuditLogService auditLogService = new AuditLogService(); auditLogService.SaveAuditLog(new AuditLogVM { ActionName = actionName, ControllerName = controllerName, SessionId = sessionId, CreateDateTime = logTime, UserDataJson = userData, LoginName = userVMObj.Name }); }); #endif } base.OnActionExecuting(filterContext); }
public void Comparison_returns_single_field_change_with_display_name_replacement() { var comparison = new AuditLogService(_settings, null, null, null); _secondOrganisation.LegalName = "New Legal Name"; var auditData = comparison.BuildListOfFieldsChanged(_firstOrganisation, _secondOrganisation).Result; var results = auditData.FieldChanges.ToList(); results.Should().HaveCount(1); results[0].FieldChanged.Should().Be("Legal Name"); results[0].PreviousValue.Should().Be("Legal Name"); results[0].NewValue.Should().Be("New Legal Name"); auditData.UpdatedBy.Should().Be("Test"); auditData.OrganisationId.Should().Be(_firstOrganisation.Id); }
public void Comparison_returns_single_field_change() { var comparison = new AuditLogService(_settings, null, null, null); _secondOrganisation.UKPRN = 11112222; var auditData = comparison.BuildListOfFieldsChanged(_firstOrganisation, _secondOrganisation).Result; var results = auditData.FieldChanges.ToList(); results.Should().HaveCount(1); results[0].FieldChanged.Should().Be("UKPRN"); results[0].PreviousValue.Should().Be(_firstOrganisation.UKPRN.ToString()); results[0].NewValue.Should().Be(_secondOrganisation.UKPRN.ToString()); auditData.UpdatedBy.Should().Be("Test"); auditData.OrganisationId.Should().Be(_firstOrganisation.Id); }