private AuditRecord GetAuditRecord(AuditRecord request) { var id = request?.Id; AuditRecord ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetSelect <AuditRecord>(currentUser, "AuditRecord", request.Select); DocEntityAuditRecord entity = null; if (id.HasValue) { entity = DocEntityAuditRecord.Get(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No AuditRecord found for Id {id.Value}"); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route."); } ret = entity?.ToDto(); return(ret); }
private void load() { string se = Request.QueryString["SerialNumber"].ToString(); DataTable dt = CreateTable(); RPCResult <AuditRecord> r = PretreatmentProxy.GetStatusReportService().GetAuditRecord(Guid.Parse(se)); if (r.Success) { if (r.Value != null) { AuditRecord s = r.Value; DataRow dr = dt.NewRow(); dr["AccountID"] = s.AccountID; dr["SerialNumber"] = s.SerialNumber; dr["Content"] = s.Content; dr["AuditTime"] = s.AuditTime; dr["Result"] = s.Result == true ? "成功" : "失败"; dt.Rows.Add(dr); lbl_message.Visible = false; } } GridView1.DataSource = dt; GridView1.DataBind(); Session["dt"] = dt; }
public async Task PublishAsync(EventMessage message, List <KeyValuePair <string, string> > indexes = null) { AuditRecord record = null; DateTime receiveTime = DateTime.UtcNow; try { record = new MessageAuditRecord(message.MessageId, identity, channelType, protocolType.ToUpperInvariant(), message.Message.Length, MessageDirectionType.In, true, receiveTime); if (indexes == null || indexes.Count == 0) { await GraphManager.PublishAsync(message.ResourceUri, message); } else { await GraphManager.PublishAsync(message.ResourceUri, message, indexes); } } catch (Exception ex) { record = new MessageAuditRecord(message.MessageId, identity, channelType, protocolType.ToUpperInvariant(), message.Message.Length, MessageDirectionType.In, false, receiveTime, ex.Message); } finally { if (message.Audit) { await auditor?.WriteAuditRecordAsync(record); } } }
public override void SaveAuditedEntity(AuditedEntity auditedEntity) { string userName = System.Threading.Thread.CurrentPrincipal.Identity.Name; var audit = new AuditRecord { Action = (byte)auditedEntity.Action, AuditDate = DateTime.Now, EntityTable = auditedEntity.EntityType.Name, EntityTableKey = auditedEntity.EntityKey, AssociationTable = auditedEntity.ParentEntityType.Name, AssociationTableKey = auditedEntity.ParentKey, UserName = userName }; foreach (var modifiedProperty in auditedEntity.ModifiedProperties) { if (modifiedProperty.DisplayName.Trim() != "Date Updated" && modifiedProperty.DisplayName.Trim() != "User Updated Id") { audit.AuditRecordFields.Add( new AuditRecordField { MemberName = modifiedProperty.DisplayName, OldValue = modifiedProperty.OldValue, NewValue = modifiedProperty.NewValue }); } } if (audit.AuditRecordFields.Count > 0) { AuditRecords.InsertOnSubmit(audit); } }
private async Task FaultTask(string id, byte[] payload, string contentType, bool canAudit) { AuditRecord record = null; try { ServiceClientCredentials credentials = new TopicCredentials(topicKey); EventGridClient client = new EventGridClient(credentials); EventGridEvent gridEvent = new EventGridEvent(id, resourceUriString, payload, resourceUriString, DateTime.UtcNow, "1.0"); IList <EventGridEvent> events = new List <EventGridEvent>(new EventGridEvent[] { gridEvent }); await clients[arrayIndex].PublishEventsAsync(topicHostname, events); record = new MessageAuditRecord(id, uri.Query.Length > 0 ? uri.ToString().Replace(uri.Query, "") : uri.ToString(), "EventGrid", "EventGrid", payload.Length, MessageDirectionType.Out, true, DateTime.UtcNow); } catch (Exception ex) { Trace.TraceWarning("Retry EventGrid failed."); Trace.TraceError(ex.Message); record = new MessageAuditRecord(id, uri.Query.Length > 0 ? uri.ToString().Replace(uri.Query, "") : uri.ToString(), "EventGrid", "EventGrid", payload.Length, MessageDirectionType.Out, false, DateTime.UtcNow, ex.Message); } finally { if (canAudit) { await auditor?.WriteAuditRecordAsync(record); } } }
public void SetUp() { record1 = new AuditRecord(); record1.EventType = SecurityEvent.ViewAuditLog; record1.Message = "Message #1"; record1.ProjectName = "Project #1"; record1.SecurityRight = SecurityRight.Allow; record1.TimeOfEvent = DateTime.Today.AddDays(-1); record1.UserName = "******"; record2 = new AuditRecord(); record2.EventType = SecurityEvent.StopProject; record2.Message = "Message #2"; record2.ProjectName = "Project #2"; record2.SecurityRight = SecurityRight.Deny; record2.TimeOfEvent = DateTime.Today.AddDays(1); record2.UserName = "******"; record3 = new AuditRecord(); record3.EventType = SecurityEvent.StopProject; record3.Message = "Message #3"; record3.ProjectName = "Project #2"; record3.SecurityRight = SecurityRight.Deny; record3.TimeOfEvent = DateTime.Today.AddDays(1); record3.UserName = "******"; }
private List <AuditRecord> GetAuditRecords(string entityId, EntityType?entityType) { List <AuditRecord> result = new List <AuditRecord>(); using (var connection = new SqliteConnection("Data Source=Auditor.db")) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = @"SELECT AuditId, ParentAuditId, EntityId, EntityType, TransactionTime, AuditTime, AutoResolved, Record FROM auditRecords WHERE EntityId=$entity AND EntityType=$type ORDER BY TransactionTime ASC"; command.Parameters.AddWithValue("$entity", entityId); command.Parameters.AddWithValue("$type", (int)(entityType ?? EntityType.Generic)); using (var reader = command.ExecuteReader()) { while (reader.Read()) { AuditRecord audit = MapAuditRecord(reader); result.Add(audit); } } } return(result); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Listing = await _context.Listing.FindAsync(id); if (Listing != null) { if (!(Listing.PhotoPath == "default-box.png")) { System.IO.File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Listings", Listing.PhotoPath)); } _context.Listing.Remove(Listing); //await _context.SaveChangesAsync(); // Once a record is deleted, create an audit record if (await _context.SaveChangesAsync() > 0) { var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Delete Listing"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.ListingID = Listing.ID; var userID = User.Identity.Name.ToString(); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); } } return(RedirectToPage("./Index")); }
private AuditRecord GetLatestAuditRecord(string entityId, EntityType?entityType) { AuditRecord result = null; using (var connection = new SqliteConnection("Data Source=Auditor.db")) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = @"SELECT AuditId, ParentAuditId, EntityId, EntityType, TransactionTime, AuditTime, AutoResolved, Record FROM auditRecords WHERE EntityId=$entity AND EntityType=$type ORDER BY TransactionTime DESC LIMIT 1"; command.Parameters.AddWithValue("$entity", entityId); command.Parameters.AddWithValue("$type", entityType ?? EntityType.Generic); using (var reader = command.ExecuteReader()) { if (reader.Read()) { result = MapAuditRecord(reader); } } } if (result != null) { // TODO this is obviously a concurrency issue. If something comes in between the read above and this call we are in trouble result.Record = GetLatestRecord(entityId, entityType); } return(result); }
private static bool CreateAuditFile(string auditFilePath) { try { string auditFileFolder = Path.GetDirectoryName(auditFilePath); if (CreateAuditFileFolder(auditFileFolder)) { string computerName = Environment.GetEnvironmentVariable(nameof(EnvironmentVariables.ComputerName)); AuditRecord auditRecord = GenerateAuditRecord(computerName); WriteAuditRecordToCsv(auditRecord, auditFilePath); } else { Global.ExitApp(3, string.Format("ERROR: Failed to create audit file folder: {0}", auditFilePath)); } if (File.Exists(auditFilePath)) { return(true); } } catch (Exception ex) { Global.ExitApp(6, String.Format("EXCEPTION in {0}: {1}", MethodBase.GetCurrentMethod(), ex.Message)); } return(false); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } ApplicationRole appRole = await _roleManager.FindByIdAsync(ApplicationRole.Id); appRole.Id = ApplicationRole.Id; appRole.Name = ApplicationRole.Name; appRole.Description = ApplicationRole.Description; IdentityResult roleRuslt = await _roleManager.UpdateAsync(appRole); var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Edit Role"; auditrecord.DateTimeStamp = DateTime.Now; var userID = User.Identity.Name.ToString(); auditrecord.Desc = String.Format("User Role called '{0}' was edited by {1}", ApplicationRole.Name, userID); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Movie = await _context.Movie.FindAsync(id); if (Movie != null) { _context.Movie.Remove(Movie); //await _context.SaveChangesAsync(); // Once a record is deleted, create an audit record if (await _context.SaveChangesAsync() > 0) { var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Delete Movie Record"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.KeyMovieFieldID = Movie.ID; var userID = User.Identity.Name.ToString(); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Rating.RatingTime = DateTime.Now; _context.Rating.Add(Rating); //await _context.SaveChangesAsync(); // Once a record is added, create an audit record if (await _context.SaveChangesAsync() > 0) { // Create an auditrecord object var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Add Rating Record"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.KeyBookFieldID = 998; // Get current logged-in user var userID = User.Identity.Name.ToString(); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Software.Add(Software); //await _context.SaveChangesAsync(); if (await _context.SaveChangesAsync() > 0) { // Create an auditrecord object var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Add Software Record (Software: " + Software.Name + ")"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.KeySoftwareFieldID = Software.ID; // Get current logged-in user var userID = User.Identity.Name.ToString(); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } ApplicationRole.CreatedDate = DateTime.UtcNow; ApplicationRole.IPAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString(); //This class takes RoleManager as constructor parameter. ASP.NET Core Dependency Injection will take care of passing the instance of RoleManager into this razor page. IdentityResult roleRuslt = await _roleManager.CreateAsync(ApplicationRole); //This method has new ApplicationRole as a parameter and creates new role in the application.This will also return true or false on the whether the creation of new role is successful. // Create an auditrecord object var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Created new Role," + ApplicationRole; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.KeyBookFieldID = 777; // Get current logged-in user var userID = User.Identity.Name.ToString(); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(RedirectToPage("Index")); }
public void AuditCreateObjectAuditTest() { foreach (IDataService dataService in DataServices) { // Arrange. string firstFild = "Field11"; string secondFild = "Field12"; Class1 class1 = new Class1 { Field11 = firstFild, Field12 = secondFild, }; // Act. dataService.UpdateObject(class1); ExternalLangDef langDef = ExternalLangDef.LanguageDef; // Вычитка записей аудита. LoadingCustomizationStruct lcs = LoadingCustomizationStruct.GetSimpleStruct(typeof(AuditRecord), AuditRecord.Views.AllFields); lcs.LimitFunction = langDef.GetFunction(langDef.funcEQ, new VariableDef(langDef.GuidType, Information.ExtractPropertyPath <AuditRecord>(x => x.ObjectPrimaryKey)), class1.__PrimaryKey); DataObject[] auditEntities = dataService.LoadObjects(lcs); AuditRecord auditRecord = auditEntities.Cast <AuditRecord>().FirstOrDefault(); // TODO: проверка полей аудита. // Assert. Assert.Equal("Создание", auditRecord.OperationType); Assert.Single(auditEntities); } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Review = await _context.Review.FindAsync(id); if (Review != null) { _context.Review.Remove(Review); var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Deleted a Review"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.KeySoftwareFieldID = 0; // Get current logged-in user var userID = User.Identity.Name.ToString(); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
internal async Task <Activity> GetActivity(AuditRecord audit, ApplicationUser user) { var avatar = user.Avatar; if (!GenericAvatarConstructor.IsGenericAvatar(avatar) && _s3Service.CheckIfPresignedUrlIsExpired(avatar)) { avatar = await _s3Service.GetPresignedUrlAsync(avatar); } var userInfo = new BasicUserInfo { UserId = audit.UserId, UserAvatar = avatar, UserName = user.FullName, }; var activityInfo = new BasicActivityInfo() { Id = audit.Id, Date = audit.Date, Type = (ActivityType)Enum.Parse(typeof(ActivityType), audit.EntityType, true), JsonEntity = await _activityService.GetEntityAsJson(audit), Seen = audit.Seen }; return(new Activity(userInfo, activityInfo)); }
private async Task ActAndAssert(AuditRecord audit) { var repo = new SqlServerAuditRepository(); using (var connection = _databaseFixture.ConnectionFactory.CreateDatabaseConnection()) { connection.Open(); using (var transaction = connection.BeginTransaction()) { var createdAudit = await repo.CreateAudit(audit, transaction).ConfigureAwait(false); var auditResult = await connection.QuerySingleOrDefaultAsync <AuditRecord>( $"SELECT AuditId, Action, ActorName, AuditDate, EntityUri, MemberKey, State, RedactedState FROM {Tables.Audit} WHERE AuditId = @AuditId", new { createdAudit.AuditId }, transaction ).ConfigureAwait(false); Assert.NotNull(auditResult); Assert.Equal(audit.Action, auditResult.Action); Assert.Equal(audit.ActorName, auditResult.ActorName); Assert.Equal(audit.AuditDate, auditResult.AuditDate); Assert.Equal(audit.EntityUri, auditResult.EntityUri); Assert.Equal(audit.MemberKey, auditResult.MemberKey); Assert.Equal(audit.State, auditResult.State); Assert.Equal(audit.RedactedState, auditResult.RedactedState); transaction.Rollback(); } } }
public FileStreamResult ExportFile(string fileType) { var mapType = Type.GetType($"HainDanielsApi.Models.FileFormatMaps.{fileType}Map", true, true); var records = productRepository.GetItems(); MemoryStream ms; using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream, Encoding.UTF8)) using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture)) { csv.Configuration.RegisterClassMap(mapType); csv.WriteRecords(records); writer.Flush(); var result = stream.ToArray(); ms = new MemoryStream(result); } var auditRecord = new AuditRecord() { Description = $"Exported {fileType} file. {records.ToArray().Length} products", Event = "Export", RecordDateTime = DateTime.UtcNow }; auditRepository.SaveItem(auditRecord); return(File(ms, "text/csv")); }
private void SetValues(WorkPackageClosingDataGridViewRow row, Audit wp, AuditRecord workPackageRecord) { if (workPackageRecord != null) { row.WorkPackage = wp; row.ClosingItem = workPackageRecord.Task; } GetRecordInstance(row, wp, workPackageRecord: workPackageRecord); SetLabelsAndText(row); if (row.ClosingItem.IsClosed) { DataGridViewCell cell = row.Cells[ColumnClosed.Index]; cell.Value = false; cell.ReadOnly = true; cell.Style.BackColor = Color.DimGray; cell.ToolTipText = "This item is closed and can't be perform"; SetCellReadOnly(row, new[] { ColumnClosed.Index, ColumnHours.Index, ColumnCycles.Index, ColumnDays.Index, ColumnDate.Index }, false); } }
public async Task <IActionResult> OnPost(string returnUrl = null) { await _signInManager.SignOutAsync(); _logger.LogInformation("User logged out."); if (returnUrl != null) { // Logout - create an audit record var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Logout"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.KeySoftwareFieldID = 0; // 0 – dummy record (no software is affected during logout) auditrecord.Username = User.Identity.Name.ToString(); // save the email used for the failed login _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(LocalRedirect(returnUrl)); } else { return(RedirectToPage()); } }
/// <summary> /// /// </summary> private void GetRecordInstance(WorkPackageClosingDataGridViewRow row, Audit wp, NextPerformance nextPerformance = null, AuditRecord workPackageRecord = null) { if (row.ClosingItem == null) { return; } IDirective currentClosingItem = row.ClosingItem; if (currentClosingItem is Procedure) { row.Record = new DirectiveRecord(); } if (nextPerformance != null) { row.Record.PerformanceNum = nextPerformance.PerformanceNum; } if (workPackageRecord != null) { row.Record.PerformanceNum = workPackageRecord.PerformanceNumFromStart; } row.Record.Parent = currentClosingItem; row.Record.ParentId = currentClosingItem.ItemId; row.Record.DirectivePackageId = wp.ItemId; }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } ApplicationRole = await _roleManager.FindByIdAsync(id); IdentityResult roleRuslt = await _roleManager.DeleteAsync(ApplicationRole); //This method has existing ApplicationRole as a parameter and delete the role in the application. // Create an auditrecord object var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Deleted " + ApplicationRole + " Role"; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.KeyBookFieldID = 777; // Get current logged-in user var userID = User.Identity.Name.ToString(); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int id) { //adding reply CustomerSupport = await _context.CustomerSupport.FirstOrDefaultAsync(m => m.CustomerSupport_ID == HttpContext.Session.GetInt32("currentId")); Reply curReply = new Reply(); curReply.Replies = StringContent; curReply.CustomerSupport_ID = CustomerSupport.CustomerSupport_ID; curReply.Username = User.Identity.Name.ToString(); curReply.DateTimeStamp = DateTime.Now; HttpContext.Session.Remove("currentId"); CustomerSupport.NoReplies += 1; _context.Reply.Add(curReply); //audit adding reply var user = await _userManager.GetUserAsync(User); var auditrecord = new AuditRecord(); //auditrecord.AuditActionType = "Adding Reply id: " + curReply.reply_ID +"into CustomerSupport id: " + id; auditrecord.AuditActionType = "Added Reply into CustomerSupport id: " + id; auditrecord.DateTimeStamp = DateTime.Now; auditrecord.PerformedBy = user; auditrecord.AuditRecordId = Guid.NewGuid().ToString(); auditrecord.IPAddress = HttpContext.Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(); _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(RedirectToPage(new { id = CustomerSupport.CustomerSupport_ID })); }
public async Task <IActionResult> OnPostDeleteReviewAsync(string reviewid, string listingid) { Listing = await _context.Listing.FirstOrDefaultAsync(m => m.ListingId == listingid); if (reviewid == null) { return(NotFound()); } Review = await _context.Review.FindAsync(reviewid); if (Review != null) { _context.ChangeTracker.DetectChanges(); _context.Review.Remove(Review); await _context.SaveChangesAsync(); // Create an auditrecord object var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Review " + Review.ReviewId + " was deleted"; auditrecord.DateTimeStamp = DateTime.Now; // Get current logged-in user auditrecord.PerformedBy = await userManager.GetUserAsync(User); auditrecord.IPAddress = auditrecord.PerformedBy.IPAddress; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); } return(Redirect("./ListingDetails?id=" + Listing.ListingId)); }
private static bool PostAuditFile(string auditFilePath) { try { if (File.Exists(auditFilePath)) { AuditRecord auditRecord = ReadAuditRecordFromFile(auditFilePath); Global.LogEvent(string.Format("Generated audit record from file: {0}", auditFilePath), Global.LogEvents.Info, logToLog4Net: false); if (PostAuditRecord(auditRecord)) { return(true); } } else { Global.ExitApp(11, string.Format("ERROR: Audit file not found: {0}", auditFilePath)); } } catch (Exception ex) { Global.ExitApp(9, String.Format("EXCEPTION in {0}: {1}", MethodBase.GetCurrentMethod(), ex.Message)); } return(false); }
private AuditRecord ConvertToAttributeAuditRecord(ShareAuditDetail auditDetails) { AuditRecord auditRecord = null; if (auditDetails != null) { Entity audit = auditDetails.AuditRecord; auditRecord = new AuditRecord { EntityLogicalName = audit.GetAttributeValue <EntityReference>("objectid")?.LogicalName, RecordName = audit.GetAttributeValue <EntityReference>("objectid")?.Name, AuthorName = audit.GetAttributeValue <EntityReference>("userid")?.Name, CreatedOn = audit.GetAttributeValue <DateTime>("createdon"), ObjectLogicalName = "", NewValue = "", NewValueFormated = "", OldValue = "", OldValueFormated = "", OperationFormated = audit.GetAttributeText("operation"), OperationValue = audit.GetAttributeValueAsString("operation"), ActionValue = audit.GetAttributeValueAsString("action"), ActionFormated = audit.GetAttributeText("action"), }; } return(auditRecord); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } ApplicationRole = await _roleManager.FindByIdAsync(id); IdentityResult roleRuslt = await _roleManager.DeleteAsync(ApplicationRole); var auditrecord = new AuditRecord(); auditrecord.AuditActionType = "Delete Role"; auditrecord.DateTimeStamp = DateTime.Now; var userID = User.Identity.Name.ToString(); auditrecord.Desc = String.Format("User Role called '{0}' was deleted by {1}", ApplicationRole.Name, userID); auditrecord.Username = userID; _context.AuditRecords.Add(auditrecord); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
private void WriteAuditRecord(AuditRecord auditRecord) { lock (sqliteLock) { using (var connection = new SqliteConnection("Data Source=Auditor.db")) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = @"INSERT INTO auditRecords (AuditId, ParentAuditId, EntityId, EntityType, TransactionTime, AuditTime, AutoResolved, Record) VALUES ($aid, $paid, $ei, $et, $tt,$at, $ar, $r)"; command.Parameters.AddWithValue("$aid", auditRecord.AuditId); if (auditRecord.ParentAuditId != null) { command.Parameters.AddWithValue("$paid", auditRecord.ParentAuditId); } else { command.Parameters.AddWithValue("$paid", DBNull.Value); } command.Parameters.AddWithValue("$ei", auditRecord.EntityId); command.Parameters.AddWithValue("$et", (int)auditRecord.EntityType); command.Parameters.AddWithValue("$tt", convertDateTimeToEpoch(auditRecord.TransactionTime)); command.Parameters.AddWithValue("$at", convertDateTimeToEpoch(auditRecord.AuditTime)); command.Parameters.AddWithValue("$ar", auditRecord.AutoResolved ? 1 : 0); command.Parameters.AddWithValue("$r", auditRecord.Record); command.ExecuteNonQuery(); } } }
internal static async Task<Uri> SaveAuditRecord(CloudStorageAccount storage, AuditRecord auditRecord) { string localIP = await AuditActor.GetLocalIP(); CloudAuditingService audit = new CloudAuditingService( Environment.MachineName, localIP, storage.CreateCloudBlobClient().GetContainerReference("auditing"), onBehalfOfThunk: null); return await audit.SaveAuditRecord(auditRecord); }
public AuditEntry(AuditRecord record, AuditActor actor) { Record = record; Actor = actor; }