diff --git a/Church.Net.DAL.EFCoreDBF/CombinedKeyCrudDALCBase - Copy.cs b/Church.Net.DAL.EFCoreDBF/Core/CombinedKeyCrudDALCBase - Copy.cs similarity index 91% rename from Church.Net.DAL.EFCoreDBF/CombinedKeyCrudDALCBase - Copy.cs rename to Church.Net.DAL.EFCoreDBF/Core/CombinedKeyCrudDALCBase - Copy.cs index 2a50922..33e6631 100644 --- a/Church.Net.DAL.EFCoreDBF/CombinedKeyCrudDALCBase - Copy.cs +++ b/Church.Net.DAL.EFCoreDBF/Core/CombinedKeyCrudDALCBase - Copy.cs @@ -12,8 +12,9 @@ using System.Reflection; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore.Metadata.Internal; +using Church.Net.DAL.EFCoreDBF.Interface; -namespace Church.Net.DAL.EFCoreDBF +namespace Church.Net.DAL.EFCoreDBF.Core { public class CrudDALCBase1 : ICrudDAL where T : class, IEntity, new() { @@ -21,7 +22,7 @@ namespace Church.Net.DAL.EFCoreDBF public CrudDALCBase1(DatabaseOptions databaseOptions) { - this.dbContext = databaseOptions.GetDbContext(); + dbContext = databaseOptions.GetDbContext(); InitKeyProperty(); } public IQueryable GetDbSet() @@ -39,7 +40,7 @@ namespace Church.Net.DAL.EFCoreDBF public virtual T GetById(string Id) { - return this.GetQuery(new string[] { Id }).FirstOrDefault(); + return GetQuery(new string[] { Id }).FirstOrDefault(); } //public virtual T GetByRefndx(string refndx) @@ -58,16 +59,16 @@ namespace Church.Net.DAL.EFCoreDBF public virtual int Create(T entity) { - this.CheckKeyIsEmpty(entity); - this.ConvertUTCTime(entity); + CheckKeyIsEmpty(entity); + ConvertUTCTime(entity); dbContext.Add(entity); return dbContext.SaveChanges(); } public virtual Task CreateAsync(T entity) { - this.CheckKeyIsEmpty(entity); - this.ConvertUTCTime(entity); + CheckKeyIsEmpty(entity); + ConvertUTCTime(entity); dbContext.Add(entity); //CreateDone(entity, newDbObj); @@ -78,14 +79,14 @@ namespace Church.Net.DAL.EFCoreDBF public int CreateOrUpdate(T entity) { int result = 0; - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); if (CheckExist(entity)) { - result = this.Update(entity); + result = Update(entity); } else { - result = this.Create(entity); + result = Create(entity); } return result; } @@ -97,7 +98,7 @@ namespace Church.Net.DAL.EFCoreDBF //{ // throw new ArgumentNullException("the Id is not exist."); //} - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); dbContext.Update(entity); diff --git a/Church.Net.DAL.EFCoreDBF/CombinedKeyCrudDALCBase.cs b/Church.Net.DAL.EFCoreDBF/Core/CombinedKeyCrudDALCBase.cs similarity index 91% rename from Church.Net.DAL.EFCoreDBF/CombinedKeyCrudDALCBase.cs rename to Church.Net.DAL.EFCoreDBF/Core/CombinedKeyCrudDALCBase.cs index c5fa1fd..da7bdab 100644 --- a/Church.Net.DAL.EFCoreDBF/CombinedKeyCrudDALCBase.cs +++ b/Church.Net.DAL.EFCoreDBF/Core/CombinedKeyCrudDALCBase.cs @@ -12,15 +12,16 @@ using System.Reflection; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore.Metadata.Internal; +using Church.Net.DAL.EFCoreDBF.Interface; -namespace Church.Net.DAL.EFCoreDBF +namespace Church.Net.DAL.EFCoreDBF.Core { - public class CombinedKeyCrudDALCBase : ICombinedKeyCrudDAL where T : class, Church.Net.Entity.Interface.ICombinedKeyEntity, new() + public class CombinedKeyCrudDALCBase : ICombinedKeyCrudDAL where T : class, ICombinedKeyEntity, new() { private readonly DatabaseOptions databaseOptions; public CombinedKeyCrudDALCBase(DatabaseOptions databaseOptions) - { + { this.databaseOptions = databaseOptions; InitKeyProperty(); } @@ -49,7 +50,7 @@ namespace Church.Net.DAL.EFCoreDBF public virtual T GetById(IEnumerable Ids) { - return this.GetQuery(Ids).FirstOrDefault(); + return GetQuery(Ids).FirstOrDefault(); } //public virtual T GetByRefndx(string refndx) @@ -71,13 +72,13 @@ namespace Church.Net.DAL.EFCoreDBF //IEnumerable list = GetDbSet().Where(filter ?? (s => true)).ToList(); - return GetDbSet().AsNoTracking().Where(filter ?? (s => true)).AsQueryable(); + return GetDbSet().AsNoTracking().Where(filter ?? (s => true)).AsQueryable(); } public virtual int Create(T entity) { - this.CheckCombinedKeyIsEmpty(entity); - this.ConvertUTCTime(entity); + CheckCombinedKeyIsEmpty(entity); + ConvertUTCTime(entity); using (var dbContext = GetDbContext()) { @@ -88,8 +89,8 @@ namespace Church.Net.DAL.EFCoreDBF } public virtual Task CreateAsync(T entity) { - this.CheckCombinedKeyIsEmpty(entity); - this.ConvertUTCTime(entity); + CheckCombinedKeyIsEmpty(entity); + ConvertUTCTime(entity); using (var dbContext = GetDbContext()) { dbContext.Add(entity); @@ -103,14 +104,14 @@ namespace Church.Net.DAL.EFCoreDBF public int CreateOrUpdate(T entity) { int result = 0; - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); if (CheckExist(entity)) { - result = this.Update(entity); + result = Update(entity); } else { - result = this.Create(entity); + result = Create(entity); } return result; } @@ -122,7 +123,7 @@ namespace Church.Net.DAL.EFCoreDBF //{ // throw new ArgumentNullException("the Id is not exist."); //} - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); using (var dbContext = GetDbContext()) { @@ -163,8 +164,8 @@ namespace Church.Net.DAL.EFCoreDBF public virtual int Delete(IEnumerable combinedKeyIds) { - var obj = this.GetById(combinedKeyIds); - return obj == null ? this.Delete(obj) : 0; + var obj = GetById(combinedKeyIds); + return obj == null ? Delete(obj) : 0; } public int Delete(Func filter) diff --git a/Church.Net.DAL.EFCoreDBF/CrudDALCBase.cs b/Church.Net.DAL.EFCoreDBF/Core/CrudDALCBase.cs similarity index 84% rename from Church.Net.DAL.EFCoreDBF/CrudDALCBase.cs rename to Church.Net.DAL.EFCoreDBF/Core/CrudDALCBase.cs index 1cc6a3a..bf22333 100644 --- a/Church.Net.DAL.EFCoreDBF/CrudDALCBase.cs +++ b/Church.Net.DAL.EFCoreDBF/Core/CrudDALCBase.cs @@ -7,10 +7,11 @@ using System.Linq; using Church.Net.Utility; using System.Threading.Tasks; using Church.Net.Entity.Interface; +using Church.Net.DAL.EFCoreDBF.Interface; -namespace Church.Net.DAL.EFCoreDBF +namespace Church.Net.DAL.EFCoreDBF.Core { - public class CrudDALCBase : ICrudDAL where T : class, Church.Net.Entity.Interface.IEntity, new() + public class CrudDALCBase : ICrudDAL where T : class, IEntity, new() { private readonly DatabaseOptions databaseOptions; @@ -21,6 +22,10 @@ namespace Church.Net.DAL.EFCoreDBF this.databaseOptions = databaseOptions; //this.dbContext = databaseOptions.GetDbContext(); } + public virtual IQueryable InitQuery(ChurchNetContext dbContext) + { + return dbContext.Set(); + } public ChurchNetContext GetDbContext() { //var result = (DbSet)typeof(ChurchNetContext).GetMethod("Set").MakeGenericMethod(typeof(T)).Invoke(dbContext, null); @@ -33,7 +38,7 @@ namespace Church.Net.DAL.EFCoreDBF { using (var dbContext = GetDbContext()) { - return dbContext.Set().Where(filter ?? (s => true)).FirstOrDefault(); + return InitQuery(dbContext).Where(filter ?? (s => true)).FirstOrDefault(); } } @@ -41,7 +46,7 @@ namespace Church.Net.DAL.EFCoreDBF { using (var dbContext = GetDbContext()) { - return dbContext.Set().FirstOrDefault(e => e.Id == Id); + return InitQuery(dbContext).FirstOrDefault(e => e.Id == Id); } } @@ -54,7 +59,7 @@ namespace Church.Net.DAL.EFCoreDBF { using (var dbContext = GetDbContext()) { - return dbContext.Set().Where(filter ?? (s => true)).ToList(); + return InitQuery(dbContext).Where(filter ?? (s => true)).ToList(); } //var dbObjs = GetDbContext().ToArray(); @@ -72,7 +77,7 @@ namespace Church.Net.DAL.EFCoreDBF //var list = new List(); - return dbContext.Set().Where(e => RowIds.Any(id => id == e.Id)).ToArray(); + return InitQuery(dbContext).Where(e => RowIds.Any(id => id == e.Id)).ToArray(); } } private bool needGenId(T entity) @@ -88,7 +93,7 @@ namespace Church.Net.DAL.EFCoreDBF entity.Id = StringHelper.Get33BaseGuid(); } - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); using (var dbContext = GetDbContext()) { @@ -100,7 +105,7 @@ namespace Church.Net.DAL.EFCoreDBF public virtual Task CreateAsync(T entity) { int result = 0; - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); if (needGenId(entity)) { entity.Id = StringHelper.Get33BaseGuid(); @@ -122,7 +127,7 @@ namespace Church.Net.DAL.EFCoreDBF } public virtual string CreateReturnId(T entity) { - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); if (Create(entity) > 0) { return entity.Id; @@ -135,7 +140,7 @@ namespace Church.Net.DAL.EFCoreDBF public int CreateOrUpdate(T entity) { - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); using (var dbContext = GetDbContext()) @@ -161,12 +166,12 @@ namespace Church.Net.DAL.EFCoreDBF { using (var dbContext = GetDbContext()) { - //var dbObj = dbContext.Set().Any(e => e.Id == entity.Id); - if (!dbContext.Set().Any(e => e.Id == entity.Id)) + //var dbObj = this.InitQuery(dbContext).Any(e => e.Id == entity.Id); + if (!InitQuery(dbContext).Any(e => e.Id == entity.Id)) { throw new ArgumentNullException("the Id is not exist."); } - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); dbContext.Update(entity); @@ -187,7 +192,7 @@ namespace Church.Net.DAL.EFCoreDBF { foreach (var entity in entities) { - this.ConvertUTCTime(entity); + ConvertUTCTime(entity); } using (var dbContext = GetDbContext()) { @@ -201,7 +206,7 @@ namespace Church.Net.DAL.EFCoreDBF { using (var dbContext = GetDbContext()) { - dbContext.Remove(dbContext.Set().FirstOrDefault(e => e.Id == obj.Id.ToString())); + dbContext.Remove(InitQuery(dbContext).FirstOrDefault(e => e.Id == obj.Id.ToString())); return dbContext.SaveChanges(); } } @@ -211,7 +216,7 @@ namespace Church.Net.DAL.EFCoreDBF using (var dbContext = GetDbContext()) { - var list = dbContext.Set().Where(filter).ToList(); + var list = InitQuery(dbContext).Where(filter).ToList(); if (list.Count > 0) { dbContext.RemoveRange(list); @@ -225,7 +230,7 @@ namespace Church.Net.DAL.EFCoreDBF { using (var dbContext = GetDbContext()) { - return dbContext.Set().Any(e => e.Id == obj.Id); + return InitQuery(dbContext).Any(e => e.Id == obj.Id); } } @@ -238,7 +243,7 @@ namespace Church.Net.DAL.EFCoreDBF if (prop.PropertyType == typeof(DateTime)) { //do stuff like prop.SetValue(t, DateTime.Now, null); - DateTime localTime = ((DateTime)prop.GetValue(entity)); + DateTime localTime = (DateTime)prop.GetValue(entity); if (localTime.Kind != DateTimeKind.Utc) { localTime = new DateTime(localTime.Year, localTime.Month, localTime.Day, @@ -253,7 +258,7 @@ namespace Church.Net.DAL.EFCoreDBF } else if (prop.PropertyType == typeof(DateTime?)) { - DateTime? localTime = ((DateTime?)prop.GetValue(entity)); + DateTime? localTime = (DateTime?)prop.GetValue(entity); if (localTime.HasValue) { if (localTime.Value.Kind != DateTimeKind.Utc) diff --git a/Church.Net.DAL.EFCoreDBF/DatabaseOptions.cs b/Church.Net.DAL.EFCoreDBF/Core/DatabaseOptions.cs similarity index 89% rename from Church.Net.DAL.EFCoreDBF/DatabaseOptions.cs rename to Church.Net.DAL.EFCoreDBF/Core/DatabaseOptions.cs index d52bc35..6dd6267 100644 --- a/Church.Net.DAL.EFCoreDBF/DatabaseOptions.cs +++ b/Church.Net.DAL.EFCoreDBF/Core/DatabaseOptions.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Church.Net.DAL.EFCoreDBF +namespace Church.Net.DAL.EFCoreDBF.Core { public class DatabaseOptions { diff --git a/Church.Net.DAL.EFCoreDBF/ChurchNetContext.cs b/Church.Net.DAL.EFCoreDBF/DBContext/ChurchNetContext.cs similarity index 80% rename from Church.Net.DAL.EFCoreDBF/ChurchNetContext.cs rename to Church.Net.DAL.EFCoreDBF/DBContext/ChurchNetContext.cs index 7ba455b..e1d86b9 100644 --- a/Church.Net.DAL.EFCoreDBF/ChurchNetContext.cs +++ b/Church.Net.DAL.EFCoreDBF/DBContext/ChurchNetContext.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; using Church.Net.Entity; +using Church.Net.Entity.Games.MD2; using Church.Net.Entity.Messenger; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; @@ -40,7 +42,7 @@ namespace Church.Net.DAL.EF private static bool _created = true; private readonly string connectionString; - + public ChurchNetContext(DbContextOptions options) : base(options) { @@ -98,13 +100,33 @@ namespace Church.Net.DAL.EF .HasOne(tt => tt.PastoralDomain) .WithMany(t => t.AutoReplyItemRelations) .HasForeignKey(tt => tt.PastoralDomainCommunityAppId); - //.HasPrincipalKey(tt => tt.L); + //.HasPrincipalKey(tt => tt.L); //modelBuilder.Entity() // .HasOne(t => t.PastoralDomain) // .WithMany(tt => tt.FamilyMember) // .HasForeignKey(f => f.ParentId); + modelBuilder.Entity().Property(x => x.Id).HasDefaultValueSql("uuid_generate_v4()"); + modelBuilder.Entity(entity => + { + entity.Property(x => x.Id).HasDefaultValueSql("uuid_generate_v4()"); + entity.HasMany(e => e.MobLevelInfos).WithOne().OnDelete(DeleteBehavior.Cascade); + entity.HasMany(e => e.Skills).WithOne(x=>x.MobInfo).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.Property(x => x.Id).HasDefaultValueSql("uuid_generate_v4()"); + entity.HasMany(e => e.Skills).WithOne(x => x.MobLevelInfo).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.Property(x => x.Id).HasDefaultValueSql("uuid_generate_v4()"); + entity.Property(x => x.MobInfoId).IsRequired(false); + entity.Property(x => x.MobLevelInfoId).IsRequired(false); + }); } public string DbPath { get; } @@ -137,11 +159,14 @@ namespace Church.Net.DAL.EF public DbSet LineMessageClients { get; set; } public DbSet LineMessagingAccounts { get; set; } - + public DbSet Contributions { get; set; } public DbSet HappinessCosts { get; set; } + //public DbSet GamePlayers { get; set; } + public DbSet Md2MobInfos { get; set; } + public DbSet Md2MobLevelInfos { get; set; } #endregion diff --git a/Church.Net.DAL.EFCoreDBF/ICrudDAL.cs b/Church.Net.DAL.EFCoreDBF/Interface/ICrudDAL.cs similarity index 97% rename from Church.Net.DAL.EFCoreDBF/ICrudDAL.cs rename to Church.Net.DAL.EFCoreDBF/Interface/ICrudDAL.cs index d25fba9..7e1e9bb 100644 --- a/Church.Net.DAL.EFCoreDBF/ICrudDAL.cs +++ b/Church.Net.DAL.EFCoreDBF/Interface/ICrudDAL.cs @@ -7,7 +7,7 @@ using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; -namespace Church.Net.DAL.EFCoreDBF +namespace Church.Net.DAL.EFCoreDBF.Interface { public interface ICrudDAL where T : class, IEntity { diff --git a/Church.Net.DAL.EFCoreDBF/Migrations/20240502213000_AddMD2MobInfo.Designer.cs b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213000_AddMD2MobInfo.Designer.cs new file mode 100644 index 0000000..7106616 --- /dev/null +++ b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213000_AddMD2MobInfo.Designer.cs @@ -0,0 +1,984 @@ +// +using System; +using Church.Net.DAL.EF; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Church.Net.DAL.EFCoreDBF.Migrations +{ + [DbContext(typeof(ChurchNetContext))] + [Migration("20240502213000_AddMD2MobInfo")] + partial class AddMD2MobInfo + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Church.Net.Entity.AddressInfo", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Zip") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AddressInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.AutoReplyItem", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Command") + .HasColumnType("text"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AutoReplyItems"); + }); + + modelBuilder.Entity("Church.Net.Entity.Career", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.ToTable("Careers"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEvent", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("PastoralDomainId") + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("PastoralDomainId"); + + b.ToTable("CellGroupRoutineEvents"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventAttendee", b => + { + b.Property("EventId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("Id") + .HasColumnType("text") + .HasColumnOrder(1); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("JoinPotluck") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("PotluckItem") + .HasColumnType("text"); + + b.HasKey("EventId", "Id"); + + b.ToTable("CellGroupRoutineEventAttendees"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventPrayer", b => + { + b.Property("EventId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("MemberId") + .HasColumnType("text") + .HasColumnOrder(1); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("Prayer") + .HasColumnType("text"); + + b.HasKey("EventId", "MemberId"); + + b.ToTable("CellGroupRoutineEventPrayers"); + }); + + modelBuilder.Entity("Church.Net.Entity.Contribution", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("Contributor") + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("Contributions"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMember", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("AvatarImage") + .HasColumnType("text"); + + b.Property("Baptized") + .HasColumnType("boolean"); + + b.Property("Birthday") + .HasColumnType("timestamp with time zone"); + + b.Property("CareerId") + .HasColumnType("text"); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("ComunityAppId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("DateOfBaptized") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfWalkIn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("FirstName") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Married") + .HasColumnType("boolean"); + + b.Property("Password") + .HasColumnType("text"); + + b.Property("Role") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CareerId"); + + b.ToTable("FamilyMembers"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMemberOAuth", b => + { + b.Property("FamilyMemberId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("OAuthType") + .HasColumnType("text") + .HasColumnOrder(1); + + b.Property("OAuthAccessToken") + .HasColumnType("text"); + + b.HasKey("FamilyMemberId", "OAuthType"); + + b.ToTable("FamilyMemberOAuths"); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasDefaultValueSql("uuid_generate_v4()"); + + b.Property("From") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Md2MobInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobLevelInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasDefaultValueSql("uuid_generate_v4()"); + + b.Property("MobInfoId") + .HasColumnType("uuid"); + + b.Property("MobInfoId1") + .HasColumnType("uuid"); + + b.Property("MobInfoId2") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("MobInfoId"); + + b.HasIndex("MobInfoId1"); + + b.ToTable("Md2MobLevelInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessBEST", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("HappinessBESTs"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessCost", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("Tasker") + .HasColumnType("text"); + + b.Property("WeekId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("WeekId"); + + b.ToTable("HappinessCosts"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessTask", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("Tasker") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("WeekId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("WeekId"); + + b.ToTable("HappinessTask"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessWeek", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("CityAndZipCode") + .HasColumnType("text"); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupId") + .HasColumnType("text"); + + b.Property("InvitationText") + .HasColumnType("text"); + + b.Property("SEQ") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("HappinessWeeks"); + }); + + modelBuilder.Entity("Church.Net.Entity.LineMessagingAccount", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ChatToken") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Seq") + .HasColumnType("integer"); + + b.Property("TotalUsage") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LineMessagingAccounts"); + }); + + modelBuilder.Entity("Church.Net.Entity.LogInfo", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DetailMessage") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Message") + .HasColumnType("text"); + + b.Property("Source") + .HasColumnType("text"); + + b.Property("StackTrace") + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.Property("TrackNo") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TrackNo")); + + b.Property("Url") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LogInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.Messenger.LineMessageClient", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ClientId") + .HasColumnType("text"); + + b.Property("IsGroup") + .HasColumnType("boolean"); + + b.Property("IsManager") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LineMessageClients"); + }); + + modelBuilder.Entity("Church.Net.Entity.NewVisitor", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("BirthDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ComunityAppId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Note") + .HasColumnType("text"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("ReligionId") + .HasColumnType("integer"); + + b.Property("VisitingDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReligionId"); + + b.ToTable("NewVisitors"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomain", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image1") + .HasColumnType("text"); + + b.Property("Image2") + .HasColumnType("text"); + + b.Property("Image3") + .HasColumnType("text"); + + b.Property("Image4") + .HasColumnType("text"); + + b.Property("Image5") + .HasColumnType("text"); + + b.Property("LeaderMemberId") + .HasColumnType("text"); + + b.Property("LineAccountId") + .HasColumnType("text"); + + b.Property("LineGroupId") + .HasColumnType("text"); + + b.Property("LogoImage") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("ServiceAddressId") + .HasColumnType("text"); + + b.Property("ServiceTime") + .HasColumnType("timestamp with time zone"); + + b.Property("TimeZone") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LeaderMemberId"); + + b.HasIndex("LineAccountId"); + + b.HasIndex("ServiceAddressId"); + + b.ToTable("PastoralDomains"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainAutoReplys", b => + { + b.Property("PastoralDomainCommunityAppId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("AutoReplyItemId") + .HasColumnType("text") + .HasColumnOrder(1); + + b.HasKey("PastoralDomainCommunityAppId", "AutoReplyItemId"); + + b.HasIndex("AutoReplyItemId"); + + b.ToTable("PastoralDomainAutoReplys"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainMembers", b => + { + b.Property("PastoralDomainId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("FamilyMemberId") + .HasColumnType("text") + .HasColumnOrder(1); + + b.HasKey("PastoralDomainId", "FamilyMemberId"); + + b.HasIndex("FamilyMemberId"); + + b.ToTable("PastoralDomainMembers"); + }); + + modelBuilder.Entity("Church.Net.Entity.Religion", b => + { + b.Property("ReligionId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReligionId")); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("ReligionId"); + + b.ToTable("Religions"); + }); + + modelBuilder.Entity("Church.Net.Entity.Vocabulary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DefinitionCh") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefinitionEn") + .IsRequired() + .HasColumnType("text"); + + b.Property("FlashCardTimes") + .HasColumnType("integer"); + + b.Property("ImagesUrl") + .HasColumnType("text"); + + b.Property("InsertDate") + .HasColumnType("timestamp with time zone"); + + b.Property("NounPlural") + .HasColumnType("text"); + + b.Property("PartOfSpeech") + .HasColumnType("integer"); + + b.Property("PracticeApply") + .HasColumnType("boolean"); + + b.Property("PracticeDate") + .HasColumnType("timestamp with time zone"); + + b.Property("PracticeMemorized") + .HasColumnType("boolean"); + + b.Property("PracticeReview") + .HasColumnType("boolean"); + + b.Property("PracticeSelect") + .HasColumnType("boolean"); + + b.Property("PracticeSentence") + .HasColumnType("text"); + + b.Property("PracticeStage") + .HasColumnType("integer"); + + b.Property("PracticeVisualize") + .HasColumnType("boolean"); + + b.Property("VerbParticiple") + .HasColumnType("text"); + + b.Property("VerbPast") + .HasColumnType("text"); + + b.Property("Word") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("Church.Net.Entity.WhoIsSpy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Answer1Chs") + .HasColumnType("text"); + + b.Property("Answer1Cht") + .HasColumnType("text"); + + b.Property("Answer1En") + .HasColumnType("text"); + + b.Property("Answer2Chs") + .HasColumnType("text"); + + b.Property("Answer2Cht") + .HasColumnType("text"); + + b.Property("Answer2En") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("WhoIsSpy"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEvent", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "CellGroupInfo") + .WithMany() + .HasForeignKey("PastoralDomainId"); + + b.Navigation("CellGroupInfo"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventAttendee", b => + { + b.HasOne("Church.Net.Entity.CellGroupRoutineEvent", "CellGroupRoutineEvent") + .WithMany("Attendees") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CellGroupRoutineEvent"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventPrayer", b => + { + b.HasOne("Church.Net.Entity.CellGroupRoutineEvent", "CellGroupRoutineEvent") + .WithMany("Prayers") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CellGroupRoutineEvent"); + }); + + modelBuilder.Entity("Church.Net.Entity.Contribution", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "HappinessGroup") + .WithMany("Contributions") + .HasForeignKey("GroupId"); + + b.Navigation("HappinessGroup"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMember", b => + { + b.HasOne("Church.Net.Entity.Career", "Career") + .WithMany() + .HasForeignKey("CareerId"); + + b.Navigation("Career"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMemberOAuth", b => + { + b.HasOne("Church.Net.Entity.FamilyMember", null) + .WithMany("OAuthInfos") + .HasForeignKey("FamilyMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobLevelInfo", b => + { + b.HasOne("Church.Net.Entity.Games.MD2.MobInfo", "MobInfo") + .WithMany() + .HasForeignKey("MobInfoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Church.Net.Entity.Games.MD2.MobInfo", null) + .WithMany("MobLevelInfos") + .HasForeignKey("MobInfoId1") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MobInfo"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessBEST", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "HappinessGroup") + .WithMany("Bests") + .HasForeignKey("GroupId"); + + b.Navigation("HappinessGroup"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessCost", b => + { + b.HasOne("Church.Net.Entity.HappinessWeek", "HappinessWeek") + .WithMany("Costs") + .HasForeignKey("WeekId"); + + b.Navigation("HappinessWeek"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessTask", b => + { + b.HasOne("Church.Net.Entity.HappinessWeek", "HappinessWeek") + .WithMany("Tasks") + .HasForeignKey("WeekId"); + + b.Navigation("HappinessWeek"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessWeek", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "HappinessGroup") + .WithMany("HappinessWeeks") + .HasForeignKey("GroupId"); + + b.Navigation("HappinessGroup"); + }); + + modelBuilder.Entity("Church.Net.Entity.NewVisitor", b => + { + b.HasOne("Church.Net.Entity.Religion", "Religion") + .WithMany() + .HasForeignKey("ReligionId"); + + b.Navigation("Religion"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomain", b => + { + b.HasOne("Church.Net.Entity.FamilyMember", "Leader") + .WithMany() + .HasForeignKey("LeaderMemberId"); + + b.HasOne("Church.Net.Entity.LineMessagingAccount", "LineMessagingAccount") + .WithMany() + .HasForeignKey("LineAccountId"); + + b.HasOne("Church.Net.Entity.AddressInfo", "ServiceAddress") + .WithMany() + .HasForeignKey("ServiceAddressId"); + + b.Navigation("Leader"); + + b.Navigation("LineMessagingAccount"); + + b.Navigation("ServiceAddress"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainAutoReplys", b => + { + b.HasOne("Church.Net.Entity.AutoReplyItem", "FamilyMember") + .WithMany("AutoReplyItemRelations") + .HasForeignKey("AutoReplyItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Church.Net.Entity.PastoralDomain", "PastoralDomain") + .WithMany("AutoReplyItemRelations") + .HasForeignKey("PastoralDomainCommunityAppId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FamilyMember"); + + b.Navigation("PastoralDomain"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainMembers", b => + { + b.HasOne("Church.Net.Entity.FamilyMember", "FamilyMember") + .WithMany("PastoralDomains") + .HasForeignKey("FamilyMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Church.Net.Entity.PastoralDomain", "PastoralDomain") + .WithMany("Members") + .HasForeignKey("PastoralDomainId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FamilyMember"); + + b.Navigation("PastoralDomain"); + }); + + modelBuilder.Entity("Church.Net.Entity.AutoReplyItem", b => + { + b.Navigation("AutoReplyItemRelations"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEvent", b => + { + b.Navigation("Attendees"); + + b.Navigation("Prayers"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMember", b => + { + b.Navigation("OAuthInfos"); + + b.Navigation("PastoralDomains"); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobInfo", b => + { + b.Navigation("MobLevelInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessWeek", b => + { + b.Navigation("Costs"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomain", b => + { + b.Navigation("AutoReplyItemRelations"); + + b.Navigation("Bests"); + + b.Navigation("Contributions"); + + b.Navigation("HappinessWeeks"); + + b.Navigation("Members"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Church.Net.DAL.EFCoreDBF/Migrations/20240502213000_AddMD2MobInfo.cs b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213000_AddMD2MobInfo.cs new file mode 100644 index 0000000..909800a --- /dev/null +++ b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213000_AddMD2MobInfo.cs @@ -0,0 +1,71 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Church.Net.DAL.EFCoreDBF.Migrations +{ + public partial class AddMD2MobInfo : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Md2MobInfos", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false, defaultValueSql: "uuid_generate_v4()"), + Type = table.Column(type: "integer", nullable: false), + From = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Md2MobInfos", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Md2MobLevelInfos", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false, defaultValueSql: "uuid_generate_v4()"), + MobInfoId = table.Column(type: "uuid", nullable: false), + MobInfoId1 = table.Column(type: "uuid", nullable: false), + MobInfoId2 = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Md2MobLevelInfos", x => x.Id); + table.ForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId", + column: x => x.MobInfoId, + principalTable: "Md2MobInfos", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId1", + column: x => x.MobInfoId1, + principalTable: "Md2MobInfos", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Md2MobLevelInfos_MobInfoId", + table: "Md2MobLevelInfos", + column: "MobInfoId"); + + migrationBuilder.CreateIndex( + name: "IX_Md2MobLevelInfos_MobInfoId1", + table: "Md2MobLevelInfos", + column: "MobInfoId1"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Md2MobLevelInfos"); + + migrationBuilder.DropTable( + name: "Md2MobInfos"); + } + } +} diff --git a/Church.Net.DAL.EFCoreDBF/Migrations/20240502213603_AddMD2MobInfoUpdateId.Designer.cs b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213603_AddMD2MobInfoUpdateId.Designer.cs new file mode 100644 index 0000000..42b633b --- /dev/null +++ b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213603_AddMD2MobInfoUpdateId.Designer.cs @@ -0,0 +1,978 @@ +// +using System; +using Church.Net.DAL.EF; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Church.Net.DAL.EFCoreDBF.Migrations +{ + [DbContext(typeof(ChurchNetContext))] + [Migration("20240502213603_AddMD2MobInfoUpdateId")] + partial class AddMD2MobInfoUpdateId + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Church.Net.Entity.AddressInfo", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Zip") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AddressInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.AutoReplyItem", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Command") + .HasColumnType("text"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AutoReplyItems"); + }); + + modelBuilder.Entity("Church.Net.Entity.Career", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.ToTable("Careers"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEvent", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("PastoralDomainId") + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("PastoralDomainId"); + + b.ToTable("CellGroupRoutineEvents"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventAttendee", b => + { + b.Property("EventId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("Id") + .HasColumnType("text") + .HasColumnOrder(1); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("JoinPotluck") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("PotluckItem") + .HasColumnType("text"); + + b.HasKey("EventId", "Id"); + + b.ToTable("CellGroupRoutineEventAttendees"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventPrayer", b => + { + b.Property("EventId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("MemberId") + .HasColumnType("text") + .HasColumnOrder(1); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("Prayer") + .HasColumnType("text"); + + b.HasKey("EventId", "MemberId"); + + b.ToTable("CellGroupRoutineEventPrayers"); + }); + + modelBuilder.Entity("Church.Net.Entity.Contribution", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("Contributor") + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("Contributions"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMember", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("AvatarImage") + .HasColumnType("text"); + + b.Property("Baptized") + .HasColumnType("boolean"); + + b.Property("Birthday") + .HasColumnType("timestamp with time zone"); + + b.Property("CareerId") + .HasColumnType("text"); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("ComunityAppId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("DateOfBaptized") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfWalkIn") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("FirstName") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Married") + .HasColumnType("boolean"); + + b.Property("Password") + .HasColumnType("text"); + + b.Property("Role") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CareerId"); + + b.ToTable("FamilyMembers"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMemberOAuth", b => + { + b.Property("FamilyMemberId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("OAuthType") + .HasColumnType("text") + .HasColumnOrder(1); + + b.Property("OAuthAccessToken") + .HasColumnType("text"); + + b.HasKey("FamilyMemberId", "OAuthType"); + + b.ToTable("FamilyMemberOAuths"); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValueSql("uuid_generate_v4()"); + + b.Property("From") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Md2MobInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobLevelInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValueSql("uuid_generate_v4()"); + + b.Property("MobInfoId") + .HasColumnType("text"); + + b.Property("MobInfoId2") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MobInfoId"); + + b.HasIndex("MobInfoId2"); + + b.ToTable("Md2MobLevelInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessBEST", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("HappinessBESTs"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessCost", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("Tasker") + .HasColumnType("text"); + + b.Property("WeekId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("WeekId"); + + b.ToTable("HappinessCosts"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessTask", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("Tasker") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("WeekId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("WeekId"); + + b.ToTable("HappinessTask"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessWeek", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("CityAndZipCode") + .HasColumnType("text"); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupId") + .HasColumnType("text"); + + b.Property("InvitationText") + .HasColumnType("text"); + + b.Property("SEQ") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("HappinessWeeks"); + }); + + modelBuilder.Entity("Church.Net.Entity.LineMessagingAccount", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ChatToken") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Seq") + .HasColumnType("integer"); + + b.Property("TotalUsage") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LineMessagingAccounts"); + }); + + modelBuilder.Entity("Church.Net.Entity.LogInfo", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DetailMessage") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Message") + .HasColumnType("text"); + + b.Property("Source") + .HasColumnType("text"); + + b.Property("StackTrace") + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.Property("TrackNo") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TrackNo")); + + b.Property("Url") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LogInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.Messenger.LineMessageClient", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ClientId") + .HasColumnType("text"); + + b.Property("IsGroup") + .HasColumnType("boolean"); + + b.Property("IsManager") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LineMessageClients"); + }); + + modelBuilder.Entity("Church.Net.Entity.NewVisitor", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Address") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("BirthDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ComunityAppId") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Note") + .HasColumnType("text"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("ReligionId") + .HasColumnType("integer"); + + b.Property("VisitingDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReligionId"); + + b.ToTable("NewVisitors"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomain", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image1") + .HasColumnType("text"); + + b.Property("Image2") + .HasColumnType("text"); + + b.Property("Image3") + .HasColumnType("text"); + + b.Property("Image4") + .HasColumnType("text"); + + b.Property("Image5") + .HasColumnType("text"); + + b.Property("LeaderMemberId") + .HasColumnType("text"); + + b.Property("LineAccountId") + .HasColumnType("text"); + + b.Property("LineGroupId") + .HasColumnType("text"); + + b.Property("LogoImage") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("ServiceAddressId") + .HasColumnType("text"); + + b.Property("ServiceTime") + .HasColumnType("timestamp with time zone"); + + b.Property("TimeZone") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LeaderMemberId"); + + b.HasIndex("LineAccountId"); + + b.HasIndex("ServiceAddressId"); + + b.ToTable("PastoralDomains"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainAutoReplys", b => + { + b.Property("PastoralDomainCommunityAppId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("AutoReplyItemId") + .HasColumnType("text") + .HasColumnOrder(1); + + b.HasKey("PastoralDomainCommunityAppId", "AutoReplyItemId"); + + b.HasIndex("AutoReplyItemId"); + + b.ToTable("PastoralDomainAutoReplys"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainMembers", b => + { + b.Property("PastoralDomainId") + .HasColumnType("text") + .HasColumnOrder(0); + + b.Property("FamilyMemberId") + .HasColumnType("text") + .HasColumnOrder(1); + + b.HasKey("PastoralDomainId", "FamilyMemberId"); + + b.HasIndex("FamilyMemberId"); + + b.ToTable("PastoralDomainMembers"); + }); + + modelBuilder.Entity("Church.Net.Entity.Religion", b => + { + b.Property("ReligionId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReligionId")); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("ReligionId"); + + b.ToTable("Religions"); + }); + + modelBuilder.Entity("Church.Net.Entity.Vocabulary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DefinitionCh") + .IsRequired() + .HasColumnType("text"); + + b.Property("DefinitionEn") + .IsRequired() + .HasColumnType("text"); + + b.Property("FlashCardTimes") + .HasColumnType("integer"); + + b.Property("ImagesUrl") + .HasColumnType("text"); + + b.Property("InsertDate") + .HasColumnType("timestamp with time zone"); + + b.Property("NounPlural") + .HasColumnType("text"); + + b.Property("PartOfSpeech") + .HasColumnType("integer"); + + b.Property("PracticeApply") + .HasColumnType("boolean"); + + b.Property("PracticeDate") + .HasColumnType("timestamp with time zone"); + + b.Property("PracticeMemorized") + .HasColumnType("boolean"); + + b.Property("PracticeReview") + .HasColumnType("boolean"); + + b.Property("PracticeSelect") + .HasColumnType("boolean"); + + b.Property("PracticeSentence") + .HasColumnType("text"); + + b.Property("PracticeStage") + .HasColumnType("integer"); + + b.Property("PracticeVisualize") + .HasColumnType("boolean"); + + b.Property("VerbParticiple") + .HasColumnType("text"); + + b.Property("VerbPast") + .HasColumnType("text"); + + b.Property("Word") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("Church.Net.Entity.WhoIsSpy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Answer1Chs") + .HasColumnType("text"); + + b.Property("Answer1Cht") + .HasColumnType("text"); + + b.Property("Answer1En") + .HasColumnType("text"); + + b.Property("Answer2Chs") + .HasColumnType("text"); + + b.Property("Answer2Cht") + .HasColumnType("text"); + + b.Property("Answer2En") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("WhoIsSpy"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEvent", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "CellGroupInfo") + .WithMany() + .HasForeignKey("PastoralDomainId"); + + b.Navigation("CellGroupInfo"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventAttendee", b => + { + b.HasOne("Church.Net.Entity.CellGroupRoutineEvent", "CellGroupRoutineEvent") + .WithMany("Attendees") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CellGroupRoutineEvent"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEventPrayer", b => + { + b.HasOne("Church.Net.Entity.CellGroupRoutineEvent", "CellGroupRoutineEvent") + .WithMany("Prayers") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CellGroupRoutineEvent"); + }); + + modelBuilder.Entity("Church.Net.Entity.Contribution", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "HappinessGroup") + .WithMany("Contributions") + .HasForeignKey("GroupId"); + + b.Navigation("HappinessGroup"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMember", b => + { + b.HasOne("Church.Net.Entity.Career", "Career") + .WithMany() + .HasForeignKey("CareerId"); + + b.Navigation("Career"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMemberOAuth", b => + { + b.HasOne("Church.Net.Entity.FamilyMember", null) + .WithMany("OAuthInfos") + .HasForeignKey("FamilyMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobLevelInfo", b => + { + b.HasOne("Church.Net.Entity.Games.MD2.MobInfo", "MobInfo") + .WithMany() + .HasForeignKey("MobInfoId"); + + b.HasOne("Church.Net.Entity.Games.MD2.MobInfo", null) + .WithMany("MobLevelInfos") + .HasForeignKey("MobInfoId2") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("MobInfo"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessBEST", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "HappinessGroup") + .WithMany("Bests") + .HasForeignKey("GroupId"); + + b.Navigation("HappinessGroup"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessCost", b => + { + b.HasOne("Church.Net.Entity.HappinessWeek", "HappinessWeek") + .WithMany("Costs") + .HasForeignKey("WeekId"); + + b.Navigation("HappinessWeek"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessTask", b => + { + b.HasOne("Church.Net.Entity.HappinessWeek", "HappinessWeek") + .WithMany("Tasks") + .HasForeignKey("WeekId"); + + b.Navigation("HappinessWeek"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessWeek", b => + { + b.HasOne("Church.Net.Entity.PastoralDomain", "HappinessGroup") + .WithMany("HappinessWeeks") + .HasForeignKey("GroupId"); + + b.Navigation("HappinessGroup"); + }); + + modelBuilder.Entity("Church.Net.Entity.NewVisitor", b => + { + b.HasOne("Church.Net.Entity.Religion", "Religion") + .WithMany() + .HasForeignKey("ReligionId"); + + b.Navigation("Religion"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomain", b => + { + b.HasOne("Church.Net.Entity.FamilyMember", "Leader") + .WithMany() + .HasForeignKey("LeaderMemberId"); + + b.HasOne("Church.Net.Entity.LineMessagingAccount", "LineMessagingAccount") + .WithMany() + .HasForeignKey("LineAccountId"); + + b.HasOne("Church.Net.Entity.AddressInfo", "ServiceAddress") + .WithMany() + .HasForeignKey("ServiceAddressId"); + + b.Navigation("Leader"); + + b.Navigation("LineMessagingAccount"); + + b.Navigation("ServiceAddress"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainAutoReplys", b => + { + b.HasOne("Church.Net.Entity.AutoReplyItem", "FamilyMember") + .WithMany("AutoReplyItemRelations") + .HasForeignKey("AutoReplyItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Church.Net.Entity.PastoralDomain", "PastoralDomain") + .WithMany("AutoReplyItemRelations") + .HasForeignKey("PastoralDomainCommunityAppId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FamilyMember"); + + b.Navigation("PastoralDomain"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomainMembers", b => + { + b.HasOne("Church.Net.Entity.FamilyMember", "FamilyMember") + .WithMany("PastoralDomains") + .HasForeignKey("FamilyMemberId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Church.Net.Entity.PastoralDomain", "PastoralDomain") + .WithMany("Members") + .HasForeignKey("PastoralDomainId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FamilyMember"); + + b.Navigation("PastoralDomain"); + }); + + modelBuilder.Entity("Church.Net.Entity.AutoReplyItem", b => + { + b.Navigation("AutoReplyItemRelations"); + }); + + modelBuilder.Entity("Church.Net.Entity.CellGroupRoutineEvent", b => + { + b.Navigation("Attendees"); + + b.Navigation("Prayers"); + }); + + modelBuilder.Entity("Church.Net.Entity.FamilyMember", b => + { + b.Navigation("OAuthInfos"); + + b.Navigation("PastoralDomains"); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobInfo", b => + { + b.Navigation("MobLevelInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.HappinessWeek", b => + { + b.Navigation("Costs"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Church.Net.Entity.PastoralDomain", b => + { + b.Navigation("AutoReplyItemRelations"); + + b.Navigation("Bests"); + + b.Navigation("Contributions"); + + b.Navigation("HappinessWeeks"); + + b.Navigation("Members"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Church.Net.DAL.EFCoreDBF/Migrations/20240502213603_AddMD2MobInfoUpdateId.cs b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213603_AddMD2MobInfoUpdateId.cs new file mode 100644 index 0000000..47f90c0 --- /dev/null +++ b/Church.Net.DAL.EFCoreDBF/Migrations/20240502213603_AddMD2MobInfoUpdateId.cs @@ -0,0 +1,168 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Church.Net.DAL.EFCoreDBF.Migrations +{ + public partial class AddMD2MobInfoUpdateId : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId", + table: "Md2MobLevelInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId1", + table: "Md2MobLevelInfos"); + + migrationBuilder.DropIndex( + name: "IX_Md2MobLevelInfos_MobInfoId1", + table: "Md2MobLevelInfos"); + + migrationBuilder.DropColumn( + name: "MobInfoId1", + table: "Md2MobLevelInfos"); + + migrationBuilder.AlterColumn( + name: "MobInfoId2", + table: "Md2MobLevelInfos", + type: "text", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "MobInfoId", + table: "Md2MobLevelInfos", + type: "text", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "Md2MobLevelInfos", + type: "text", + nullable: false, + defaultValueSql: "uuid_generate_v4()", + oldClrType: typeof(Guid), + oldType: "uuid", + oldDefaultValueSql: "uuid_generate_v4()"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "Md2MobInfos", + type: "text", + nullable: false, + defaultValueSql: "uuid_generate_v4()", + oldClrType: typeof(Guid), + oldType: "uuid", + oldDefaultValueSql: "uuid_generate_v4()"); + + migrationBuilder.CreateIndex( + name: "IX_Md2MobLevelInfos_MobInfoId2", + table: "Md2MobLevelInfos", + column: "MobInfoId2"); + + migrationBuilder.AddForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId", + table: "Md2MobLevelInfos", + column: "MobInfoId", + principalTable: "Md2MobInfos", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId2", + table: "Md2MobLevelInfos", + column: "MobInfoId2", + principalTable: "Md2MobInfos", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId", + table: "Md2MobLevelInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId2", + table: "Md2MobLevelInfos"); + + migrationBuilder.DropIndex( + name: "IX_Md2MobLevelInfos_MobInfoId2", + table: "Md2MobLevelInfos"); + + migrationBuilder.AlterColumn( + name: "MobInfoId2", + table: "Md2MobLevelInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MobInfoId", + table: "Md2MobLevelInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Id", + table: "Md2MobLevelInfos", + type: "uuid", + nullable: false, + defaultValueSql: "uuid_generate_v4()", + oldClrType: typeof(string), + oldType: "text", + oldDefaultValueSql: "uuid_generate_v4()"); + + migrationBuilder.AddColumn( + name: "MobInfoId1", + table: "Md2MobLevelInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AlterColumn( + name: "Id", + table: "Md2MobInfos", + type: "uuid", + nullable: false, + defaultValueSql: "uuid_generate_v4()", + oldClrType: typeof(string), + oldType: "text", + oldDefaultValueSql: "uuid_generate_v4()"); + + migrationBuilder.CreateIndex( + name: "IX_Md2MobLevelInfos_MobInfoId1", + table: "Md2MobLevelInfos", + column: "MobInfoId1"); + + migrationBuilder.AddForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId", + table: "Md2MobLevelInfos", + column: "MobInfoId", + principalTable: "Md2MobInfos", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Md2MobLevelInfos_Md2MobInfos_MobInfoId1", + table: "Md2MobLevelInfos", + column: "MobInfoId1", + principalTable: "Md2MobInfos", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Church.Net.DAL.EFCoreDBF/Migrations/ChurchNetContextModelSnapshot.cs b/Church.Net.DAL.EFCoreDBF/Migrations/ChurchNetContextModelSnapshot.cs index b4e9bb7..7138ac0 100644 --- a/Church.Net.DAL.EFCoreDBF/Migrations/ChurchNetContextModelSnapshot.cs +++ b/Church.Net.DAL.EFCoreDBF/Migrations/ChurchNetContextModelSnapshot.cs @@ -255,6 +255,46 @@ namespace Church.Net.DAL.EFCoreDBF.Migrations b.ToTable("FamilyMemberOAuths"); }); + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValueSql("uuid_generate_v4()"); + + b.Property("From") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Md2MobInfos"); + }); + + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobLevelInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValueSql("uuid_generate_v4()"); + + b.Property("MobInfoId") + .HasColumnType("text"); + + b.Property("MobInfoId2") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MobInfoId"); + + b.HasIndex("MobInfoId2"); + + b.ToTable("Md2MobLevelInfos"); + }); + modelBuilder.Entity("Church.Net.Entity.HappinessBEST", b => { b.Property("Id") @@ -769,6 +809,20 @@ namespace Church.Net.DAL.EFCoreDBF.Migrations .IsRequired(); }); + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobLevelInfo", b => + { + b.HasOne("Church.Net.Entity.Games.MD2.MobInfo", "MobInfo") + .WithMany() + .HasForeignKey("MobInfoId"); + + b.HasOne("Church.Net.Entity.Games.MD2.MobInfo", null) + .WithMany("MobLevelInfos") + .HasForeignKey("MobInfoId2") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("MobInfo"); + }); + modelBuilder.Entity("Church.Net.Entity.HappinessBEST", b => { b.HasOne("Church.Net.Entity.PastoralDomain", "HappinessGroup") @@ -892,6 +946,11 @@ namespace Church.Net.DAL.EFCoreDBF.Migrations b.Navigation("PastoralDomains"); }); + modelBuilder.Entity("Church.Net.Entity.Games.MD2.MobInfo", b => + { + b.Navigation("MobLevelInfos"); + }); + modelBuilder.Entity("Church.Net.Entity.HappinessWeek", b => { b.Navigation("Costs"); diff --git a/Church.Net.Entity2/Games/MD2/MobInfo.cs b/Church.Net.Entity2/Games/MD2/MobInfo.cs new file mode 100644 index 0000000..e08105c --- /dev/null +++ b/Church.Net.Entity2/Games/MD2/MobInfo.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Text; +using Newtonsoft.Json; +using Church.Net.Entity.Interface; + +namespace Church.Net.Entity.Games.MD2 +{ + public enum MobType + { + Mob, + RoamingMonster, + Boss + } + + public enum GameBundle + { + CoreGame, + HeavenFallen, + Zombiecide, + + } + public enum MobSkillType + { + Attack, + Defense, + Combat, + Passive + } + + public enum MobSkillTarget + { + LeastHp, + LeastMaxHp, + LeastMana, + LeastMaxMana, + } + public enum MD2Icon + { + Attack, + Defense, + Mana, + Shadow, + EnemySkill, + EnemyClaw, + Reroll, + Fire, + Frost, + OneHand, + TwoHand, + Helmet, + Armor, + Ring, + Foot, + Melee, + Range, + Magic, + HP, + MP, + Dice, + Arrow, + ArrowBullseye, + ArrowOverload, + SoulToken, + Rage, + RedDice, + BlueDice, + YellowDice, + OrangeDice, + BlackDice + } + public class MobInfo : IEntity + { + [Key] + public string Id { get; set; } + public MobType Type { get; set; } + public GameBundle From { get; set; } + public string Name { get; set; } + public string LeaderImgUrl { get; set; } + public string MinionImgUrl { get; set; } + public virtual ICollection MobLevelInfos { get; set; } + public virtual ICollection Skills { get; set; } + } + + + public class MobLevelInfo : IEntity + { + + [Key] + public string Id { get; set; } + [ForeignKey("MobInfo")] + public string MobInfoId { get; set; } + [JsonIgnore] + public virtual MobInfo MobInfo { get; set; } + public int RewardTokens { get; set; } + public int FixedRareTreasure { get; set; } + public int FixedEpicTreasure { get; set; } + public int FixedLegendTreasure { get; set; } + public int FixedHp { get; set; } + public int HpPerHero { get; set; } + public int Actions { get; set; } + + [ForeignKey("AttackInfo")] + public string AttackInfoId { get; set; } + public MD2DiceSet AttackInfo { get; set; } + [ForeignKey("DefenceInfo")] + public string DefenceInfoId { get; set; } + public MD2DiceSet DefenceInfo { get; set; } + public virtual ICollection Skills { get; set; } + + + } + public class MobSkill : IEntity + { + + [Key] + public string Id { get; set; } + [ForeignKey("MobLevelInfo")] + public string MobLevelInfoId { get; set; } + + [ForeignKey("MobInfo")] + public string MobInfoId { get; set; } + [JsonIgnore] + public virtual MobInfo MobInfo { get; set; } + + [JsonIgnore] + public virtual MobLevelInfo MobLevelInfo { get; set; } + + public MobSkillType Type { get; set; } + public int ClawRoll { get; set; } + public int SkillRoll { get; set; } + public string Name { get; set; } + public string Description { get; set; } + } + + public class MD2DiceSet : IEntity + { + [Key] + public string Id { get; set; } + public int? Yellow { get; set; } + public int? Orange { get; set; } + public int? Red { get; set; } + public int? Blue { get; set; } + public int? Green { get; set; } + public int? Black { get; set; } + } +} diff --git a/Church.Net.Entity2/Interface/IEntity.cs b/Church.Net.Entity2/Interface/IEntity.cs index 4ff893c..e97f131 100644 --- a/Church.Net.Entity2/Interface/IEntity.cs +++ b/Church.Net.Entity2/Interface/IEntity.cs @@ -11,4 +11,8 @@ namespace Church.Net.Entity.Interface public interface ICombinedKeyEntity { } + public interface IBussinessEntity + { + Guid Id { get; set; } + } } diff --git a/WebAPI/.config/dotnet-tools.json b/Church.Net.WebAPI/.config/dotnet-tools.json similarity index 100% rename from WebAPI/.config/dotnet-tools.json rename to Church.Net.WebAPI/.config/dotnet-tools.json diff --git a/Church.Net.WebAPI/App_Data/Files/BigTresureChest-Epic.jpg b/Church.Net.WebAPI/App_Data/Files/BigTresureChest-Epic.jpg new file mode 100644 index 0000000..d36befb Binary files /dev/null and b/Church.Net.WebAPI/App_Data/Files/BigTresureChest-Epic.jpg differ diff --git a/WebAPI/App_Data/LinePostLog.txt b/Church.Net.WebAPI/App_Data/LinePostLog.txt similarity index 100% rename from WebAPI/App_Data/LinePostLog.txt rename to Church.Net.WebAPI/App_Data/LinePostLog.txt diff --git a/WebAPI/App_Data/LinePostRawLog.txt b/Church.Net.WebAPI/App_Data/LinePostRawLog.txt similarity index 100% rename from WebAPI/App_Data/LinePostRawLog.txt rename to Church.Net.WebAPI/App_Data/LinePostRawLog.txt diff --git a/WebAPI/App_Data/ScaneMeQrCode.png b/Church.Net.WebAPI/App_Data/ScaneMeQrCode.png similarity index 100% rename from WebAPI/App_Data/ScaneMeQrCode.png rename to Church.Net.WebAPI/App_Data/ScaneMeQrCode.png diff --git a/WebAPI/App_Data/arial.ttf b/Church.Net.WebAPI/App_Data/arial.ttf similarity index 100% rename from WebAPI/App_Data/arial.ttf rename to Church.Net.WebAPI/App_Data/arial.ttf diff --git a/WebAPI/WebAPI.csproj b/Church.Net.WebAPI/Church.Net.WebAPI.csproj similarity index 93% rename from WebAPI/WebAPI.csproj rename to Church.Net.WebAPI/Church.Net.WebAPI.csproj index 0a08b40..938df0e 100644 --- a/WebAPI/WebAPI.csproj +++ b/Church.Net.WebAPI/Church.Net.WebAPI.csproj @@ -4,6 +4,7 @@ net6.0 983731f5-925d-44ec-b4c8-a7c4ad857569 Linux + 1.0.0.2 @@ -38,9 +39,10 @@ - + - + + diff --git a/WebAPI/Controllers/ApiControllerBase.cs b/Church.Net.WebAPI/Controllers/ApiControllerBase.cs similarity index 99% rename from WebAPI/Controllers/ApiControllerBase.cs rename to Church.Net.WebAPI/Controllers/ApiControllerBase.cs index 85dadc7..eb90cc1 100644 --- a/WebAPI/Controllers/ApiControllerBase.cs +++ b/Church.Net.WebAPI/Controllers/ApiControllerBase.cs @@ -143,4 +143,6 @@ namespace WebAPI.Controllers }); } } + + } diff --git a/WebAPI/Controllers/BestController.cs b/Church.Net.WebAPI/Controllers/BestController.cs similarity index 100% rename from WebAPI/Controllers/BestController.cs rename to Church.Net.WebAPI/Controllers/BestController.cs diff --git a/WebAPI/Controllers/CellGroupRoutineEventAttendeesController.cs b/Church.Net.WebAPI/Controllers/CellGroupRoutineEventAttendeesController.cs similarity index 100% rename from WebAPI/Controllers/CellGroupRoutineEventAttendeesController.cs rename to Church.Net.WebAPI/Controllers/CellGroupRoutineEventAttendeesController.cs diff --git a/WebAPI/Controllers/CellGroupRoutineEventsController.cs b/Church.Net.WebAPI/Controllers/CellGroupRoutineEventsController.cs similarity index 100% rename from WebAPI/Controllers/CellGroupRoutineEventsController.cs rename to Church.Net.WebAPI/Controllers/CellGroupRoutineEventsController.cs diff --git a/WebAPI/Controllers/ContributionController.cs b/Church.Net.WebAPI/Controllers/ContributionController.cs similarity index 100% rename from WebAPI/Controllers/ContributionController.cs rename to Church.Net.WebAPI/Controllers/ContributionController.cs diff --git a/Church.Net.WebAPI/Controllers/FileListController.cs b/Church.Net.WebAPI/Controllers/FileListController.cs new file mode 100644 index 0000000..e52c45e --- /dev/null +++ b/Church.Net.WebAPI/Controllers/FileListController.cs @@ -0,0 +1,42 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.IO; +using System.Linq; +using WebAPI; +using WebAPI.Services.Interfaces; + +namespace Church.Net.WebAPI.Controllers +{ + [Route("[controller]")] + [ApiController] + public class FileListController : ControllerBase + { + private readonly ILoggingService loggingService; + + public FileListController(ILoggingService loggingService) + { + this.loggingService = loggingService; + } + [HttpGet("{*filePath}")] + public ActionResult Get(string filePath) + { + string folderRootPath = ""; + string folderPath = ""; + try + { +#if DEBUG + folderRootPath = "//ArkNAS/docker/ChurchAPI/App_Data/Files"; +#else + folderRootPath = "/App_Data/Files"; +#endif + folderPath = System.IO.Path.Combine(folderRootPath, filePath); + return Directory.GetFiles(folderPath).Select(s=>s.Replace(folderRootPath,"").Replace(filePath, "").Replace("\\","/")).ToArray(); + } + catch (System.Exception ex) + { + loggingService.Error(ex); + return NotFound(); + } + } + } +} diff --git a/Church.Net.WebAPI/Controllers/FilesController.cs b/Church.Net.WebAPI/Controllers/FilesController.cs new file mode 100644 index 0000000..c7cc96d --- /dev/null +++ b/Church.Net.WebAPI/Controllers/FilesController.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.IO; +using WebAPI; +using WebAPI.Services.Interfaces; + +namespace Church.Net.WebAPI.Controllers +{ + [Route("[controller]")] + [ApiController] + public class FilesController : ControllerBase + { + private readonly ILoggingService loggingService; + + public FilesController(ILoggingService loggingService) + { + this.loggingService = loggingService; + } + [HttpGet("{*filePath}")] + public IActionResult Get(string filePath) + { + try + { + string folderRootPath = ""; +#if DEBUG + folderRootPath = "//ArkNAS/docker/ChurchAPI/App_Data/Files"; +#else + folderRootPath = "/App_Data/Files"; +#endif + + return PhysicalFile(System.IO.Path.Combine(folderRootPath, filePath), "image/jpeg"); + } + catch (System.Exception ex) + { + loggingService.Error(ex); + return NotFound(); + } + } + } +} diff --git a/Church.Net.WebAPI/Controllers/GameRoomController.cs b/Church.Net.WebAPI/Controllers/GameRoomController.cs new file mode 100644 index 0000000..604935d --- /dev/null +++ b/Church.Net.WebAPI/Controllers/GameRoomController.cs @@ -0,0 +1,57 @@ +using Church.Net.WebAPI.Models; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using WebAPI.Models.IceBreak; +using WebAPI; +using System.Linq; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace Church.Net.WebAPI.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class GameRoomController : ControllerBase + { + private readonly GameRoomLogic gameRoomLogic; + + public GameRoomController(GameRoomLogic gameRoomLogic) + { + this.gameRoomLogic = gameRoomLogic; + } + // GET: api/ + [HttpGet] + public IEnumerable Get() + { + return gameRoomLogic.GameRooms; + } + + // GET api//5 + [HttpGet("{id}")] + public IEnumerable Get(string roomId) + { + return gameRoomLogic.GameRooms.Where(r => r.Id == roomId).FirstOrDefault()?.Players; + } + + // POST api/ + [HttpPost] + public void Post([FromBody] GamePlayer gamePlayer) + { + gameRoomLogic.CreateGameRoom(gamePlayer); + } + + // PUT api//5 + [HttpPut("{roomId}")] + public bool Put(string roomId, [FromBody] GamePlayer value) + { + return gameRoomLogic.UserJoinGameRoom(roomId, value); + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(string id) + { + gameRoomLogic.UserLeave(new GamePlayer() { Id = id }); + } + } +} diff --git a/Church.Net.WebAPI/Controllers/GameRoomMessageController.cs b/Church.Net.WebAPI/Controllers/GameRoomMessageController.cs new file mode 100644 index 0000000..5e3b1d1 --- /dev/null +++ b/Church.Net.WebAPI/Controllers/GameRoomMessageController.cs @@ -0,0 +1,55 @@ +using Church.Net.WebAPI.Models; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Linq; +using WebAPI; +using WebAPI.Models.IceBreak; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace Church.Net.WebAPI.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class GameRoomMessageController : ControllerBase + { + private readonly GameRoomLogic gameRoomLogic; + + public GameRoomMessageController(GameRoomLogic gameRoomLogic) + { + this.gameRoomLogic = gameRoomLogic; + } + // GET: api/ + [HttpGet] + public IEnumerable Get() + { + return gameRoomLogic.GameRooms; + } + + // GET api//5 + [HttpGet("{id}")] + public IEnumerable Get(string roomId) + { + return gameRoomLogic.GameRooms.Where(r => r.Id == roomId).FirstOrDefault()?.Players; + } + + // POST api/ + [HttpPost] + public void Post([FromBody] SignalRMessage message) + { + gameRoomLogic.SendMessage(message); + } + + // PUT api//5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/WebAPI/Controllers/HappinessCostController.cs b/Church.Net.WebAPI/Controllers/HappinessCostController.cs similarity index 100% rename from WebAPI/Controllers/HappinessCostController.cs rename to Church.Net.WebAPI/Controllers/HappinessCostController.cs diff --git a/WebAPI/Controllers/HappinessWeekTaskController.cs b/Church.Net.WebAPI/Controllers/HappinessWeekTaskController.cs similarity index 100% rename from WebAPI/Controllers/HappinessWeekTaskController.cs rename to Church.Net.WebAPI/Controllers/HappinessWeekTaskController.cs diff --git a/WebAPI/Controllers/LineMessageController.cs b/Church.Net.WebAPI/Controllers/LineMessageController.cs similarity index 99% rename from WebAPI/Controllers/LineMessageController.cs rename to Church.Net.WebAPI/Controllers/LineMessageController.cs index b007cfc..b5991f7 100644 --- a/WebAPI/Controllers/LineMessageController.cs +++ b/Church.Net.WebAPI/Controllers/LineMessageController.cs @@ -23,8 +23,8 @@ using WebAPI.Services; using Jint.Native; using WebAPI.Services.Interfaces; using Church.Net.DAL.EFCoreDBF.Migrations; -using Church.Net.DAL.EFCoreDBF; using WebAPI.Logics; +using Church.Net.DAL.EFCoreDBF.Interface; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace WebAPI.Controllers diff --git a/WebAPI/Controllers/LineMessagingAccountController.cs b/Church.Net.WebAPI/Controllers/LineMessagingAccountController.cs similarity index 100% rename from WebAPI/Controllers/LineMessagingAccountController.cs rename to Church.Net.WebAPI/Controllers/LineMessagingAccountController.cs diff --git a/WebAPI/Controllers/LogController.cs b/Church.Net.WebAPI/Controllers/LogController.cs similarity index 100% rename from WebAPI/Controllers/LogController.cs rename to Church.Net.WebAPI/Controllers/LogController.cs diff --git a/Church.Net.WebAPI/Controllers/MD2Controller.cs b/Church.Net.WebAPI/Controllers/MD2Controller.cs new file mode 100644 index 0000000..e458a26 --- /dev/null +++ b/Church.Net.WebAPI/Controllers/MD2Controller.cs @@ -0,0 +1,19 @@ +using Church.Net.Entity; +using Church.Net.Entity.Games.MD2; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; +using System.Threading.Tasks; +using WebAPI.Logics.Interface; + +namespace WebAPI.Controllers +{ + [Route("[controller]/[action]")] + [ApiController] + public class MD2MobInfoController : ApiControllerBase + { + public MD2MobInfoController(ICrudLogic logic) : base(logic) + { + } + } +} diff --git a/WebAPI/Controllers/MemberController.cs b/Church.Net.WebAPI/Controllers/MemberController.cs similarity index 100% rename from WebAPI/Controllers/MemberController.cs rename to Church.Net.WebAPI/Controllers/MemberController.cs diff --git a/WebAPI/Controllers/NewVisitorController.cs b/Church.Net.WebAPI/Controllers/NewVisitorController.cs similarity index 100% rename from WebAPI/Controllers/NewVisitorController.cs rename to Church.Net.WebAPI/Controllers/NewVisitorController.cs diff --git a/WebAPI/Controllers/PasswordLoginController.cs b/Church.Net.WebAPI/Controllers/PasswordLoginController.cs similarity index 99% rename from WebAPI/Controllers/PasswordLoginController.cs rename to Church.Net.WebAPI/Controllers/PasswordLoginController.cs index d949707..03f666f 100644 --- a/WebAPI/Controllers/PasswordLoginController.cs +++ b/Church.Net.WebAPI/Controllers/PasswordLoginController.cs @@ -1,5 +1,5 @@ using Church.Net.DAL.EF; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Core; using Church.Net.Entity; using Church.Net.Utility; using Microsoft.AspNetCore.Mvc; diff --git a/WebAPI/Controllers/PastoralDomainController.cs b/Church.Net.WebAPI/Controllers/PastoralDomainController.cs similarity index 100% rename from WebAPI/Controllers/PastoralDomainController.cs rename to Church.Net.WebAPI/Controllers/PastoralDomainController.cs diff --git a/WebAPI/Controllers/PingController.cs b/Church.Net.WebAPI/Controllers/PingController.cs similarity index 100% rename from WebAPI/Controllers/PingController.cs rename to Church.Net.WebAPI/Controllers/PingController.cs diff --git a/Church.Net.WebAPI/Controllers/QRCodeController.cs b/Church.Net.WebAPI/Controllers/QRCodeController.cs new file mode 100644 index 0000000..726de3d --- /dev/null +++ b/Church.Net.WebAPI/Controllers/QRCodeController.cs @@ -0,0 +1,93 @@ +using Church.Net.Utility; +using Microsoft.AspNetCore.Mvc; +using QRCoder; +using SixLabors.Fonts; +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.Drawing.Processing; +using SixLabors.ImageSharp.Processing; +using System.IO; +using System.Threading.Tasks; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace Church.Net.WebAPI.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class QRCodeController : ControllerBase + { + // GET api//5 + [HttpGet] + public async Task Get(string content,int size) + { + + QRCodeGenerator gen = new QRCodeGenerator(); + QRCodeGenerator qrGenerator = new QRCodeGenerator(); + QRCodeData qrCodeData = qrGenerator.CreateQrCode(content, QRCodeGenerator.ECCLevel.Q); + QRCode qrCode = new QRCode(qrCodeData); + var qrCodeImage = qrCode.GetGraphic(size); + //string qrCodeImagePath = "/App_Data/ScaneMeQrCode.png"; + //var backgroundBitmap = SixLabors.ImageSharp.Image.Load(qrCodeImagePath); + //string qrCodeImagePath = Environment.GetEnvironmentVariable("AppData"); + //HttpContext.Current.Server.MapPath("~/App_Data/"); + //var fullPath = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/ScaneMeQrCode.png"); + //System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/yourXmlFile.xml"); + + //int positionLeft = 0; + //int positionTop = 0; + //var best = logic.GetById(id); + //if (best != null) + //{ + // using (var memoryStream = new MemoryStream()) + // { + // //fileStream.CopyTo(memoryStream); + // var image = Superimpose(best.Name, backgroundBitmap, qrCodeImage, 10, 32); + // image.Scalling(75); + // image.SaveAsPng(memoryStream); + // byte[] byteImage = memoryStream.ToArray(); + // return File(byteImage, "image/png"); + // } + //} + using (var memoryStream = new MemoryStream()) + { + qrCodeImage.SaveAsJpeg(memoryStream); + return File(memoryStream.ToArray(), "image/jpeg"); + } + + } + + + private Font arialFont; + [NonAction] + public Image Superimpose(string bestName, Image largeBmp, Image smallBmp, int? x = null, int? y = null) + { + FontCollection collection = new(); + FontFamily family = collection.Add("/App_Data/arial.ttf"); + arialFont = family.CreateFont(12, FontStyle.Italic); + //Graphics g = Graphics.FromImage(largeBmp); + //g.CompositingMode = CompositingMode.SourceOver; + //smallBmp.MakeTransparent(); + int margin = 5; + if (!x.HasValue) + { + x = largeBmp.Width - smallBmp.Width - margin; + } + if (!y.HasValue) + { + y = largeBmp.Height - smallBmp.Height - margin; + } + var scale = 0.8; + var scaleWidth = (int)(smallBmp.Width * scale); + var scaleHeight = (int)(smallBmp.Height * scale); + + + largeBmp.Mutate(x => x.DrawText(bestName, arialFont, Color.Black, new PointF(10, 10))); + + smallBmp.Scalling(80); + + largeBmp.Mutate(ctx => ctx.DrawImage(smallBmp, new Point(x.Value, y.Value), 1f)); + return largeBmp; + } + + } +} diff --git a/Church.Net.WebAPI/Controllers/VersionController.cs b/Church.Net.WebAPI/Controllers/VersionController.cs new file mode 100644 index 0000000..664c664 --- /dev/null +++ b/Church.Net.WebAPI/Controllers/VersionController.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace WebAPI.Controllers +{ + [ApiController] + [Route("[controller]")] + public class VersionController : ControllerBase + { + + [HttpGet] + public string Get() + { + System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); + System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); + string version = fvi.FileVersion; + return version; + } + } +} diff --git a/WebAPI/Controllers/WeatherForecastController.cs b/Church.Net.WebAPI/Controllers/WeatherForecastController.cs similarity index 100% rename from WebAPI/Controllers/WeatherForecastController.cs rename to Church.Net.WebAPI/Controllers/WeatherForecastController.cs diff --git a/WebAPI/Controllers/WhoIsSpyController.cs b/Church.Net.WebAPI/Controllers/WhoIsSpyController.cs similarity index 100% rename from WebAPI/Controllers/WhoIsSpyController.cs rename to Church.Net.WebAPI/Controllers/WhoIsSpyController.cs diff --git a/WebAPI/Dockerfile b/Church.Net.WebAPI/Dockerfile similarity index 62% rename from WebAPI/Dockerfile rename to Church.Net.WebAPI/Dockerfile index ce0f637..af9cf8c 100644 --- a/WebAPI/Dockerfile +++ b/Church.Net.WebAPI/Dockerfile @@ -7,19 +7,19 @@ EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -COPY ["WebAPI/WebAPI.csproj", "WebAPI/"] +COPY ["Church.Net.WebAPI/Church.Net.WebAPI.csproj", "Church.Net.WebAPI/"] COPY ["Church.Net.DAL.EFCoreDBF/Church.Net.DAL.EFCoreDBF.csproj", "Church.Net.DAL.EFCoreDBF/"] COPY ["Church.Net.Entity2/Church.Net.Entity.csproj", "Church.Net.Entity/"] COPY ["Church.Net.Utility/Church.Net.Utility.csproj", "Church.Net.Utility/"] -RUN dotnet restore "WebAPI/WebAPI.csproj" +RUN dotnet restore "Church.Net.WebAPI/Church.Net.WebAPI.csproj" COPY . . -WORKDIR "/src/WebAPI" -RUN dotnet build "WebAPI.csproj" -c Release -o /app/build +WORKDIR "/src/Church.Net.WebAPI" +RUN dotnet build "Church.Net.WebAPI.csproj" -c Release -o /app/build FROM build AS publish -RUN dotnet publish "WebAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false +RUN dotnet publish "Church.Net.WebAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "WebAPI.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "Church.Net.WebAPI.dll"] \ No newline at end of file diff --git a/Church.Net.WebAPI/GameRoomLogic.cs b/Church.Net.WebAPI/GameRoomLogic.cs new file mode 100644 index 0000000..87083da --- /dev/null +++ b/Church.Net.WebAPI/GameRoomLogic.cs @@ -0,0 +1,141 @@ +using Church.Net.WebAPI.Models; +using Jint.Native; +using Microsoft.AspNetCore.SignalR; +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebAPI.Hubs; +using WebAPI.Models.IceBreak; +using WebAPI.Services.Interfaces; + +namespace WebAPI +{ + public class GameRoomLogic + { + public List OnlinePlayers { get; set; } + private readonly IHubContext gameHubContext; + + public GameRoomLogic( + IHubContext GameHubContext + ) + { + gameHubContext = GameHubContext; + GameRooms = new List(); + OnlinePlayers = new List(); + } + public List GameRooms { get; set; } + public void CreateGameRoom(IGamePlayer gamePlayer) + { + if (!this.GameRooms.Any(g => g.Id == gamePlayer.Id)) + { + this.GameRooms.Add(new GameRoom() + { + Id = gamePlayer.Id, + Name = gamePlayer.Name, + SignalRClientId = gamePlayer.SignalRClientId, + }); + } + else + { + var existingRoom = this.GameRooms.FirstOrDefault(g => g.Id == gamePlayer.Id); + existingRoom.SignalRClientId = gamePlayer.SignalRClientId; + } + //this.OnlinePlayers.FirstOrDefault(p => p.SignalRClientId == gamePlayer.SignalRClientId).GameRoomId = gamePlayer.Id; + //gameHubContext.Groups.AddToGroupAsync(gamePlayer.SignalRClientId, gamePlayer.Id); + } + + public bool UserJoinGameRoom(string gameRoomId, IGamePlayer gamePlayer) + { + //this.OnlinePlayers.FirstOrDefault(p => p.SignalRClientId == gamePlayer.SignalRClientId) + // .GameRoomId = gameRoomId; + //if (GameRooms.Any(g => g.Id == gameRoomId)) + //{ + // //Make sure user not exist in other room + // UserLeave(gamePlayer); + + //} + + var gameRoom = GameRooms.FirstOrDefault(r => r.Id == gameRoomId); + if (gameRoom == null) + { + CreateGameRoom(gamePlayer); + } + if (gameRoom != null) + { + //gameHubContext.Groups.AddToGroupAsync(gamePlayer.SignalRClientId, gameRoomId); + gameRoom.Players.Add(gamePlayer); + var message = new SignalRMessage(new SignalRSession(gameRoomId, "", true), "GameRoom", "Join"); + message.From = new SignalRSession(gamePlayer.SignalRClientId, gamePlayer.Name); + SendMessage(message); + return true; + } + return false; + } + public void UserLeave(IGamePlayer gamePlayer) + { + //foreach (var room in GameRooms) + //{ + // if (room.Id == gamePlayer.SignalRClientId) + // { + // GameRooms.Remove(room); + // break; + + // } + // if (room.Players.Any(p => p.Id == gamePlayer.Id)) + // { + // room.Players.Remove(room.Players.FirstOrDefault(p => p.Id == gamePlayer.Id)); + // var message = new SignalRMessage(new SignalRSession(room.Id, "", true), "GameRoom", "Leaving"); + // message.From = new SignalRSession(gamePlayer.SignalRClientId, gamePlayer.Name); + // SendMessage(message); + // break; + // } + //} + if (!string.IsNullOrWhiteSpace(gamePlayer.GameRoomId)) + { + //gameHubContext.Groups.RemoveFromGroupAsync(gamePlayer.SignalRClientId, gamePlayer.GameRoomId); + var message = new SignalRMessage(new SignalRSession(gamePlayer.GameRoomId, "", true), "GameRoom", "Leaving"); + message.From = new SignalRSession(gamePlayer.TabId, gamePlayer.Name); + SendMessage(message); + } + } + public void BrodcastMessage(GameRoom room) + { + } + + public void SendMessage(SignalRMessage message) + { + string jsonString = JsonConvert.SerializeObject(message, new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver(), + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + //DateTimeZoneHandling = DateTimeZoneHandling.Local + }); + if (message.Receiver.IsGroup) + { + //this.gameHubContext.Clients.Clients( + // this.GameRooms.FirstOrDefault(g => g.Id == message.Receiver.SessionId).Players.Select(p => p.Id)) + // .SendAsync("ReceivedMessage", jsonString); + //this.gameHubContext.Clients.All.SendAsync("ReceivedMessage", jsonString); + + gameHubContext.Clients.Group(message.Receiver.SessionId).SendAsync("ReceivedMessage", jsonString); + + + } + else + { + gameHubContext.Clients.Client(message.Receiver.SessionId).SendAsync("ReceivedMessage", jsonString); + + } + + } + + public bool GetOnlinePlayerByTabId(string tabId,out IGamePlayer gamePlayer) + { + gamePlayer= this.OnlinePlayers.FirstOrDefault(p => p.TabId == tabId); + return gamePlayer != null; + } + } +} diff --git a/WebAPI/HandleExceptionFilter.cs b/Church.Net.WebAPI/HandleExceptionFilter.cs similarity index 100% rename from WebAPI/HandleExceptionFilter.cs rename to Church.Net.WebAPI/HandleExceptionFilter.cs diff --git a/WebAPI/Handlers/BasicAuthorizationMiddlewareResultHandler.cs b/Church.Net.WebAPI/Handlers/BasicAuthorizationMiddlewareResultHandler.cs similarity index 100% rename from WebAPI/Handlers/BasicAuthorizationMiddlewareResultHandler.cs rename to Church.Net.WebAPI/Handlers/BasicAuthorizationMiddlewareResultHandler.cs diff --git a/WebAPI/Hubs/AvalonHub.cs b/Church.Net.WebAPI/Hubs/AvalonHub.cs similarity index 100% rename from WebAPI/Hubs/AvalonHub.cs rename to Church.Net.WebAPI/Hubs/AvalonHub.cs diff --git a/WebAPI/Hubs/BaseHub.cs b/Church.Net.WebAPI/Hubs/BaseHub.cs similarity index 100% rename from WebAPI/Hubs/BaseHub.cs rename to Church.Net.WebAPI/Hubs/BaseHub.cs diff --git a/Church.Net.WebAPI/Hubs/GameRoomHub.cs b/Church.Net.WebAPI/Hubs/GameRoomHub.cs new file mode 100644 index 0000000..7a97a24 --- /dev/null +++ b/Church.Net.WebAPI/Hubs/GameRoomHub.cs @@ -0,0 +1,121 @@ + +using Church.Net.WebAPI.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.SignalR; +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebAPI.Models.IceBreak; +using System.Diagnostics; +using System.Text.RegularExpressions; + +namespace WebAPI.Hubs +{ + public class GameRoomHub : Hub + { + private readonly GameRoomLogic gameRoomLogic; + + public GameRoomHub(GameRoomLogic gameRoomLogic) + { + this.gameRoomLogic = gameRoomLogic; + } + + public void SendMessage(SignalRMessage message) + { + string jsonString = JsonConvert.SerializeObject(message, new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver(), + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + //DateTimeZoneHandling = DateTimeZoneHandling.Local + }); + Task.Run(() => + { + if (message.Receiver.IsGroup) + { + Clients.Group(message.Receiver.SessionId).SendAsync("ReceivedMessage", jsonString); + } + else + { + Clients.Client(message.Receiver.SessionId).SendAsync("ReceivedMessage", jsonString); + + } + + }); + + } + + public override Task OnConnectedAsync() + { + var playerInfo = GetPlayerInfoFromRequest(); + //var gameHostName = Context.GetHttpContext().Request.Query["gameHostName"]; + //if (false==string.IsNullOrWhiteSpace(gameHostName)) + //{ + + //} + //var groupId = Context.GetHttpContext().Request.Query["groupId"]; + //Groups.AddToGroupAsync(Context.ConnectionId, groupId); + Debug.WriteLine($"{playerInfo.Name}({playerInfo.Id}) Conection Id:{playerInfo.SignalRClientId}"); + + if (!string.IsNullOrWhiteSpace(playerInfo.TabId)) + { + if (gameRoomLogic.GetOnlinePlayerByTabId(playerInfo.TabId, out IGamePlayer gamePlayer)) + { + gamePlayer.SignalRClientId = Context.ConnectionId; + } + else + { + gameRoomLogic.OnlinePlayers.Add(playerInfo); + } + } + + + if (!string.IsNullOrWhiteSpace(playerInfo.GameRoomId)) + { + Groups.AddToGroupAsync(Context.ConnectionId, playerInfo.GameRoomId); + } + + + this.SendMessage(new SignalRMessage(new SignalRSession(playerInfo.SignalRClientId, ""), "GameRoom", "sendJoinInfo").AddParameter("signalRConnId", Context.ConnectionId)); + + return base.OnConnectedAsync(); + } + + public override Task OnDisconnectedAsync(Exception exception) + { + + var playerInfo = GetPlayerInfoFromRequest(); + Debug.WriteLine($"{playerInfo.Name}({playerInfo.Id}) Conection Id:{playerInfo.SignalRClientId} Disconnected"); + //var groupId = Context.GetHttpContext().Request.Query["groupId"]; + //Groups.RemoveFromGroupAsync(Context.ConnectionId, groupId); + if (!string.IsNullOrWhiteSpace(playerInfo.GameRoomId)) + { + Groups.RemoveFromGroupAsync(Context.ConnectionId, playerInfo.GameRoomId); + } + + if (!string.IsNullOrWhiteSpace(playerInfo.TabId)) + { + gameRoomLogic.UserLeave(playerInfo); + gameRoomLogic.OnlinePlayers.RemoveAll(u => u.TabId == playerInfo.TabId); + } + return base.OnDisconnectedAsync(exception); + } + private GamePlayer GetPlayerInfoFromRequest() + { + var playerId = Context.GetHttpContext().Request.Query["userId"]; + var username = Context.GetHttpContext().Request.Query["username"]; + var playerTabId = Context.GetHttpContext().Request.Query["tabId"]; + var roomId = Context.GetHttpContext().Request.Query["roomId"]; + return new GamePlayer() + { + Id = playerId, + SignalRClientId = Context.ConnectionId, + Name = username, + TabId = playerTabId, + GameRoomId = roomId, + }; + } + } +} diff --git a/WebAPI/Hubs/WhoIsSpyHub.cs b/Church.Net.WebAPI/Hubs/WhoIsSpyHub.cs similarity index 100% rename from WebAPI/Hubs/WhoIsSpyHub.cs rename to Church.Net.WebAPI/Hubs/WhoIsSpyHub.cs diff --git a/WebAPI/Logics/Core/CombinedKeyLogicBase.cs b/Church.Net.WebAPI/Logics/Core/CombinedKeyLogicBase.cs similarity index 98% rename from WebAPI/Logics/Core/CombinedKeyLogicBase.cs rename to Church.Net.WebAPI/Logics/Core/CombinedKeyLogicBase.cs index 9e0510e..fcbd5ef 100644 --- a/WebAPI/Logics/Core/CombinedKeyLogicBase.cs +++ b/Church.Net.WebAPI/Logics/Core/CombinedKeyLogicBase.cs @@ -7,7 +7,7 @@ using System.Linq; using Church.Net.Utility; using System.Threading.Tasks; using WebAPI.Logics.Interface; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; namespace WebAPI.Logics.Core { diff --git a/WebAPI/Logics/Core/LogicBase.cs b/Church.Net.WebAPI/Logics/Core/LogicBase.cs similarity index 98% rename from WebAPI/Logics/Core/LogicBase.cs rename to Church.Net.WebAPI/Logics/Core/LogicBase.cs index b934590..674e141 100644 --- a/WebAPI/Logics/Core/LogicBase.cs +++ b/Church.Net.WebAPI/Logics/Core/LogicBase.cs @@ -7,7 +7,7 @@ using System.Linq; using Church.Net.Utility; using System.Threading.Tasks; using WebAPI.Logics.Interface; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; namespace WebAPI.Logics.Core { diff --git a/WebAPI/Logics/Core/LogicService.cs b/Church.Net.WebAPI/Logics/Core/LogicService.cs similarity index 100% rename from WebAPI/Logics/Core/LogicService.cs rename to Church.Net.WebAPI/Logics/Core/LogicService.cs diff --git a/WebAPI/Logics/Interface/ICrudLogic.cs b/Church.Net.WebAPI/Logics/Interface/ICrudLogic.cs similarity index 100% rename from WebAPI/Logics/Interface/ICrudLogic.cs rename to Church.Net.WebAPI/Logics/Interface/ICrudLogic.cs diff --git a/WebAPI/Logics/LineMessagingAccountLogic.cs b/Church.Net.WebAPI/Logics/LineMessagingAccountLogic.cs similarity index 96% rename from WebAPI/Logics/LineMessagingAccountLogic.cs rename to Church.Net.WebAPI/Logics/LineMessagingAccountLogic.cs index 07218af..d865f98 100644 --- a/WebAPI/Logics/LineMessagingAccountLogic.cs +++ b/Church.Net.WebAPI/Logics/LineMessagingAccountLogic.cs @@ -1,4 +1,4 @@ -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using Church.Net.Entity.Interface; using System; diff --git a/WebAPI/Logics/MemberLogic.cs b/Church.Net.WebAPI/Logics/MemberLogic.cs similarity index 92% rename from WebAPI/Logics/MemberLogic.cs rename to Church.Net.WebAPI/Logics/MemberLogic.cs index a30c1cd..1cc089b 100644 --- a/WebAPI/Logics/MemberLogic.cs +++ b/Church.Net.WebAPI/Logics/MemberLogic.cs @@ -1,4 +1,4 @@ -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using WebAPI.Logics.Core; using WebAPI.Logics.Interface; diff --git a/WebAPI/Logics/PastoralDomainLogic.cs b/Church.Net.WebAPI/Logics/PastoralDomainLogic.cs similarity index 99% rename from WebAPI/Logics/PastoralDomainLogic.cs rename to Church.Net.WebAPI/Logics/PastoralDomainLogic.cs index 88500c8..21c9366 100644 --- a/WebAPI/Logics/PastoralDomainLogic.cs +++ b/Church.Net.WebAPI/Logics/PastoralDomainLogic.cs @@ -1,5 +1,4 @@ -using Church.Net.DAL.EFCoreDBF; -using Church.Net.Entity; +using Church.Net.Entity; using Church.Net.Utility; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; @@ -9,6 +8,7 @@ using WebAPI.Logics.Interface; using System.Linq; using Microsoft.Extensions.DependencyInjection; using System.Text.RegularExpressions; +using Church.Net.DAL.EFCoreDBF.Interface; namespace WebAPI.Logics { diff --git a/WebAPI/Logics/VideoDownloadLogic.cs b/Church.Net.WebAPI/Logics/VideoDownloadLogic.cs similarity index 100% rename from WebAPI/Logics/VideoDownloadLogic.cs rename to Church.Net.WebAPI/Logics/VideoDownloadLogic.cs diff --git a/WebAPI/Models/IceBreak.cs b/Church.Net.WebAPI/Models/IceBreak.cs similarity index 72% rename from WebAPI/Models/IceBreak.cs rename to Church.Net.WebAPI/Models/IceBreak.cs index c7afc57..b45379a 100644 --- a/WebAPI/Models/IceBreak.cs +++ b/Church.Net.WebAPI/Models/IceBreak.cs @@ -11,20 +11,32 @@ namespace WebAPI.Models.IceBreak WereWolf, WhoIsSpy } - public class GameRoom + + public interface IGameRoom + { + string Id { get; set; } + string Name { get; set; } + List Players { get; set; } + int TotalPlayer { get; } + string SignalRClientId { get; set; } + } + + public class GameRoom : IGameRoom { GameType Type { get; set; } public string Id { get; set; } - private List _players; + public string SignalRClientId { get; set; } + public string Name { get; set; } + private List _players; public int TotalPlayer => Players.Count; - public List Players + public List Players { get { if (_players == null) { - _players = new List(); + _players = new List(); } @@ -35,12 +47,26 @@ namespace WebAPI.Models.IceBreak } - public class GamePlayer + public interface IGamePlayer { public string Id { get; set; } + public string SignalRClientId { get; set; } + public string TabId { get; set; } [Required] public string Name { get; set; } - public string TempGameRoomId { get; set; } + public string GameRoomId { get; set; } + public bool IsPlayer { get; set; } + } + + public class GamePlayer : IGamePlayer + { + public string Id { get; set; } + public string SignalRClientId { get; set; } + public string TabId { get; set; } + [Required] + public string Name { get; set; } + public string GameRoomId { get; set; } + public bool IsPlayer { get; set; } } @@ -54,7 +80,7 @@ namespace WebAPI.Models.IceBreak Closed } - public class WhoIsSpyGameRoom : GameRoom + public class WhoIsSpyGameRoom : GameRoom, IGameRoom { public WhoIsSpyGameRoom() { @@ -76,12 +102,10 @@ namespace WebAPI.Models.IceBreak public List PlayedAnswerId { get; set; } public int VoteAmount { get; set; } } - public class WhoIsSpyPlayer + public class WhoIsSpyPlayer : GamePlayer, IGamePlayer { - public string Id { get; set; } public string RoomId { get; set; } public int Seed { get; set; } - public string Name { get; set; } public WhoIsSpyAnswer Answer { get; set; } public bool IsSpy { get; set; } public bool IsDead { get; set; } diff --git a/Church.Net.WebAPI/Models/SigmalRMessage.cs b/Church.Net.WebAPI/Models/SigmalRMessage.cs new file mode 100644 index 0000000..c31886b --- /dev/null +++ b/Church.Net.WebAPI/Models/SigmalRMessage.cs @@ -0,0 +1,72 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Church.Net.WebAPI.Models +{ + + public class SignalRMessage + { + public SignalRSession From { get; set; } + public SignalRSession Receiver { get; set; } + public string ActionType { get; set; } + public string ActionName { get; set; } + public Dictionary Parameters { get; set; } + public string JsonValue { get; set; } + [JsonIgnore] + public object Value { get; set; } + public SignalRMessage() + { + Parameters = new Dictionary(); + + } + + public SignalRMessage(SignalRSession receiver, string actionType, string actionName = null, object value = null) + { + Parameters = new Dictionary(); + this.Receiver = receiver; + ActionType = actionType; + ActionName = actionName; + Value = value; + } + public SignalRMessage AddParameter(string key, string value) + { + if (!string.IsNullOrEmpty(key)) + { + key = key.ToLower(); + if (Parameters.ContainsKey(key)) + { + Parameters[key] = value; + } + else + { + Parameters.Add(key, value); + } + } + + return this; + } + public string GetParameter(string key) + { + return Parameters[key.ToLower()]; + } + } + + public class SignalRSession + { + public SignalRSession() + { + + } + + public SignalRSession(string sessionId, string name, bool isGroup = false) + { + SessionId = sessionId; + Name = name; + IsGroup = isGroup; + } + + public string SessionId { get; set; } + public string Name { get; set; } + public bool IsGroup { get; set; } + } +} diff --git a/Church.Net.WebAPI/Program.cs b/Church.Net.WebAPI/Program.cs new file mode 100644 index 0000000..0b41bec --- /dev/null +++ b/Church.Net.WebAPI/Program.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using DotNetTools.SharpGrabber.Grabbed; +using DotNetTools.SharpGrabber; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using DotNetTools.SharpGrabber.Converter; + +namespace WebAPI +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } + //public static class Program + //{ + // private static readonly HttpClient Client = new HttpClient(); + // private static readonly HashSet TempFiles = new HashSet(); + + // public static async Task Main(string[] args) + // { + // var grabber = GrabberBuilder.New() + // .UseDefaultServices() + // .AddYouTube() + // .Build(); + + // Console.WriteLine("Enter FFMPEG path:"); + // var ffmpegPath = Console.ReadLine().Trim(); + // FFmpeg.AutoGen.ffmpeg.RootPath = ffmpegPath; + + // Console.WriteLine("Enter a YouTube URL:"); + // var url = Console.ReadLine(); + // if (url == null) + // return; + + // var result = await grabber.GrabAsync(new Uri(url, UriKind.Absolute)); + + // var audioStream = ChooseMonoMedia(result, MediaChannels.Audio); + // //var videoStream = ChooseMonoMedia(result, MediaChannels.Video); + // if (audioStream == null) + // throw new InvalidOperationException("No audio stream detected."); + // //if (videoStream == null) + // // throw new InvalidOperationException("No video stream detected."); + + // try + // { + // var audioPath = await DownloadMedia(audioStream, result); + // //var videoPath = await DownloadMedia(videoStream, result); + // GenerateOutputFile(audioPath); + // } + // finally + // { + // foreach (var tempFile in TempFiles) + // { + // try + // { + // File.Delete(tempFile); + // } + // catch (Exception) + // { + // // ignored + // } + // } + // } + // } + + // private static void GenerateOutputFile(string audioPath) + // { + // Console.WriteLine("Output Path:"); + // var outputPath = Console.ReadLine(); + // if (string.IsNullOrWhiteSpace(outputPath)) + // throw new Exception("No output path is specified."); + // var merger = new MediaMerger(outputPath); + // merger.AddStreamSource(audioPath, MediaStreamType.Audio); + // //merger.AddStreamSource(videoPath, MediaStreamType.Video); + // merger.OutputMimeType = "audio/mp3";//videoStream.Format.Mime; + // merger.OutputShortName = "mp3";//videoStream.Format.Extension; + + // merger.Build(); + // Console.WriteLine($"Output file successfully created."); + // } + + // private static GrabbedMedia ChooseMonoMedia(GrabResult result, MediaChannels channel) + // { + // var resources = result.Resources() + // .Where(m => m.Channels == channel) + // .ToList(); + + // if (resources.Count == 0) + // return null; + + // for (var i = 0; i < resources.Count; i++) + // { + // var resource = resources[i]; + // Console.WriteLine($"{i}. {resource.Title ?? resource.FormatTitle ?? resource.Resolution}"); + // } + + // while (true) + // { + // Console.Write($"Choose the {channel} file: "); + // var choiceStr = Console.ReadLine(); + // if (!int.TryParse(choiceStr, out var choice)) + // { + // Console.WriteLine("Number expected."); + // continue; + // } + + // if (choice < 0 || choice >= resources.Count) + // { + // Console.WriteLine("Invalid number."); + // continue; + // } + + // return resources[choice]; + // } + // } + + // private static async Task DownloadMedia(GrabbedMedia media, IGrabResult grabResult) + // { + // Console.WriteLine("Downloading {0}...", media.Title ?? media.FormatTitle ?? media.Resolution); + // Console.WriteLine(media.ResourceUri); + // Client.Timeout=TimeSpan.FromSeconds(200); + // using var response = await Client.GetAsync(media.ResourceUri); + // response.EnsureSuccessStatusCode(); + // using var downloadStream = await response.Content.ReadAsStreamAsync(); + // using var resourceStream = await grabResult.WrapStreamAsync(downloadStream); + // var path = Path.GetTempFileName(); + + // using var fileStream = new FileStream(path, FileMode.Create); + // TempFiles.Add(path); + // await resourceStream.CopyToAsync(fileStream); + // return path; + // } + //} +} diff --git a/WebAPI/Properties/launchSettings.json b/Church.Net.WebAPI/Properties/launchSettings.json similarity index 100% rename from WebAPI/Properties/launchSettings.json rename to Church.Net.WebAPI/Properties/launchSettings.json diff --git a/WebAPI/ServerUtils.cs b/Church.Net.WebAPI/ServerUtils.cs similarity index 100% rename from WebAPI/ServerUtils.cs rename to Church.Net.WebAPI/ServerUtils.cs diff --git a/WebAPI/Services/AutoReplyCommands/ArArkCellGroupDinner.cs b/Church.Net.WebAPI/Services/AutoReplyCommands/ArArkCellGroupDinner.cs similarity index 100% rename from WebAPI/Services/AutoReplyCommands/ArArkCellGroupDinner.cs rename to Church.Net.WebAPI/Services/AutoReplyCommands/ArArkCellGroupDinner.cs diff --git a/WebAPI/Services/AutoReplyCommands/ArArkCellGroupInfo.cs b/Church.Net.WebAPI/Services/AutoReplyCommands/ArArkCellGroupInfo.cs similarity index 100% rename from WebAPI/Services/AutoReplyCommands/ArArkCellGroupInfo.cs rename to Church.Net.WebAPI/Services/AutoReplyCommands/ArArkCellGroupInfo.cs diff --git a/WebAPI/Services/AutoReplyCommands/ArArkCellGroupPrayer.cs b/Church.Net.WebAPI/Services/AutoReplyCommands/ArArkCellGroupPrayer.cs similarity index 100% rename from WebAPI/Services/AutoReplyCommands/ArArkCellGroupPrayer.cs rename to Church.Net.WebAPI/Services/AutoReplyCommands/ArArkCellGroupPrayer.cs diff --git a/WebAPI/Services/AutoReplyCommands/ArChurchInfo.cs b/Church.Net.WebAPI/Services/AutoReplyCommands/ArChurchInfo.cs similarity index 100% rename from WebAPI/Services/AutoReplyCommands/ArChurchInfo.cs rename to Church.Net.WebAPI/Services/AutoReplyCommands/ArChurchInfo.cs diff --git a/WebAPI/Services/AutoReplyCommands/ArHappinessBEST.cs b/Church.Net.WebAPI/Services/AutoReplyCommands/ArHappinessBEST.cs similarity index 100% rename from WebAPI/Services/AutoReplyCommands/ArHappinessBEST.cs rename to Church.Net.WebAPI/Services/AutoReplyCommands/ArHappinessBEST.cs diff --git a/WebAPI/Services/AutoReplyCommands/ArHappinessGroupTask.cs b/Church.Net.WebAPI/Services/AutoReplyCommands/ArHappinessGroupTask.cs similarity index 100% rename from WebAPI/Services/AutoReplyCommands/ArHappinessGroupTask.cs rename to Church.Net.WebAPI/Services/AutoReplyCommands/ArHappinessGroupTask.cs diff --git a/WebAPI/Services/DbLoggingService.cs b/Church.Net.WebAPI/Services/DbLoggingService.cs similarity index 99% rename from WebAPI/Services/DbLoggingService.cs rename to Church.Net.WebAPI/Services/DbLoggingService.cs index 7ab9ba0..dc42fb1 100644 --- a/WebAPI/Services/DbLoggingService.cs +++ b/Church.Net.WebAPI/Services/DbLoggingService.cs @@ -5,9 +5,9 @@ using WebAPI.Services.Interfaces; using System.Diagnostics; using Church.Net.Entity; using Church.Net.Entity.Interface; -using Church.Net.DAL.EFCoreDBF; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; +using Church.Net.DAL.EFCoreDBF.Interface; namespace WebAPI.Services { diff --git a/WebAPI/Services/IdentityService.cs b/Church.Net.WebAPI/Services/IdentityService.cs similarity index 100% rename from WebAPI/Services/IdentityService.cs rename to Church.Net.WebAPI/Services/IdentityService.cs diff --git a/WebAPI/Services/Interfaces/IAutoReplyCommand.cs b/Church.Net.WebAPI/Services/Interfaces/IAutoReplyCommand.cs similarity index 100% rename from WebAPI/Services/Interfaces/IAutoReplyCommand.cs rename to Church.Net.WebAPI/Services/Interfaces/IAutoReplyCommand.cs diff --git a/WebAPI/Services/Interfaces/ILoggingService.cs b/Church.Net.WebAPI/Services/Interfaces/ILoggingService.cs similarity index 100% rename from WebAPI/Services/Interfaces/ILoggingService.cs rename to Church.Net.WebAPI/Services/Interfaces/ILoggingService.cs diff --git a/WebAPI/Services/Interfaces/IScheduledTask.cs b/Church.Net.WebAPI/Services/Interfaces/IScheduledTask.cs similarity index 100% rename from WebAPI/Services/Interfaces/IScheduledTask.cs rename to Church.Net.WebAPI/Services/Interfaces/IScheduledTask.cs diff --git a/WebAPI/Services/LineAutoBotService.cs b/Church.Net.WebAPI/Services/LineAutoBotService.cs similarity index 99% rename from WebAPI/Services/LineAutoBotService.cs rename to Church.Net.WebAPI/Services/LineAutoBotService.cs index 3da4561..5ab4e88 100644 --- a/WebAPI/Services/LineAutoBotService.cs +++ b/Church.Net.WebAPI/Services/LineAutoBotService.cs @@ -1,4 +1,4 @@ -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using Church.Net.Entity.Messenger; using Church.Net.Utility; diff --git a/WebAPI/Services/ScheduledTask/MorningPrayer.cs b/Church.Net.WebAPI/Services/ScheduledTask/MorningPrayer.cs similarity index 100% rename from WebAPI/Services/ScheduledTask/MorningPrayer.cs rename to Church.Net.WebAPI/Services/ScheduledTask/MorningPrayer.cs diff --git a/WebAPI/Services/WorkerService.cs b/Church.Net.WebAPI/Services/WorkerService.cs similarity index 100% rename from WebAPI/Services/WorkerService.cs rename to Church.Net.WebAPI/Services/WorkerService.cs diff --git a/WebAPI/Startup.cs b/Church.Net.WebAPI/Startup.cs similarity index 89% rename from WebAPI/Startup.cs rename to Church.Net.WebAPI/Startup.cs index c957683..74beed5 100644 --- a/WebAPI/Startup.cs +++ b/Church.Net.WebAPI/Startup.cs @@ -4,7 +4,8 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using Church.Net.DAL.EF; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Core; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; @@ -64,14 +65,22 @@ namespace WebAPI services.AddSignalR(); services.AddSingleton(); - //services.AddSingleton(_ => new DatabaseOptions { ConnectionString = "Host=192.168.86.131;Port=49154;Database=Church;Username=chris;Password=1124" }); - services.AddSingleton(_ => new DatabaseOptions { ConnectionString = "Host=192.168.86.131;Port=49154;Database=Church;Username=chris;Password=1124" }); + + services.AddSingleton(); + + //Localted at \\ArkNAS\docker\ChurchAPI\docker-compose.yaml + string databaseConnString = Environment.GetEnvironmentVariable("DB_CONN_STRING"); +#if DEBUG + databaseConnString = "Host=192.168.68.55;Port=49154;Database=Church;Username=chris;Password=1124"; +#endif + //services.AddSingleton(_ => new DatabaseOptions { ConnectionString = databaseConnString }); + services.AddSingleton(_ => new DatabaseOptions { ConnectionString = databaseConnString }); //services.AddSingleton(new ChurchNetContext()); services.AddDbContext(options => options.UseNpgsql( //Configuration.GetConnectionString() - //"Host=192.168.86.131;Port=49154;Database=ChurchSandbox;Username=chris;Password=1124" - "Host=192.168.86.131;Port=49154;Database=Church;Username=chris;Password=1124" + //"Host=192.168.68.55;Port=49154;Database=ChurchSandbox;Username=chris;Password=1124" + databaseConnString )); services.AddScoped(); @@ -82,7 +91,7 @@ namespace WebAPI services.AddScoped(); services.AddScoped(); - services.AddScoped(); + //services.AddScoped(); services.AddScoped(); @@ -155,6 +164,7 @@ namespace WebAPI endpoints.MapHub("/AvalonHub"); endpoints.MapHub("/WhoIsSpyHub"); endpoints.MapHub("/BaseHub"); + endpoints.MapHub("/GameRoomHub"); endpoints.MapControllers(); diff --git a/WebAPI/ViewModel/RegisterViewModel.cs b/Church.Net.WebAPI/ViewModel/RegisterViewModel.cs similarity index 100% rename from WebAPI/ViewModel/RegisterViewModel.cs rename to Church.Net.WebAPI/ViewModel/RegisterViewModel.cs diff --git a/WebAPI/WeatherForecast.cs b/Church.Net.WebAPI/WeatherForecast.cs similarity index 100% rename from WebAPI/WeatherForecast.cs rename to Church.Net.WebAPI/WeatherForecast.cs diff --git a/WebAPI/appsettings.Development.json b/Church.Net.WebAPI/appsettings.Development.json similarity index 100% rename from WebAPI/appsettings.Development.json rename to Church.Net.WebAPI/appsettings.Development.json diff --git a/WebAPI/appsettings.json b/Church.Net.WebAPI/appsettings.json similarity index 100% rename from WebAPI/appsettings.json rename to Church.Net.WebAPI/appsettings.json diff --git a/WebAPI/web.config b/Church.Net.WebAPI/web.config similarity index 100% rename from WebAPI/web.config rename to Church.Net.WebAPI/web.config diff --git a/Church.Net.sln b/Church.Net.sln index d2b1ba9..cc9f590 100644 --- a/Church.Net.sln +++ b/Church.Net.sln @@ -9,7 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BLL", "BLL", "{8EA076BD-086 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utility", "Utility", "{251C9BF4-223F-4D00-9BB0-9C80537D1A37}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAPI", "WebAPI\WebAPI.csproj", "{1DD6DC3F-D6E1-43E0-A2FD-2E5FF7AE20C6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Church.Net.WebAPI", "Church.Net.WebAPI\Church.Net.WebAPI.csproj", "{1DD6DC3F-D6E1-43E0-A2FD-2E5FF7AE20C6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Church.Net.Entity", "Church.Net.Entity2\Church.Net.Entity.csproj", "{FAEEA0AD-9C16-4BED-BF7D-BF74A3810D77}" EndProject diff --git a/TestProject/DateTimeTest.cs b/TestProject/DateTimeTest.cs index d9286fa..3b32540 100644 --- a/TestProject/DateTimeTest.cs +++ b/TestProject/DateTimeTest.cs @@ -1,5 +1,5 @@ using Church.Net.DAL.EF; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; diff --git a/TestProject/FamilyMemberTest.cs b/TestProject/FamilyMemberTest.cs index 2fe50cb..7a2b7f2 100644 --- a/TestProject/FamilyMemberTest.cs +++ b/TestProject/FamilyMemberTest.cs @@ -1,5 +1,5 @@ using Church.Net.DAL.EF; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; diff --git a/TestProject/LineMessageTest.cs b/TestProject/LineMessageTest.cs index fb91890..9b64cb7 100644 --- a/TestProject/LineMessageTest.cs +++ b/TestProject/LineMessageTest.cs @@ -1,5 +1,5 @@ using Church.Net.DAL.EF; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using Church.Net.Utility; using LineMessaging; diff --git a/TestProject/TestBase.cs b/TestProject/TestBase.cs index 5553746..6391bce 100644 --- a/TestProject/TestBase.cs +++ b/TestProject/TestBase.cs @@ -1,5 +1,6 @@ using Church.Net.DAL.EF; -using Church.Net.DAL.EFCoreDBF; +using Church.Net.DAL.EFCoreDBF.Core; +using Church.Net.DAL.EFCoreDBF.Interface; using Church.Net.Entity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; @@ -21,7 +22,7 @@ namespace TestProject services.AddDbContext(options => options.UseNpgsql( //Configuration.GetConnectionString() - "Host=192.168.86.131;Port=49154;Database=Church;Username=chris;Password=1124" + "Host=192.168.68.55;Port=49154;Database=Church;Username=chris;Password=1124" )); services.AddTransient(); diff --git a/TestProject/TestProject.csproj b/TestProject/TestProject.csproj index 7f9fc86..a7c65de 100644 --- a/TestProject/TestProject.csproj +++ b/TestProject/TestProject.csproj @@ -18,7 +18,7 @@ - + diff --git a/WebAPI/GameRoomLogic.cs b/WebAPI/GameRoomLogic.cs deleted file mode 100644 index b53e394..0000000 --- a/WebAPI/GameRoomLogic.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using WebAPI.Models.IceBreak; - -namespace WebAPI -{ - public class GameRoomLogic - { - public List GameRooms { get; set; } - - public bool UserJoinGameRoom(string id,string userName,string gameRoomId) - { - if (GameRooms.Any(g => g.Id == gameRoomId)) - { - //Make sure user not exist in other room - UserLeave(id); - - } - return false; - } - public void UserLeave(string id) - { - foreach (var room in GameRooms) - { - if (room.Players.Any(p => p.Id == id)) - { - room.Players.Remove(room.Players.FirstOrDefault(p => p.Id == id)); - break; - } - } - } - } -} diff --git a/WebAPI/Program.cs b/WebAPI/Program.cs deleted file mode 100644 index 491169d..0000000 --- a/WebAPI/Program.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; - -namespace WebAPI -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -}