Skip to content

Commit

Permalink
Add logging sql model
Browse files Browse the repository at this point in the history
  • Loading branch information
amos-cha committed Jul 13, 2023
1 parent b59712d commit 128309b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
10 changes: 4 additions & 6 deletions Gordon360/Models/CCT/Context/CCTContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public CCTContext(DbContextOptions<CCTContext> options)
public virtual DbSet<Police> Police { get; set; }
public virtual DbSet<PrivType> PrivType { get; set; }
public virtual DbSet<REQUEST> REQUEST { get; set; }
public virtual DbSet<RequestResponseLog> RequestResponseLog { get; set; }
public virtual DbSet<RequestView> RequestView { get; set; }
public virtual DbSet<RoleType> RoleType { get; set; }
public virtual DbSet<RoomAssign> RoomAssign { get; set; }
Expand Down Expand Up @@ -399,8 +400,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.PART_CDE).IsFixedLength();
entity.Property(e => e.SESS_CDE).IsFixedLength();
entity.Property(e => e.USER_NAME).IsFixedLength();
});

modelBuilder.Entity<MYSCHEDULE>(entity =>
Expand Down Expand Up @@ -509,9 +508,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<Participant>(entity =>
{
entity.HasKey(e => e.Username)
.HasName("PK__Particip__536C85E53B50E910");
entity.Property(e => e.ID).ValueGeneratedOnAdd();
});

Expand All @@ -525,6 +521,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.HasOne(d => d.ParticipantUsernameNavigation)
.WithMany(p => p.ParticipantActivity)
.HasForeignKey(d => d.ParticipantUsername)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_ParticipantActivity_Participant");
entity.HasOne(d => d.PrivType)
Expand All @@ -540,7 +537,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.WithMany(p => p.ParticipantNotification)
.HasForeignKey(d => d.ParticipantUsername)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_PartipantNotification_Participant");
.HasConstraintName("FK_ParticipantNotification_Participant");
});

modelBuilder.Entity<ParticipantStatusHistory>(entity =>
Expand All @@ -563,6 +560,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.HasOne(d => d.ParticipantUsernameNavigation)
.WithMany(p => p.ParticipantTeam)
.HasForeignKey(d => d.ParticipantUsername)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_ParticipantTeam_Participant");
entity.HasOne(d => d.RoleType)
Expand Down
6 changes: 5 additions & 1 deletion Gordon360/Models/CCT/Context/efpt.CCT.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
"Name": "[dbo].[REQUEST]",
"ObjectType": 0
},
{
"Name": "[dbo].[RequestResponseLog]",
"ObjectType": 0
},
{
"Name": "[dbo].[Rooms]",
"ObjectType": 0
Expand Down Expand Up @@ -799,7 +803,7 @@
"ObjectType": 1
}
],
"UiHint": "SQLTrain1.CCT",
"UiHint": "sqltrain1.CCT.dbo",
"UseBoolPropertiesWithoutDefaultSql": false,
"UseDatabaseNames": true,
"UseDbContextSplitting": false,
Expand Down
46 changes: 46 additions & 0 deletions Gordon360/Models/CCT/dbo/RequestResponseLog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace Gordon360.Models.CCT
{
[Table("RequestResponseLog", Schema = "dbo")]
public partial class RequestResponseLog
{
[Key]
[StringLength(36)]
[Unicode(false)]
public string LogID { get; set; }
[Required]
[StringLength(15)]
[Unicode(false)]
public string ClientIP { get; set; }
[Column(TypeName = "datetime")]
public DateTime RequestDate { get; set; }
[Required]
[StringLength(510)]
[Unicode(false)]
public string UserAgent { get; set; }
[Required]
[StringLength(63)]
[Unicode(false)]
public string RequestHost { get; set; }
[Required]
[StringLength(7)]
[Unicode(false)]
public string RequestMethod { get; set; }
[Required]
[StringLength(100)]
[Unicode(false)]
public string RequestPath { get; set; }
[StringLength(510)]
[Unicode(false)]
public string RequestQuery { get; set; }
public int ResponseStatus { get; set; }
public int? ResponseContentLength { get; set; }
}
}

0 comments on commit 128309b

Please sign in to comment.