1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-09 23:00:57 -05:00

added 'none' and extra m16 variants to weapon list

moved killstreak/deathstreak messages into configuration file
cleaned up configuration manager
fixed misc startup issue and threading
added more importing stuff
network id is a ulong now
ip str is now ip
added time played (per server)
This commit is contained in:
RaidMax
2018-02-10 22:33:42 -06:00
parent d1cdb93cc3
commit b8a161161d
33 changed files with 418 additions and 213 deletions

View File

@ -19,6 +19,8 @@ namespace SharedLibrary.Database
{
context = new DatabaseContext();
context.Configuration.AutoDetectChangesEnabled = false;
context.Configuration.LazyLoadingEnabled = false;
context.Configuration.ProxyCreationEnabled = false;
int count = 0;
foreach (var entityToInsert in clients)
@ -96,6 +98,8 @@ namespace SharedLibrary.Database
{
context = new DatabaseContext();
context.Configuration.AutoDetectChangesEnabled = false;
context.Configuration.LazyLoadingEnabled = false;
context.Configuration.ProxyCreationEnabled = false;
int count = 0;
foreach (var entityToInsert in penalties)
@ -161,5 +165,59 @@ namespace SharedLibrary.Database
return context;
}
public static void ImportSQLite<T>(IList<T> SQLiteData) where T : class
{
DatabaseContext context = null;
try
{
context = new DatabaseContext();
context.Configuration.AutoDetectChangesEnabled = false;
context.Configuration.LazyLoadingEnabled = false;
context.Configuration.ProxyCreationEnabled = false;
int count = 0;
foreach (var entityToInsert in SQLiteData)
{
++count;
context = AddSQLite(context, entityToInsert, count, 100, true);
}
context.SaveChanges();
}
finally
{
if (context != null)
context.Dispose();
}
}
private static DatabaseContext AddSQLite<T>(DatabaseContext context, T entity, int count, int commitCount, bool recreateContext) where T : class
{
context.Set<T>().Add(entity);
if (count % commitCount == 0)
{
try
{
context.SaveChanges();
}
catch (Exception e)
{
var a = 1;
}
if (recreateContext)
{
context.Dispose();
context = new DatabaseContext();
context.Configuration.AutoDetectChangesEnabled = false;
}
}
return context;
}
}
}

View File

@ -17,7 +17,7 @@ namespace SharedLibrary.Database
{
Active = true,
DateAdded = DateTime.UtcNow,
IPAddress = "0.0.0.0",
IPAddress = 0,
Name = "IW4MAdmin",
Link = aliasLink
};
@ -30,7 +30,7 @@ namespace SharedLibrary.Database
LastConnection = DateTime.UtcNow,
Level = Objects.Player.Permission.Console,
Masked = true,
NetworkId = "0000000000000000",
NetworkId = 0,
AliasLink = aliasLink,
CurrentAlias = currentAlias
});

View File

@ -14,10 +14,12 @@ namespace SharedLibrary.Database.Models
public virtual EFAliasLink Link { get; set; }
// [Index("IX_IPandName", 0, IsUnique = true)]
//[MaxLength(24)]
[Required]
public string Name { get; set; }
// [Index("IX_IPandName", 1, IsUnique = true)]
// [MaxLength(24)]
public string IPAddress { get; set; }
[Required]
public int IPAddress { get; set; }
[Required]
public DateTime DateAdded { get; set; }
}

View File

@ -13,8 +13,7 @@ namespace SharedLibrary.Database.Models
[Key]
public int ClientId { get; set; }
[Index(IsUnique = true)]
public string NetworkId { get; set; }
public long NetworkId { get; set; }
[Required]
public int Connections { get; set; }
[Required]
@ -44,12 +43,15 @@ namespace SharedLibrary.Database.Models
set { }
}
[NotMapped]
public virtual string IPAddress
public virtual int IPAddress
{
get { return CurrentAlias.IPAddress; }
set { }
}
[NotMapped]
public string IPAddressString => new System.Net.IPAddress(BitConverter.GetBytes(IPAddress)).ToString();
public virtual ICollection<EFPenalty> ReceivedPenalties { get; set; }
public virtual ICollection<EFPenalty> AdministeredPenalties { get; set; }