Moved the welcome plugin announcements into the plugin configuration
EF optimizations for webfront requests removed FindAll command and moved it's functionality into find fixed undefined link on admin page
This commit is contained in:
parent
1dbacd2188
commit
d2ead61061
@ -172,7 +172,6 @@ namespace IW4MAdmin
|
|||||||
Commands.Add(new CListBanInfo());
|
Commands.Add(new CListBanInfo());
|
||||||
Commands.Add(new CListAlias());
|
Commands.Add(new CListAlias());
|
||||||
Commands.Add(new CExecuteRCON());
|
Commands.Add(new CExecuteRCON());
|
||||||
Commands.Add(new CFindAllPlayers());
|
|
||||||
Commands.Add(new CPlugins());
|
Commands.Add(new CPlugins());
|
||||||
Commands.Add(new CIP());
|
Commands.Add(new CIP());
|
||||||
Commands.Add(new CMask());
|
Commands.Add(new CMask());
|
||||||
|
@ -318,6 +318,7 @@ namespace IW4MAdmin
|
|||||||
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} specified invalid player for \"{C.Name}\"");
|
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} specified invalid player for \"{C.Name}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
E.Data = E.Data.Trim();
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,6 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
var f = File.ReadAllBytes(path.Replace("/", "\\").Substring(1));
|
var f = File.ReadAllBytes(path.Replace("/", "\\").Substring(1));
|
||||||
|
|
||||||
|
|
||||||
if (path.Contains(".css"))
|
if (path.Contains(".css"))
|
||||||
{
|
{
|
||||||
HttpResponse css = new HttpResponse()
|
HttpResponse css = new HttpResponse()
|
||||||
@ -383,9 +382,11 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
if (S != null)
|
if (S != null)
|
||||||
{
|
{
|
||||||
// fixme
|
int ip = querySet["ip"].ConvertToIP();
|
||||||
Func<EFClient, bool> predicate = c => c.IPAddress == querySet["IP"].ConvertToIP();
|
var admins = (await (ApplicationManager.GetInstance().GetClientService() as ClientService).GetPrivilegedClients());
|
||||||
Player admin = (await ApplicationManager.GetInstance().GetClientService().Find(predicate)).FirstOrDefault()?.AsPlayer();
|
Player admin = admins.FirstOrDefault(a => a.IPAddress == ip)?.AsPlayer();
|
||||||
|
if (ip == 16777343)
|
||||||
|
admin = admins.First(a => a.IPAddress == 0).AsPlayer();
|
||||||
|
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
admin = new Player() { Name = "RestUser"};
|
admin = new Player() { Name = "RestUser"};
|
||||||
@ -626,9 +627,10 @@ namespace IW4MAdmin
|
|||||||
contentType = GetContentType(),
|
contentType = GetContentType(),
|
||||||
content = Admins.Select(a => new
|
content = Admins.Select(a => new
|
||||||
{
|
{
|
||||||
ClientId = a.ClientId,
|
a.ClientId,
|
||||||
Level = a.Level,
|
a.Level,
|
||||||
Name = a.Name
|
a.Name,
|
||||||
|
playerID = a.ClientId
|
||||||
}),
|
}),
|
||||||
additionalHeaders = new Dictionary<string, string>()
|
additionalHeaders = new Dictionary<string, string>()
|
||||||
};
|
};
|
||||||
@ -746,15 +748,16 @@ namespace IW4MAdmin
|
|||||||
public async Task<HttpResponse> GetPage(System.Collections.Specialized.NameValueCollection querySet, IDictionary<string, string> headers)
|
public async Task<HttpResponse> GetPage(System.Collections.Specialized.NameValueCollection querySet, IDictionary<string, string> headers)
|
||||||
{
|
{
|
||||||
List<PlayerInfo> pInfo = new List<PlayerInfo>();
|
List<PlayerInfo> pInfo = new List<PlayerInfo>();
|
||||||
IList<SharedLibrary.Database.Models.EFClient> matchedPlayers = new List<SharedLibrary.Database.Models.EFClient>();
|
IList<EFClient> matchedPlayers = new List<EFClient>();
|
||||||
HttpResponse resp = new HttpResponse()
|
HttpResponse resp = new HttpResponse()
|
||||||
{
|
{
|
||||||
contentType = GetContentType(),
|
contentType = GetContentType(),
|
||||||
additionalHeaders = new Dictionary<string, string>()
|
additionalHeaders = new Dictionary<string, string>()
|
||||||
};
|
};
|
||||||
Func<EFClient, bool> predicate = c => c.IPAddress == querySet["IP"].ConvertToIP() && c.Level > Player.Permission.Trusted;
|
|
||||||
bool authed = (await ApplicationManager.GetInstance().GetClientService().Find(predicate)).Count > 0
|
int ip = querySet["IP"].ConvertToIP();
|
||||||
|| querySet["IP"] == "127.0.0.1";
|
var admins = (await (ApplicationManager.GetInstance().GetClientService() as ClientService).GetPrivilegedClients());
|
||||||
|
bool authed = admins.FirstOrDefault(c => c.IPAddress == ip) != null || ip == 16777343;
|
||||||
bool recent = false;
|
bool recent = false;
|
||||||
bool individual = querySet["id"] != null;
|
bool individual = querySet["id"] != null;
|
||||||
|
|
||||||
@ -770,7 +773,7 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
else if (querySet["name"] != null)
|
else if (querySet["name"] != null)
|
||||||
{
|
{
|
||||||
matchedPlayers = await ApplicationManager.GetInstance().GetClientService().Find(c => c.Name.Contains(querySet["name"]));
|
matchedPlayers = (await ApplicationManager.GetInstance().GetClientService().GetClientByName(querySet["name"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (querySet["recent"] != null)
|
else if (querySet["recent"] != null)
|
||||||
@ -865,15 +868,6 @@ namespace IW4MAdmin
|
|||||||
public string name;
|
public string name;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
struct PageInfo
|
|
||||||
{
|
|
||||||
public string pageName;
|
|
||||||
public string pagePath;
|
|
||||||
public string pageType;
|
|
||||||
public bool visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
struct PlayerInfo
|
struct PlayerInfo
|
||||||
{
|
{
|
||||||
@ -903,17 +897,4 @@ namespace IW4MAdmin
|
|||||||
public string penaltyTime;
|
public string penaltyTime;
|
||||||
public string Expires;
|
public string Expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
struct CommandInfo
|
|
||||||
{
|
|
||||||
public List<string> Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
class PrivilegedUsers
|
|
||||||
{
|
|
||||||
public Player.Permission Permission { get; set; }
|
|
||||||
public List<Player> Players { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
Binary file not shown.
@ -331,6 +331,10 @@ namespace StatsPlugin.Helpers
|
|||||||
|
|
||||||
public async Task AddMessageAsync(int clientId, int serverId, string message)
|
public async Task AddMessageAsync(int clientId, int serverId, string message)
|
||||||
{
|
{
|
||||||
|
// the web users can have no account
|
||||||
|
if (clientId < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
var messageSvc = ContextThreads[serverId].MessageSvc;
|
var messageSvc = ContextThreads[serverId].MessageSvc;
|
||||||
messageSvc.Insert(new EFClientMessage()
|
messageSvc.Insert(new EFClientMessage()
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ using SharedLibrary.Helpers;
|
|||||||
using SharedLibrary.Objects;
|
using SharedLibrary.Objects;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using StatsPlugin.Models;
|
using StatsPlugin.Models;
|
||||||
|
using SharedLibrary.Services;
|
||||||
|
|
||||||
namespace IW4MAdmin.Plugins
|
namespace IW4MAdmin.Plugins
|
||||||
{
|
{
|
||||||
@ -59,6 +60,31 @@ namespace IW4MAdmin.Plugins
|
|||||||
|
|
||||||
public async Task OnLoadAsync(IManager manager)
|
public async Task OnLoadAsync(IManager manager)
|
||||||
{
|
{
|
||||||
|
#if DO_IMPORT
|
||||||
|
var svc = new GenericRepository<EFServer>();
|
||||||
|
svc.Insert(new EFServer()
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Port = 28960,
|
||||||
|
ServerId = Math.Abs("127.0.0.1:28960".GetHashCode()),
|
||||||
|
});
|
||||||
|
|
||||||
|
svc.Insert(new EFServer()
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Port = 28965,
|
||||||
|
ServerId = Math.Abs("127.0.0.1:28965".GetHashCode()),
|
||||||
|
});
|
||||||
|
|
||||||
|
svc.Insert(new EFServer()
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Port = 28970,
|
||||||
|
ServerId = Math.Abs("127.0.0.1:28970".GetHashCode()),
|
||||||
|
});
|
||||||
|
|
||||||
|
svc.SaveChanges();
|
||||||
|
#endif
|
||||||
Interval = DateTime.Now;
|
Interval = DateTime.Now;
|
||||||
var clients = new List<Player>();
|
var clients = new List<Player>();
|
||||||
var oldClients = new Dictionary<int, Player>();
|
var oldClients = new Dictionary<int, Player>();
|
||||||
@ -151,7 +177,7 @@ namespace IW4MAdmin.Plugins
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields[2].Contains("0110") || fields[2].Contains("0000000"))
|
if (fields[2].Substring(0, 5) == "01100" || fields[2].Contains("0000000"))
|
||||||
continue;
|
continue;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -159,13 +185,17 @@ namespace IW4MAdmin.Plugins
|
|||||||
var expires = DateTime.Parse(fields[6]);
|
var expires = DateTime.Parse(fields[6]);
|
||||||
var when = DateTime.Parse(fields[5]);
|
var when = DateTime.Parse(fields[5]);
|
||||||
|
|
||||||
|
var penaltyType = (Penalty.PenaltyType)Int32.Parse(fields[0]);
|
||||||
|
if (penaltyType == Penalty.PenaltyType.Ban)
|
||||||
|
expires = DateTime.MaxValue;
|
||||||
|
|
||||||
var penalty = new Penalty()
|
var penalty = new Penalty()
|
||||||
{
|
{
|
||||||
Type = (Penalty.PenaltyType)Int32.Parse(fields[0]),
|
Type = penaltyType,
|
||||||
Expires = expires == DateTime.MinValue ? when : expires,
|
Expires = expires == DateTime.MinValue ? when : expires,
|
||||||
Punisher = new SharedLibrary.Database.Models.EFClient() { NetworkId = fields[3].ConvertLong() },
|
Punisher = new SharedLibrary.Database.Models.EFClient() { NetworkId = fields[3].ConvertLong() },
|
||||||
Offender = new SharedLibrary.Database.Models.EFClient() { NetworkId = fields[2].ConvertLong() },
|
Offender = new SharedLibrary.Database.Models.EFClient() { NetworkId = fields[2].ConvertLong() },
|
||||||
Offense = fields[1],
|
Offense = fields[1].Replace("\"", "").Trim(),
|
||||||
Active = true,
|
Active = true,
|
||||||
When = when,
|
When = when,
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
using SharedLibrary.Network;
|
using SharedLibrary.Network;
|
||||||
using SharedLibrary.Objects;
|
using SharedLibrary.Objects;
|
||||||
|
using SharedLibrary.Helpers;
|
||||||
|
|
||||||
namespace Welcome_Plugin
|
namespace Welcome_Plugin
|
||||||
{
|
{
|
||||||
@ -46,13 +47,12 @@ namespace Welcome_Plugin
|
|||||||
return "fourth";
|
return "fourth";
|
||||||
case 5:
|
case 5:
|
||||||
return "fifth";
|
return "fifth";
|
||||||
case 100:
|
/* case 100:
|
||||||
return "One-Hundreth (amazing!)";
|
return "One-Hundreth (amazing!)";
|
||||||
case 500:
|
case 500:
|
||||||
return "you're really ^5dedicated ^7to this server! This is your ^5500th^7";
|
return "you're really ^5dedicated ^7to this server! This is your ^5500th^7";
|
||||||
case 1000:
|
case 1000:
|
||||||
return "you deserve a medal. it's your ^11000th^7";
|
return "you deserve a medal. it's your ^11000th^7";*/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return connection.ToString() + Prefix;
|
return connection.ToString() + Prefix;
|
||||||
}
|
}
|
||||||
@ -64,8 +64,11 @@ namespace Welcome_Plugin
|
|||||||
|
|
||||||
public string Name => "Welcome Plugin";
|
public string Name => "Welcome Plugin";
|
||||||
|
|
||||||
|
private Dictionary<int, ConfigurationManager> Configs;
|
||||||
|
|
||||||
public async Task OnLoadAsync(IManager manager)
|
public async Task OnLoadAsync(IManager manager)
|
||||||
{
|
{
|
||||||
|
await Task.FromResult(Configs = new Dictionary<int, ConfigurationManager>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task OnUnloadAsync()
|
public async Task OnUnloadAsync()
|
||||||
@ -81,34 +84,59 @@ namespace Welcome_Plugin
|
|||||||
if (E.Type == Event.GType.Connect)
|
if (E.Type == Event.GType.Connect)
|
||||||
{
|
{
|
||||||
Player newPlayer = E.Origin;
|
Player newPlayer = E.Origin;
|
||||||
|
var cfg = Configs[S.GetHashCode()];
|
||||||
if (newPlayer.Level >= Player.Permission.Trusted && !E.Origin.Masked)
|
if (newPlayer.Level >= Player.Permission.Trusted && !E.Origin.Masked)
|
||||||
await E.Owner.Broadcast(Utilities.ConvertLevelToColor(newPlayer.Level) + " ^5" + newPlayer.Name + " ^7has joined the server.");
|
await E.Owner.Broadcast(ProcessAnnouncement(cfg.GetProperty<string>("PrivilegedAnnouncementMessage"), newPlayer));
|
||||||
|
|
||||||
await newPlayer.Tell($"Welcome ^5{newPlayer.Name}^7, this is your ^5{TimesConnected(newPlayer)} ^7time connecting!");
|
await newPlayer.Tell(ProcessAnnouncement(cfg.GetProperty<string>("UserWelcomeMessage"), newPlayer));
|
||||||
|
|
||||||
if (newPlayer.Level == Player.Permission.Flagged)
|
if (newPlayer.Level == Player.Permission.Flagged)
|
||||||
await E.Owner.ToAdmins($"^1NOTICE: ^7Flagged player ^5{newPlayer.Name}^7 has joined!");
|
await E.Owner.ToAdmins($"^1NOTICE: ^7Flagged player ^5{newPlayer.Name}^7 has joined!");
|
||||||
|
|
||||||
else
|
else
|
||||||
|
await E.Owner.Broadcast(ProcessAnnouncement(cfg.GetProperty<string>("UserAnnouncementMessage"), newPlayer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (E.Type == Event.GType.Start)
|
||||||
{
|
{
|
||||||
|
var cfg = new ConfigurationManager(S);
|
||||||
|
Configs.Add(S.GetHashCode(), cfg);
|
||||||
|
if (cfg.GetProperty<string>("UserWelcomeMessage") == null)
|
||||||
|
{
|
||||||
|
string welcomeMsg = "Welcome ^5{{ClientName}}^7, this is your ^5{{TimesConnected}} ^7time connecting!";
|
||||||
|
cfg.AddProperty(new KeyValuePair<string, dynamic>("UserWelcomeMessage", welcomeMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg.GetProperty<string>("PrivilegedAnnouncementMessage") == null)
|
||||||
|
{
|
||||||
|
string annoucementMsg = "{{ClientLevel}} {{ClientName}} has joined the server";
|
||||||
|
cfg.AddProperty(new KeyValuePair<string, dynamic>("PrivilegedAnnouncementMessage", annoucementMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg.GetProperty<string>("UserAnnouncementMessage") == null)
|
||||||
|
{
|
||||||
|
string annoucementMsg = "^5{{ClientName}}^7hails from ^5{{ClientLocation}}";
|
||||||
|
cfg.AddProperty(new KeyValuePair<string, dynamic>("UserAnnouncementMessage", annoucementMsg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ProcessAnnouncement(string msg, Player joining)
|
||||||
|
{
|
||||||
|
msg = msg.Replace("{{ClientName}}", joining.Name);
|
||||||
|
msg = msg.Replace("{{ClientLevel}}", Utilities.ConvertLevelToColor(joining.Level));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CountryLookupProj.CountryLookup CLT = new CountryLookupProj.CountryLookup("Plugins/GeoIP.dat");
|
CountryLookupProj.CountryLookup CLT = new CountryLookupProj.CountryLookup("Plugins/GeoIP.dat");
|
||||||
await E.Owner.Broadcast($"^5{newPlayer.Name} ^7hails from ^5{CLT.lookupCountryName(newPlayer.IPAddressString)}");
|
msg = msg.Replace("{{ClientLocation}}", CLT.lookupCountryName(joining.IPAddressString));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
E.Owner.Manager.GetLogger().WriteError("Could not open file Plugins/GeoIP.dat for Welcome Plugin");
|
joining.CurrentServer.Manager.GetLogger().WriteError("Could not open file Plugins/GeoIP.dat for Welcome Plugin");
|
||||||
}
|
}
|
||||||
|
msg = msg.Replace("{{TimesConnected}}", TimesConnected(joining));
|
||||||
|
|
||||||
}
|
return msg;
|
||||||
}
|
|
||||||
|
|
||||||
if (E.Type == Event.GType.Disconnect)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ using SharedLibrary.Objects;
|
|||||||
using SharedLibrary.Database;
|
using SharedLibrary.Database;
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
using SharedLibrary.Database.Models;
|
using SharedLibrary.Database.Models;
|
||||||
|
using SharedLibrary.Services;
|
||||||
|
|
||||||
namespace SharedLibrary.Commands
|
namespace SharedLibrary.Commands
|
||||||
{
|
{
|
||||||
@ -526,7 +527,7 @@ namespace SharedLibrary.Commands
|
|||||||
|
|
||||||
public override async Task ExecuteAsync(Event E)
|
public override async Task ExecuteAsync(Event E)
|
||||||
{
|
{
|
||||||
var db_players = await E.Owner.Manager.GetClientService().Find(c => c.Name.Contains(E.Data));
|
var db_players = await (E.Owner.Manager.GetClientService() as ClientService).GetClientByName(E.Data);
|
||||||
|
|
||||||
if (db_players.Count == 0)
|
if (db_players.Count == 0)
|
||||||
{
|
{
|
||||||
@ -534,51 +535,17 @@ namespace SharedLibrary.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Player P in db_players)
|
foreach (var P in db_players)
|
||||||
{
|
{
|
||||||
String mesg = String.Format("[^3{0}^7] [^3@{1}^7] - [{2}^7] - {3} | last seen {4}", P.Name, P.ClientNumber, Utilities.ConvertLevelToColor(P.Level), P.IPAddress, P.GetLastConnection());
|
// they're not going by another alias
|
||||||
await E.Origin.Tell(mesg);
|
string msg = P.Name.ToLower().Contains(E.Data.ToLower()) ?
|
||||||
|
$"[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level)}^7] - {P.IPAddressString} | last seen {Utilities.GetTimePassed(P.LastConnection)}" :
|
||||||
|
$"({P.AliasLink.Children.First(a => a.Name.ToLower().Contains(E.Data.ToLower())).Name})->[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level)}^7] - {P.IPAddressString} | last seen {Utilities.GetTimePassed(P.LastConnection)}";
|
||||||
|
await E.Origin.Tell(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CFindAllPlayers : Command
|
|
||||||
{
|
|
||||||
public CFindAllPlayers() :
|
|
||||||
base("findall", "find a player by their aliase(s)", "fa", Player.Permission.Administrator, false, new CommandArgument[]
|
|
||||||
{
|
|
||||||
new CommandArgument()
|
|
||||||
{
|
|
||||||
Name = "player",
|
|
||||||
Required = true,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public override async Task ExecuteAsync(Event E)
|
|
||||||
{
|
|
||||||
E.Data = E.Data.Trim();
|
|
||||||
|
|
||||||
if (E.Data.Length < 3)
|
|
||||||
{
|
|
||||||
await E.Origin.Tell("You must enter at least 3 characters");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var db_aliases = await E.Owner.Manager.GetAliasService()
|
|
||||||
.Find(a => a.Name.ToLower().Contains(E.Data.ToLower()));
|
|
||||||
|
|
||||||
if (db_aliases.Count == 0)
|
|
||||||
{
|
|
||||||
await E.Origin.Tell("No players found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var P in db_aliases)
|
|
||||||
await E.Origin.Tell($"^4{P.Name} ^7now goes by ^5{P.Link.Children.OrderByDescending(a => a.DateAdded).First().Name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CListRules : Command
|
public class CListRules : Command
|
||||||
{
|
{
|
||||||
public CListRules() :
|
public CListRules() :
|
||||||
@ -668,9 +635,10 @@ namespace SharedLibrary.Commands
|
|||||||
|
|
||||||
public override async Task ExecuteAsync(Event E)
|
public override async Task ExecuteAsync(Event E)
|
||||||
{
|
{
|
||||||
|
// todo: move unflag to seperate command
|
||||||
if (E.Target.Level >= E.Origin.Level)
|
if (E.Target.Level >= E.Origin.Level)
|
||||||
{
|
{
|
||||||
await E.Origin.Tell("You cannot flag " + E.Target.Name);
|
await E.Origin.Tell($"You cannot flag {E.Target.Name}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,7 +646,7 @@ namespace SharedLibrary.Commands
|
|||||||
{
|
{
|
||||||
E.Target.Level = Player.Permission.User;
|
E.Target.Level = Player.Permission.User;
|
||||||
await E.Owner.Manager.GetClientService().Update(E.Target);
|
await E.Owner.Manager.GetClientService().Update(E.Target);
|
||||||
await E.Origin.Tell("You have ^5unflagged ^7" + E.Target.Name);
|
await E.Origin.Tell($"You have ^5unflagged ^7{E.Target.Name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -52,7 +52,7 @@ namespace SharedLibrary.Database
|
|||||||
NetworkId = entityToInsert.NetworkId
|
NetworkId = entityToInsert.NetworkId
|
||||||
};
|
};
|
||||||
|
|
||||||
context = AddClient(context, client, count, 100, true);
|
context = AddClient(context, client, count, 1000, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
@ -84,6 +84,8 @@ namespace SharedLibrary.Database
|
|||||||
context.Dispose();
|
context.Dispose();
|
||||||
context = new DatabaseContext();
|
context = new DatabaseContext();
|
||||||
context.Configuration.AutoDetectChangesEnabled = false;
|
context.Configuration.AutoDetectChangesEnabled = false;
|
||||||
|
context.Configuration.LazyLoadingEnabled = false;
|
||||||
|
context.Configuration.ProxyCreationEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +121,7 @@ namespace SharedLibrary.Database
|
|||||||
var penalty = new EFPenalty()
|
var penalty = new EFPenalty()
|
||||||
{
|
{
|
||||||
Active = true,
|
Active = true,
|
||||||
Expires = entityToInsert.Expires.Year == 9999 ? DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MinValue.ToString()) : entityToInsert.Expires,
|
Expires = entityToInsert.Expires.Year == 9999 ? DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MaxValue.ToString()) : entityToInsert.Expires,
|
||||||
Offender = offender,
|
Offender = offender,
|
||||||
Punisher = punisher,
|
Punisher = punisher,
|
||||||
Offense = entityToInsert.Offense,
|
Offense = entityToInsert.Offense,
|
||||||
@ -128,7 +130,7 @@ namespace SharedLibrary.Database
|
|||||||
Link = offender.AliasLink
|
Link = offender.AliasLink
|
||||||
};
|
};
|
||||||
|
|
||||||
context = AddPenalty(context, penalty, count, 100, true);
|
context = AddPenalty(context, penalty, count, 1000, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
@ -160,6 +162,8 @@ namespace SharedLibrary.Database
|
|||||||
context.Dispose();
|
context.Dispose();
|
||||||
context = new DatabaseContext();
|
context = new DatabaseContext();
|
||||||
context.Configuration.AutoDetectChangesEnabled = false;
|
context.Configuration.AutoDetectChangesEnabled = false;
|
||||||
|
context.Configuration.LazyLoadingEnabled = false;
|
||||||
|
context.Configuration.ProxyCreationEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +185,7 @@ namespace SharedLibrary.Database
|
|||||||
foreach (var entityToInsert in SQLiteData)
|
foreach (var entityToInsert in SQLiteData)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
context = AddSQLite(context, entityToInsert, count, 100, true);
|
context = AddSQLite(context, entityToInsert, count, 1000, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
@ -214,6 +218,8 @@ namespace SharedLibrary.Database
|
|||||||
context.Dispose();
|
context.Dispose();
|
||||||
context = new DatabaseContext();
|
context = new DatabaseContext();
|
||||||
context.Configuration.AutoDetectChangesEnabled = false;
|
context.Configuration.AutoDetectChangesEnabled = false;
|
||||||
|
context.Configuration.LazyLoadingEnabled = false;
|
||||||
|
context.Configuration.ProxyCreationEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Microsoft.CSharp.RuntimeBinder;
|
||||||
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@ -54,6 +55,11 @@ namespace SharedLibrary.Helpers
|
|||||||
return ConfigSet[prop].ToObject<T>();
|
return ConfigSet[prop].ToObject<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch (RuntimeBinderException)
|
||||||
|
{
|
||||||
|
return ConfigSet[prop];
|
||||||
|
}
|
||||||
|
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return default(T);
|
return default(T);
|
||||||
|
@ -8,6 +8,7 @@ using System.Data.Entity;
|
|||||||
using SharedLibrary.Database;
|
using SharedLibrary.Database;
|
||||||
using SharedLibrary.Database.Models;
|
using SharedLibrary.Database.Models;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using SharedLibrary.Objects;
|
||||||
|
|
||||||
namespace SharedLibrary.Services
|
namespace SharedLibrary.Services
|
||||||
{
|
{
|
||||||
@ -91,11 +92,16 @@ namespace SharedLibrary.Services
|
|||||||
return await Task.Run(() =>
|
return await Task.Run(() =>
|
||||||
{
|
{
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
context.Configuration.AutoDetectChangesEnabled = false;
|
||||||
|
context.Configuration.LazyLoadingEnabled = false;
|
||||||
|
context.Configuration.ProxyCreationEnabled = false;
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(c => c.CurrentAlias)
|
.Include(c => c.CurrentAlias)
|
||||||
.Include(c => c.AliasLink.Children)
|
.Include(c => c.AliasLink.Children)
|
||||||
.Where(e).ToList();
|
.Where(e).ToList();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +110,7 @@ namespace SharedLibrary.Services
|
|||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
context.Configuration.LazyLoadingEnabled = false;
|
context.Configuration.LazyLoadingEnabled = false;
|
||||||
context.Configuration.ProxyCreationEnabled = false;
|
//context.Configuration.ProxyCreationEnabled = false;
|
||||||
return await new DatabaseContext().Clients
|
return await new DatabaseContext().Clients
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(c => c.CurrentAlias)
|
.Include(c => c.CurrentAlias)
|
||||||
@ -191,13 +197,43 @@ namespace SharedLibrary.Services
|
|||||||
public async Task<IList<EFClient>> GetPrivilegedClients()
|
public async Task<IList<EFClient>> GetPrivilegedClients()
|
||||||
{
|
{
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
context.Configuration.LazyLoadingEnabled = false;
|
||||||
|
context.Configuration.ProxyCreationEnabled = false;
|
||||||
|
context.Configuration.AutoDetectChangesEnabled = false;
|
||||||
|
|
||||||
return await new DatabaseContext().Clients
|
return await new DatabaseContext().Clients
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(c => c.CurrentAlias)
|
.Include(c => c.CurrentAlias)
|
||||||
.Where(c => c.Level >= Objects.Player.Permission.Trusted)
|
.Where(c => c.Level >= Player.Permission.Trusted)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IList<EFClient>> GetClientByName(string name)
|
||||||
|
{
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
context.Configuration.LazyLoadingEnabled = false;
|
||||||
|
context.Configuration.ProxyCreationEnabled = false;
|
||||||
|
context.Configuration.AutoDetectChangesEnabled = false;
|
||||||
|
|
||||||
|
var iqClients = (from alias in context.Aliases
|
||||||
|
.AsNoTracking()
|
||||||
|
where alias.Name
|
||||||
|
.Contains(name)
|
||||||
|
join link in context.AliasLinks
|
||||||
|
on alias.LinkId equals link.AliasLinkId
|
||||||
|
join client in context.Clients
|
||||||
|
.AsNoTracking()
|
||||||
|
on alias.LinkId equals client.AliasLinkId
|
||||||
|
select client)
|
||||||
|
.Include(c => c.CurrentAlias)
|
||||||
|
.Include(c => c.AliasLink.Children);
|
||||||
|
|
||||||
|
return await iqClients.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IList<EFClient>> GetRecentClients(int offset, int count)
|
public async Task<IList<EFClient>> GetRecentClients(int offset, int count)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user