|
@@ -6,12 +6,15 @@ using NPOI.SS.Formula.Functions;
|
|
|
|
|
|
namespace InABox.Rpc
|
|
|
{
|
|
|
- public abstract class RpcCommandHandler<TSender, TParameters, TResult> : IRpcCommandHandler
|
|
|
+ public abstract class RpcCommandHandler<TSender, TCommand, TParameters, TResult> : IRpcCommandHandler
|
|
|
where TSender : class
|
|
|
+ where TCommand : IRpcCommand<TParameters, TResult>
|
|
|
where TParameters : IRpcCommandParameters, new()
|
|
|
where TResult : IRpcCommandResult
|
|
|
{
|
|
|
public TSender Sender { get; }
|
|
|
+
|
|
|
+ private static bool IsLogCommand = typeof(TCommand).IsAssignableTo(typeof(IRpcLogCommand));
|
|
|
|
|
|
public RpcCommandHandler(TSender sender)
|
|
|
{
|
|
@@ -24,17 +27,21 @@ namespace InABox.Rpc
|
|
|
{
|
|
|
var start = DateTime.Now;
|
|
|
var parameters = Serialization.ReadBinary<TParameters>(payload, BinarySerializationSettings.Latest);
|
|
|
- //Logger.Send(LogType.Information, session.UserID, $"[{session.Platform} {session.Version}] {parameters.FullDescription()}");
|
|
|
-
|
|
|
+ if (IsLogCommand)
|
|
|
+ Logger.Send(LogType.Information, session.UserID, $"[{session.Platform} {session.Version}] {parameters.FullDescription()}");
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
var result = Execute(session, parameters);
|
|
|
|
|
|
- var description = result.FullDescription();
|
|
|
- // Logger.Send(LogType.Information, session.UserID, string.Format("[{0} {1}] [{2:D8}] {3} Complete{4}",
|
|
|
- // session.Platform, session.Version,
|
|
|
- // (int)DateTime.Now.Subtract(start).TotalMilliseconds, parameters.ShortDescription(),
|
|
|
- // string.IsNullOrWhiteSpace(description) ? "" : $" {description}"));
|
|
|
+ if (IsLogCommand)
|
|
|
+ {
|
|
|
+ var description = result.FullDescription();
|
|
|
+ Logger.Send(LogType.Information, session.UserID, string.Format("[{0} {1}] [{2:D8}] {3} Complete{4}",
|
|
|
+ session.Platform, session.Version,
|
|
|
+ (int)DateTime.Now.Subtract(start).TotalMilliseconds, parameters.ShortDescription(),
|
|
|
+ string.IsNullOrWhiteSpace(description) ? "" : $" {description}"));
|
|
|
+ }
|
|
|
|
|
|
return Serialization.WriteBinary(result, BinarySerializationSettings.Latest);
|
|
|
}
|