Removed ConnectionManager from MtApi4 and MtApi5 installers. Api server side listens all newtwork connections

This commit is contained in:
Vyacheslav Demidyuk
2014-12-14 19:58:26 +02:00
parent ab14a5f8a2
commit 7147734e9f
15 changed files with 229 additions and 257 deletions
+2 -2
View File
@@ -94,7 +94,7 @@ void _stdcall verify(int isDemo, wchar_t* accountName, long accountNumber)
g_IsVerified = VerifySignature(inputData, gcnew System::String(signature), publicKey); g_IsVerified = VerifySignature(inputData, gcnew System::String(signature), publicKey);
} }
int _stdcall initExpert(int expertHandle, wchar_t* connectionProfile, wchar_t* symbol, double bid, double ask, wchar_t* err) int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, wchar_t* err)
{ {
if (g_IsVerified == false) if (g_IsVerified == false)
{ {
@@ -107,7 +107,7 @@ int _stdcall initExpert(int expertHandle, wchar_t* connectionProfile, wchar_t* s
try try
{ {
MT5Handler^ mtHander = gcnew MT5Handler(); MT5Handler^ mtHander = gcnew MT5Handler();
MtServerInstance::GetInstance()->InitExpert(expertHandle, gcnew String(connectionProfile), gcnew String(symbol), bid, ask, mtHander); MtServerInstance::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHander);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
+122 -65
View File
@@ -8,6 +8,7 @@ using System.Net;
using System.Diagnostics; using System.Diagnostics;
using System.ServiceModel.Channels; using System.ServiceModel.Channels;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Net.Sockets;
namespace MTApiService namespace MTApiService
{ {
@@ -19,38 +20,28 @@ namespace MTApiService
#endregion #endregion
#region ctor #region ctor
public MtServer(MtConnectionProfile profile) public MtServer(int port)
{ {
Profile = profile; Port = port;
mService = new MtService(this); mService = new MtService(this);
mHosts = new List<ServiceHost>();
mExecutorManager = new MtCommandExecutorManager(); mExecutorManager = new MtCommandExecutorManager();
mExecutorManager.CommandExecuted += mExecutorManager_CommandExecuted; mExecutorManager.CommandExecuted += mExecutorManager_CommandExecuted;
} }
#endregion #endregion
#region Properties #region Properties
public MtConnectionProfile Profile { get; private set; } public int Port { get; private set; }
#endregion #endregion
#region Public Methods #region Public Methods
public void Start() public void Start()
{ {
lock (mHostLocker) bool hostsInitialized = InitHosts(Port);
{ if (hostsInitialized == false)
if (mHost != null) return;
return;
ServiceHost host = new ServiceHost(mService);
string mServerUrlAdress = CreateConnectionAddress(Profile);
Binding mBinding = CreateConnectionBinding(Profile);
host.AddServiceEndpoint(typeof(IMtApi), mBinding, mServerUrlAdress);
host.Open();
mHost = host;
}
lock (mExpertsLocker) lock (mExpertsLocker)
{ {
@@ -58,6 +49,69 @@ namespace MTApiService
} }
} }
private bool InitHosts(int port)
{
lock (mHostLocker)
{
if (mHosts.Count > 0)
return false;
//init local pipe host
string localUrl = CreateConnectionAddress(null, port, true);
ServiceHost localServiceHost = CreateServiceHost(localUrl, true);
if (localServiceHost != null)
{
mHosts.Add(localServiceHost);
}
//init network hosts
IPHostEntry ips = Dns.GetHostEntry(Dns.GetHostName());
if (ips != null)
{
foreach (IPAddress ipAddress in ips.AddressList)
{
if (ipAddress != null)
{
if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
{
string ip = ipAddress.ToString();
string networkUrl = CreateConnectionAddress(ip, port, false);
ServiceHost serviceHost = CreateServiceHost(networkUrl, false);
if (serviceHost != null)
{
mHosts.Add(serviceHost);
}
}
}
}
}
}
return true;
}
private ServiceHost CreateServiceHost(string serverUrlAdress, bool local)
{
ServiceHost serviceHost = null;
if (serverUrlAdress != null)
{
try
{
serviceHost = new ServiceHost(mService);
Binding binding = CreateConnectionBinding(local);
serviceHost.AddServiceEndpoint(typeof(IMtApi), binding, serverUrlAdress);
serviceHost.Open();
}
catch(Exception e)
{
Debug.WriteLine("CreateServiceHost: Create ServiceHost failed. " + e.Message);
}
}
return serviceHost;
}
public void AddExpert(MtExpert expert) public void AddExpert(MtExpert expert)
{ {
if (expert != null) if (expert != null)
@@ -148,67 +202,64 @@ namespace MTApiService
stopTimer.Elapsed -= stopTimer_Elapsed; stopTimer.Elapsed -= stopTimer_Elapsed;
} }
private string CreateConnectionAddress(MtConnectionProfile profile) private string CreateConnectionAddress(string host, int port, bool local)
{ {
string connectionAddress = null; string connectionAddress = null;
if (profile != null) if (local == true)
{ {
if (string.IsNullOrEmpty(profile.Host)) //by Pipe
connectionAddress = "net.pipe://localhost/MtApiService_" + port.ToString();
}
else
{
//by Socket
if (host != null)
{ {
//by Pipe connectionAddress = "net.tcp://" + host.ToString() + ":" + port.ToString() + "/MtApiService";
connectionAddress = "net.pipe://localhost/MtApiService_" + profile.Port.ToString();
}
else
{
//by Socket
connectionAddress = "net.tcp://" + profile.Host.ToString() + ":" + profile.Port.ToString() + "/MtApiService";
} }
} }
return connectionAddress; return connectionAddress;
} }
private static Binding CreateConnectionBinding(MtConnectionProfile profile) private static Binding CreateConnectionBinding(bool local)
{ {
Binding connectionBinding = null; Binding connectionBinding = null;
if (profile != null) if (local == true)
{ {
if (string.IsNullOrEmpty(profile.Host)) //by Pipe
{ var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
//by Pipe bind.MaxReceivedMessageSize = 2147483647;
var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); bind.MaxBufferSize = 2147483647;
bind.MaxReceivedMessageSize = 2147483647;
bind.MaxBufferSize = 2147483647;
// Commented next statement since it is not required // Commented next statement since it is not required
bind.MaxBufferPoolSize = 2147483647; bind.MaxBufferPoolSize = 2147483647;
bind.ReaderQuotas.MaxArrayLength = 2147483647; bind.ReaderQuotas.MaxArrayLength = 2147483647;
bind.ReaderQuotas.MaxBytesPerRead = 2147483647; bind.ReaderQuotas.MaxBytesPerRead = 2147483647;
bind.ReaderQuotas.MaxDepth = 2147483647; bind.ReaderQuotas.MaxDepth = 2147483647;
bind.ReaderQuotas.MaxStringContentLength = 2147483647; bind.ReaderQuotas.MaxStringContentLength = 2147483647;
bind.ReaderQuotas.MaxNameTableCharCount = 2147483647; bind.ReaderQuotas.MaxNameTableCharCount = 2147483647;
connectionBinding = bind; connectionBinding = bind;
} }
else else
{ {
//by Socket //by Socket
var bind = new NetTcpBinding(SecurityMode.None); var bind = new NetTcpBinding(SecurityMode.None);
bind.MaxReceivedMessageSize = 2147483647; bind.MaxReceivedMessageSize = 2147483647;
bind.MaxBufferSize = 2147483647; bind.MaxBufferSize = 2147483647;
// Commented next statement since it is not required // Commented next statement since it is not required
bind.MaxBufferPoolSize = 2147483647; bind.MaxBufferPoolSize = 2147483647;
bind.ReaderQuotas.MaxArrayLength = 2147483647; bind.ReaderQuotas.MaxArrayLength = 2147483647;
bind.ReaderQuotas.MaxBytesPerRead = 2147483647; bind.ReaderQuotas.MaxBytesPerRead = 2147483647;
bind.ReaderQuotas.MaxDepth = 2147483647; bind.ReaderQuotas.MaxDepth = 2147483647;
bind.ReaderQuotas.MaxStringContentLength = 2147483647; bind.ReaderQuotas.MaxStringContentLength = 2147483647;
bind.ReaderQuotas.MaxNameTableCharCount = 2147483647; bind.ReaderQuotas.MaxNameTableCharCount = 2147483647;
connectionBinding = bind; connectionBinding = bind;
}
} }
return connectionBinding; return connectionBinding;
@@ -220,23 +271,29 @@ namespace MTApiService
lock (mHostLocker) lock (mHostLocker)
{ {
if (mHost == null) if (mHosts.Count == 0)
return; return;
try try
{ {
mHost.Close(); foreach (var host in mHosts)
{
host.Close();
}
} }
catch (TimeoutException) catch (TimeoutException)
{ {
mHost.Abort(); foreach (var host in mHosts)
{
host.Abort();
}
} }
catch (Exception) catch (Exception)
{ {
} }
finally finally
{ {
mHost = null; mHosts.Clear();
} }
} }
@@ -317,7 +374,7 @@ namespace MTApiService
#region Fields #region Fields
private readonly MtService mService; private readonly MtService mService;
private ServiceHost mHost; private readonly List<ServiceHost> mHosts;
private readonly MtCommandExecutorManager mExecutorManager; private readonly MtCommandExecutorManager mExecutorManager;
private List<MtExpert> mExperts; private List<MtExpert> mExperts;
+12 -30
View File
@@ -31,37 +31,22 @@ namespace MTApiService
#region Public Methods #region Public Methods
public void InitExpert(int expertHandle, string profileName, string symbol, double bid, double ask, IMetaTraderHandler mtHandler) public void InitExpert(int expertHandle, int port, string symbol, double bid, double ask, IMetaTraderHandler mtHandler)
{ {
Debug.WriteLine("MtApiServerInstance::InitExpert: symbol = {0}, expertHandle = {1}, profileName = {2}", symbol, expertHandle, profileName); Debug.WriteLine("MtApiServerInstance::InitExpert: symbol = {0}, expertHandle = {1}, port = {2}", symbol, expertHandle, port);
if (profileName == null)
{
string errorMessage = string.Format("Connection profile is null or empty");
throw new Exception(errorMessage);
}
MtServer server = null; MtServer server = null;
lock (mServersDictionary) lock (mServersDictionary)
{ {
if (mServersDictionary.ContainsKey(profileName)) if (mServersDictionary.ContainsKey(port))
{ {
server = mServersDictionary[profileName]; server = mServersDictionary[port];
} }
else else
{ {
var profile = MtRegistryManager.LoadConnectionProfile(profileName); server = new MtServer(port);
if (profile == null)
{
string errorMessage = string.Format("Connection profile '{0}' is not found", profileName);
throw new Exception(errorMessage);
}
server = new MtServer(profile);
server.Stopped += new EventHandler(server_Stopped); server.Stopped += new EventHandler(server_Stopped);
mServersDictionary[port] = server;
mServersDictionary[profile.Name] = server;
server.Start(); server.Start();
} }
@@ -69,7 +54,7 @@ namespace MTApiService
var expert = new MtExpert(expertHandle, new MtQuote(symbol, bid, ask), mtHandler); var expert = new MtExpert(expertHandle, new MtQuote(symbol, bid, ask), mtHandler);
lock(mExpertsDictionary) lock (mExpertsDictionary)
{ {
mExpertsDictionary[expert.Handle] = expert; mExpertsDictionary[expert.Handle] = expert;
} }
@@ -167,15 +152,12 @@ namespace MTApiService
MtServer server = (MtServer)sender; MtServer server = (MtServer)sender;
server.Stopped -= server_Stopped; server.Stopped -= server_Stopped;
var profile = server.Profile; var port = server.Port;
if (profile != null) lock (mServersDictionary)
{ {
lock (mServersDictionary) if (mServersDictionary.ContainsKey(port))
{ {
if (mServersDictionary.ContainsKey(profile.Name)) mServersDictionary.Remove(port);
{
mServersDictionary.Remove(profile.Name);
}
} }
} }
} }
@@ -183,7 +165,7 @@ namespace MTApiService
#region Fields #region Fields
private readonly MtRegistryManager mConnectionManager = new MtRegistryManager(); private readonly MtRegistryManager mConnectionManager = new MtRegistryManager();
private readonly Dictionary<string, MtServer> mServersDictionary = new Dictionary<string, MtServer>(); private readonly Dictionary<int, MtServer> mServersDictionary = new Dictionary<int, MtServer>();
private readonly Dictionary<int, MtExpert> mExpertsDictionary = new Dictionary<int, MtExpert>(); private readonly Dictionary<int, MtExpert> mExpertsDictionary = new Dictionary<int, MtExpert>();
#endregion #endregion
} }
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.15.0")] [assembly: AssemblyVersion("1.0.16.0")]
[assembly: AssemblyFileVersion("1.0.15.0")] [assembly: AssemblyFileVersion("1.0.16.0")]
+2 -2
View File
@@ -36,13 +36,13 @@ void mqlStrFromNetStr(MqlStr* dst, String^ src)
*((int*) dst) = num; *((int*) dst) = num;
} }
int _stdcall initExpert(int expertHandle, char* connectionProfile, char* symbol, double bid, double ask, MqlStr* err) int _stdcall initExpert(int expertHandle, int port, char* symbol, double bid, double ask, MqlStr* err)
{ {
try try
{ {
MT4Handler^ mtHandler = gcnew MT4Handler(); MT4Handler^ mtHandler = gcnew MT4Handler();
MtServerInstance::GetInstance()->InitExpert(expertHandle, gcnew String(connectionProfile), gcnew String(symbol), bid, ask, mtHandler); MtServerInstance::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHandler);
} }
catch (Exception^ e) catch (Exception^ e)
{ {
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.17.0")] [assembly: AssemblyVersion("1.0.18.0")]
[assembly: AssemblyFileVersion("1.0.17.0")] [assembly: AssemblyFileVersion("1.0.18.0")]
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.8.0")] [assembly: AssemblyVersion("1.0.9.0")]
[assembly: AssemblyFileVersion("1.0.8.0")] [assembly: AssemblyFileVersion("1.0.9.0")]
+30 -65
View File
@@ -15,13 +15,13 @@
{ {
"Entry" "Entry"
{ {
"MsmKey" = "8:_26066077D06445DAA7176D267C4A5A5C" "MsmKey" = "8:_09A2A529F84A49C7B6AB040A24312600"
"OwnerKey" = "8:_UNDEFINED" "OwnerKey" = "8:_8B9C059CECE541EF9F06C906252E106A"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_324E39D64C4D4ECDA1AAA532677EA0F4" "MsmKey" = "8:_26066077D06445DAA7176D267C4A5A5C"
"OwnerKey" = "8:_UNDEFINED" "OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
@@ -40,7 +40,7 @@
"Entry" "Entry"
{ {
"MsmKey" = "8:_C28BD2D9EC05E0CCB849ABEEA4360539" "MsmKey" = "8:_C28BD2D9EC05E0CCB849ABEEA4360539"
"OwnerKey" = "8:_324E39D64C4D4ECDA1AAA532677EA0F4" "OwnerKey" = "8:_A1E29B278F4C4BCAA1195F775A473B52"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
@@ -51,14 +51,14 @@
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_C28BD2D9EC05E0CCB849ABEEA4360539" "MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_A1E29B278F4C4BCAA1195F775A473B52" "OwnerKey" = "8:_A1E29B278F4C4BCAA1195F775A473B52"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_UNDEFINED" "MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_324E39D64C4D4ECDA1AAA532677EA0F4" "OwnerKey" = "8:_8B9C059CECE541EF9F06C906252E106A"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
@@ -67,18 +67,6 @@
"OwnerKey" = "8:_C28BD2D9EC05E0CCB849ABEEA4360539" "OwnerKey" = "8:_C28BD2D9EC05E0CCB849ABEEA4360539"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_8B9C059CECE541EF9F06C906252E106A"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_A1E29B278F4C4BCAA1195F775A473B52"
"MsmSig" = "8:_UNDEFINED"
}
} }
"Configurations" "Configurations"
{ {
@@ -208,9 +196,14 @@
{ {
"AssemblyRegister" = "3:1" "AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE" "AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:MTApiService, Version=1.0.13.0, Culture=neutral, PublicKeyToken=704b91b7000ff499, processorArchitecture=MSIL" "AssemblyAsmDisplayName" = "8:MTApiService, Version=1.0.16.0, Culture=neutral, PublicKeyToken=704b91b7000ff499, processorArchitecture=MSIL"
"ScatterAssemblies" "ScatterAssemblies"
{ {
"_C28BD2D9EC05E0CCB849ABEEA4360539"
{
"Name" = "8:MTApiService.dll"
"Attributes" = "3:512"
}
} }
"SourcePath" = "8:MTApiService.dll" "SourcePath" = "8:MTApiService.dll"
"TargetName" = "8:" "TargetName" = "8:"
@@ -341,15 +334,15 @@
{ {
"Name" = "8:Microsoft Visual Studio" "Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:MtApi5" "ProductName" = "8:MtApi5"
"ProductCode" = "8:{02DC498A-5F06-4134-BD32-C5D677B8017A}" "ProductCode" = "8:{63AEBD77-6321-43A9-AAD6-A23851E21689}"
"PackageCode" = "8:{23755B17-D96D-4C2C-A6BD-D3E136A8992E}" "PackageCode" = "8:{7C51C7DD-2527-4EAA-BFEB-E679F5598C7C}"
"UpgradeCode" = "8:{5673F99F-74B5-4D75-9648-3250C9B492FB}" "UpgradeCode" = "8:{5673F99F-74B5-4D75-9648-3250C9B492FB}"
"AspNetVersion" = "8:4.0.30319.0" "AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE" "RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE" "RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE" "InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.0.8" "ProductVersion" = "8:1.0.9"
"Manufacturer" = "8:DW" "Manufacturer" = "8:DW"
"ARPHELPTELEPHONE" = "8:" "ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:" "ARPHELPLINK" = "8:"
@@ -612,20 +605,6 @@
} }
"Shortcut" "Shortcut"
{ {
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_1ED863424C6F4192BB1EA4C93066568D"
{
"Name" = "8:ConnectionsManager"
"Arguments" = "8:"
"Description" = "8:"
"ShowCmd" = "3:1"
"IconIndex" = "3:32512"
"Transitive" = "11:FALSE"
"Target" = "8:_324E39D64C4D4ECDA1AAA532677EA0F4"
"Folder" = "8:_DBA35A849F8E43DA91CB111FD9E4DA07"
"WorkingFolder" = "8:_234A0E905EAA4F9288321F174D48109C"
"Icon" = "8:_324E39D64C4D4ECDA1AAA532677EA0F4"
"Feature" = "8:"
}
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_A632B76B37AF4FF4B995A0F1797DB1D8" "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_A632B76B37AF4FF4B995A0F1797DB1D8"
{ {
"Name" = "8:MtApi5.ex5" "Name" = "8:MtApi5.ex5"
@@ -1036,40 +1015,26 @@
} }
"MergeModule" "MergeModule"
{ {
"{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_09A2A529F84A49C7B6AB040A24312600"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
"SourcePath" = "8:Microsoft_VC100_CRT_x64.msm"
"Properties"
{
}
"LanguageId" = "3:0"
"Exclude" = "11:FALSE"
"Folder" = "8:"
"Feature" = "8:"
"IsolateTo" = "8:"
}
} }
"ProjectOutput" "ProjectOutput"
{ {
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_324E39D64C4D4ECDA1AAA532677EA0F4"
{
"SourcePath" = "8:..\\ConnectionsManager\\obj\\Release\\ConnectionsManager.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_234A0E905EAA4F9288321F174D48109C"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
"ProjectOutputGroupRegister" = "3:1"
"OutputConfiguration" = "8:"
"OutputGroupCanonicalName" = "8:Built"
"OutputProjectGuid" = "8:{C8751BA1-6A85-468C-87BD-758F37B8C0DD}"
"ShowKeyOutput" = "11:TRUE"
"ExcludeFilters"
{
}
}
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_8B9C059CECE541EF9F06C906252E106A" "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_8B9C059CECE541EF9F06C906252E106A"
{ {
"SourcePath" = "8:..\\Release\\MT5Connector.dll" "SourcePath" = "8:..\\x64\\Release\\MT5Connector.dll"
"TargetName" = "8:" "TargetName" = "8:"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_6185AD4113574BCA9BE89DF5A396A60C" "Folder" = "8:_6185AD4113574BCA9BE89DF5A396A60C"
+30 -65
View File
@@ -28,29 +28,23 @@
"Entry" "Entry"
{ {
"MsmKey" = "8:_1894B11511EC28CA06BF342E1D467761" "MsmKey" = "8:_1894B11511EC28CA06BF342E1D467761"
"OwnerKey" = "8:_67B77AB154964269BD0C77F69052517C"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_1894B11511EC28CA06BF342E1D467761"
"OwnerKey" = "8:_BC617CC9A43A49E8B6CDC49115E4A3BC" "OwnerKey" = "8:_BC617CC9A43A49E8B6CDC49115E4A3BC"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_67B77AB154964269BD0C77F69052517C"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_BC617CC9A43A49E8B6CDC49115E4A3BC" "MsmKey" = "8:_BC617CC9A43A49E8B6CDC49115E4A3BC"
"OwnerKey" = "8:_UNDEFINED" "OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_D37870AADDAD48659E6D4F4674204721"
"OwnerKey" = "8:_BC617CC9A43A49E8B6CDC49115E4A3BC"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_EEB0B45EB0DA4A1C8854FBB96C7C1BC1" "MsmKey" = "8:_EEB0B45EB0DA4A1C8854FBB96C7C1BC1"
"OwnerKey" = "8:_UNDEFINED" "OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
@@ -64,12 +58,6 @@
"Entry" "Entry"
{ {
"MsmKey" = "8:_UNDEFINED" "MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_67B77AB154964269BD0C77F69052517C"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_038CD973685F41E989B4EFA7BDE0FCC7" "OwnerKey" = "8:_038CD973685F41E989B4EFA7BDE0FCC7"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
@@ -188,9 +176,14 @@
{ {
"AssemblyRegister" = "3:1" "AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE" "AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:MTApiService, Version=1.0.13.0, Culture=neutral, PublicKeyToken=704b91b7000ff499, processorArchitecture=MSIL" "AssemblyAsmDisplayName" = "8:MTApiService, Version=1.0.16.0, Culture=neutral, PublicKeyToken=704b91b7000ff499, processorArchitecture=MSIL"
"ScatterAssemblies" "ScatterAssemblies"
{ {
"_1894B11511EC28CA06BF342E1D467761"
{
"Name" = "8:MTApiService.dll"
"Attributes" = "3:512"
}
} }
"SourcePath" = "8:MTApiService.dll" "SourcePath" = "8:MTApiService.dll"
"TargetName" = "8:" "TargetName" = "8:"
@@ -341,15 +334,15 @@
{ {
"Name" = "8:Microsoft Visual Studio" "Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:MtApi5" "ProductName" = "8:MtApi5"
"ProductCode" = "8:{4B2B9BEE-9FB1-4E27-9B5F-0C7DAE61A624}" "ProductCode" = "8:{75616430-7567-496D-A23B-F985F257B728}"
"PackageCode" = "8:{743CA117-4184-4A9C-B0F9-298A4D6925DB}" "PackageCode" = "8:{AEFB2055-7349-4209-A97F-10C3125D1609}"
"UpgradeCode" = "8:{0D37B66D-F57F-4AF8-9AF5-B0EB060D60BE}" "UpgradeCode" = "8:{0D37B66D-F57F-4AF8-9AF5-B0EB060D60BE}"
"AspNetVersion" = "8:4.0.30319.0" "AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE" "RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE" "RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE" "InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.0.8" "ProductVersion" = "8:1.0.9"
"Manufacturer" = "8:DW" "Manufacturer" = "8:DW"
"ARPHELPTELEPHONE" = "8:" "ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:" "ARPHELPLINK" = "8:"
@@ -520,20 +513,6 @@
} }
"Shortcut" "Shortcut"
{ {
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_1E1CBEE93704418385DA08BF427F2BFB"
{
"Name" = "8:ConnectionsManager"
"Arguments" = "8:"
"Description" = "8:"
"ShowCmd" = "3:1"
"IconIndex" = "3:32512"
"Transitive" = "11:FALSE"
"Target" = "8:_67B77AB154964269BD0C77F69052517C"
"Folder" = "8:_AF5FE77112F9440DA1B35AC8377AB0B0"
"WorkingFolder" = "8:_C5686AA9455245A68A7C203AF12544DE"
"Icon" = "8:_67B77AB154964269BD0C77F69052517C"
"Feature" = "8:"
}
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_A1DA4D11FC714A5BB03D89269007F5FF" "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_A1DA4D11FC714A5BB03D89269007F5FF"
{ {
"Name" = "8:MtApi5.ex5" "Name" = "8:MtApi5.ex5"
@@ -944,6 +923,20 @@
} }
"MergeModule" "MergeModule"
{ {
"{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_D37870AADDAD48659E6D4F4674204721"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
"SourcePath" = "8:Microsoft_VC100_CRT_x86.msm"
"Properties"
{
}
"LanguageId" = "3:0"
"Exclude" = "11:FALSE"
"Folder" = "8:"
"Feature" = "8:"
"IsolateTo" = "8:"
}
} }
"ProjectOutput" "ProjectOutput"
{ {
@@ -975,37 +968,9 @@
{ {
} }
} }
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_67B77AB154964269BD0C77F69052517C"
{
"SourcePath" = "8:..\\ConnectionsManager\\obj\\Release\\ConnectionsManager.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_C5686AA9455245A68A7C203AF12544DE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
"ProjectOutputGroupRegister" = "3:1"
"OutputConfiguration" = "8:"
"OutputGroupCanonicalName" = "8:Built"
"OutputProjectGuid" = "8:{C8751BA1-6A85-468C-87BD-758F37B8C0DD}"
"ShowKeyOutput" = "11:TRUE"
"ExcludeFilters"
{
}
}
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_BC617CC9A43A49E8B6CDC49115E4A3BC" "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_BC617CC9A43A49E8B6CDC49115E4A3BC"
{ {
"SourcePath" = "8:..\\x64\\Release\\MT5Connector.dll" "SourcePath" = "8:..\\Release\\MT5Connector.dll"
"TargetName" = "8:" "TargetName" = "8:"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_82290571E7764B168E741604315C2206" "Folder" = "8:_82290571E7764B168E741604315C2206"
+5 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductName="MtApi" ?> <?define ProductName="MtApi" ?>
<?define ProductVersion="1.0.17" ?> <?define ProductVersion="1.0.18" ?>
<?define Manufacturer="DW"?> <?define Manufacturer="DW"?>
<Product Id="*" <Product Id="*"
@@ -77,17 +77,21 @@
Source="..\mq4\MtApi.ex4" /> Source="..\mq4\MtApi.ex4" />
</Component> </Component>
<!--
<Component Id="ConnectionsManagerApp" Directory="INSTALLFOLDER"> <Component Id="ConnectionsManagerApp" Directory="INSTALLFOLDER">
<File Id="ConnectionsManager.exe" Name="ConnectionsManager.exe" KeyPath="yes" <File Id="ConnectionsManager.exe" Name="ConnectionsManager.exe" KeyPath="yes"
Source="..\Release\ConnectionsManager.exe" /> Source="..\Release\ConnectionsManager.exe" />
</Component> </Component>
-->
<Component Id="AppShortcutConnMgr" Guid="*" Directory="ApplicationProgramsFolder"> <Component Id="AppShortcutConnMgr" Guid="*" Directory="ApplicationProgramsFolder">
<!--
<Shortcut Id="ShortcutConnMgr" <Shortcut Id="ShortcutConnMgr"
Name="ConnectionManager" Name="ConnectionManager"
Description="$(var.ProductName)" Description="$(var.ProductName)"
Target="[INSTALLFOLDER]ConnectionsManager.exe" Target="[INSTALLFOLDER]ConnectionsManager.exe"
WorkingDirectory="INSTALLFOLDER"/> WorkingDirectory="INSTALLFOLDER"/>
-->
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/> <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/> <RegistryValue Root="HKCU" Key="Software\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component> </Component>
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -5,7 +5,7 @@
#include <stdlib.mqh> #include <stdlib.mqh>
#import "MTConnector.dll" #import "MTConnector.dll"
bool initExpert(int expertHandle, string connectionProfile, string symbol, double bid, double ask, string& err[]); bool initExpert(int expertHandle, int port, string symbol, double bid, double ask, string& err[]);
bool deinitExpert(int expertHandle, string& err[]); bool deinitExpert(int expertHandle, string& err[]);
bool updateQuote(int expertHandle, string symbol, double bid, double ask, string& err[]); bool updateQuote(int expertHandle, string symbol, double bid, double ask, string& err[]);
@@ -23,7 +23,7 @@
bool getStringValue(int expertHandle, int paramIndex, string& res[]); bool getStringValue(int expertHandle, int paramIndex, string& res[]);
#import #import
extern string ConnectionProfile = "Local"; extern int Port = 8222;
int ExpertHandle; int ExpertHandle;
@@ -169,7 +169,7 @@ int init() {
ExpertHandle = WindowHandle(Symbol(), Period()); ExpertHandle = WindowHandle(Symbol(), Period());
if (!initExpert(ExpertHandle, ConnectionProfile, Symbol(), Bid, Ask, message)) if (!initExpert(ExpertHandle, Port, Symbol(), Bid, Ask, message))
{ {
MessageBox(message[0], "MtApi", MB_OK); MessageBox(message[0], "MtApi", MB_OK);
isCrashed = TRUE; isCrashed = TRUE;
Executable
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+13 -14
View File
@@ -5,7 +5,7 @@
#include <trade/trade.mqh> #include <trade/trade.mqh>
#import "MT5Connector.dll" #import "MT5Connector.dll"
bool initExpert(int expertHandle, string connectionProfile, string symbol, double bid, double ask, string& err); bool initExpert(int expertHandle, int port, string symbol, double bid, double ask, string& err);
bool deinitExpert(int expertHandle, string& err); bool deinitExpert(int expertHandle, string& err);
bool updateQuote(int expertHandle, string symbol, double bid, double ask, string& err); bool updateQuote(int expertHandle, string symbol, double bid, double ask, string& err);
@@ -36,7 +36,7 @@
// void verify(bool isDemo, string accountName, long accountNumber); // void verify(bool isDemo, string accountName, long accountNumber);
#import #import
input string ConnectionProfile = "Local5"; input int Port = 8228;
int ExpertHandle; int ExpertHandle;
@@ -121,7 +121,7 @@ int init()
myBid = Bid; myBid = Bid;
myAsk = Ask; myAsk = Ask;
if (!initExpert(ExpertHandle, ConnectionProfile, Symbol(), Bid, Ask, message)) if (!initExpert(ExpertHandle, Port, Symbol(), Bid, Ask, message))
{ {
MessageBox(message, "MtApi", 0); MessageBox(message, "MtApi", 0);
isCrashed = true; isCrashed = true;
@@ -218,6 +218,16 @@ int executeCommand()
} }
break; break;
case 63: //OrderCloseAll
{
bool retVal;
retVal = OrderCloseAll();
sendBooleanResponse(ExpertHandle, retVal);
}
break;
case 2: // OrderCalcMargin case 2: // OrderCalcMargin
{ {
ENUM_ORDER_TYPE action; ENUM_ORDER_TYPE action;
@@ -1592,17 +1602,6 @@ int executeCommand()
} }
break; break;
case 63: //OrderCloseAll
{
bool retVal;
retVal = OrderCloseAll();
sendBooleanResponse(ExpertHandle, retVal);
}
break;
default: default:
Print("Unknown command type = ", commandType); Print("Unknown command type = ", commandType);
sendVoidResponse(ExpertHandle); sendVoidResponse(ExpertHandle);