mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
the meats
This commit is contained in:
@ -1,2 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration />
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding>
|
||||
<!-- <probing privatePath="lib"/>-->
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="System.Data.SqlServerCe.4.0" />
|
||||
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
<connectionStrings>
|
||||
<add name="DefaultConnection"
|
||||
providerName="System.Data.SqlServerCe.4.0"
|
||||
connectionString="Data Source=|DataDirectory|\Database.sdf"/>
|
||||
</connectionStrings>
|
||||
</configuration>
|
||||
|
@ -11,6 +11,7 @@ using SharedLibrary.Database;
|
||||
using System.Data.Entity;
|
||||
using SharedLibrary.Database.Models;
|
||||
using SharedLibrary.Services;
|
||||
using SharedLibrary.Exceptions;
|
||||
|
||||
namespace SharedLibrary.Commands
|
||||
{
|
||||
@ -170,6 +171,9 @@ namespace SharedLibrary.Commands
|
||||
{
|
||||
String Message = Utilities.RemoveWords(E.Data, 1).Trim();
|
||||
var length = E.Data.Split(' ')[0].ToLower().ParseTimespan();
|
||||
if (length.TotalHours >= 1 && length.TotalHours < 2)
|
||||
Message = E.Data;
|
||||
|
||||
|
||||
if (E.Origin.Level > E.Target.Level)
|
||||
{
|
||||
@ -428,8 +432,8 @@ namespace SharedLibrary.Commands
|
||||
|
||||
if (newPerm > Player.Permission.Banned)
|
||||
{
|
||||
var ActiveClient = E.Owner.Manager.GetActiveClients().FirstOrDefault(p => p.NetworkId == E.Target.NetworkId);
|
||||
|
||||
var ActiveClient = E.Owner.Manager.GetActiveClients()
|
||||
.FirstOrDefault(p => p.NetworkId == E.Target.NetworkId);
|
||||
|
||||
if (ActiveClient != null)
|
||||
{
|
||||
@ -444,7 +448,6 @@ namespace SharedLibrary.Commands
|
||||
}
|
||||
|
||||
await E.Origin.Tell($"{E.Target.Name} was successfully promoted!");
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
@ -485,17 +488,22 @@ namespace SharedLibrary.Commands
|
||||
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
int numOnline = 0;
|
||||
for (int i = 0; i < E.Owner.Players.Count; i++)
|
||||
{
|
||||
var P = E.Owner.Players[i];
|
||||
if (P != null && P.Level > Player.Permission.Flagged && !P.Masked)
|
||||
{
|
||||
numOnline++;
|
||||
if (E.Message[0] == '@')
|
||||
await E.Owner.Broadcast(String.Format("[^3{0}^7] {1}", Utilities.ConvertLevelToColor(P.Level), P.Name));
|
||||
else
|
||||
await E.Origin.Tell(String.Format("[^3{0}^7] {1}", Utilities.ConvertLevelToColor(P.Level), P.Name));
|
||||
}
|
||||
}
|
||||
|
||||
if (numOnline == 0)
|
||||
await E.Origin.Tell("No visible administrators online");
|
||||
}
|
||||
}
|
||||
|
||||
@ -519,14 +527,14 @@ namespace SharedLibrary.Commands
|
||||
{
|
||||
if (m.Name.ToLower() == newMap || m.Alias.ToLower() == newMap)
|
||||
{
|
||||
await E.Owner.Broadcast("Changing to map ^2" + m.Alias);
|
||||
await E.Owner.Broadcast($"Changing to map ^5{m.Alias}");
|
||||
Task.Delay(5000).Wait();
|
||||
await E.Owner.LoadMap(m.Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await E.Owner.Broadcast("Attempting to change to unknown map ^1" + newMap);
|
||||
await E.Owner.Broadcast($"Attempting to change to unknown map ^5{newMap}");
|
||||
Task.Delay(5000).Wait();
|
||||
await E.Owner.LoadMap(newMap);
|
||||
}
|
||||
@ -927,7 +935,7 @@ namespace SharedLibrary.Commands
|
||||
}
|
||||
})
|
||||
{ }
|
||||
|
||||
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
int inactiveDays = 30;
|
||||
@ -961,7 +969,89 @@ namespace SharedLibrary.Commands
|
||||
inactiveUsers.ForEach(c => c.Level = Player.Permission.User);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
await E.Origin.Tell($"Pruned {inactiveUsers.Count} inactive privileged users");
|
||||
await E.Origin.Tell($"Pruned {inactiveUsers.Count} inactive privileged users");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class CRestartServer : Command
|
||||
{
|
||||
public CRestartServer() : base("restartserver", "restart the server", "restart", Player.Permission.Administrator, false)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
var gameserverProcesses = System.Diagnostics.Process.GetProcessesByName("iw4x");
|
||||
var currentProcess = gameserverProcesses.FirstOrDefault(g => g.GetCommandLine().Contains($"+set net_port {E.Owner.GetPort()}"));
|
||||
|
||||
if (currentProcess == null)
|
||||
{
|
||||
await E.Origin.Tell("Could not find running/stalled instance of IW4x");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var commandLine = currentProcess.GetCommandLine();
|
||||
// attempt to kill it natively
|
||||
try
|
||||
{
|
||||
if (!E.Owner.Throttled)
|
||||
{
|
||||
// await E.Owner.ExecuteCommandAsync("quit");
|
||||
}
|
||||
}
|
||||
|
||||
catch (NetworkException)
|
||||
{
|
||||
await E.Origin.Tell("Unable to cleanly shutdown server, forcing");
|
||||
}
|
||||
|
||||
if (!currentProcess.HasExited)
|
||||
{
|
||||
try
|
||||
{
|
||||
currentProcess.Kill();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await E.Origin.Tell("Could not kill IW4x process");
|
||||
E.Owner.Logger.WriteDebug("Unable to kill process");
|
||||
E.Owner.Logger.WriteDebug($"Exception: {e.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
System.Diagnostics.Process process = new System.Diagnostics.Process();
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
#if !DEBUG
|
||||
process.StartInfo.WorkingDirectory = E.Owner.WorkingDirectory;
|
||||
#else
|
||||
process.StartInfo.WorkingDirectory = @"C:\Users\User\Desktop\MW2";
|
||||
#endif
|
||||
process.StartInfo.FileName = $"{process.StartInfo.WorkingDirectory}\\iw4x.exe";
|
||||
process.StartInfo.Arguments = commandLine.Substring(6);
|
||||
process.StartInfo.UserName = E.Owner.Config.RestartUsername;
|
||||
|
||||
var pw = new System.Security.SecureString();
|
||||
foreach (char c in E.Owner.Config.RestartPassword)
|
||||
pw.AppendChar(c);
|
||||
|
||||
process.StartInfo.Password = pw;
|
||||
process.Start();
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
await E.Origin.Tell("Could not start the IW4x process");
|
||||
E.Owner.Logger.WriteDebug("Unable to start process");
|
||||
E.Owner.Logger.WriteDebug($"Exception: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using System.Data.Entity.ModelConfiguration.Conventions;
|
||||
using System.Reflection;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Data.Entity.SqlServerCompact;
|
||||
using System.IO;
|
||||
|
||||
namespace SharedLibrary.Database
|
||||
{
|
||||
@ -23,7 +24,8 @@ namespace SharedLibrary.Database
|
||||
|
||||
public DatabaseContext() : base("DefaultConnection")
|
||||
{
|
||||
System.Data.Entity.Database.SetInitializer(new Initializer());
|
||||
System.Data.Entity.Database.SetInitializer(new MigrateDatabaseToLatestVersion<DatabaseContext, Migrations.Configuration>());
|
||||
//Database.CreateIfNotExists();
|
||||
Configuration.LazyLoadingEnabled = true;
|
||||
}
|
||||
|
||||
@ -50,7 +52,12 @@ namespace SharedLibrary.Database
|
||||
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
|
||||
|
||||
// https://aleemkhan.wordpress.com/2013/02/28/dynamically-adding-dbset-properties-in-dbcontext-for-entity-framework-code-first/
|
||||
//string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
|
||||
#if !DEBUG
|
||||
foreach (string dllPath in System.IO.Directory.GetFiles($"{Utilities.OperatingDirectory}Plugins"))
|
||||
#else
|
||||
foreach (string dllPath in System.IO.Directory.GetFiles(@"C:\Users\User\Desktop\stuff\IW4M-Admin\IW4M-Admin\WebfrontCore\bin\x86\Debug\Plugins"))
|
||||
#endif
|
||||
{
|
||||
Assembly library;
|
||||
try
|
||||
@ -64,7 +71,7 @@ namespace SharedLibrary.Database
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach(var type in library.ExportedTypes)
|
||||
foreach (var type in library.ExportedTypes)
|
||||
{
|
||||
if (type.IsClass && type.IsSubclassOf(typeof(SharedEntity)))
|
||||
{
|
||||
|
@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibrary.Database
|
||||
{
|
||||
public class Initializer : DropCreateDatabaseIfModelChanges<DatabaseContext>
|
||||
{
|
||||
protected override void Seed(DatabaseContext context)
|
||||
{
|
||||
var aliasLink = new Models.EFAliasLink();
|
||||
|
||||
var currentAlias = new Models.EFAlias()
|
||||
{
|
||||
Active = true,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
IPAddress = 0,
|
||||
Name = "IW4MAdmin",
|
||||
Link = aliasLink
|
||||
};
|
||||
|
||||
context.Clients.Add(new Models.EFClient()
|
||||
{
|
||||
Active = false,
|
||||
Connections = 0,
|
||||
FirstConnection = DateTime.UtcNow,
|
||||
LastConnection = DateTime.UtcNow,
|
||||
Level = Objects.Player.Permission.Console,
|
||||
Masked = true,
|
||||
NetworkId = 0,
|
||||
AliasLink = aliasLink,
|
||||
CurrentAlias = currentAlias
|
||||
});
|
||||
|
||||
base.Seed(context);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
26
SharedLibrary/Database/Repair.cs
Normal file
26
SharedLibrary/Database/Repair.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using SharedLibrary.Interfaces;
|
||||
using System;
|
||||
using System.Data.SqlServerCe;
|
||||
|
||||
namespace SharedLibrary.Database
|
||||
{
|
||||
public class Repair
|
||||
{
|
||||
public static void Run(ILogger log)
|
||||
{
|
||||
SqlCeEngine engine = new SqlCeEngine(@"Data Source=|DataDirectory|\Database.sdf");
|
||||
if (false == engine.Verify())
|
||||
{
|
||||
log.WriteWarning("Database is corrupted.");
|
||||
try
|
||||
{
|
||||
engine.Repair(null, RepairOption.DeleteCorruptedRows);
|
||||
}
|
||||
catch (SqlCeException ex)
|
||||
{
|
||||
log.WriteError(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibrary.Dtos
|
||||
{
|
||||
public class PenaltyInfo
|
||||
public class PenaltyInfo : SharedInfo
|
||||
{
|
||||
public string OffenderName { get; set; }
|
||||
public int OffenderId { get; set; }
|
||||
|
@ -7,9 +7,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibrary.Dtos
|
||||
{
|
||||
public class ProfileMeta
|
||||
public class ProfileMeta : SharedInfo
|
||||
{
|
||||
public DateTime When { get; set; }
|
||||
public bool Sensitive { get; set; }
|
||||
public string WhenString => Utilities.GetTimePassed(When, false);
|
||||
public string Key { get; set; }
|
||||
public dynamic Value { get; set; }
|
||||
|
8
SharedLibrary/Dtos/SharedInfo.cs
Normal file
8
SharedLibrary/Dtos/SharedInfo.cs
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
namespace SharedLibrary.Dtos
|
||||
{
|
||||
public class SharedInfo
|
||||
{
|
||||
public bool Sensitive { get; set; }
|
||||
}
|
||||
}
|
@ -2,12 +2,13 @@
|
||||
using SharedLibrary.Objects;
|
||||
using SharedLibrary.Database.Models;
|
||||
using SharedLibrary.Services;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibrary.Interfaces
|
||||
{
|
||||
public interface IManager
|
||||
{
|
||||
void Init();
|
||||
Task Init();
|
||||
void Start();
|
||||
void Stop();
|
||||
ILogger GetLogger();
|
||||
@ -15,7 +16,7 @@ namespace SharedLibrary.Interfaces
|
||||
IList<Command> GetCommands();
|
||||
IList<Helpers.MessageToken> GetMessageTokens();
|
||||
IList<Player> GetActiveClients();
|
||||
ClientService GetClientService();
|
||||
ClientService GetClientService();
|
||||
AliasService GetAliasService();
|
||||
PenaltyService GetPenaltyService();
|
||||
}
|
||||
|
29
SharedLibrary/Migrations/201803030146021_Intial.Designer.cs
generated
Normal file
29
SharedLibrary/Migrations/201803030146021_Intial.Designer.cs
generated
Normal file
@ -0,0 +1,29 @@
|
||||
// <auto-generated />
|
||||
namespace SharedLibrary.Migrations
|
||||
{
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using System.Resources;
|
||||
|
||||
[GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
|
||||
public sealed partial class Intial : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(Intial));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "201803030146021_Intial"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
16
SharedLibrary/Migrations/201803030146021_Intial.cs
Normal file
16
SharedLibrary/Migrations/201803030146021_Intial.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace SharedLibrary.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class Intial : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
126
SharedLibrary/Migrations/201803030146021_Intial.resx
Normal file
126
SharedLibrary/Migrations/201803030146021_Intial.resx
Normal file
File diff suppressed because one or more lines are too long
52
SharedLibrary/Migrations/Configuration.cs
Normal file
52
SharedLibrary/Migrations/Configuration.cs
Normal file
@ -0,0 +1,52 @@
|
||||
namespace SharedLibrary.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Linq;
|
||||
|
||||
internal sealed class Configuration : DbMigrationsConfiguration<SharedLibrary.Database.DatabaseContext>
|
||||
{
|
||||
public Configuration()
|
||||
{
|
||||
AutomaticMigrationsEnabled = true;
|
||||
AutomaticMigrationDataLossAllowed = true;
|
||||
}
|
||||
|
||||
protected override void Seed(SharedLibrary.Database.DatabaseContext context)
|
||||
{
|
||||
context.AliasLinks.AddOrUpdate(new SharedLibrary.Database.Models.EFAliasLink()
|
||||
{
|
||||
AliasLinkId = 1
|
||||
});
|
||||
|
||||
var currentAlias = new SharedLibrary.Database.Models.EFAlias()
|
||||
{
|
||||
AliasId = 1,
|
||||
Active = true,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
IPAddress = 0,
|
||||
Name = "IW4MAdmin",
|
||||
LinkId = 1
|
||||
};
|
||||
|
||||
context.Aliases.AddOrUpdate(currentAlias);
|
||||
|
||||
context.Clients.AddOrUpdate(new SharedLibrary.Database.Models.EFClient()
|
||||
{
|
||||
ClientId = 1,
|
||||
Active = false,
|
||||
Connections = 0,
|
||||
FirstConnection = DateTime.UtcNow,
|
||||
LastConnection = DateTime.UtcNow,
|
||||
Level = Objects.Player.Permission.Console,
|
||||
Masked = true,
|
||||
NetworkId = 0,
|
||||
AliasLinkId = 1,
|
||||
CurrentAliasId = 1,
|
||||
});
|
||||
|
||||
base.Seed(context);
|
||||
}
|
||||
}
|
||||
}
|
@ -66,7 +66,7 @@ namespace SharedLibrary.Network
|
||||
do
|
||||
{
|
||||
ReceiveBuffer = ServerOOBConnection.Receive(ref Endpoint);
|
||||
QueryResponseString.Append(Encoding.ASCII.GetString(ReceiveBuffer).TrimEnd('\0'));
|
||||
QueryResponseString.Append(Encoding.UTF7.GetString(ReceiveBuffer).TrimEnd('\0'));
|
||||
} while (ServerOOBConnection.Available > 0 && ServerOOBConnection.Client.Connected);
|
||||
|
||||
if (QueryResponseString.ToString().Contains("Invalid password"))
|
||||
|
@ -385,6 +385,7 @@ namespace SharedLibrary
|
||||
public string Password { get; private set; }
|
||||
public bool Throttled { get; protected set; }
|
||||
public bool CustomCallback { get; protected set; }
|
||||
public string WorkingDirectory { get; protected set; }
|
||||
|
||||
// Internal
|
||||
protected string IP;
|
||||
|
@ -10,6 +10,8 @@ namespace SharedLibrary
|
||||
public string FtpPrefix;
|
||||
public bool AllowMultipleOwners;
|
||||
public bool AllowTrustedRank;
|
||||
public string RestartUsername;
|
||||
public string RestartPassword;
|
||||
|
||||
public override string Filename()
|
||||
{
|
||||
|
@ -168,6 +168,11 @@ namespace SharedLibrary.Services
|
||||
};
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
client.CurrentAliasId = entity.CurrentAliasId;
|
||||
}
|
||||
|
||||
// set remaining non-navigation properties that may have been updated
|
||||
client.Level = entity.Level;
|
||||
client.LastConnection = entity.LastConnection;
|
||||
|
@ -15,6 +15,21 @@
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -118,22 +133,10 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServerCompact, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.SqlServerCompact.6.2.0\lib\net45\EntityFramework.SqlServerCompact.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.SqlServer.Compact.4.0.8876.1\lib\net40\System.Data.SqlServerCe.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@ -144,19 +147,20 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Database\Importer.cs" />
|
||||
<Compile Include="Database\Initializer.cs" />
|
||||
<Compile Include="Database\DatabaseContext.cs" />
|
||||
<Compile Include="Database\Models\EFAlias.cs" />
|
||||
<Compile Include="Database\Models\EFAliasLink.cs" />
|
||||
<Compile Include="Database\Models\EFClient.cs" />
|
||||
<Compile Include="Database\Models\EFPenalty.cs" />
|
||||
<Compile Include="Database\Models\SharedEntity.cs" />
|
||||
<Compile Include="Database\Repair.cs" />
|
||||
<Compile Include="Dtos\CommandResponseInfo.cs" />
|
||||
<Compile Include="Dtos\PlayerInfo.cs" />
|
||||
<Compile Include="Dtos\ClientInfo.cs" />
|
||||
<Compile Include="Dtos\ProfileMeta.cs" />
|
||||
<Compile Include="Dtos\PenaltyInfo.cs" />
|
||||
<Compile Include="Dtos\ServerInfo.cs" />
|
||||
<Compile Include="Dtos\SharedInfo.cs" />
|
||||
<Compile Include="Exceptions\DatabaseException.cs" />
|
||||
<Compile Include="Helpers\AsyncStatus.cs" />
|
||||
<Compile Include="Commands\NativeCommands.cs" />
|
||||
@ -173,6 +177,11 @@
|
||||
<Compile Include="Interfaces\IManager.cs" />
|
||||
<Compile Include="Interfaces\ISerializable.cs" />
|
||||
<Compile Include="Helpers\MessageToken.cs" />
|
||||
<Compile Include="Migrations\201803030146021_Intial.cs" />
|
||||
<Compile Include="Migrations\201803030146021_Intial.Designer.cs">
|
||||
<DependentUpon>201803030146021_Intial.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\Configuration.cs" />
|
||||
<Compile Include="Objects\Alias.cs" />
|
||||
<Compile Include="Objects\Penalty.cs" />
|
||||
<Compile Include="Command.cs" />
|
||||
@ -197,13 +206,37 @@
|
||||
<Compile Include="Utilities.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EntityFramework">
|
||||
<Version>6.2.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="EntityFramework.SqlServerCompact">
|
||||
<Version>6.2.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>11.0.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Migrations\201803030146021_Intial.resx">
|
||||
<DependentUpon>201803030146021_Intial.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\lib"
|
||||
@ -218,9 +251,7 @@ if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
|
||||
xcopy /Y /I /E "$(TargetDir)*" "$(SolutionDir)BUILD\Lib"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>if exist "$(SolutionDir)BUILD\Plugins" rmdir /Q /S "$(SolutionDir)BUILD\Plugins"
|
||||
mkdir "$(SolutionDir)BUILD\Plugins"
|
||||
|
||||
<PreBuildEvent>
|
||||
if not exist "$(SolutionDir)BUILD" mkdir "$(SolutionDir)BUILD"
|
||||
if not exist "$(SolutionDir)BUILD\Lib" mkdir "$(SolutionDir)BUILD\Lib"
|
||||
if not exist "$(SolutionDir)BUILD\userraw\scripts" mkdir "$(SolutionDir)BUILD\userraw\scripts"</PreBuildEvent>
|
||||
|
@ -4,11 +4,13 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Management;
|
||||
|
||||
using SharedLibrary.Objects;
|
||||
using static SharedLibrary.Server;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SharedLibrary
|
||||
{
|
||||
@ -61,14 +63,14 @@ namespace SharedLibrary
|
||||
int cID = -1;
|
||||
int Ping = -1;
|
||||
Int32.TryParse(playerInfo[2], out Ping);
|
||||
String cName = Utilities.StripColors(responseLine.Substring(46, 18)).Trim();
|
||||
String cName = Encoding.UTF8.GetString(Encoding.Convert(Encoding.UTF7, Encoding.UTF8, Encoding.UTF7.GetBytes(StripColors(responseLine.Substring(46, 18)).Trim())));
|
||||
long npID = Regex.Match(responseLine, @"([a-z]|[0-9]){16}", RegexOptions.IgnoreCase).Value.ConvertLong();
|
||||
int.TryParse(playerInfo[0], out cID);
|
||||
var regex = Regex.Match(responseLine, @"\d+\.\d+\.\d+.\d+\:\d{1,5}");
|
||||
int cIP = regex.Value.Split(':')[0].ConvertToIP();
|
||||
regex = Regex.Match(responseLine, @"[0-9]{1,2}\s+[0-9]+\s+");
|
||||
int score = Int32.Parse(regex.Value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]);
|
||||
Player P = new Player() { Name = cName, NetworkId = npID, ClientNumber = cID, IPAddress = cIP, Ping = Ping, Score = score};
|
||||
Player P = new Player() { Name = cName, NetworkId = npID, ClientNumber = cID, IPAddress = cIP, Ping = Ping, Score = score };
|
||||
StatusPlayers.Add(P);
|
||||
}
|
||||
}
|
||||
@ -96,8 +98,11 @@ namespace SharedLibrary
|
||||
{
|
||||
if (str == null)
|
||||
return "";
|
||||
return Regex.Replace(str, @"(\^+((?![a-z]|[A-Z]).){0,1})+", "")
|
||||
str = Regex.Replace(str, @"(\^+((?![a-z]|[A-Z]).){0,1})+", "");
|
||||
string str2 = Regex.Match(str, @"(^\/+.*$)|(^.*\/+$)")
|
||||
.Value
|
||||
.Replace("/", " /");
|
||||
return str2.Length > 0 ? str2 : str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -334,11 +339,6 @@ namespace SharedLibrary
|
||||
return "1 hour";
|
||||
}
|
||||
|
||||
public static string EscapeMarkdown(this string markdownString)
|
||||
{
|
||||
return markdownString.Replace("<", "\\<").Replace(">", "\\>").Replace("|", "\\|");
|
||||
}
|
||||
|
||||
public static Player AsPlayer(this Database.Models.EFClient client)
|
||||
{
|
||||
return client == null ? null : new Player()
|
||||
@ -361,5 +361,35 @@ namespace SharedLibrary
|
||||
CurrentAliasId = client.CurrentAlias.AliasId
|
||||
};
|
||||
}
|
||||
|
||||
/*https://stackoverflow.com/questions/2633628/can-i-get-command-line-arguments-of-other-processes-from-net-c*/
|
||||
// Define an extension method for type System.Process that returns the command
|
||||
// line via WMI.
|
||||
public static string GetCommandLine(this Process process)
|
||||
{
|
||||
string cmdLine = null;
|
||||
using (var searcher = new ManagementObjectSearcher(
|
||||
$"SELECT CommandLine FROM Win32_Process WHERE ProcessId = {process.Id}"))
|
||||
{
|
||||
// By definition, the query returns at most 1 match, because the process
|
||||
// is looked up by ID (which is unique by definition).
|
||||
var matchEnum = searcher.Get().GetEnumerator();
|
||||
if (matchEnum.MoveNext()) // Move to the 1st item.
|
||||
{
|
||||
cmdLine = matchEnum.Current["CommandLine"]?.ToString();
|
||||
}
|
||||
}
|
||||
if (cmdLine == null)
|
||||
{
|
||||
// Not having found a command line implies 1 of 2 exceptions, which the
|
||||
// WMI query masked:
|
||||
// An "Access denied" exception due to lack of privileges.
|
||||
// A "Cannot process request because the process (<pid>) has exited."
|
||||
// exception due to the process having terminated.
|
||||
// We provoke the same exception again simply by accessing process.MainModule.
|
||||
var dummy = process.MainModule; // Provoke exception.
|
||||
}
|
||||
return cmdLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user