From 1d407b5e163c2a7f11d5a6fcf812bba4f8aceb1d Mon Sep 17 00:00:00 2001 From: vdemydiuk Date: Wed, 12 Oct 2016 16:37:54 +0300 Subject: [PATCH] Changed sign key in library MtApiService: using MtApiKey.snk. Added logging into MtApiService and used ILMerge.Task to merge assemblies into one dll. --- MTApiService/ILMerge.props | 67 ++++ MTApiService/ILMergeOrder.txt | 4 + MTApiService/IMtApiServer.cs | 7 +- MTApiService/LogConfigurator.cs | 55 ++++ MTApiService/MTApiService.csproj | 30 +- MTApiService/MtApiKey.pfx | Bin 1764 -> 0 bytes MTApiService/MtApiKey.snk | Bin 0 -> 596 bytes MTApiService/MtApiProxy.cs | 25 +- MTApiService/MtClient.cs | 143 +++++++-- MTApiService/MtCommand.cs | 10 +- MTApiService/MtCommandTask.cs | 14 +- MTApiService/MtConnectionProfile.cs | 6 +- MTApiService/MtExecutorManager.cs | 56 +++- MTApiService/MtExpert.cs | 161 ++++++---- MTApiService/MtInstrument.cs | 6 +- MTApiService/MtMqlBookInfo.cs | 6 +- MTApiService/MtMqlRates.cs | 7 +- MTApiService/MtMqlTick.cs | 6 +- MTApiService/MtMqlTradeRequest.cs | 33 +- MTApiService/MtRegistryManager.cs | 172 +++++----- MTApiService/MtResponse.cs | 66 ++++ MTApiService/MtServer.cs | 300 +++++++++++------- MTApiService/MtServerInstance.cs | 165 ++++++---- MTApiService/MtService.cs | 141 +++++--- MTApiService/packages.config | 6 + MtApi/MtApiClient.cs | 4 + MtApi5/MtApi5Client.cs | 5 +- .../MtApi5TestClient/MtApi5TestClient.csproj | 12 +- .../Properties/Resources.Designer.cs | 44 ++- .../Properties/Settings.Designer.cs | 24 +- TestClients/MtApi5TestClient/app.config | 3 + 31 files changed, 1050 insertions(+), 528 deletions(-) create mode 100755 MTApiService/ILMerge.props create mode 100755 MTApiService/ILMergeOrder.txt create mode 100755 MTApiService/LogConfigurator.cs delete mode 100755 MTApiService/MtApiKey.pfx create mode 100755 MTApiService/MtApiKey.snk mode change 100644 => 100755 MTApiService/MtCommandTask.cs create mode 100755 MTApiService/packages.config create mode 100755 TestClients/MtApi5TestClient/app.config diff --git a/MTApiService/ILMerge.props b/MTApiService/ILMerge.props new file mode 100755 index 00000000..08fa84c3 --- /dev/null +++ b/MTApiService/ILMerge.props @@ -0,0 +1,67 @@ + + + + + + + + + + + true + + + + + + + + + + + + MtApiKey.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MTApiService/ILMergeOrder.txt b/MTApiService/ILMergeOrder.txt new file mode 100755 index 00000000..c39ca3e4 --- /dev/null +++ b/MTApiService/ILMergeOrder.txt @@ -0,0 +1,4 @@ +# this file contains the partial list of the merged assemblies in the merge order +# you can fill it from the obj\CONFIG\PROJECT.ilmerge generated on every build +# and finetune merge order to your satisfaction + diff --git a/MTApiService/IMtApiServer.cs b/MTApiService/IMtApiServer.cs index 2962612b..d43e5a85 100755 --- a/MTApiService/IMtApiServer.cs +++ b/MTApiService/IMtApiServer.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace MTApiService { public interface IMtApiServer { MtResponse SendCommand(MtCommand command); - IEnumerable GetQuotes(); + List GetQuotes(); } } diff --git a/MTApiService/LogConfigurator.cs b/MTApiService/LogConfigurator.cs new file mode 100755 index 00000000..ca1beef8 --- /dev/null +++ b/MTApiService/LogConfigurator.cs @@ -0,0 +1,55 @@ +using System; +using log4net; +using log4net.Appender; +using log4net.Core; +using log4net.Layout; +using log4net.Repository.Hierarchy; + +namespace MTApiService +{ + public class LogConfigurator + { + private const string LogFileNameExtension = "txt"; + + public static void Setup(string profileName) + { + if (string.IsNullOrEmpty(profileName)) + throw new ArgumentNullException(); + + var hierarchy = (Hierarchy) LogManager.GetRepository(); + + var patternLayout = new PatternLayout + { + ConversionPattern = "%date [%thread] %-5level %logger - %message%newline" + }; + patternLayout.ActivateOptions(); + + string filename = $"{DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss")}.{LogFileNameExtension}"; + + var roller = new RollingFileAppender + { + AppendToFile = false, + File = $@"{System.IO.Path.GetTempPath()}{profileName}\Logs\{filename}", + Layout = patternLayout, + PreserveLogFileNameExtension = true, + MaxSizeRollBackups = 5, + MaximumFileSize = "1GB", + RollingStyle = RollingFileAppender.RollingMode.Size, + StaticLogFileName = false + }; + roller.ActivateOptions(); + hierarchy.Root.AddAppender(roller); + + var memory = new MemoryAppender(); + memory.ActivateOptions(); + hierarchy.Root.AddAppender(memory); + +#if (DEBUG) + hierarchy.Root.Level = Level.Debug; +#else + hierarchy.Root.Level = Level.Info; +#endif + hierarchy.Configured = true; + } + } +} diff --git a/MTApiService/MTApiService.csproj b/MTApiService/MTApiService.csproj index ed103b9b..f27bbab7 100755 --- a/MTApiService/MTApiService.csproj +++ b/MTApiService/MTApiService.csproj @@ -1,5 +1,6 @@  + Debug AnyCPU @@ -14,6 +15,8 @@ 512 + + true @@ -35,12 +38,17 @@ AnyCPU - true + false - MtApiKey.pfx + + + + ..\packages\log4net.2.0.5\lib\net40-full\log4net.dll + True + @@ -54,6 +62,7 @@ + @@ -78,13 +87,28 @@ - + + Designer + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + +