mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 11:07:48 +00:00
Compare commits
206 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc54b5dd4a | |||
| dd05804082 | |||
| 4349eb3538 | |||
| e0daf9a82e | |||
| 3997b6df74 | |||
| abfe1a281a | |||
| 93bfe8e56f | |||
| bb27b4e50d | |||
| 0f809cd60a | |||
| f22a6c21f0 | |||
| 625753d83a | |||
| d621312a8b | |||
| a4df4bbf1e | |||
| 43ef628c69 | |||
| 688149bd67 | |||
| c33a5ed6f5 | |||
| 828c1185b3 | |||
| 4b384d9da2 | |||
| 26de553443 | |||
| ee81cfe012 | |||
| 5f4ae3cd9e | |||
| 13b8aa9644 | |||
| e364b313c3 | |||
| 68f2a7ae07 | |||
| 42a1da3356 | |||
| 44fab4dae1 | |||
| d1387148df | |||
| bb4ac426cd | |||
| 34b4e33cc9 | |||
| f01ec01a5f | |||
| 0c38d37559 | |||
| 897892dc89 | |||
| 1a5882b75a | |||
| 0f717f1cb7 | |||
| 5d78ad5067 | |||
| 6c45f28a05 | |||
| ca3c0e735f | |||
| f71151104b | |||
| 28816a75ac | |||
| 6023bffed6 | |||
| fd34f009cd | |||
| 1bb2b65cdf | |||
| 37e8275465 | |||
| 52ca4fae1e | |||
| 6b327e017a | |||
| 10a758bd93 | |||
| 4a9642b60c | |||
| 6ba6496e46 | |||
| 1ffbba5ee3 | |||
| 8cdfd6fb91 | |||
| 7c3ddbabac | |||
| 83e0145a3a | |||
| f17c7cd554 | |||
| 4aefdd554b | |||
| 820ed9a631 | |||
| 95c55e90be | |||
| 486a1979a6 | |||
| faef5f7d18 | |||
| bd45c45fa1 | |||
| 29be184136 | |||
| 9bfda95cf7 | |||
| 24b881d8a0 | |||
| 07dd83f890 | |||
| 9afd30e463 | |||
| 16f454ca61 | |||
| f3a3a582fd | |||
| 93aaae86ed | |||
| bce68fd168 | |||
| 0812229538 | |||
| d0fa4af1d0 | |||
| 8eb4bcfabe | |||
| 9ea58354be | |||
| 02774d7328 | |||
| cbff71f8d0 | |||
| 951a91976c | |||
| 6a37826486 | |||
| cab2de6d24 | |||
| ec6c71607b | |||
| 0a39b69b15 | |||
| fe94ec21de | |||
| 34c78c73c0 | |||
| d7b8ef894c | |||
| 7f33cebce1 | |||
| 84740787d5 | |||
| ad6bad5187 | |||
| 0086b02bc8 | |||
| f7e06c1570 | |||
| c86a3a3752 | |||
| be8a17c0fd | |||
| 5c6751de9b | |||
| 83776f8b7a | |||
| f1c1df1e00 | |||
| d6640300f5 | |||
| c9c188f697 | |||
| 3a4f561836 | |||
| bdb30edee3 | |||
| 29f501b055 | |||
| 521d7ea2c0 | |||
| 0e5bb40a6f | |||
| 14079dc3c1 | |||
| 3600a86971 | |||
| 83e62fbff7 | |||
| 5c96aeb2fd | |||
| a238e5eb36 | |||
| 11fd5b7527 | |||
| cbe75cfbf6 | |||
| 9581431a9f | |||
| acf0c12531 | |||
| 1eccda9b2c | |||
| fd4aac7c32 | |||
| 36c90c8481 | |||
| fefa451371 | |||
| 1c57f88cb1 | |||
| 08ba45c65f | |||
| b8314e9ed7 | |||
| 9587b10c8c | |||
| b838084ba2 | |||
| cd24891022 | |||
| add69a4c03 | |||
| 5a3407e47c | |||
| ce8cfbbb70 | |||
| 8470bbd5cc | |||
| 5c7ae748a5 | |||
| 7abb4d3b5e | |||
| 486c42685a | |||
| f41ab37b6f | |||
| 9e129fb6e2 | |||
| f7b00a8d88 | |||
| a7cb14de25 | |||
| f50925c8d3 | |||
| e29a11de68 | |||
| 12141775f3 | |||
| b6d24b8aa9 | |||
| 7175fae18c | |||
| 3c4d8d52ca | |||
| 6873363d41 | |||
| 947599327a | |||
| 5645902a48 | |||
| c82787473f | |||
| c213fb709a | |||
| 2ac29dc871 | |||
| 1f72b2b790 | |||
| 3a62ff56d7 | |||
| d25fe529b4 | |||
| 15538e81f4 | |||
| a33be3c764 | |||
| 023fe8c7c9 | |||
| b77516e324 | |||
| 4b48423c3f | |||
| 9800177b08 | |||
| a33d4a4594 | |||
| 29722f362d | |||
| e072343fe1 | |||
| acb0c20ca8 | |||
| 83543fee88 | |||
| 3ce6b042de | |||
| 9dd770e768 | |||
| abb8b8afaa | |||
| 1d6569caa8 | |||
| 441a3cb8de | |||
| 443f5c982c | |||
| 515a12ab15 | |||
| 84b00b605a | |||
| 10e267d031 | |||
| abcd489367 | |||
| d630e61e3c | |||
| 280bab7faf | |||
| 26d270422b | |||
| 9cd2e3b18f | |||
| 50013c0c29 | |||
| ca49d23017 | |||
| 0346836d35 | |||
| 2cc41df01a | |||
| f05ade2cbf | |||
| d34524d77f | |||
| d06cc67a5d | |||
| 5b76bf0547 | |||
| 1c269f7339 | |||
| 21fb790d8c | |||
| 7c9a0aa8cc | |||
| 18ddf3df1c | |||
| a8832b79ba | |||
| 39146d68b2 | |||
| 5b03f01e9b | |||
| 8f5a1c8222 | |||
| f5f13a13cc | |||
| 9ef970cf1e | |||
| b5878ccb62 | |||
| 4a7bb6f2cb | |||
| 5abfeebc90 | |||
| e333164552 | |||
| 9a6968f618 | |||
| d63a53b8a9 | |||
| 7e821fcade | |||
| 88e2d22abe | |||
| fcfd741e5b | |||
| c722511c03 | |||
| 39599436ab | |||
| 8e3f206c76 | |||
| 8e5dcbd2ee | |||
| 563a5a895b | |||
| 32f6018858 | |||
| c64417474a | |||
| 6d4b5f4c00 | |||
| 601c95369e | |||
| 0542dd3e71 |
@@ -18,6 +18,9 @@ bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
|
||||
# Roslyn cache directories
|
||||
*.ide/
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<Window x:Class="ConnectionsManager.AboutWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="About" Height="130" Width="300"
|
||||
WindowStyle="ToolWindow"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Window.Resources>
|
||||
<BitmapImage x:Key="MtApiIcon" UriSource="pack://application:,,,/ConnectionsManager;component/favicon.ico"/>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Source="{StaticResource MtApiIcon}" Width="50" Height="50" HorizontalAlignment="Left" Margin="5"/>
|
||||
<TextBlock Grid.Column="1" Text="Connection manager for MtApi" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
|
||||
<Button Grid.Row="1" Content="OK" Margin="5"
|
||||
Width="70" IsDefault="True" IsCancel="True"
|
||||
DockPanel.Dock="Bottom"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ConnectionsManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AboutWindow.xaml
|
||||
/// </summary>
|
||||
public partial class AboutWindow : Window
|
||||
{
|
||||
public AboutWindow(Window owner)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.Owner = owner;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<Window x:Class="ConnectionsManager.AddProfileDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Add new connection profile" Height="180" Width="300"
|
||||
WindowStyle="ToolWindow"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Grid x:Name="_MainLayout">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Profile name" Margin="5"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="5"
|
||||
Text="{Binding Path=ProfileName, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Host" Margin="5"/>
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" Margin="5"
|
||||
ItemsSource="{Binding HostList}"
|
||||
SelectedItem="{Binding Host}"/>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Port" Margin="5"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="5"
|
||||
Text="{Binding Path=Port, UpdateSourceTrigger=PropertyChanged}"
|
||||
PreviewTextInput="TextBox_PreviewTextInput"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<StackPanel Grid.Row="3" Grid.ColumnSpan="2" Margin="0,10,0,0"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Bottom">
|
||||
<Button Content="OK" Width="70" Margin="4" IsDefault="True" Command="{Binding OkCommand}"/>
|
||||
<Button Content="Cancel" Width="70" Margin="4" IsCancel="True"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,97 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net;
|
||||
|
||||
namespace ConnectionsManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AddProfileDialog.xaml
|
||||
/// </summary>
|
||||
public partial class AddProfileDialog : Window
|
||||
{
|
||||
// private const string PIPE_SERVER_NAME = "localhost(pipe)";
|
||||
private const string LOCALHOST_NAME = "localhost";
|
||||
|
||||
public string ProfileName { get; set; }
|
||||
|
||||
public static readonly DependencyProperty HostProperty = DependencyProperty.Register("Host", typeof(string), typeof(AddProfileDialog));
|
||||
public string Host
|
||||
{
|
||||
get { return (string)this.GetValue(HostProperty); }
|
||||
set { this.SetValue(HostProperty, value); }
|
||||
}
|
||||
|
||||
public string Port { get; set; }
|
||||
|
||||
public DelegateCommand OkCommand { get; set; }
|
||||
|
||||
public List<string> HostList { get; set; }
|
||||
|
||||
public AddProfileDialog(Window owner)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.Owner = owner;
|
||||
|
||||
OkCommand = new DelegateCommand(ExecuteOk, CanExecuteOk);
|
||||
_MainLayout.DataContext = this;
|
||||
|
||||
Loaded += (sender, e) => MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
|
||||
|
||||
IPHostEntry ips = Dns.GetHostEntry(Dns.GetHostName());
|
||||
|
||||
HostList = new List<string>();
|
||||
HostList.Add(string.Empty);
|
||||
HostList.Add(LOCALHOST_NAME);
|
||||
|
||||
if (ips != null)
|
||||
{
|
||||
foreach (IPAddress ipAddress in ips.AddressList)
|
||||
{
|
||||
HostList.Add(ipAddress.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Host = HostList.First();
|
||||
}
|
||||
|
||||
private bool CanExecuteOk(object o)
|
||||
{
|
||||
return string.IsNullOrEmpty(ProfileName) == false
|
||||
&& string.IsNullOrEmpty(Port) == false;
|
||||
}
|
||||
|
||||
private void ExecuteOk(object o)
|
||||
{
|
||||
this.DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private static bool IsTextAllowed(string text)
|
||||
{
|
||||
Regex regex = new Regex("[^0-9]+");
|
||||
return !regex.IsMatch(text);
|
||||
}
|
||||
|
||||
private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !IsTextAllowed(e.Text);
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
OkCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<Application x:Class="ConnectionsManager.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace ConnectionsManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{C8751BA1-6A85-468C-87BD-758F37B8C0DD}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ConnectionsManager</RootNamespace>
|
||||
<AssemblyName>ConnectionsManager</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Debug\ConnectionsManager.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\ConnectionsManager.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="AboutWindow.xaml.cs">
|
||||
<DependentUpon>AboutWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AddProfileDialog.xaml.cs">
|
||||
<DependentUpon>AddProfileDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DelegateCommand.cs" />
|
||||
<Compile Include="ViewModel.cs" />
|
||||
<Page Include="AboutWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="AddProfileDialog.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
|
||||
<Project>{DE76D5C7-B99C-4467-8408-78173BDD84E0}</Project>
|
||||
<Name>MTApiService</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="favicon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy $(TargetPath) $(SolutionDir)Release\</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace ConnectionsManager
|
||||
{
|
||||
public class DelegateCommand : ICommand
|
||||
{
|
||||
private readonly Predicate<object> _canExecute;
|
||||
private readonly Action<object> _execute;
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public DelegateCommand(Action<object> execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
}
|
||||
|
||||
public DelegateCommand(Action<object> execute,
|
||||
Predicate<object> canExecute)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
if (_canExecute == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return _canExecute(parameter);
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
_execute(parameter);
|
||||
}
|
||||
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
if (CanExecuteChanged != null)
|
||||
{
|
||||
CanExecuteChanged(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<Window x:Class="ConnectionsManager.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="MtApi Connections Manager" Height="300" Width="440"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid x:Name="_MainLayout">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Menu>
|
||||
<MenuItem Header="Edit">
|
||||
<MenuItem Header="Add Profile..." Command="{Binding AddProfileCommand}"/>
|
||||
<MenuItem Header="Delete Profile" Command="{Binding DeleteProfileCommand}"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Help">
|
||||
<MenuItem Header="About" Command="{Binding ShowAboutCommand}"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<ListView Grid.Row="1"
|
||||
ItemsSource="{Binding ConnectionProfiles}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{Binding SelectedProfile}">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="140" Header="Profile" DisplayMemberBinding="{Binding Name}" />
|
||||
<GridViewColumn Width="180" Header="Host" DisplayMemberBinding="{Binding Host}" />
|
||||
<GridViewColumn Width="80" Header="Port" DisplayMemberBinding="{Binding Port}" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ConnectionsManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private ViewModel _vm;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_vm = new ViewModel();
|
||||
_MainLayout.DataContext = _vm;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_vm.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ConnectionsManager")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ConnectionsManager")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18034
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ConnectionsManager.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ConnectionsManager.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18034
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ConnectionsManager.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -1,114 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
using MTApiService;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
|
||||
namespace ConnectionsManager
|
||||
{
|
||||
class ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private ObservableCollection<MtConnectionProfile> _ConnectionProfiles = new ObservableCollection<MtConnectionProfile>();
|
||||
public ObservableCollection<MtConnectionProfile> ConnectionProfiles
|
||||
{
|
||||
get { return _ConnectionProfiles; }
|
||||
}
|
||||
|
||||
public DelegateCommand AddProfileCommand { get; private set; }
|
||||
public DelegateCommand DeleteProfileCommand { get; private set; }
|
||||
public DelegateCommand ShowAboutCommand { get; private set; }
|
||||
|
||||
private MtConnectionProfile _SelectedProfile;
|
||||
public MtConnectionProfile SelectedProfile
|
||||
{
|
||||
get { return _SelectedProfile; }
|
||||
set
|
||||
{
|
||||
_SelectedProfile = value;
|
||||
OnPropertyChanged("SelectedProfile");
|
||||
DeleteProfileCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
public ViewModel()
|
||||
{
|
||||
AddProfileCommand = new DelegateCommand(ExecuteAddProfile);
|
||||
DeleteProfileCommand = new DelegateCommand(ExecuteDeleteProfile, CanExecuteDeleteProfile);
|
||||
ShowAboutCommand = new DelegateCommand(ExecuteShowAbout);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
var profiles = MtRegistryManager.LoadConnectionProfiles();
|
||||
if (profiles != null)
|
||||
{
|
||||
foreach(var prof in profiles)
|
||||
{
|
||||
ConnectionProfiles.Add(prof);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
private void ExecuteAddProfile(object o)
|
||||
{
|
||||
var dlg = new AddProfileDialog(App.Current.MainWindow);
|
||||
var result = dlg.ShowDialog();
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
var profile = new MtConnectionProfile(dlg.ProfileName);
|
||||
profile.Host = dlg.Host;
|
||||
profile.Port = int.Parse(dlg.Port);
|
||||
|
||||
MtRegistryManager.AddConnectionProfile(profile);
|
||||
ConnectionProfiles.Add(profile);
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanExecuteDeleteProfile(object o)
|
||||
{
|
||||
return SelectedProfile != null;
|
||||
}
|
||||
|
||||
private void ExecuteDeleteProfile(object o)
|
||||
{
|
||||
var result = MessageBox.Show("Do you want to delete connection profile '" + SelectedProfile.Name + "' ?"
|
||||
, "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
MtRegistryManager.RemoveConnectionProfile(SelectedProfile.Name);
|
||||
ConnectionProfiles.Remove(SelectedProfile);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteShowAbout(object o)
|
||||
{
|
||||
var dlg = new AboutWindow(App.Current.MainWindow);
|
||||
dlg.ShowDialog();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 894 B |
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Security;
|
||||
|
||||
namespace Licensing
|
||||
{
|
||||
public class DigitalSignatureHelper
|
||||
{
|
||||
public static String GeneratePrivateKey()
|
||||
{
|
||||
DSACryptoServiceProvider dsa = new DSACryptoServiceProvider();
|
||||
return dsa.ToXmlString(true);
|
||||
}
|
||||
|
||||
public static String GetPublicKey(String privateKey)
|
||||
{
|
||||
DSACryptoServiceProvider dsa = new DSACryptoServiceProvider();
|
||||
dsa.FromXmlString(privateKey);
|
||||
return dsa.ToXmlString(false);
|
||||
}
|
||||
|
||||
public static string CreateSignature(string inputData, String privateKey)
|
||||
{
|
||||
// create the crypto-service provider:
|
||||
DSACryptoServiceProvider dsa = new DSACryptoServiceProvider();
|
||||
|
||||
// setup the dsa from the private key:
|
||||
dsa.FromXmlString(privateKey);
|
||||
|
||||
byte[] data = UTF8Encoding.ASCII.GetBytes(inputData);
|
||||
|
||||
// get the signature:
|
||||
byte[] signature = dsa.SignData(data);
|
||||
|
||||
return Convert.ToBase64String(signature);
|
||||
}
|
||||
|
||||
public static bool VerifySignature(string inputData, string signature, string publicKey)
|
||||
{
|
||||
// create the crypto-service provider:
|
||||
DSACryptoServiceProvider dsa = new DSACryptoServiceProvider();
|
||||
|
||||
// setup the provider from the public key:
|
||||
dsa.FromXmlString(publicKey);
|
||||
|
||||
// get the license terms data:
|
||||
//byte[] data = Convert.FromBase64String(inputData);
|
||||
byte[] data = UTF8Encoding.ASCII.GetBytes(inputData);
|
||||
|
||||
// get the signature data:
|
||||
byte[] signatureData = Convert.FromBase64String(signature);
|
||||
|
||||
// verify that the license-terms match the signature data
|
||||
if (dsa.VerifyData(data, signatureData) == false)
|
||||
throw new SecurityException("Signature Not Verified!");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{21FA6E21-EE5D-4A84-B0ED-E1D8876B41FB}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Licensing</RootNamespace>
|
||||
<AssemblyName>Licensing</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DigitalSignatureHelper.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
|
||||
<Project>{DE76D5C7-B99C-4467-8408-78173BDD84E0}</Project>
|
||||
<Name>MTApiService</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Generated
-326
@@ -1,326 +0,0 @@
|
||||
namespace Licensing
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textBoxPublicKey = new System.Windows.Forms.TextBox();
|
||||
this.buttonGenerateKey = new System.Windows.Forms.Button();
|
||||
this.buttonLoadKey = new System.Windows.Forms.Button();
|
||||
this.buttonSaveKey = new System.Windows.Forms.Button();
|
||||
this.textBoxPrivateKey = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.textBoxAccountName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxAccountNumber = new System.Windows.Forms.TextBox();
|
||||
this.buttonSign = new System.Windows.Forms.Button();
|
||||
this.textBoxSignature = new System.Windows.Forms.TextBox();
|
||||
this.buttonGetPublicKey = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.clipboardCopyBtn = new System.Windows.Forms.Button();
|
||||
this.buttonExportPublicKey = new System.Windows.Forms.Button();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
this.saveToRegBtn = new System.Windows.Forms.Button();
|
||||
this.buttonVerify = new System.Windows.Forms.Button();
|
||||
this.buttonExportSignature = new System.Windows.Forms.Button();
|
||||
this.readRegBtn = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxPublicKey
|
||||
//
|
||||
this.textBoxPublicKey.Location = new System.Drawing.Point(6, 19);
|
||||
this.textBoxPublicKey.Name = "textBoxPublicKey";
|
||||
this.textBoxPublicKey.ReadOnly = true;
|
||||
this.textBoxPublicKey.Size = new System.Drawing.Size(620, 20);
|
||||
this.textBoxPublicKey.TabIndex = 0;
|
||||
//
|
||||
// buttonGenerateKey
|
||||
//
|
||||
this.buttonGenerateKey.Location = new System.Drawing.Point(6, 45);
|
||||
this.buttonGenerateKey.Name = "buttonGenerateKey";
|
||||
this.buttonGenerateKey.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonGenerateKey.TabIndex = 2;
|
||||
this.buttonGenerateKey.Text = "Generate";
|
||||
this.buttonGenerateKey.UseVisualStyleBackColor = true;
|
||||
this.buttonGenerateKey.Click += new System.EventHandler(this.buttonGenerateKey_Click);
|
||||
//
|
||||
// buttonLoadKey
|
||||
//
|
||||
this.buttonLoadKey.Location = new System.Drawing.Point(168, 45);
|
||||
this.buttonLoadKey.Name = "buttonLoadKey";
|
||||
this.buttonLoadKey.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonLoadKey.TabIndex = 3;
|
||||
this.buttonLoadKey.Text = "Load";
|
||||
this.buttonLoadKey.UseVisualStyleBackColor = true;
|
||||
this.buttonLoadKey.Click += new System.EventHandler(this.buttonLoadKey_Click);
|
||||
//
|
||||
// buttonSaveKey
|
||||
//
|
||||
this.buttonSaveKey.Location = new System.Drawing.Point(87, 45);
|
||||
this.buttonSaveKey.Name = "buttonSaveKey";
|
||||
this.buttonSaveKey.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSaveKey.TabIndex = 4;
|
||||
this.buttonSaveKey.Text = "Save";
|
||||
this.buttonSaveKey.UseVisualStyleBackColor = true;
|
||||
this.buttonSaveKey.Click += new System.EventHandler(this.buttonSaveKey_Click);
|
||||
//
|
||||
// textBoxPrivateKey
|
||||
//
|
||||
this.textBoxPrivateKey.Location = new System.Drawing.Point(6, 19);
|
||||
this.textBoxPrivateKey.Name = "textBoxPrivateKey";
|
||||
this.textBoxPrivateKey.ReadOnly = true;
|
||||
this.textBoxPrivateKey.Size = new System.Drawing.Size(620, 20);
|
||||
this.textBoxPrivateKey.TabIndex = 0;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(8, 48);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(47, 13);
|
||||
this.label4.TabIndex = 6;
|
||||
this.label4.Text = "Number:";
|
||||
//
|
||||
// textBoxAccountName
|
||||
//
|
||||
this.textBoxAccountName.Location = new System.Drawing.Point(67, 19);
|
||||
this.textBoxAccountName.Name = "textBoxAccountName";
|
||||
this.textBoxAccountName.Size = new System.Drawing.Size(559, 20);
|
||||
this.textBoxAccountName.TabIndex = 7;
|
||||
//
|
||||
// textBoxAccountNumber
|
||||
//
|
||||
this.textBoxAccountNumber.Location = new System.Drawing.Point(67, 45);
|
||||
this.textBoxAccountNumber.Name = "textBoxAccountNumber";
|
||||
this.textBoxAccountNumber.Size = new System.Drawing.Size(559, 20);
|
||||
this.textBoxAccountNumber.TabIndex = 7;
|
||||
//
|
||||
// buttonSign
|
||||
//
|
||||
this.buttonSign.Location = new System.Drawing.Point(10, 45);
|
||||
this.buttonSign.Name = "buttonSign";
|
||||
this.buttonSign.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSign.TabIndex = 8;
|
||||
this.buttonSign.Text = "Sign";
|
||||
this.buttonSign.UseVisualStyleBackColor = true;
|
||||
this.buttonSign.Click += new System.EventHandler(this.buttonSign_Click);
|
||||
//
|
||||
// textBoxSignature
|
||||
//
|
||||
this.textBoxSignature.Location = new System.Drawing.Point(10, 19);
|
||||
this.textBoxSignature.Name = "textBoxSignature";
|
||||
this.textBoxSignature.Size = new System.Drawing.Size(615, 20);
|
||||
this.textBoxSignature.TabIndex = 10;
|
||||
//
|
||||
// buttonGetPublicKey
|
||||
//
|
||||
this.buttonGetPublicKey.Location = new System.Drawing.Point(6, 45);
|
||||
this.buttonGetPublicKey.Name = "buttonGetPublicKey";
|
||||
this.buttonGetPublicKey.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonGetPublicKey.TabIndex = 11;
|
||||
this.buttonGetPublicKey.Text = "Get Key";
|
||||
this.buttonGetPublicKey.UseVisualStyleBackColor = true;
|
||||
this.buttonGetPublicKey.Click += new System.EventHandler(this.buttonGetPublicKey_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.textBoxPrivateKey);
|
||||
this.groupBox1.Controls.Add(this.buttonGenerateKey);
|
||||
this.groupBox1.Controls.Add(this.buttonLoadKey);
|
||||
this.groupBox1.Controls.Add(this.buttonSaveKey);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(632, 78);
|
||||
this.groupBox1.TabIndex = 12;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Private Key";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.clipboardCopyBtn);
|
||||
this.groupBox2.Controls.Add(this.buttonExportPublicKey);
|
||||
this.groupBox2.Controls.Add(this.textBoxPublicKey);
|
||||
this.groupBox2.Controls.Add(this.buttonGetPublicKey);
|
||||
this.groupBox2.Location = new System.Drawing.Point(12, 96);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(632, 77);
|
||||
this.groupBox2.TabIndex = 13;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Public Key";
|
||||
//
|
||||
// clipboardCopyBtn
|
||||
//
|
||||
this.clipboardCopyBtn.Location = new System.Drawing.Point(169, 46);
|
||||
this.clipboardCopyBtn.Name = "clipboardCopyBtn";
|
||||
this.clipboardCopyBtn.Size = new System.Drawing.Size(113, 23);
|
||||
this.clipboardCopyBtn.TabIndex = 13;
|
||||
this.clipboardCopyBtn.Text = "Copy to Clipboard";
|
||||
this.clipboardCopyBtn.UseVisualStyleBackColor = true;
|
||||
this.clipboardCopyBtn.Click += new System.EventHandler(this.clipboardCopyBtn_Click);
|
||||
//
|
||||
// buttonExportPublicKey
|
||||
//
|
||||
this.buttonExportPublicKey.Location = new System.Drawing.Point(88, 46);
|
||||
this.buttonExportPublicKey.Name = "buttonExportPublicKey";
|
||||
this.buttonExportPublicKey.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonExportPublicKey.TabIndex = 12;
|
||||
this.buttonExportPublicKey.Text = "Export";
|
||||
this.buttonExportPublicKey.UseVisualStyleBackColor = true;
|
||||
this.buttonExportPublicKey.Click += new System.EventHandler(this.buttonExportPublicKey_Click);
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.textBoxAccountName);
|
||||
this.groupBox3.Controls.Add(this.label3);
|
||||
this.groupBox3.Controls.Add(this.textBoxAccountNumber);
|
||||
this.groupBox3.Controls.Add(this.label4);
|
||||
this.groupBox3.Location = new System.Drawing.Point(12, 180);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(635, 81);
|
||||
this.groupBox3.TabIndex = 14;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Account";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(8, 22);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(38, 13);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Name:";
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.readRegBtn);
|
||||
this.groupBox4.Controls.Add(this.saveToRegBtn);
|
||||
this.groupBox4.Controls.Add(this.buttonVerify);
|
||||
this.groupBox4.Controls.Add(this.buttonExportSignature);
|
||||
this.groupBox4.Controls.Add(this.textBoxSignature);
|
||||
this.groupBox4.Controls.Add(this.buttonSign);
|
||||
this.groupBox4.Location = new System.Drawing.Point(13, 268);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(631, 76);
|
||||
this.groupBox4.TabIndex = 15;
|
||||
this.groupBox4.TabStop = false;
|
||||
this.groupBox4.Text = "Signature";
|
||||
//
|
||||
// saveToRegBtn
|
||||
//
|
||||
this.saveToRegBtn.Location = new System.Drawing.Point(172, 45);
|
||||
this.saveToRegBtn.Name = "saveToRegBtn";
|
||||
this.saveToRegBtn.Size = new System.Drawing.Size(101, 23);
|
||||
this.saveToRegBtn.TabIndex = 13;
|
||||
this.saveToRegBtn.Text = "Save To Reg";
|
||||
this.saveToRegBtn.UseVisualStyleBackColor = true;
|
||||
this.saveToRegBtn.Click += new System.EventHandler(this.saveToRegBtn_Click);
|
||||
//
|
||||
// buttonVerify
|
||||
//
|
||||
this.buttonVerify.Location = new System.Drawing.Point(550, 45);
|
||||
this.buttonVerify.Name = "buttonVerify";
|
||||
this.buttonVerify.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonVerify.TabIndex = 12;
|
||||
this.buttonVerify.Text = "Verify";
|
||||
this.buttonVerify.UseVisualStyleBackColor = true;
|
||||
this.buttonVerify.Click += new System.EventHandler(this.buttonVerify_Click);
|
||||
//
|
||||
// buttonExportSignature
|
||||
//
|
||||
this.buttonExportSignature.Location = new System.Drawing.Point(91, 45);
|
||||
this.buttonExportSignature.Name = "buttonExportSignature";
|
||||
this.buttonExportSignature.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonExportSignature.TabIndex = 11;
|
||||
this.buttonExportSignature.Text = "Export";
|
||||
this.buttonExportSignature.UseVisualStyleBackColor = true;
|
||||
this.buttonExportSignature.Click += new System.EventHandler(this.buttonExportSignature_Click);
|
||||
//
|
||||
// readRegBtn
|
||||
//
|
||||
this.readRegBtn.Location = new System.Drawing.Point(279, 45);
|
||||
this.readRegBtn.Name = "readRegBtn";
|
||||
this.readRegBtn.Size = new System.Drawing.Size(132, 23);
|
||||
this.readRegBtn.TabIndex = 14;
|
||||
this.readRegBtn.Text = "Read from Registry";
|
||||
this.readRegBtn.UseVisualStyleBackColor = true;
|
||||
this.readRegBtn.Click += new System.EventHandler(this.readRegBtn_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(659, 351);
|
||||
this.Controls.Add(this.groupBox4);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "Liccensing";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.groupBox4.ResumeLayout(false);
|
||||
this.groupBox4.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBoxPublicKey;
|
||||
private System.Windows.Forms.Button buttonGenerateKey;
|
||||
private System.Windows.Forms.Button buttonLoadKey;
|
||||
private System.Windows.Forms.Button buttonSaveKey;
|
||||
private System.Windows.Forms.TextBox textBoxPrivateKey;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox textBoxAccountName;
|
||||
private System.Windows.Forms.TextBox textBoxAccountNumber;
|
||||
private System.Windows.Forms.Button buttonSign;
|
||||
private System.Windows.Forms.TextBox textBoxSignature;
|
||||
private System.Windows.Forms.Button buttonGetPublicKey;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button buttonExportPublicKey;
|
||||
private System.Windows.Forms.GroupBox groupBox4;
|
||||
private System.Windows.Forms.Button buttonExportSignature;
|
||||
private System.Windows.Forms.Button buttonVerify;
|
||||
private System.Windows.Forms.Button clipboardCopyBtn;
|
||||
private System.Windows.Forms.Button saveToRegBtn;
|
||||
private System.Windows.Forms.Button readRegBtn;
|
||||
}
|
||||
}
|
||||
@@ -1,352 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using MTApiService;
|
||||
|
||||
namespace Licensing
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private bool mIsSaved = true;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonGenerateKey_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBoxPrivateKey.Text = DigitalSignatureHelper.GeneratePrivateKey();
|
||||
|
||||
mIsSaved = false;
|
||||
}
|
||||
|
||||
private void buttonGetPublicKey_Click(object sender, EventArgs e)
|
||||
{
|
||||
string privateKey = textBoxPrivateKey.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(privateKey) == false)
|
||||
{
|
||||
textBoxPublicKey.Text = DigitalSignatureHelper.GetPublicKey(privateKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Private Key is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSaveKey_Click(object sender, EventArgs e)
|
||||
{
|
||||
string privateKey = textBoxPrivateKey.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(privateKey) == false)
|
||||
{
|
||||
SaveFileDialog dlg = new SaveFileDialog();
|
||||
|
||||
dlg.Filter = "MetaTraderApi Key Files (*.mtk)|*.mtk";
|
||||
dlg.Title = "Save MetaTraderApi Key File";
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TextWriter file = new StreamWriter(dlg.FileName, true))
|
||||
{
|
||||
file.WriteLine(privateKey);
|
||||
}
|
||||
|
||||
mIsSaved = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorMsg = string.Format("Saving failed!\n{0}", ex.Message);
|
||||
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Private Key is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonLoadKey_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (mIsSaved == false)
|
||||
{
|
||||
if (MessageBox.Show("Private Key is not saved. Continue?", "Private Key", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||||
return;
|
||||
}
|
||||
|
||||
OpenFileDialog dlg = new OpenFileDialog();
|
||||
|
||||
dlg.Filter = "MetaTraderApi Key Files (*.mtk)|*.mtk";
|
||||
dlg.Title = "Load MetaTraderApi Key File";
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
textBoxPrivateKey.Text = string.Empty;
|
||||
textBoxPublicKey.Text = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
using (TextReader file = new StreamReader(dlg.FileName))
|
||||
{
|
||||
textBoxPrivateKey.Text = file.ReadLine();
|
||||
}
|
||||
|
||||
mIsSaved = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorMsg = string.Format("Saving failed!\n{0}", ex.Message);
|
||||
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSign_Click(object sender, EventArgs e)
|
||||
{
|
||||
string privateKey = textBoxPrivateKey.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(privateKey) == false)
|
||||
{
|
||||
string accountName = textBoxAccountName.Text;
|
||||
string accountNumber = textBoxAccountNumber.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(accountName) == false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accountNumber) == false)
|
||||
{
|
||||
string inputData = accountName + accountNumber;
|
||||
|
||||
textBoxSignature.Text = DigitalSignatureHelper.CreateSignature(inputData, privateKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("AccountNumber is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("AccountName is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Private Key is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonExportPublicKey_Click(object sender, EventArgs e)
|
||||
{
|
||||
string publicKey = textBoxPublicKey.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(publicKey) == false)
|
||||
{
|
||||
SaveFileDialog dlg = new SaveFileDialog();
|
||||
|
||||
dlg.Filter = "MetaTraderApi Key Files (*.mtk)|*.mtk";
|
||||
dlg.Title = "Export MetaTraderApi Key File";
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TextWriter file = new StreamWriter(dlg.FileName, true))
|
||||
{
|
||||
file.WriteLine(publicKey);
|
||||
}
|
||||
|
||||
mIsSaved = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorMsg = string.Format("Export failed!\n{0}", ex.Message);
|
||||
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Public Key is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonExportSignature_Click(object sender, EventArgs e)
|
||||
{
|
||||
string signature = textBoxSignature.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(signature) == false)
|
||||
{
|
||||
SaveFileDialog dlg = new SaveFileDialog();
|
||||
|
||||
dlg.Filter = "MetaTraderApi Key (*.mta)|*.mta";
|
||||
dlg.Title = "Export MetaTraderApi Key";
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TextWriter file = new StreamWriter(dlg.FileName))
|
||||
{
|
||||
file.WriteLine(signature);
|
||||
}
|
||||
|
||||
mIsSaved = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorMsg = string.Format("Export failed!\n{0}", ex.Message);
|
||||
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Signature is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonVerify_Click(object sender, EventArgs e)
|
||||
{
|
||||
string publicKey = textBoxPublicKey.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(publicKey) == false)
|
||||
{
|
||||
string signature = textBoxSignature.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(signature) == false)
|
||||
{
|
||||
string accountName = textBoxAccountName.Text;
|
||||
string accountNumber = textBoxAccountNumber.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(accountName) == false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accountNumber) == false)
|
||||
{
|
||||
string inputData = accountName + accountNumber;
|
||||
var verifyResult = false;
|
||||
try
|
||||
{
|
||||
verifyResult = DigitalSignatureHelper.VerifySignature(inputData, signature, publicKey);
|
||||
}
|
||||
catch (SecurityException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Verify", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
verifyResult = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string errorMsg = string.Format("Verify process failed!\n{0}", ex.Message);
|
||||
MessageBox.Show(errorMsg, "Verify", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
verifyResult = false;
|
||||
}
|
||||
|
||||
if (verifyResult == true)
|
||||
{
|
||||
MessageBox.Show("Signature good", "Verify", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("AccountNumber is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("AccountName is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Signature is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Public Key is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void clipboardCopyBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Clipboard.SetText(textBoxPublicKey.Text);
|
||||
}
|
||||
|
||||
private void saveToRegBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
string signature = textBoxSignature.Text;
|
||||
string accountName = textBoxAccountName.Text;
|
||||
string accountNumber = textBoxAccountNumber.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(signature))
|
||||
{
|
||||
MessageBox.Show("Signature is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(accountName))
|
||||
{
|
||||
MessageBox.Show("AccountName is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(accountNumber))
|
||||
{
|
||||
MessageBox.Show("AccountNumber is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
SaveFileDialog dlg = new SaveFileDialog();
|
||||
|
||||
dlg.Filter = "Registry files (*.reg)|*.reg";
|
||||
dlg.Title = "Registry files";
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string key = MtRegistryManager.SaveSignatureKey(accountName, accountNumber, signature);
|
||||
|
||||
bool exported = MtRegistryManager.ExportKey(key, dlg.FileName);
|
||||
|
||||
if (exported)
|
||||
{
|
||||
MessageBox.Show("Export successed.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Export failed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readRegBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
string accountName = textBoxAccountName.Text;
|
||||
string accountNumber = textBoxAccountNumber.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(accountName))
|
||||
{
|
||||
MessageBox.Show("AccountName is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(accountNumber))
|
||||
{
|
||||
MessageBox.Show("AccountNumber is empty!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string signature = MtRegistryManager.ReadSignatureKey(accountName, accountNumber);
|
||||
textBoxSignature.Text = signature;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Licensing
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Licensing")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("DW")]
|
||||
[assembly: AssemblyProduct("Licensing")]
|
||||
[assembly: AssemblyCopyright("Copyright © DW 2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("2c3df81b-2285-44ff-a152-0111e25d9b1a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -35,6 +35,4 @@ using namespace System::Security::Permissions;
|
||||
|
||||
[assembly:ComVisible(false)];
|
||||
|
||||
[assembly:CLSCompliantAttribute(true)];
|
||||
|
||||
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
|
||||
[assembly:CLSCompliantAttribute(true)];
|
||||
+146
-380
@@ -6,14 +6,15 @@
|
||||
#include "MT5Handler.h"
|
||||
|
||||
#include "Windows.h"
|
||||
#include < vcclr.h >
|
||||
#include <vcclr.h>
|
||||
#include <functional>
|
||||
|
||||
using namespace System;
|
||||
using namespace MTApiService;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using namespace System::Reflection;
|
||||
using namespace System::Text;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Diagnostics;
|
||||
using namespace System::Security::Cryptography;
|
||||
using namespace System::Security;
|
||||
@@ -30,297 +31,166 @@ public struct CMqlRates
|
||||
int spread; // Spread
|
||||
__int64 real_volume; // Trade volume
|
||||
};
|
||||
|
||||
public struct CMqlTick
|
||||
{
|
||||
__int64 time; // Time of the last prices update
|
||||
double bid; // Current Bid price
|
||||
double ask; // Current Ask price
|
||||
double last; // Price of the last deal (Last)
|
||||
unsigned __int64 volume; // Volume for the current Last price
|
||||
};
|
||||
|
||||
public struct CMqlBookInfo
|
||||
{
|
||||
int type; // Order type from ENUM_BOOK_TYPE enumeration
|
||||
double price; // Price
|
||||
__int64 volume; // Volume
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
void convertSystemString(wchar_t* dest, String^ src)
|
||||
{
|
||||
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
|
||||
memcpy(dest, wch, wcslen(wch) * sizeof(wchar_t));
|
||||
dest[wcslen(wch)] = '\0';
|
||||
if (src != nullptr) {
|
||||
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
|
||||
memcpy(dest, wch, wcsnlen(wch, 1000) * sizeof(wchar_t));
|
||||
dest[wcsnlen(wch, 1000)] = L'\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
dest[0] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
bool VerifySignature(System::String^ inputData, System::String^ signature, System::String^ publicKey)
|
||||
{
|
||||
bool verifyResult = false;
|
||||
#define _DLLAPI extern "C" __declspec(dllexport)
|
||||
|
||||
template <typename T> T Execute(std::function<T()> func, wchar_t* err, T default_value)
|
||||
{
|
||||
T result = default_value;
|
||||
try
|
||||
{
|
||||
DSACryptoServiceProvider^ dsa = gcnew DSACryptoServiceProvider();
|
||||
dsa->FromXmlString(publicKey);
|
||||
array<System::Byte>^ data = UTF8Encoding::ASCII->GetBytes(inputData);
|
||||
array<System::Byte>^ signatureData = Convert::FromBase64String(signature);
|
||||
verifyResult = dsa->VerifyData(data, signatureData);
|
||||
}
|
||||
catch(Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:VerifySignature(): failed. " + e->Message);
|
||||
verifyResult = false;
|
||||
}
|
||||
|
||||
return verifyResult;
|
||||
}
|
||||
|
||||
bool g_IsVerified = true;
|
||||
|
||||
void _stdcall verify(int isDemo, wchar_t* accountName, long accountNumber)
|
||||
{
|
||||
if (isDemo != 0)
|
||||
{
|
||||
g_IsVerified = true;
|
||||
return;
|
||||
}
|
||||
|
||||
System::String^ signature = MtRegistryManager::ReadSignatureKey(gcnew String(accountName), accountNumber.ToString());
|
||||
Resources::ResourceManager^ rm = gcnew Resources::ResourceManager(L"MT5Connector.cl", Assembly::GetExecutingAssembly());
|
||||
System::String^ inputData = gcnew System::String(accountName);
|
||||
inputData += accountNumber.ToString();
|
||||
System::String^ publicKey = rm->GetString(L"cl");
|
||||
g_IsVerified = VerifySignature(inputData, gcnew System::String(signature), publicKey);
|
||||
}
|
||||
|
||||
int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, wchar_t* err)
|
||||
{
|
||||
if (g_IsVerified == false)
|
||||
{
|
||||
System::String^ errorVerified = "Verification is failed!\nPlease contact with support.";
|
||||
convertSystemString(err, errorVerified);
|
||||
Debug::WriteLine("[ERROR] MT5Connector:initExpert(): not verified");
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
MT5Handler^ mtHander = gcnew MT5Handler();
|
||||
MtServerInstance::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHander);
|
||||
result = func();
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
convertSystemString(err, e->Message);
|
||||
Debug::WriteLine("[ERROR] MT5Connector:initExpert(): " + e->Message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
int _stdcall deinitExpert(int expertHandle, wchar_t* err)
|
||||
_DLLAPI int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, int isTestMode, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->DeinitExpert(expertHandle);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
convertSystemString(err, e->Message);
|
||||
Debug::WriteLine("[ERROR] MT5Connector:deinitExpert(): " + e->Message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, &port, symbol, &bid, &ask, &isTestMode]() {
|
||||
bool isTesting = (isTestMode != 0) ? true : false;
|
||||
auto expert = gcnew Mt5Expert(expertHandle, gcnew String(symbol), bid, ask, gcnew MT5Handler(), isTesting);
|
||||
MtAdapter::GetInstance()->AddExpert(port, expert);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err)
|
||||
_DLLAPI int _stdcall deinitExpert(int expertHandle, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
convertSystemString(err, e->Message);
|
||||
Debug::WriteLine("[ERROR] MT5Connector:updateQuote(): " + e->Message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle]() {
|
||||
MtAdapter::GetInstance()->RemoveExpert(expertHandle);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendIntResponse(int expertHandle, int response)
|
||||
_DLLAPI int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendIntResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, symbol, &bid, &ask]() {
|
||||
MtAdapter::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendLongResponse(int expertHandle, __int64 response)
|
||||
_DLLAPI bool _stdcall sendEvent(int expertHandle, int eventType, wchar_t* payload, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &eventType, payload]() {
|
||||
MtAdapter::GetInstance()->SendEvent(expertHandle, eventType, gcnew String(payload));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendULongResponse(int expertHandle, unsigned __int64 response)
|
||||
_DLLAPI int _stdcall sendIntResponse(int expertHandle, int response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseULong(response));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendLongResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendBooleanResponse(int expertHandle, int response)
|
||||
_DLLAPI int _stdcall sendLongResponse(int expertHandle, __int64 response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Execute<int>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
_DLLAPI int _stdcall sendULongResponse(int expertHandle, unsigned __int64 response, wchar_t* err)
|
||||
{
|
||||
return Execute<int>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseULong(response));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
_DLLAPI int _stdcall sendBooleanResponse(int expertHandle, int response, wchar_t* err)
|
||||
{
|
||||
return Execute<int>([&expertHandle, &response]() {
|
||||
bool value = (response != 0) ? true : false;
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendBooleanResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendDoubleResponse(int expertHandle, double response)
|
||||
_DLLAPI int _stdcall sendDoubleResponse(int expertHandle, double response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendDoubleResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendStringResponse(int expertHandle, wchar_t* response)
|
||||
_DLLAPI int _stdcall sendStringResponse(int expertHandle, wchar_t* response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendStringResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendVoidResponse(int expertHandle)
|
||||
_DLLAPI int _stdcall sendVoidResponse(int expertHandle, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, nullptr);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendVoidResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseObject(nullptr));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size)
|
||||
_DLLAPI int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Execute<int>([&expertHandle, values, &size]() {
|
||||
array<double>^ list = gcnew array<double>(size);
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
list[i] = values[i];
|
||||
}
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendDoubleArrayResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size)
|
||||
_DLLAPI int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Execute<int>([&expertHandle, values, &size]() {
|
||||
array<int>^ list = gcnew array<int>(size);
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
list[i] = values[i];
|
||||
}
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendIntArrayResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendLongArrayResponse(int expertHandle, __int64* values, int size)
|
||||
_DLLAPI int _stdcall sendLongArrayResponse(int expertHandle, __int64* values, int size, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Execute<int>([&expertHandle, values, &size]() {
|
||||
array<System::Int64>^ list = gcnew array<System::Int64>(size);
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
list[i] = values[i];
|
||||
}
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLongArray(list));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendLongArrayResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLongArray(list));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int size)
|
||||
_DLLAPI int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int size, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Execute<int>([&expertHandle, values, &size]() {
|
||||
array<MtMqlRates^>^ list = gcnew array<MtMqlRates^>(size);
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
MtMqlRates^ rates = gcnew MtMqlRates();
|
||||
rates->time = values[i].time;
|
||||
@@ -331,180 +201,76 @@ int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int
|
||||
rates->tick_volume = values[i].tick_volume;
|
||||
rates->spread = values[i].spread;
|
||||
rates->real_volume = values[i].real_volume;
|
||||
|
||||
list[i] = rates;
|
||||
}
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlRatesArray(list));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _stdcall sendMqlTickResponse(int expertHandle, CMqlTick* response, int size)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtMqlTick^ mtResponse = gcnew MtMqlTick();
|
||||
|
||||
mtResponse->time = response->time;
|
||||
mtResponse->bid = response->bid;
|
||||
mtResponse->ask = response->ask;
|
||||
mtResponse->last = response->last;
|
||||
mtResponse->volume = response->volume;
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlTick(mtResponse));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendMqlTickResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _stdcall sendMqlBookInfoArrayResponse(int expertHandle, CMqlBookInfo values[], int size)
|
||||
{
|
||||
try
|
||||
{
|
||||
array<MtMqlBookInfo^>^ list = gcnew array<MtMqlBookInfo^>(size);
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
MtMqlBookInfo^ info = gcnew MtMqlBookInfo();
|
||||
|
||||
info->type = values[i].type;
|
||||
info->price = values[i].price;
|
||||
info->volume = values[i].volume;
|
||||
|
||||
list[i] = info;
|
||||
}
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlBookInfoArray(list));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:sendMqlRatesArrayResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlRatesArray(list));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
//----------- get values -------------------------------
|
||||
|
||||
int _stdcall getCommandType(int expertHandle, int* res)
|
||||
_DLLAPI int _stdcall getCommandType(int expertHandle, int* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = MtServerInstance::GetInstance()->GetCommandType(expertHandle);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getCommandType(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, res]() {
|
||||
*res = MtAdapter::GetInstance()->GetCommandType(expertHandle);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall getIntValue(int expertHandle, int paramIndex, int* res)
|
||||
_DLLAPI int _stdcall getIntValue(int expertHandle, int paramIndex, int* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = (int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getIntValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res)
|
||||
_DLLAPI int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = (double)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getDoubleValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (double)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res)
|
||||
_DLLAPI int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
convertSystemString(res, (String^)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getStringValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
convertSystemString(res, (String^)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res)
|
||||
_DLLAPI int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = (unsigned long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getULongValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (unsigned __int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res)
|
||||
_DLLAPI int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = (long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getLongValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (__int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res)
|
||||
_DLLAPI int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool val = (bool)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
bool val = (bool)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
*res = val == true ? 1 : 0;
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getBooleanValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int* res)
|
||||
_DLLAPI int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = (unsigned int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getUIntValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (unsigned int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
LIBRARY MT5Connector
|
||||
|
||||
EXPORTS initExpert
|
||||
deinitExpert
|
||||
updateQuote
|
||||
sendIntResponse
|
||||
sendBooleanResponse
|
||||
sendDoubleResponse
|
||||
sendStringResponse
|
||||
sendVoidResponse
|
||||
sendDoubleArrayResponse
|
||||
sendIntArrayResponse
|
||||
sendLongArrayResponse
|
||||
sendMqlRatesArrayResponse
|
||||
sendLongResponse
|
||||
sendULongResponse
|
||||
sendMqlTickResponse
|
||||
sendMqlBookInfoArrayResponse
|
||||
getCommandType
|
||||
getIntValue
|
||||
getUIntValue
|
||||
getDoubleValue
|
||||
getStringValue
|
||||
getLongValue
|
||||
getULongValue
|
||||
getBooleanValue
|
||||
verify
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@@ -23,6 +23,7 @@
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>MT5Connector</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -30,28 +31,28 @@
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -95,7 +96,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -108,7 +108,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -120,7 +119,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -132,7 +130,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MT5Connector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -157,7 +154,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.ico" />
|
||||
<None Include="MT5Connector.def" />
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
<None Include="app.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="MT5Connector.def">
|
||||
<Filter>Source Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc">
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace MTApiService
|
||||
{
|
||||
public interface ICommandManager
|
||||
internal interface ICommandManager
|
||||
{
|
||||
void EnqueueCommandTask(MtCommandTask task);
|
||||
MtCommandTask DequeueCommandTask();
|
||||
MtCommandTask SendCommand(MtCommand task);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MTApiService
|
||||
namespace MTApiService
|
||||
{
|
||||
public interface IMetaTraderHandler
|
||||
{
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MTApiService
|
||||
{
|
||||
internal interface ITaskExecutor
|
||||
{
|
||||
void Execute(MtCommandTask task);
|
||||
|
||||
int Handle { get; }
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,53 @@ using log4net.Repository.Hierarchy;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
public class MtLog
|
||||
{
|
||||
#region ctor
|
||||
internal MtLog(Type type)
|
||||
{
|
||||
_log = LogManager.GetLogger(type);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
|
||||
public void Debug(object message)
|
||||
{
|
||||
_log.Debug(message);
|
||||
}
|
||||
|
||||
public void Error(object message)
|
||||
{
|
||||
_log.Error(message);
|
||||
}
|
||||
|
||||
public void Fatal(object message)
|
||||
{
|
||||
_log.Fatal(message);
|
||||
}
|
||||
|
||||
public void Info(object message)
|
||||
{
|
||||
_log.Info(message);
|
||||
}
|
||||
|
||||
public void Warn(object message)
|
||||
{
|
||||
_log.Warn(message);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private
|
||||
|
||||
private readonly ILog _log;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class LogConfigurator
|
||||
{
|
||||
private const string LogFileNameExtension = "txt";
|
||||
private const string LogFileNameExtension = "log";
|
||||
|
||||
public static void Setup(string profileName)
|
||||
{
|
||||
@@ -29,7 +73,7 @@ namespace MTApiService
|
||||
|
||||
var roller = new RollingFileAppender
|
||||
{
|
||||
AppendToFile = false,
|
||||
AppendToFile = true,
|
||||
File = $@"{System.IO.Path.GetTempPath()}{profileName}\Logs\{filename}",
|
||||
Layout = patternLayout,
|
||||
PreserveLogFileNameExtension = true,
|
||||
@@ -41,10 +85,6 @@ namespace MTApiService
|
||||
roller.ActivateOptions();
|
||||
hierarchy.Root.AddAppender(roller);
|
||||
|
||||
var memory = new MemoryAppender();
|
||||
memory.ActivateOptions();
|
||||
hierarchy.Root.AddAppender(memory);
|
||||
|
||||
#if (DEBUG)
|
||||
hierarchy.Root.Level = Level.Debug;
|
||||
#else
|
||||
@@ -52,5 +92,13 @@ namespace MTApiService
|
||||
#endif
|
||||
hierarchy.Configured = true;
|
||||
}
|
||||
|
||||
public static MtLog GetLogger(Type type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
return new MtLog(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="ICommandManager.cs" />
|
||||
<Compile Include="IMetaTraderHandler.cs" />
|
||||
<Compile Include="ITaskExecutor.cs" />
|
||||
<Compile Include="LogConfigurator.cs" />
|
||||
<Compile Include="Mt5Expert.cs" />
|
||||
<Compile Include="MtCommandEventArgs.cs" />
|
||||
<Compile Include="IDisposableChannel.cs" />
|
||||
<Compile Include="IMtApiServer.cs" />
|
||||
@@ -70,19 +72,17 @@
|
||||
<Compile Include="MtClient.cs" />
|
||||
<Compile Include="MtCommandTask.cs" />
|
||||
<Compile Include="MtEvent.cs" />
|
||||
<Compile Include="MtMqlBookInfo.cs" />
|
||||
<Compile Include="MtMqlRates.cs" />
|
||||
<Compile Include="MtMqlTick.cs" />
|
||||
<Compile Include="MtMqlTradeRequest.cs" />
|
||||
<Compile Include="MtRegistryManager.cs" />
|
||||
<Compile Include="MtConnectionProfile.cs" />
|
||||
<Compile Include="MtExecutorManager.cs" />
|
||||
<Compile Include="MtExpert.cs" />
|
||||
<Compile Include="MtInstrument.cs" />
|
||||
<Compile Include="MtQuote.cs" />
|
||||
<Compile Include="MtResponse.cs" />
|
||||
<Compile Include="MtServer.cs" />
|
||||
<Compile Include="MtCommand.cs" />
|
||||
<Compile Include="MtServerInstance.cs" />
|
||||
<Compile Include="MtAdapter.cs" />
|
||||
<Compile Include="MtService.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
using log4net;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
public class Mt5Expert : MtExpert
|
||||
{
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(Mt5Expert));
|
||||
private const int StopExpertInterval = 2000; // 2 sec for testing mode
|
||||
private System.Timers.Timer _stopTimer;
|
||||
|
||||
|
||||
public Mt5Expert(int handle, string symbol, double bid, double ask, IMetaTraderHandler mtHandler, bool isTestMode) :
|
||||
base(handle, symbol, bid, ask, mtHandler)
|
||||
{
|
||||
IsTestMode = isTestMode;
|
||||
}
|
||||
|
||||
public bool IsTestMode { get; }
|
||||
|
||||
public override int GetCommandType()
|
||||
{
|
||||
Log.Debug("GetCommandType: called.");
|
||||
|
||||
if (IsTestMode)
|
||||
{
|
||||
ResetTestModeTimer();
|
||||
}
|
||||
|
||||
return base.GetCommandType();
|
||||
}
|
||||
|
||||
public override void SendEvent(MtEvent mtEvent)
|
||||
{
|
||||
Log.DebugFormat("SendEvent: begin. event = {0}", mtEvent);
|
||||
|
||||
if (IsTestMode)
|
||||
{
|
||||
if (_stopTimer == null)
|
||||
{
|
||||
_stopTimer = new System.Timers.Timer
|
||||
{
|
||||
Interval = StopExpertInterval,
|
||||
AutoReset = false
|
||||
};
|
||||
_stopTimer.Elapsed += _stopTimer_Elapsed;
|
||||
}
|
||||
}
|
||||
|
||||
base.SendEvent(mtEvent);
|
||||
|
||||
Log.Debug("SendEvent: end.");
|
||||
}
|
||||
|
||||
private void _stopTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
Log.Debug("_stopTimer_Elapsed: begin.");
|
||||
|
||||
Log.Warn("Mt5Expert has received new tick during 2 sec in testing mode. The possible cause: user has stopped the tester manually in MetaTrader 5.");
|
||||
Deinit();
|
||||
|
||||
_stopTimer.Elapsed -= _stopTimer_Elapsed;
|
||||
_stopTimer = null;
|
||||
|
||||
Log.Debug("_stopTimer_Elapsed: end.");
|
||||
}
|
||||
|
||||
private void ResetTestModeTimer()
|
||||
{
|
||||
if (_stopTimer == null)
|
||||
return;
|
||||
|
||||
//reset timer
|
||||
_stopTimer.Stop();
|
||||
_stopTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable → Regular
+90
-23
@@ -4,13 +4,13 @@ using log4net;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
public class MtServerInstance
|
||||
public class MtAdapter
|
||||
{
|
||||
#region Fields
|
||||
private const string LogProfileName = "MtApiService";
|
||||
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(MtServerInstance));
|
||||
private static readonly MtServerInstance Instance = new MtServerInstance();
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(MtAdapter));
|
||||
private static readonly MtAdapter Instance = new MtAdapter();
|
||||
|
||||
private readonly Dictionary<int, MtServer> _servers = new Dictionary<int, MtServer>();
|
||||
private readonly Dictionary<int, MtExpert> _experts = new Dictionary<int, MtExpert>();
|
||||
@@ -18,16 +18,16 @@ namespace MTApiService
|
||||
|
||||
#region Init Instance
|
||||
|
||||
private MtServerInstance()
|
||||
private MtAdapter()
|
||||
{
|
||||
LogConfigurator.Setup(LogProfileName);
|
||||
}
|
||||
|
||||
static MtServerInstance()
|
||||
static MtAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
public static MtServerInstance GetInstance()
|
||||
public static MtAdapter GetInstance()
|
||||
{
|
||||
return Instance;
|
||||
}
|
||||
@@ -36,12 +36,12 @@ namespace MTApiService
|
||||
|
||||
|
||||
#region Public Methods
|
||||
public void InitExpert(int expertHandle, int port, string symbol, double bid, double ask, IMetaTraderHandler mtHandler)
|
||||
public void AddExpert(int port, MtExpert expert)
|
||||
{
|
||||
if (mtHandler == null)
|
||||
throw new ArgumentNullException(nameof(mtHandler));
|
||||
if (expert == null)
|
||||
throw new ArgumentNullException(nameof(expert));
|
||||
|
||||
Log.InfoFormat("InitExpert: begin. symbol = {0}, expertHandle = {1}, port = {2}", symbol, expertHandle, port);
|
||||
Log.InfoFormat("AddExpert: begin. expert = {0}", expert);
|
||||
|
||||
MtServer server;
|
||||
lock (_servers)
|
||||
@@ -60,21 +60,20 @@ namespace MTApiService
|
||||
}
|
||||
}
|
||||
|
||||
var expert = new MtExpert(expertHandle, new MtQuote(symbol, bid, ask), mtHandler);
|
||||
|
||||
lock (_experts)
|
||||
{
|
||||
_experts[expert.Handle] = expert;
|
||||
}
|
||||
|
||||
server.AddExpert(expert);
|
||||
expert.Deinited += ExpertOnDeinited;
|
||||
|
||||
Log.Info("InitExpert: end");
|
||||
Log.Info("AddExpert: end");
|
||||
}
|
||||
|
||||
public void DeinitExpert(int expertHandle)
|
||||
public void RemoveExpert(int expertHandle)
|
||||
{
|
||||
Log.InfoFormat("DeinitExpert: begin. expertHandle = {0}", expertHandle);
|
||||
Log.InfoFormat("RemoveExpert: begin. expertHandle = {0}", expertHandle);
|
||||
|
||||
MtExpert expert = null;
|
||||
|
||||
@@ -83,7 +82,6 @@ namespace MTApiService
|
||||
if (_experts.ContainsKey(expertHandle))
|
||||
{
|
||||
expert = _experts[expertHandle];
|
||||
_experts.Remove(expertHandle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,15 +91,15 @@ namespace MTApiService
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.WarnFormat("DeinitExpert: expert with id {0} has not been found.", expertHandle);
|
||||
Log.WarnFormat("RemoveExpert: expert with id {0} has not been found.", expertHandle);
|
||||
}
|
||||
|
||||
Log.Info("DeinitExpert: end");
|
||||
Log.Info("RemoveExpert: end");
|
||||
}
|
||||
|
||||
public void SendQuote(int expertHandle, string symbol, double bid, double ask)
|
||||
{
|
||||
Log.DebugFormat("SendQuote: begin. symbol = {0}, bid = {1}, ask = {2}", symbol, bid, ask);
|
||||
Log.DebugFormat("UpdateQuote: begin. symbol = {0}, bid = {1}, ask = {2}", symbol, bid, ask);
|
||||
|
||||
MtExpert expert;
|
||||
lock (_experts)
|
||||
@@ -111,14 +109,14 @@ namespace MTApiService
|
||||
|
||||
if (expert != null)
|
||||
{
|
||||
expert.Quote = new MtQuote(symbol, bid, ask);
|
||||
expert.UpdateQuote(new MtQuote { Instrument = symbol, Bid = bid, Ask = ask, ExpertHandle = expertHandle });
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.WarnFormat("SendQuote: expert with id {0} has not been found.", expertHandle);
|
||||
Log.WarnFormat("UpdateQuote: expert with id {0} has not been found.", expertHandle);
|
||||
}
|
||||
|
||||
Log.Debug("SendQuote: end");
|
||||
Log.Debug("UpdateQuote: end");
|
||||
}
|
||||
|
||||
public void SendEvent(int expertHandle, int eventType, string payload)
|
||||
@@ -133,7 +131,7 @@ namespace MTApiService
|
||||
|
||||
if (expert != null)
|
||||
{
|
||||
expert.SendEvent(new MtEvent(eventType, payload));
|
||||
expert.SendEvent(new MtEvent { EventType = eventType, Payload = payload, ExpertHandle = expertHandle });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -208,6 +206,50 @@ namespace MTApiService
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public object GetNamedParameter(int expertHandle, string name)
|
||||
{
|
||||
Log.DebugFormat("GetNamedParameter: begin. expertHandle = {0}, name = {1}", expertHandle, name);
|
||||
|
||||
MtExpert expert;
|
||||
lock (_experts)
|
||||
{
|
||||
expert = _experts[expertHandle];
|
||||
}
|
||||
|
||||
if (expert == null)
|
||||
{
|
||||
Log.WarnFormat("GetNamedParameter: expert with id {0} has not been found.", expertHandle);
|
||||
}
|
||||
|
||||
var retval = expert?.GetNamedParameter(name);
|
||||
|
||||
Log.DebugFormat("GetNamedParameter: end. retval = {0}", retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public bool ContainsNamedParameter(int expertHandle, string name)
|
||||
{
|
||||
Log.DebugFormat("ContainsNamedParameter: begin. expertHandle = {0}, name = {1}", expertHandle, name);
|
||||
|
||||
MtExpert expert;
|
||||
lock (_experts)
|
||||
{
|
||||
expert = _experts[expertHandle];
|
||||
}
|
||||
|
||||
if (expert == null)
|
||||
{
|
||||
Log.WarnFormat("ContainsNamedParameter: expert with id {0} has not been found.", expertHandle);
|
||||
}
|
||||
|
||||
bool retval = expert != null ? expert.ContainsNamedParameter(name) : false;
|
||||
|
||||
Log.DebugFormat("ContainsNamedParameter: end. retval = {0}", retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
@@ -228,6 +270,31 @@ namespace MTApiService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ExpertOnDeinited(object sender, EventArgs eventArgs)
|
||||
{
|
||||
Log.Debug("ExpertOnDeinited: begin.");
|
||||
|
||||
var expert = sender as MtExpert;
|
||||
if (expert == null)
|
||||
{
|
||||
Log.Warn("expert_Deinited: end. Expert is not defined.");
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_experts)
|
||||
{
|
||||
if (_experts.ContainsKey(expert.Handle))
|
||||
{
|
||||
_experts.Remove(expert.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
Log.DebugFormat("ExpertOnDeinited: removed expert {0}", expert.Handle);
|
||||
|
||||
Log.Debug("ExpertOnDeinited: end.");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@ namespace MTApiService
|
||||
: base(callbackContext, binding, remoteAddress)
|
||||
{
|
||||
InnerDuplexChannel.Faulted += InnerDuplexChannel_Faulted;
|
||||
InnerDuplexChannel.Open();
|
||||
}
|
||||
|
||||
#region IMtApi Members
|
||||
|
||||
public bool Connect()
|
||||
{
|
||||
InnerDuplexChannel.Open();
|
||||
return Channel.Connect();
|
||||
}
|
||||
|
||||
|
||||
+42
-90
@@ -6,38 +6,33 @@ using log4net;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
[CallbackBehavior(UseSynchronizationContext = false)]
|
||||
public class MtClient: IMtApiCallback, IDisposable
|
||||
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
|
||||
public class MtClient : IMtApiCallback, IDisposable
|
||||
{
|
||||
private const string ServiceName = "MtApiService";
|
||||
|
||||
public delegate void MtQuoteHandler(MtQuote quote);
|
||||
public delegate void MtEventHandler(MtEvent e);
|
||||
|
||||
#region Fields
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(MtClient));
|
||||
|
||||
private MtApiProxy _proxy;
|
||||
private bool _isConnected;
|
||||
private readonly MtApiProxy _proxy;
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
public void Open(string host, int port)
|
||||
#region ctor
|
||||
public MtClient(string host, int port)
|
||||
{
|
||||
Log.DebugFormat("Open: begin. host = {0}, port = {1}", host, port);
|
||||
|
||||
if (string.IsNullOrEmpty(host))
|
||||
throw new ArgumentNullException(nameof(host), "host is null or empty");
|
||||
|
||||
if (port < 0 || port > 65536)
|
||||
throw new ArgumentOutOfRangeException(nameof(port), "port value is invalid");
|
||||
|
||||
var urlService = $"net.tcp://{host}:{port}/{ServiceName}";
|
||||
Host = host;
|
||||
Port = port;
|
||||
|
||||
if (_proxy != null)
|
||||
{
|
||||
Log.Warn("Open: end. _proxy is not null.");
|
||||
return;
|
||||
}
|
||||
var urlService = $"net.tcp://{host}:{port}/{ServiceName}";
|
||||
|
||||
var bind = new NetTcpBinding(SecurityMode.None)
|
||||
{
|
||||
@@ -55,28 +50,19 @@ namespace MTApiService
|
||||
MaxNameTableCharCount = 2147483647
|
||||
}
|
||||
};
|
||||
// Commented next statement since it is not required
|
||||
|
||||
_proxy = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
|
||||
_proxy.Faulted += ProxyFaulted;
|
||||
|
||||
Log.Debug("Open: end.");
|
||||
}
|
||||
|
||||
public void Open(int port)
|
||||
public MtClient(int port)
|
||||
{
|
||||
Log.DebugFormat("Open: begin. port = {0}", port);
|
||||
|
||||
if (port < 0 || port > 65536)
|
||||
throw new ArgumentOutOfRangeException(nameof(port), "port value is invalid");
|
||||
|
||||
var urlService = $"net.pipe://localhost/{ServiceName}_{port}";
|
||||
Port = port;
|
||||
|
||||
if (_proxy != null)
|
||||
{
|
||||
Log.Warn("Open: end. _proxy is not null.");
|
||||
return;
|
||||
}
|
||||
var urlService = $"net.pipe://localhost/{ServiceName}_{port}";
|
||||
|
||||
var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
|
||||
{
|
||||
@@ -94,61 +80,40 @@ namespace MTApiService
|
||||
MaxNameTableCharCount = 2147483647
|
||||
}
|
||||
};
|
||||
// Commented next statement since it is not required
|
||||
|
||||
_proxy = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
|
||||
_proxy.Faulted += ProxyFaulted;
|
||||
|
||||
Log.Debug("Open: end.");
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Log.Debug("Close: begin.");
|
||||
|
||||
if (_proxy != null)
|
||||
{
|
||||
_proxy.Faulted -= ProxyFaulted;
|
||||
_proxy.Dispose();
|
||||
_proxy = null;
|
||||
}
|
||||
|
||||
_isConnected = false;
|
||||
|
||||
Log.Debug("Close: end.");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <exception cref="CommunicationException">Thrown when connection failed</exception>
|
||||
public void Connect()
|
||||
{
|
||||
Log.Debug("Connect: begin.");
|
||||
|
||||
if (_proxy == null)
|
||||
if (_proxy.State != CommunicationState.Created)
|
||||
{
|
||||
Log.Error("Connect: _proxy is not defined.");
|
||||
throw new CommunicationException("Connection failed to service. Proxy is not defined (needs to call Open)");
|
||||
}
|
||||
|
||||
if (_isConnected)
|
||||
{
|
||||
Log.Warn("Connected: end. Client is already connected.");
|
||||
Log.ErrorFormat("Connected: end. Client has invalid state {0}", _proxy.State);
|
||||
return;
|
||||
}
|
||||
|
||||
bool coonected;
|
||||
|
||||
try
|
||||
{
|
||||
_isConnected = _proxy.Connect();
|
||||
coonected = _proxy.Connect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ErrorFormat("Connect: Exception - {0}", ex.Message);
|
||||
|
||||
Close();
|
||||
|
||||
throw new CommunicationException($"Connection failed to service. {ex.Message}");
|
||||
}
|
||||
|
||||
if (_isConnected == false)
|
||||
if (coonected == false)
|
||||
{
|
||||
Log.Error("Connect: end. Connection failed.");
|
||||
throw new CommunicationException("Connection failed");
|
||||
@@ -163,72 +128,60 @@ namespace MTApiService
|
||||
|
||||
try
|
||||
{
|
||||
_isConnected = false;
|
||||
|
||||
_proxy?.Disconnect();
|
||||
_proxy.Disconnect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ErrorFormat("Disconnect: Exception - {0}", ex.Message);
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
Log.Debug("Disconnect: end.");
|
||||
}
|
||||
|
||||
/// <exception cref="CommunicationException">Thrown when connection failed</exception>
|
||||
public MtResponse SendCommand(int commandType, ArrayList parameters)
|
||||
public MtResponse SendCommand(int commandType, ArrayList parameters, Dictionary<string, object> namedParams, int expertHandle)
|
||||
{
|
||||
Log.DebugFormat("SendCommand: begin. commandType = {0}, parameters count = {1}", commandType, parameters?.Count);
|
||||
|
||||
MtResponse result;
|
||||
|
||||
if (_isConnected == false)
|
||||
if (IsConnected == false)
|
||||
{
|
||||
Log.Error("SendCommand: Client is not connected.");
|
||||
throw new CommunicationException("Client is not connected.");
|
||||
}
|
||||
|
||||
if (_proxy == null)
|
||||
{
|
||||
Log.Error("SendCommand: Proxy is not defined.");
|
||||
throw new CommunicationException("Proxy is not defined.");
|
||||
}
|
||||
MtResponse result;
|
||||
|
||||
try
|
||||
{
|
||||
result = _proxy.SendCommand(new MtCommand(commandType, parameters));
|
||||
result = _proxy.SendCommand(new MtCommand {
|
||||
CommandType = commandType,
|
||||
Parameters = parameters,
|
||||
NamedParams = namedParams,
|
||||
ExpertHandle = expertHandle});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ErrorFormat("SendCommand: Exception - {0}", ex.Message);
|
||||
|
||||
Close();
|
||||
|
||||
throw new CommunicationException("Service connection failed! " + ex.Message);
|
||||
}
|
||||
|
||||
Log.DebugFormat("SendCommand: end. result = {0}", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <exception cref="CommunicationException">Thrown when connection failed</exception>
|
||||
public IEnumerable<MtQuote> GetQuotes()
|
||||
public List<MtQuote> GetQuotes()
|
||||
{
|
||||
Log.Debug("GetQuotes: begin.");
|
||||
|
||||
if (_isConnected == false)
|
||||
if (IsConnected == false)
|
||||
{
|
||||
Log.Warn("GetQuotes: end. Client is not connected.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_proxy == null)
|
||||
{
|
||||
Log.Warn("GetQuotes: end. _proxy is not defined.");
|
||||
return null;
|
||||
}
|
||||
|
||||
List<MtQuote> result;
|
||||
|
||||
try
|
||||
@@ -239,8 +192,6 @@ namespace MTApiService
|
||||
{
|
||||
Log.ErrorFormat("GetQuotes: Exception - {0}", ex.Message);
|
||||
|
||||
Close();
|
||||
|
||||
throw new CommunicationException($"Service connection failed! {ex.Message}");
|
||||
}
|
||||
|
||||
@@ -286,18 +237,17 @@ namespace MTApiService
|
||||
{
|
||||
Log.Debug("OnServerStopped: begin.");
|
||||
|
||||
Close();
|
||||
ServerDisconnected?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
Log.Debug("OnServerStopped: end.");
|
||||
}
|
||||
|
||||
|
||||
public void OnMtEvent(MtEvent mtEvent)
|
||||
public void OnMtEvent(MtEvent e)
|
||||
{
|
||||
Log.DebugFormat("OnMtEvent: begin. event = {0}", mtEvent);
|
||||
Log.DebugFormat("OnMtEvent: begin. event = {0}", e);
|
||||
|
||||
MtEventReceived?.Invoke(this, new MtEventArgs(mtEvent));
|
||||
MtEventReceived?.Invoke(e);
|
||||
|
||||
Log.Debug("OnMtEvent: end.");
|
||||
}
|
||||
@@ -305,7 +255,10 @@ namespace MTApiService
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public bool IsConnected => _proxy.State == CommunicationState.Opened && _isConnected;
|
||||
public string Host { get; private set; }
|
||||
public int Port { get; private set; }
|
||||
|
||||
private bool IsConnected => _proxy.State == CommunicationState.Opened;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -315,7 +268,6 @@ namespace MTApiService
|
||||
{
|
||||
Log.Debug("ProxyFaulted: begin.");
|
||||
|
||||
Close();
|
||||
ServerFailed?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
Log.Debug("ProxyFaulted: end.");
|
||||
@@ -329,7 +281,7 @@ namespace MTApiService
|
||||
{
|
||||
Log.Debug("Dispose: begin.");
|
||||
|
||||
Close();
|
||||
_proxy.Dispose();
|
||||
|
||||
Log.Debug("Dispose: end.");
|
||||
}
|
||||
@@ -342,7 +294,7 @@ namespace MTApiService
|
||||
public event MtQuoteHandler QuoteUpdated;
|
||||
public event EventHandler ServerDisconnected;
|
||||
public event EventHandler ServerFailed;
|
||||
public event EventHandler<MtEventArgs> MtEventReceived;
|
||||
public event MtEventHandler MtEventReceived;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
[DataContract]
|
||||
public class MtCommand
|
||||
{
|
||||
public MtCommand(int commandType, ArrayList parameters)
|
||||
{
|
||||
CommandType = commandType;
|
||||
Parameters = parameters;
|
||||
}
|
||||
[DataMember]
|
||||
public int CommandType { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int CommandType { get; private set; }
|
||||
public ArrayList Parameters { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public ArrayList Parameters { get; private set; }
|
||||
public Dictionary<string, object> NamedParams { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int ExpertHandle { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"CommandType = {CommandType}";
|
||||
return $"CommandType = {CommandType}; ExpertHandle = {ExpertHandle}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace MTApiService
|
||||
Command = command;
|
||||
}
|
||||
|
||||
public MtCommand Command { get; private set; }
|
||||
public MtCommand Command { get; }
|
||||
|
||||
public MtResponse WaitResult(int time)
|
||||
{
|
||||
|
||||
+5
-18
@@ -7,30 +7,17 @@ namespace MTApiService
|
||||
public class MtEvent
|
||||
{
|
||||
[DataMember]
|
||||
public int EventType { get; private set; }
|
||||
public int EventType { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public string Payload { get; private set; }
|
||||
public string Payload { get; internal set; }
|
||||
|
||||
public MtEvent(int eventType, string payload)
|
||||
{
|
||||
EventType = eventType;
|
||||
Payload = payload;
|
||||
}
|
||||
[DataMember]
|
||||
public int ExpertHandle { get; internal set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "MtEvent = " + EventType + ", Payload = " + Payload;
|
||||
return $"EventType = {EventType}; Payload = {Payload}; ExpertHandle = {ExpertHandle}";
|
||||
}
|
||||
}
|
||||
|
||||
public class MtEventArgs: EventArgs
|
||||
{
|
||||
public MtEventArgs(MtEvent e)
|
||||
{
|
||||
Event = e;
|
||||
}
|
||||
|
||||
public MtEvent Event { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ using log4net;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
internal class MtCommandExecutorManager : ICommandManager
|
||||
internal class MtExecutorManager : ICommandManager
|
||||
{
|
||||
#region Private Fields
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(MtCommandExecutorManager));
|
||||
|
||||
private readonly List<MtExpert> _commandExecutors = new List<MtExpert>();
|
||||
private readonly Queue<MtCommandTask> _commandTasks = new Queue<MtCommandTask>();
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(MtExecutorManager));
|
||||
|
||||
private readonly List<ITaskExecutor> _executorList = new List<ITaskExecutor>();
|
||||
private readonly Dictionary<int, ITaskExecutor> _executorMap = new Dictionary<int, ITaskExecutor>();
|
||||
private readonly object _locker = new object();
|
||||
#endregion
|
||||
|
||||
@@ -23,149 +22,94 @@ namespace MTApiService
|
||||
|
||||
lock (_locker)
|
||||
{
|
||||
_commandExecutors.Clear();
|
||||
_commandTasks.Clear();
|
||||
_executorList.Clear();
|
||||
_executorMap.Clear();
|
||||
}
|
||||
|
||||
Log.Debug("Stop: end.");
|
||||
}
|
||||
|
||||
public void AddCommandExecutor(MtExpert commandExecutor)
|
||||
public void AddExecutor(ITaskExecutor executor)
|
||||
{
|
||||
if (commandExecutor == null)
|
||||
throw new ArgumentNullException(nameof(commandExecutor));
|
||||
if (executor == null)
|
||||
throw new ArgumentNullException(nameof(executor));
|
||||
|
||||
Log.DebugFormat("AddCommandExecutor: begin. commandExecutor = {0}", commandExecutor);
|
||||
Log.DebugFormat("AddExecutor: begin. executor = {0}", executor);
|
||||
|
||||
var notify = false;
|
||||
lock (_locker)
|
||||
{
|
||||
if (_commandExecutors.Contains(commandExecutor))
|
||||
if (_executorList.Contains(executor))
|
||||
{
|
||||
Log.Warn("AddCommandExecutor: end. Command executor already exist.");
|
||||
Log.Warn("AddExecutor: end. Executor already exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
_commandExecutors.Add(commandExecutor);
|
||||
if (_commandTasks.Count > 0)
|
||||
{
|
||||
notify = true;
|
||||
}
|
||||
}
|
||||
|
||||
commandExecutor.CommandExecuted += CommandExecutor_CommandExecuted;
|
||||
commandExecutor.CommandManager = this;
|
||||
|
||||
if (notify)
|
||||
{
|
||||
NotifyCommandReady();
|
||||
_executorList.Add(executor);
|
||||
_executorMap[executor.Handle] = executor;
|
||||
}
|
||||
|
||||
Log.Debug("AddCommandExecutor: end.");
|
||||
}
|
||||
|
||||
public void RemoveCommandExecutor(MtExpert commandExecutor)
|
||||
public void RemoveExecutor(ITaskExecutor executor)
|
||||
{
|
||||
if (commandExecutor == null)
|
||||
throw new ArgumentNullException(nameof(commandExecutor));
|
||||
if (executor == null)
|
||||
throw new ArgumentNullException(nameof(executor));
|
||||
|
||||
Log.DebugFormat("RemoveCommandExecutor: begin. commandExecutor = {0}", commandExecutor);
|
||||
Log.DebugFormat("RemoveExecutor: begin. executor = {0}", executor);
|
||||
|
||||
var notify = false;
|
||||
lock (_locker)
|
||||
{
|
||||
if (_commandExecutors.Contains(commandExecutor) == false)
|
||||
if (_executorList.Contains(executor) == false)
|
||||
{
|
||||
Log.Warn("RemoveCommandExecutor: end. Command executor is not exist in collection.");
|
||||
Log.Warn("RemoveExecutor: end. Executor is not exist in collection.");
|
||||
return;
|
||||
}
|
||||
|
||||
_commandExecutors.Remove(commandExecutor);
|
||||
if (_commandTasks.Count > 0)
|
||||
_executorList.Remove(executor);
|
||||
_executorMap.Remove(executor.Handle);
|
||||
}
|
||||
|
||||
Log.Debug("RemoveExecutor: end.");
|
||||
}
|
||||
|
||||
public MtCommandTask SendCommand(MtCommand command)
|
||||
{
|
||||
if (command == null)
|
||||
throw new ArgumentNullException(nameof(command));
|
||||
|
||||
var task = new MtCommandTask(command);
|
||||
|
||||
Log.DebugFormat("SendTask: begin. command = {0}", command);
|
||||
|
||||
ITaskExecutor executor;
|
||||
|
||||
lock (_locker)
|
||||
{
|
||||
if (_executorMap.ContainsKey(command.ExpertHandle))
|
||||
{
|
||||
notify = true;
|
||||
executor = _executorMap[command.ExpertHandle];
|
||||
}
|
||||
else
|
||||
{
|
||||
executor = _executorList.Count > 0 ? _executorList[0] : null;
|
||||
}
|
||||
}
|
||||
|
||||
commandExecutor.CommandExecuted -= CommandExecutor_CommandExecuted;
|
||||
commandExecutor.CommandManager = null;
|
||||
|
||||
if (notify)
|
||||
if (executor == null)
|
||||
{
|
||||
NotifyCommandReady();
|
||||
Log.Error("SendTask: Executor is null!");
|
||||
}
|
||||
else
|
||||
{
|
||||
executor.Execute(task);
|
||||
}
|
||||
|
||||
Log.Debug("RemoveCommandExecutor: end.");
|
||||
Log.Debug("SendTask: end.");
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
public void EnqueueCommandTask(MtCommandTask task)
|
||||
{
|
||||
if (task == null)
|
||||
throw new ArgumentNullException(nameof(task));
|
||||
|
||||
Log.DebugFormat("EnqueueCommandTask: begin. task = {0}", task);
|
||||
|
||||
lock (_locker)
|
||||
{
|
||||
_commandTasks.Enqueue(task);
|
||||
}
|
||||
|
||||
NotifyCommandReady();
|
||||
|
||||
Log.Debug("EnqueueCommandTask: end.");
|
||||
}
|
||||
|
||||
public MtCommandTask DequeueCommandTask()
|
||||
{
|
||||
Log.Debug("DequeueCommandTask: called.");
|
||||
|
||||
lock (_locker)
|
||||
{
|
||||
return _commandTasks.Count > 0 ? _commandTasks.Dequeue() : null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
private void NotifyCommandReady()
|
||||
{
|
||||
Log.Debug("NotifyCommandReady: begin.");
|
||||
|
||||
var commandExecutors = new List<MtExpert>();
|
||||
lock (_locker)
|
||||
{
|
||||
commandExecutors.AddRange(_commandExecutors);
|
||||
}
|
||||
|
||||
foreach (var executor in commandExecutors)
|
||||
{
|
||||
executor.NotifyCommandReady();
|
||||
}
|
||||
|
||||
Log.DebugFormat("NotifyCommandReady: end. Notified executor count = {0}", commandExecutors.Count);
|
||||
}
|
||||
|
||||
private void CommandExecutor_CommandExecuted(object sender, EventArgs e)
|
||||
{
|
||||
Log.Debug("CommandExecutor_CommandExecuted: begin.");
|
||||
|
||||
var notify = false;
|
||||
lock (_locker)
|
||||
{
|
||||
if (_commandTasks.Count > 0)
|
||||
{
|
||||
notify = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (notify)
|
||||
{
|
||||
NotifyCommandReady();
|
||||
}
|
||||
|
||||
Log.Debug("CommandExecutor_CommandExecuted: end.");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
+107
-80
@@ -1,37 +1,38 @@
|
||||
using System;
|
||||
using log4net;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
public class MtExpert
|
||||
public class MtExpert: ITaskExecutor
|
||||
{
|
||||
public delegate void MtQuoteHandler(MtExpert expert, MtQuote quote);
|
||||
public delegate void MtEventHandler(MtExpert expert, MtEvent e);
|
||||
|
||||
#region Private Fields
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(MtExpert));
|
||||
|
||||
private readonly IMetaTraderHandler _mtHadler;
|
||||
private MtCommandTask _commandTask;
|
||||
private ICommandManager _commandManager;
|
||||
private MtCommandTask _currentTask;
|
||||
private readonly Queue<MtCommandTask> _taskQueue = new Queue<MtCommandTask>();
|
||||
private readonly object _locker = new object();
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
public MtExpert(int handle, MtQuote quote, IMetaTraderHandler mtHandler)
|
||||
public MtExpert(int handle, string symbol, double bid, double ask, IMetaTraderHandler mtHandler)
|
||||
{
|
||||
if (mtHandler == null)
|
||||
throw new ArgumentNullException(nameof(mtHandler));
|
||||
|
||||
Quote = quote;
|
||||
_quote = new MtQuote { ExpertHandle = handle, Instrument = symbol, Bid = bid, Ask = ask};
|
||||
Handle = handle;
|
||||
_mtHadler = mtHandler;
|
||||
}
|
||||
|
||||
public void Deinit()
|
||||
public virtual void Deinit()
|
||||
{
|
||||
Log.Debug("Deinit: begin.");
|
||||
|
||||
IsEnable = false;
|
||||
FireOnDeinited();
|
||||
|
||||
Log.Debug("Deinit: end.");
|
||||
@@ -41,31 +42,26 @@ namespace MTApiService
|
||||
{
|
||||
Log.DebugFormat("SendResponse: begin. response = {0}", response);
|
||||
|
||||
_commandTask.SetResult(response);
|
||||
_commandTask = null;
|
||||
FireOnCommandExecuted();
|
||||
_currentTask.SetResult(response);
|
||||
_currentTask = null;
|
||||
|
||||
Log.Debug("SendResponse: end.");
|
||||
}
|
||||
|
||||
public int GetCommandType()
|
||||
public virtual int GetCommandType()
|
||||
{
|
||||
Log.Debug("GetCommandType: called.");
|
||||
|
||||
var commandManager = CommandManager;
|
||||
if (commandManager != null)
|
||||
{
|
||||
_commandTask = commandManager.DequeueCommandTask();
|
||||
}
|
||||
_currentTask = DequeueTask();
|
||||
|
||||
return _commandTask?.Command?.CommandType ?? 0;
|
||||
return _currentTask?.Command?.CommandType ?? 0;
|
||||
}
|
||||
|
||||
public object GetCommandParameter(int index)
|
||||
{
|
||||
Log.DebugFormat("GetCommandType: called. index = {0}", index);
|
||||
Log.DebugFormat("GetCommandParameter: called. index = {0}", index);
|
||||
|
||||
var command = _commandTask?.Command;
|
||||
var command = _currentTask?.Command;
|
||||
if (command?.Parameters != null && index >= 0 && index < command.Parameters.Count)
|
||||
{
|
||||
return command.Parameters[index];
|
||||
@@ -74,7 +70,47 @@ namespace MTApiService
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SendEvent(MtEvent mtEvent)
|
||||
public object GetNamedParameter(string name)
|
||||
{
|
||||
Log.DebugFormat("GetNamedParameter: called. name = {0}", name);
|
||||
|
||||
var command = _currentTask?.Command;
|
||||
if (command == null)
|
||||
{
|
||||
Log.Warn("GetNamedParameter: command is not defined in task.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (command.NamedParams == null)
|
||||
{
|
||||
Log.Warn("GetNamedParameter: NamedParams is not defined in command.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return command.NamedParams[name];
|
||||
}
|
||||
|
||||
public bool ContainsNamedParameter(string name)
|
||||
{
|
||||
Log.DebugFormat("ContainsNamedParameter: called. name = {0}", name);
|
||||
|
||||
var command = _currentTask?.Command;
|
||||
if (command == null)
|
||||
{
|
||||
Log.Warn("ContainsNamedParameter: command is not defined in task.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.NamedParams == null)
|
||||
{
|
||||
Log.Warn("ContainsNamedParameter: NamedParams is not defined in command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return command.NamedParams.ContainsKey(name);
|
||||
}
|
||||
|
||||
public virtual void SendEvent(MtEvent mtEvent)
|
||||
{
|
||||
Log.DebugFormat("SendEvent: begin. event = {0}", mtEvent);
|
||||
|
||||
@@ -83,14 +119,38 @@ namespace MTApiService
|
||||
Log.Debug("SendEvent: end.");
|
||||
}
|
||||
|
||||
public void UpdateQuote(MtQuote quote)
|
||||
{
|
||||
Log.DebugFormat("UpdateQuote: begin. quote = {0}", quote);
|
||||
|
||||
Quote = quote;
|
||||
|
||||
Log.Debug("UpdateQuote: end.");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"ExpertHandle = {Handle}";
|
||||
return $"ExpertHandle = {Handle}, Quote = {Quote}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITaskExecutor
|
||||
|
||||
public void Execute(MtCommandTask task)
|
||||
{
|
||||
lock (_taskQueue)
|
||||
{
|
||||
_taskQueue.Enqueue(task);
|
||||
}
|
||||
|
||||
NotifyCommandReady();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
private MtQuote _quote;
|
||||
public MtQuote Quote
|
||||
{
|
||||
@@ -101,7 +161,7 @@ namespace MTApiService
|
||||
return _quote;
|
||||
}
|
||||
}
|
||||
set
|
||||
private set
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
@@ -113,61 +173,34 @@ namespace MTApiService
|
||||
}
|
||||
|
||||
public int Handle { get; }
|
||||
|
||||
private bool _isEnable = true;
|
||||
public bool IsEnable
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
return _isEnable;
|
||||
}
|
||||
}
|
||||
private set
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_isEnable = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICommandManager CommandManager
|
||||
{
|
||||
private get
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
return _commandManager;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_commandManager = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IMtCommandExecutor
|
||||
public void NotifyCommandReady()
|
||||
{
|
||||
Log.Debug("NotifyCommandReady: begin.");
|
||||
|
||||
SendTickToMetaTrader();
|
||||
|
||||
Log.Debug("NotifyCommandReady: end.");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
private void SendTickToMetaTrader()
|
||||
private MtCommandTask DequeueTask()
|
||||
{
|
||||
Log.Debug("DequeueTask: called.");
|
||||
|
||||
MtCommandTask task;
|
||||
int count;
|
||||
|
||||
lock (_locker)
|
||||
{
|
||||
count = _taskQueue.Count;
|
||||
task = _taskQueue.Count > 0 ? _taskQueue.Dequeue() : null;
|
||||
}
|
||||
|
||||
Log.DebugFormat("DequeueTask: end. left task count = {0}.", count);
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
private void NotifyCommandReady()
|
||||
{
|
||||
Log.Debug("NotifyCommandReady: begin.");
|
||||
|
||||
_mtHadler.SendTickToMetaTrader(Handle);
|
||||
|
||||
Log.Debug("NotifyCommandReady: end.");
|
||||
}
|
||||
|
||||
private void FireOnQuoteChanged(MtQuote quote)
|
||||
@@ -180,22 +213,16 @@ namespace MTApiService
|
||||
Deinited?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void FireOnCommandExecuted()
|
||||
{
|
||||
CommandExecuted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void FireOnMtEvent(MtEvent mtEvent)
|
||||
{
|
||||
OnMtEvent?.Invoke(this, new MtEventArgs(mtEvent));
|
||||
OnMtEvent?.Invoke(this, mtEvent);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
public event EventHandler Deinited;
|
||||
public event MtQuoteHandler QuoteChanged;
|
||||
public event EventHandler CommandExecuted;
|
||||
public event EventHandler<MtEventArgs> OnMtEvent;
|
||||
public event MtEventHandler OnMtEvent;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
[DataContract]
|
||||
public class MtQuote
|
||||
{
|
||||
[DataMember]
|
||||
public string Instrument { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public double Bid { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public double Ask { get; private set; }
|
||||
|
||||
public MtQuote(string instrument, double bid, double ask)
|
||||
{
|
||||
Instrument = instrument;
|
||||
Bid = bid;
|
||||
Ask = ask;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Instrument = " + Instrument + ", Bid = " + Bid + ", Ask = " + Ask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
[DataContract]
|
||||
public class MtMqlBookInfo
|
||||
{
|
||||
[DataMember]
|
||||
public int type { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public double price { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long volume { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
[DataContract]
|
||||
public class MtMqlTick
|
||||
{
|
||||
[DataMember]
|
||||
public long time { get; set; } // Time of the last prices update
|
||||
|
||||
[DataMember]
|
||||
public double bid { get; set; } // Current Bid price
|
||||
|
||||
[DataMember]
|
||||
public double ask { get; set; } // Current Ask price
|
||||
|
||||
[DataMember]
|
||||
public double last { get; set; } // Price of the last deal (Last)
|
||||
|
||||
[DataMember]
|
||||
public ulong volume { get; set; } // Volume for the current Last price
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@ namespace MTApiService
|
||||
[DataMember]
|
||||
public int Action { get; set; }
|
||||
[DataMember]
|
||||
public uint Magic { get; set; }
|
||||
public ulong Magic { get; set; }
|
||||
[DataMember]
|
||||
public uint Order { get; set; }
|
||||
public ulong Order { get; set; }
|
||||
[DataMember]
|
||||
public string Symbol { get; set; }
|
||||
[DataMember]
|
||||
@@ -25,7 +25,7 @@ namespace MTApiService
|
||||
[DataMember]
|
||||
public double Tp { get; set; }
|
||||
[DataMember]
|
||||
public uint Deviation { get; set; }
|
||||
public ulong Deviation { get; set; }
|
||||
[DataMember]
|
||||
public int Type { get; set; }
|
||||
[DataMember]
|
||||
@@ -36,5 +36,9 @@ namespace MTApiService
|
||||
public DateTime Expiration { get; set; }
|
||||
[DataMember]
|
||||
public string Comment { get; set; }
|
||||
[DataMember]
|
||||
public ulong Position { get; set; }
|
||||
[DataMember]
|
||||
public ulong PositionBy { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MTApiService
|
||||
{
|
||||
[DataContract]
|
||||
public class MtQuote
|
||||
{
|
||||
[DataMember]
|
||||
public string Instrument { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public double Bid { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public double Ask { get; internal set; }
|
||||
|
||||
[DataMember]
|
||||
public int ExpertHandle { get; internal set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Instrument = {Instrument}; Bid = {Bid}; Ask = {Ask}; ExpertHandle = {ExpertHandle}";
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
-43
@@ -12,16 +12,38 @@ namespace MTApiService
|
||||
{
|
||||
static IEnumerable<Type> GetKnownTypes()
|
||||
{
|
||||
return new Type[] { typeof(MtResponseInt), typeof(MtResponseDouble),
|
||||
return new Type[] { typeof(MtResponseObject),
|
||||
typeof(MtResponseInt), typeof(MtResponseDouble),
|
||||
typeof(MtResponseString), typeof(MtResponseBool),
|
||||
typeof(MtResponseLong), typeof(MtResponseULong),
|
||||
typeof(MtResponseDoubleArray), typeof(MtResponseIntArray),
|
||||
typeof(MtResponseLongArray), typeof(MtResponseMqlTick),
|
||||
typeof(MtResponseArrayList), typeof(MtResponseMqlRatesArray),
|
||||
typeof(MtResponseMqlBookInfoArray)};
|
||||
typeof(MtResponseLongArray),
|
||||
typeof(MtResponseArrayList), typeof(MtResponseMqlRatesArray)};
|
||||
}
|
||||
|
||||
public abstract object GetValue();
|
||||
|
||||
[DataMember]
|
||||
public int ErrorCode { get; set; }
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class MtResponseObject : MtResponse
|
||||
{
|
||||
public MtResponseObject(object value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public object Value { get; private set; }
|
||||
|
||||
public override object GetValue() { return Value; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Value?.ToString() ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
@@ -232,43 +254,4 @@ namespace MTApiService
|
||||
return Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class MtResponseMqlTick : MtResponse
|
||||
{
|
||||
public MtResponseMqlTick(MtMqlTick value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public MtMqlTick Value { get; private set; }
|
||||
|
||||
public override object GetValue() { return Value; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class MtResponseMqlBookInfoArray : MtResponse
|
||||
{
|
||||
public MtResponseMqlBookInfoArray(MtMqlBookInfo[] value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public MtMqlBookInfo[] Value { get; private set; }
|
||||
|
||||
public override object GetValue() { return Value; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+29
-17
@@ -21,7 +21,7 @@ namespace MTApiService
|
||||
|
||||
private readonly MtService _service;
|
||||
private readonly List<ServiceHost> _hosts = new List<ServiceHost>();
|
||||
private readonly MtCommandExecutorManager _executorManager = new MtCommandExecutorManager();
|
||||
private readonly MtExecutorManager _executorManager = new MtExecutorManager();
|
||||
private readonly List<MtExpert> _experts = new List<MtExpert>();
|
||||
#endregion
|
||||
|
||||
@@ -62,21 +62,24 @@ namespace MTApiService
|
||||
}
|
||||
|
||||
//init local pipe host
|
||||
var localUrl = CreateConnectionAddress(null, port, true);
|
||||
var localServiceHost = CreateServiceHost(localUrl, true);
|
||||
var localPipeUrl = CreateConnectionAddress(null, port, true);
|
||||
var localPipeServiceHost = CreateServiceHost(localPipeUrl, true);
|
||||
if (localPipeServiceHost != null)
|
||||
{
|
||||
_hosts.Add(localPipeServiceHost);
|
||||
}
|
||||
|
||||
//init localhost
|
||||
var localUrl = CreateConnectionAddress("localhost", port, false);
|
||||
var localServiceHost = CreateServiceHost(localUrl, false);
|
||||
if (localServiceHost != null)
|
||||
{
|
||||
_hosts.Add(localServiceHost);
|
||||
}
|
||||
|
||||
|
||||
//init network hosts
|
||||
var dnsHostName = Dns.GetHostName();
|
||||
var ips = Dns.GetHostEntry(dnsHostName);
|
||||
if (ips == null)
|
||||
{
|
||||
Log.WarnFormat("InitHosts: end. Dns.GetHostEntry has returned null for DNS Host Name {0}", dnsHostName);
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var ipAddress in ips.AddressList)
|
||||
{
|
||||
@@ -149,7 +152,7 @@ namespace MTApiService
|
||||
_experts.Add(expert);
|
||||
}
|
||||
|
||||
_executorManager.AddCommandExecutor(expert);
|
||||
_executorManager.AddExecutor(expert);
|
||||
|
||||
_service.OnQuoteAdded(expert.Quote);
|
||||
|
||||
@@ -170,11 +173,20 @@ namespace MTApiService
|
||||
return null;
|
||||
}
|
||||
|
||||
var task = new MtCommandTask(command);
|
||||
_executorManager.EnqueueCommandTask(task);
|
||||
var task = _executorManager.SendCommand(command);
|
||||
|
||||
//wait for execute command in MetaTrader
|
||||
var response = task.WaitResult(WaitResponseTime);
|
||||
MtResponse response = null;
|
||||
try
|
||||
{
|
||||
response = task.WaitResult(WaitResponseTime);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WarnFormat("SendCommand: Exception - {0}", ex.Message);
|
||||
}
|
||||
|
||||
Log.DebugFormat("SendCommand: end. response = {0}", response);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -371,7 +383,7 @@ namespace MTApiService
|
||||
expertsCount = _experts.Count;
|
||||
}
|
||||
|
||||
_executorManager.RemoveCommandExecutor(expert);
|
||||
_executorManager.RemoveExecutor(expert);
|
||||
|
||||
expert.Deinited -= expert_Deinited;
|
||||
expert.QuoteChanged -= expert_QuoteChanged;
|
||||
@@ -398,11 +410,11 @@ namespace MTApiService
|
||||
Log.Debug("expert_QuoteChanged: end.");
|
||||
}
|
||||
|
||||
private void Expert_OnMtEvent(object sender, MtEventArgs e)
|
||||
private void Expert_OnMtEvent(MtExpert expert, MtEvent e)
|
||||
{
|
||||
Log.DebugFormat("Expert_OnMtEvent: begin. event = {0}", e.Event);
|
||||
Log.DebugFormat("Expert_OnMtEvent: begin. expert = {0}, event = {1}", expert, e);
|
||||
|
||||
_service.OnMtEvent(e.Event);
|
||||
_service.OnMtEvent(e);
|
||||
|
||||
Log.Debug("Expert_OnMtEvent: end.");
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace MTApiService
|
||||
|
||||
if (callback == null)
|
||||
{
|
||||
Log.Warn("Connect: end. Callback is not definded.");
|
||||
Log.Warn("Connect: end. Callback is not defined.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace MTApiService
|
||||
|
||||
public void QuoteUpdate(MtQuote quote)
|
||||
{
|
||||
Log.Debug("QuoteUpdate: begin.");
|
||||
Log.DebugFormat("QuoteUpdate: begin. quote = {0}", quote);
|
||||
|
||||
ExecuteCallbackAction(a => a.OnQuoteUpdate(quote));
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace MTApiService
|
||||
|
||||
public void OnQuoteAdded(MtQuote quote)
|
||||
{
|
||||
Log.Debug("OnQuoteAdded: begin.");
|
||||
Log.DebugFormat("OnQuoteAdded: begin. quote = {0}", quote);
|
||||
|
||||
ExecuteCallbackAction(a => a.OnQuoteAdded(quote));
|
||||
|
||||
@@ -176,18 +176,18 @@ namespace MTApiService
|
||||
|
||||
public void OnQuoteRemoved(MtQuote quote)
|
||||
{
|
||||
Log.Debug("OnQuoteRemoved: begin.");
|
||||
Log.DebugFormat("OnQuoteRemoved: begin. quote = {0}", quote);
|
||||
|
||||
ExecuteCallbackAction(a => a.OnQuoteRemoved(quote));
|
||||
|
||||
Log.Debug("OnQuoteRemoved: end.");
|
||||
}
|
||||
|
||||
public void OnMtEvent(MtEvent mtEvent)
|
||||
public void OnMtEvent(MtEvent e)
|
||||
{
|
||||
Log.Debug("OnMtEvent: begin.");
|
||||
Log.DebugFormat("OnMtEvent: begin.quote = {0}", e);
|
||||
|
||||
ExecuteCallbackAction(a => a.OnMtEvent(mtEvent));
|
||||
ExecuteCallbackAction(a => a.OnMtEvent(e));
|
||||
|
||||
Log.Debug("OnMtEvent: end.");
|
||||
}
|
||||
|
||||
Executable → Regular
+2
-2
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.23.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.23.0")]
|
||||
[assembly: AssemblyVersion("1.0.31.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.31.0")]
|
||||
+175
-196
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "MT4Handler.h"
|
||||
#include "Windows.h"
|
||||
#include < vcclr.h >
|
||||
#include <vcclr.h>
|
||||
#include <functional>
|
||||
|
||||
using namespace System;
|
||||
using namespace MTApiService;
|
||||
@@ -17,6 +18,8 @@ using namespace System::IO;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Diagnostics;
|
||||
|
||||
#define _DLLAPI extern "C" __declspec(dllexport)
|
||||
|
||||
void convertSystemString(wchar_t* dest, String^ src)
|
||||
{
|
||||
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
|
||||
@@ -24,264 +27,240 @@ void convertSystemString(wchar_t* dest, String^ src)
|
||||
dest[wcslen(wch)] = '\0';
|
||||
}
|
||||
|
||||
int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, wchar_t* err)
|
||||
template <typename T> T Execute(std::function<T()> func, wchar_t* err, T default_value)
|
||||
{
|
||||
T result = default_value;
|
||||
try
|
||||
{
|
||||
MT4Handler^ mtHandler = gcnew MT4Handler();
|
||||
|
||||
MtServerInstance::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHandler);
|
||||
result = func();
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
convertSystemString(err, e->Message);
|
||||
Debug::WriteLine("[ERROR] MTConnector:initExpert(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
int _stdcall deinitExpert(int expertHandle, wchar_t* err)
|
||||
_DLLAPI bool _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid, double ask, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->DeinitExpert(expertHandle);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
convertSystemString(err, e->Message);
|
||||
Debug::WriteLine("[ERROR] MTConnector:deinitExpert(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &port, symbol, &bid, &ask]() {
|
||||
auto expert = gcnew MtExpert(expertHandle, gcnew String(symbol), bid, ask, gcnew MT4Handler());
|
||||
MtAdapter::GetInstance()->AddExpert(port, expert);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err)
|
||||
_DLLAPI bool _stdcall deinitExpert(int expertHandle, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
convertSystemString(err, e->Message);
|
||||
Debug::WriteLine("[ERROR] MTConnector:updateQuote(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle]() {
|
||||
MtAdapter::GetInstance()->RemoveExpert(expertHandle);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double ask, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, symbol, &bid, &ask]() {
|
||||
MtAdapter::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
|
||||
int _stdcall sendEvent(int expertHandle, int eventType, wchar_t* payload, wchar_t* err)
|
||||
_DLLAPI bool _stdcall sendEvent(int expertHandle, int eventType, wchar_t* payload, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendEvent(expertHandle, eventType, gcnew String(payload));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
convertSystemString(err, e->Message);
|
||||
Debug::WriteLine("[ERROR] MTConnector:updateTimeBar(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &eventType, payload]() {
|
||||
MtAdapter::GetInstance()->SendEvent(expertHandle, eventType, gcnew String(payload));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendIntResponse(int expertHandle, int response)
|
||||
_DLLAPI bool _stdcall sendIntResponse(int expertHandle, int response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendIntResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendBooleanResponse(int expertHandle, int response)
|
||||
_DLLAPI bool _stdcall sendBooleanResponse(int expertHandle, bool response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool value = (response != 0) ? true : false;
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendBooleanResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(response));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendDoubleResponse(int expertHandle, double response)
|
||||
_DLLAPI bool _stdcall sendDoubleResponse(int expertHandle, double response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendDoubleResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendStringResponse(int expertHandle, wchar_t* response)
|
||||
_DLLAPI bool _stdcall sendStringResponse(int expertHandle, wchar_t* response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendStringResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendVoidResponse(int expertHandle)
|
||||
_DLLAPI bool _stdcall sendErrorResponse(int expertHandle, int code, wchar_t* message, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, nullptr);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendVoidResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &code, message]() {
|
||||
MtResponseString^ res = gcnew MtResponseString(gcnew String(message));
|
||||
res->ErrorCode = code;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, res);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size)
|
||||
_DLLAPI bool _stdcall sendVoidResponse(int expertHandle, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Execute<bool>([&expertHandle]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseObject(nullptr));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, values, &size]() {
|
||||
array<double>^ list = gcnew array<double>(size);
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
list[i] = values[i];
|
||||
}
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendDoubleArrayResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size)
|
||||
_DLLAPI bool _stdcall sendIntArrayResponse(int expertHandle, int* values, int size, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Execute<bool>([&expertHandle, values, &size]() {
|
||||
array<int>^ list = gcnew array<int>(size);
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
list[i] = values[i];
|
||||
}
|
||||
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendIntArrayResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall sendLongResponse(int expertHandle, __int64 response)
|
||||
_DLLAPI bool _stdcall sendLongResponse(int expertHandle, __int64 response, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:sendLongResponse(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, &response]() {
|
||||
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall getCommandType(int expertHandle, int* res)
|
||||
_DLLAPI bool _stdcall getCommandType(int expertHandle, int* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = MtServerInstance::GetInstance()->GetCommandType(expertHandle);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:getCommandType(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, res]() {
|
||||
*res = MtAdapter::GetInstance()->GetCommandType(expertHandle);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall getIntValue(int expertHandle, int paramIndex, int* res)
|
||||
_DLLAPI bool _stdcall getIntValue(int expertHandle, int paramIndex, int* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = (int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:getIntValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res)
|
||||
// --- index parameters
|
||||
|
||||
_DLLAPI bool _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
*res = (double)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:getDoubleValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (double)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res)
|
||||
_DLLAPI bool _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
convertSystemString(res, (String^)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MTConnector:getStringValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, ¶mIndex, res]() {
|
||||
convertSystemString(res, (String^)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res)
|
||||
_DLLAPI bool _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res, wchar_t* err)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool val = (bool)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
*res = val == true ? 1 : 0;
|
||||
}
|
||||
catch (Exception^ e)
|
||||
{
|
||||
Debug::WriteLine("[ERROR] MT5Connector:getBooleanValue(): " + e->Message);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return Execute<bool>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (bool)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (__int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
// --- named parameters
|
||||
|
||||
_DLLAPI bool _stdcall containsNamedValue(int expertHandle, wchar_t* paramName)
|
||||
{
|
||||
wchar_t err[1000];
|
||||
return Execute<bool>([&expertHandle, paramName]() {
|
||||
return MtAdapter::GetInstance()->ContainsNamedParameter(expertHandle, gcnew String(paramName));
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall getNamedIntValue(int expertHandle, wchar_t* paramName, int* res, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, paramName, res]() {
|
||||
System::Object^ obj = MtAdapter::GetInstance()->GetNamedParameter(expertHandle, gcnew String(paramName));
|
||||
*res = (int)obj;
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall getNamedDoubleValue(int expertHandle, wchar_t* paramName, double* res, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, paramName, res]() {
|
||||
System::Object^ obj = MtAdapter::GetInstance()->GetNamedParameter(expertHandle, gcnew String(paramName));
|
||||
*res = (double)obj;
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall getNamedStringValue(int expertHandle, wchar_t* paramName, wchar_t* res, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, paramName, res]() {
|
||||
System::Object^ obj = MtAdapter::GetInstance()->GetNamedParameter(expertHandle, gcnew String(paramName));
|
||||
convertSystemString(res, (String^)obj);
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall getNamedBooleanValue(int expertHandle, wchar_t* paramName, int* res, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, paramName, res]() {
|
||||
System::Object^ obj = MtAdapter::GetInstance()->GetNamedParameter(expertHandle, gcnew String(paramName));
|
||||
*res = (bool)obj;
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
|
||||
_DLLAPI bool _stdcall getNamedLongValue(int expertHandle, wchar_t* paramName, __int64* res, wchar_t* err)
|
||||
{
|
||||
return Execute<bool>([&expertHandle, paramName, res]() {
|
||||
System::Object^ obj = MtAdapter::GetInstance()->GetNamedParameter(expertHandle, gcnew String(paramName));
|
||||
if (obj != nullptr)
|
||||
*res = (__int64)obj;
|
||||
return true;
|
||||
}, err, false);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
LIBRARY MTConnector
|
||||
|
||||
EXPORTS initExpert
|
||||
deinitExpert
|
||||
updateQuote
|
||||
sendEvent
|
||||
sendIntResponse
|
||||
sendBooleanResponse
|
||||
sendDoubleResponse
|
||||
sendStringResponse
|
||||
sendVoidResponse
|
||||
sendDoubleArrayResponse
|
||||
sendIntArrayResponse
|
||||
sendLongResponse
|
||||
getCommandType
|
||||
getIntValue
|
||||
getDoubleValue
|
||||
getStringValue
|
||||
getBooleanValue
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@@ -24,6 +24,7 @@
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<RootNamespace>MTConnector</RootNamespace>
|
||||
<ProjectName>MTConnector</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -31,28 +32,28 @@
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -96,7 +97,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MTConnector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -109,7 +109,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MTConnector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -121,7 +120,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MTConnector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -133,7 +131,6 @@
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>.\MTConnector.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -154,7 +151,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.ico" />
|
||||
<None Include="MTConnector.def" />
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
<None Include="app.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="MTConnector.def">
|
||||
<Filter>Source Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="app.rc">
|
||||
|
||||
@@ -42,6 +42,11 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "MtApi5Bootstrapper", "MtApi
|
||||
{A9ED070F-AB4D-4380-9DDE-5D931AC71333} = {A9ED070F-AB4D-4380-9DDE-5D931AC71333}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "MtApiBootstrapper", "MtApiBootstrapper\MtApiBootstrapper.wixproj", "{8E63046B-56E5-4623-8808-558AD72A8F2B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{78B94552-DB17-40EC-B7C6-23D32DB85DC1} = {78B94552-DB17-40EC-B7C6-23D32DB85DC1}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -215,6 +220,18 @@ Global
|
||||
{1497E285-C228-490B-9638-565E118548FB}.Release|x64.ActiveCfg = Release|x64
|
||||
{1497E285-C228-490B-9638-565E118548FB}.Release|x86.ActiveCfg = Release|x86
|
||||
{1497E285-C228-490B-9638-565E118548FB}.Release|x86.Build.0 = Release|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Debug|Win32.ActiveCfg = Debug|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Debug|Win32.Build.0 = Debug|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Debug|x86.Build.0 = Debug|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Release|Win32.ActiveCfg = Release|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Release|Win32.Build.0 = Release|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Release|x64.ActiveCfg = Release|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Release|x86.ActiveCfg = Release|x86
|
||||
{8E63046B-56E5-4623-8808-558AD72A8F2B}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
public class ChartEventArgs : EventArgs
|
||||
{
|
||||
internal ChartEventArgs(int expertHandle, MtChartEvent chartEvent)
|
||||
{
|
||||
ExpertHandle = expertHandle;
|
||||
ChartId = chartEvent.ChartId;
|
||||
EventId = chartEvent.EventId;
|
||||
Lparam = chartEvent.Lparam;
|
||||
Dparam = chartEvent.Dparam;
|
||||
Sparam = chartEvent.Sparam;
|
||||
}
|
||||
|
||||
public int ExpertHandle { get; }
|
||||
public long ChartId { get; }
|
||||
public int EventId { get; }
|
||||
public long Lparam { get; }
|
||||
public double Dparam { get; }
|
||||
public string Sparam { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumAlignMode
|
||||
{
|
||||
ALIGN_LEFT = 1,
|
||||
ALIGN_CENTER = 2,
|
||||
ALIGN_RIGHT = 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumChartEvent
|
||||
{
|
||||
CHARTEVENT_KEYDOWN = 0,
|
||||
CHARTEVENT_MOUSE_MOVE = 10,
|
||||
CHARTEVENT_OBJECT_CREATE = 7,
|
||||
CHARTEVENT_OBJECT_CHANGE = 8,
|
||||
CHARTEVENT_OBJECT_DELETE = 6,
|
||||
CHARTEVENT_CLICK = 4,
|
||||
CHARTEVENT_OBJECT_CLICK = 1,
|
||||
CHARTEVENT_OBJECT_DRAG = 2,
|
||||
CHARTEVENT_OBJECT_ENDEDIT = 3,
|
||||
CHARTEVENT_CHART_CHANGE = 9,
|
||||
CHARTEVENT_CUSTOM = 1000,
|
||||
CHARTEVENT_CUSTOM_LAST = 66534
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumChartPropertyDouble
|
||||
{
|
||||
CHART_SHIFT_SIZE = 3,
|
||||
CHART_FIXED_POSITION = 41,
|
||||
CHART_FIXED_MAX = 8,
|
||||
CHART_FIXED_MIN = 9,
|
||||
CHART_POINTS_PER_BAR = 11,
|
||||
CHART_PRICE_MIN = 108,
|
||||
CHART_PRICE_MAX = 109
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumChartPropertyInteger
|
||||
{
|
||||
CHART_BRING_TO_TOP = 35,
|
||||
CHART_MOUSE_SCROLL = 42,
|
||||
CHART_EVENT_MOUSE_MOVE = 40,
|
||||
CHART_EVENT_OBJECT_CREATE = 38,
|
||||
CHART_EVENT_OBJECT_DELETE = 39,
|
||||
CHART_MODE = 0,
|
||||
CHART_FOREGROUND = 1,
|
||||
CHART_SHIFT = 2,
|
||||
CHART_AUTOSCROLL = 4,
|
||||
CHART_QUICK_NAVIGATION = 45,
|
||||
CHART_SCALE = 5,
|
||||
CHART_SCALEFIX = 6,
|
||||
CHART_SCALEFIX_11 = 7,
|
||||
CHART_SCALE_PT_PER_BAR = 10,
|
||||
CHART_SHOW_OHLC = 12,
|
||||
CHART_SHOW_BID_LINE = 13,
|
||||
CHART_SHOW_ASK_LINE = 14,
|
||||
CHART_SHOW_LAST_LINE = 15,
|
||||
CHART_SHOW_PERIOD_SEP = 16,
|
||||
CHART_SHOW_GRID = 17,
|
||||
CHART_SHOW_VOLUMES = 18,
|
||||
CHART_SHOW_OBJECT_DESCR = 19,
|
||||
CHART_VISIBLE_BARS = 100,
|
||||
CHART_WINDOWS_TOTAL = 101,
|
||||
CHART_WINDOW_IS_VISIBLE = 102,
|
||||
CHART_WINDOW_HANDLE = 103,
|
||||
CHART_WINDOW_YDISTANCE = 110,
|
||||
CHART_FIRST_VISIBLE_BAR = 104,
|
||||
CHART_WIDTH_IN_BARS = 105,
|
||||
CHART_WIDTH_IN_PIXELS = 106,
|
||||
CHART_HEIGHT_IN_PIXELS = 107,
|
||||
CHART_COLOR_BACKGROUND = 21,
|
||||
CHART_COLOR_FOREGROUND = 22,
|
||||
CHART_COLOR_GRID = 23,
|
||||
CHART_COLOR_VOLUME = 24,
|
||||
CHART_COLOR_CHART_UP = 25,
|
||||
CHART_COLOR_CHART_DOWN = 26,
|
||||
CHART_COLOR_CHART_LINE = 27,
|
||||
CHART_COLOR_CANDLE_BULL = 28,
|
||||
CHART_COLOR_CANDLE_BEAR = 29,
|
||||
CHART_COLOR_BID = 30,
|
||||
CHART_COLOR_ASK = 31,
|
||||
CHART_COLOR_LAST = 32,
|
||||
CHART_COLOR_STOP_LEVEL = 33,
|
||||
CHART_SHOW_TRADE_LEVELS = 34,
|
||||
CHART_DRAG_TRADE_LEVELS = 43,
|
||||
CHART_SHOW_DATE_SCALE = 36,
|
||||
CHART_SHOW_PRICE_SCALE = 37,
|
||||
CHART_IS_OFFLINE = 112
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumChartPropertyString
|
||||
{
|
||||
CHART_COMMENT = 20
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MtApi
|
||||
{
|
||||
enum EnumColorFormat
|
||||
{
|
||||
COLOR_FORMAT_XRGB_NOALPHA = 0, //The component of the alpha channel is ignored
|
||||
COLOR_FORMAT_ARGB_RAW = 1, //Color components are not handled by the terminal (must be correctly set by the user)
|
||||
COLOR_FORMAT_ARGB_NORMALIZE = 2 //Color components are handled by the terminal
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumObject
|
||||
{
|
||||
OBJ_VLINE = 0, //Vertical Line
|
||||
OBJ_HLINE = 1, //Horizontal Line
|
||||
OBJ_TREND = 2, //Trend Line
|
||||
BJ_TRENDBYANGLE = 3, //Trend Line By Angle
|
||||
OBJ_CYCLES = 20, //Cycle Lines
|
||||
OBJ_CHANNEL = 5, //Equidistant Channel
|
||||
OBJ_STDDEVCHANNEL = 6, //Standard Deviation Channel
|
||||
OBJ_REGRESSION = 4, //Linear Regression Channel
|
||||
OBJ_PITCHFORK = 19, //Andrews Pitchfork
|
||||
OBJ_GANNLINE = 7, //Gann Line
|
||||
OBJ_GANNFAN = 8, //Gann Fan
|
||||
OBJ_GANNGRID = 9, //Gann Grid
|
||||
OBJ_FIBO = 10, //Fibonacci Retracement
|
||||
OBJ_FIBOTIMES = 11, //Fibonacci Time Zones
|
||||
OBJ_FIBOFAN = 12, //Fibonacci Fan
|
||||
OBJ_FIBOARC = 13, //Fibonacci Arcs
|
||||
OBJ_FIBOCHANNEL = 15, //Fibonacci Channel
|
||||
OBJ_EXPANSION = 14, //Fibonacci Expansion
|
||||
OBJ_RECTANGLE = 16, //Rectangle
|
||||
OBJ_TRIANGLE = 17, //Triangle
|
||||
OBJ_ELLIPSE = 18, //Ellipse
|
||||
OBJ_ARROW_THUMB_UP = 29, //Thumbs Up
|
||||
OBJ_ARROW_THUMB_DOWN = 30, //Thumbs Down
|
||||
OBJ_ARROW_UP = 31, //Arrow Up
|
||||
OBJ_ARROW_DOWN = 32, //Arrow Down
|
||||
OBJ_ARROW_STOP = 33, //Stop Sign
|
||||
OBJ_ARROW_CHECK = 34, //Check Sign
|
||||
OBJ_ARROW_LEFT_PRICE = 35, //Left Price Label
|
||||
OBJ_ARROW_RIGHT_PRICE = 36, //Right Price Label
|
||||
OBJ_ARROW_BUY = 37, //Buy Sign
|
||||
OBJ_ARROW_SELL = 38, //Sell Sign
|
||||
OBJ_ARROW = 22, //Arrow
|
||||
OBJ_TEXT = 21, //Text
|
||||
OBJ_LABEL = 23, //Label
|
||||
OBJ_BUTTON = 25, //Button
|
||||
OBJ_BITMAP = 26, //Bitmap
|
||||
OBJ_BITMAP_LABEL = 24, //Bitmap Label
|
||||
OBJ_EDIT = 27, //Edit
|
||||
OBJ_EVENT = 42, //The "Event" object corresponding to an event in the economic calendar
|
||||
OBJ_RECTANGLE_LABEL = 28 //The "Rectangle label" object for creating and designing the custom graphical interface.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumObjectPropertyDouble
|
||||
{
|
||||
OBJPROP_PRICE = 20, // Price coordinate
|
||||
OBJPROP_LEVELVALUE = 204, // Level value
|
||||
OBJPROP_SCALE = 12, // Scale (properties of Gann objects, Fibonacci Arcs and Ellipse)
|
||||
OBJPROP_ANGLE = 13, // Angle. For the objects with no angle specified, created from a program, the value is equal to EMPTY_VALUE
|
||||
OBJPROP_DEVIATION = 16, // Deviation for the Standard Deviation Channel
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumObjectPropertyInteger
|
||||
{
|
||||
OBJPROP_COLOR = 6,
|
||||
OBJPROP_STYLE = 7,
|
||||
OBJPROP_WIDTH = 8,
|
||||
OBJPROP_BACK = 9,
|
||||
OBJPROP_ZORDER = 207,
|
||||
OBJPROP_HIDDEN = 208,
|
||||
OBJPROP_SELECTED = 17,
|
||||
OBJPROP_READONLY = 1028,
|
||||
OBJPROP_TYPE = 18,
|
||||
OBJPROP_TIME = 19,
|
||||
OBJPROP_SELECTABLE = 1000,
|
||||
OBJPROP_CREATETIME = 998,
|
||||
OBJPROP_LEVELS = 200,
|
||||
OBJPROP_LEVELCOLOR = 201,
|
||||
OBJPROP_LEVELSTYLE = 202,
|
||||
OBJPROP_LEVELWIDTH = 203,
|
||||
OBJPROP_ALIGN = 1036,
|
||||
OBJPROP_FONTSIZE = 100,
|
||||
OBJPROP_RAY_RIGHT = 1004,
|
||||
OBJPROP_ELLIPSE = 11,
|
||||
OBJPROP_ARROWCODE = 14,
|
||||
OBJPROP_TIMEFRAMES = 15,
|
||||
OBJPROP_ANCHOR = 1011,
|
||||
OBJPROP_XDISTANCE = 102,
|
||||
OBJPROP_YDISTANCE = 103,
|
||||
OBJPROP_STATE = 1018,
|
||||
OBJPROP_XSIZE = 1019,
|
||||
OBJPROP_YSIZE = 1020,
|
||||
OBJPROP_XOFFSET = 1033,
|
||||
OBJPROP_YOFFSET = 1034,
|
||||
OBJPROP_BGCOLOR = 1025,
|
||||
OBJPROP_CORNER = 101,
|
||||
OBJPROP_BORDER_TYPE = 1029,
|
||||
OBJPROP_BORDER_COLOR = 1035
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumObjectPropertyString
|
||||
{
|
||||
OBJPROP_NAME = 1037,
|
||||
OBJPROP_TEXT = 999,
|
||||
OBJPROP_TOOLTIP = 206,
|
||||
OBJPROP_LEVELTEXT = 205,
|
||||
OBJPROP_FONT = 1001,
|
||||
OBJPROP_BMPFILE = 1017,
|
||||
OBJPROP_SYMBOL = 1021
|
||||
}
|
||||
}
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
namespace MtApi
|
||||
{
|
||||
public enum EnumSeriesInfoInteger
|
||||
{
|
||||
SERIES_BARS_COUNT = 0,
|
||||
SERIES_FIRSTDATE = 1,
|
||||
SERIES_LASTBAR_DATE = 5,
|
||||
SERIES_SERVER_FIRSTDATE = 2
|
||||
}
|
||||
}
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
namespace MtApi
|
||||
{
|
||||
// https://docs.mql4.com/constants/environment_state/marketinfoconstants#enum_symbol_info_double
|
||||
public enum EnumSymbolInfoDouble
|
||||
{
|
||||
SYMBOL_BID = 1, // Bid - best sell offer
|
||||
SYMBOL_BIDHIGH = 2, // Not supported
|
||||
SYMBOL_BIDLOW = 3, // Not supported
|
||||
SYMBOL_ASK = 4, // Ask - best buy offer
|
||||
SYMBOL_ASKHIGH = 5, // Not supported
|
||||
SYMBOL_ASKLOW = 6, // Not supported
|
||||
SYMBOL_LAST = 7, // Not supported
|
||||
SYMBOL_LASTHIGH = 8, // Not supported
|
||||
SYMBOL_LASTLOW = 9, // Not supported
|
||||
SYMBOL_POINT = 16, // Symbol point value
|
||||
SYMBOL_TRADE_TICK_VALUE = 26, // Value of SYMBOL_TRADE_TICK_VALUE_PROFIT
|
||||
SYMBOL_TRADE_TICK_VALUE_PROFIT = 53, // Not supported
|
||||
SYMBOL_TRADE_TICK_VALUE_LOSS = 54, // Not supported
|
||||
SYMBOL_TRADE_TICK_SIZE = 27, // Minimal price change
|
||||
SYMBOL_TRADE_CONTRACT_SIZE = 28, // Trade contract size
|
||||
SYMBOL_VOLUME_MIN = 34, // Minimal volume for a deal
|
||||
SYMBOL_VOLUME_MAX = 35, // Maximal volume for a deal
|
||||
SYMBOL_VOLUME_STEP = 36, // Minimal volume change step for deal execution
|
||||
SYMBOL_VOLUME_LIMIT = 55, // Not supported
|
||||
SYMBOL_SWAP_LONG = 38, // Buy order swap value
|
||||
SYMBOL_SWAP_SHORT = 39, // Sell order swap value
|
||||
SYMBOL_MARGIN_INITIAL = 42, // Initial margin means the amount in the margin currency required for opening an order with the volume of one lot. It is used for checking a client's assets when he or she enters the market.
|
||||
SYMBOL_MARGIN_MAINTENANCE = 43, // The maintenance margin. If it is set, it sets the margin amount in the margin currency of the symbol, charged from one lot. It is used for checking a client's assets when his/her account state changes. If the maintenance margin is equal to 0, the initial margin is used.
|
||||
SYMBOL_MARGIN_LONG = 44, // Not supported
|
||||
SYMBOL_MARGIN_SHORT = 45, // Not supported
|
||||
SYMBOL_MARGIN_LIMIT = 46, // Not supported
|
||||
SYMBOL_MARGIN_STOP = 47, // Not supported
|
||||
SYMBOL_MARGIN_STOPLIMIT = 48, // Not supported
|
||||
SYMBOL_SESSION_VOLUME = 57, // Not supported
|
||||
SYMBOL_SESSION_TURNOVER = 58, // Not supported
|
||||
SYMBOL_SESSION_INTEREST = 59, // Not supported
|
||||
SYMBOL_SESSION_BUY_ORDERS_VOLUME = 61, // Not supported
|
||||
SYMBOL_SESSION_SELL_ORDERS_VOLUME = 63, // Not supported
|
||||
SYMBOL_SESSION_OPEN = 64, // Not supported
|
||||
SYMBOL_SESSION_CLOSE = 65, // Not supported
|
||||
SYMBOL_SESSION_AW = 66, // Not supported
|
||||
SYMBOL_SESSION_PRICE_SETTLEMENT = 67, // Not supported
|
||||
SYMBOL_SESSION_PRICE_LIMIT_MIN = 68, // Not supported
|
||||
SYMBOL_SESSION_PRICE_LIMIT_MAX = 69, // Not supported
|
||||
}
|
||||
}
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
namespace MtApi
|
||||
{
|
||||
// https://docs.mql4.com/constants/environment_state/terminalstatus#enum_terminal_info_double
|
||||
public enum EnumTerminalInfoDouble
|
||||
{
|
||||
TERMINAL_COMMUNITY_BALANCE = 25 // Balance in MQL5.community
|
||||
}
|
||||
}
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
namespace MtApi
|
||||
{
|
||||
// https://docs.mql4.com/constants/environment_state/terminalstatus#enum_terminal_info_integer
|
||||
public enum EnumTerminalInfoInteger
|
||||
{
|
||||
TERMINAL_BUILD = 5, // The client terminal build number
|
||||
TERMINAL_COMMUNITY_ACCOUNT = 23, // The flag indicates the presence of MQL5.community authorization data in the terminal
|
||||
TERMINAL_COMMUNITY_CONNECTION = 24, // Connection to MQL5.community
|
||||
TERMINAL_CONNECTED = 6, // Connection to a trade server
|
||||
TERMINAL_DLLS_ALLOWED = 7, // Permission to use DLL
|
||||
TERMINAL_TRADE_ALLOWED = 8, // Permission to trade
|
||||
TERMINAL_EMAIL_ENABLED = 9, // Permission to send e-mails using SMTP-server and login, specified in the terminal settings
|
||||
TERMINAL_FTP_ENABLED = 10, // Permission to send reports using FTP-server and login, specified in the terminal settings
|
||||
TERMINAL_NOTIFICATIONS_ENABLED = 26, // Permission to send notifications to smartphone
|
||||
TERMINAL_MAXBARS = 11, // The maximal bars count on the chart
|
||||
TERMINAL_MQID = 22, // The flag indicates the presence of MetaQuotes ID data to send Push notifications
|
||||
TERMINAL_CODEPAGE = 12, // Number of the code page of the language installed in the client terminal
|
||||
TERMINAL_CPU_CORES = 21, // The number of CPU cores in the system
|
||||
TERMINAL_DISK_SPACE = 20, // Free disk space for the MQL4\Files folder of the terminal, Mb
|
||||
TERMINAL_MEMORY_PHYSICAL = 14, // Physical memory in the system, Mb
|
||||
TERMINAL_MEMORY_TOTAL = 15, // Memory available to the process of the terminal , Mb
|
||||
TERMINAL_MEMORY_AVAILABLE = 16, // Free memory of the terminal process, Mb
|
||||
TERMINAL_MEMORY_USED = 17, // Memory used by the terminal , Mb
|
||||
TERMINAL_SCREEN_DPI = 27, // The resolution of information display on the screen is measured as number of Dots in a line per Inch (DPI). Knowing the parameter value, you can set the size of graphical objects so that they look the same on monitors with different resolution characteristics.
|
||||
TERMINAL_PING_LAST = 28 // The last known value of a ping to a trade server in microseconds. One second comprises of one million microseconds
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
static class ExtensionMethods
|
||||
{
|
||||
#region Event Methods
|
||||
|
||||
public static Task FireEventAsync(this MtApiQuoteHandler evenHandler, object sender, string symbol, double bid, double ask)
|
||||
{
|
||||
return Task.Factory.StartNew(() =>
|
||||
{
|
||||
evenHandler?.Invoke(sender, symbol, bid, ask);
|
||||
});
|
||||
}
|
||||
|
||||
public static Task FireEventAsync(this EventHandler eventHandler, object sender)
|
||||
{
|
||||
return Task.Factory.StartNew(() =>
|
||||
{
|
||||
eventHandler?.Invoke(sender, EventArgs.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
public static Task FireEventAsync<T>(this EventHandler<T> eventHandler, object sender, T e)
|
||||
where T : EventArgs
|
||||
{
|
||||
return Task.Factory.StartNew(() =>
|
||||
{
|
||||
eventHandler?.Invoke(sender, e);
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static MtQuote Convert(this MTApiService.MtQuote quote)
|
||||
{
|
||||
return (quote != null) ? new MtQuote(quote.Instrument, quote.Bid, quote.Ask) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
[Flags]
|
||||
public enum FlagFontStyle
|
||||
{
|
||||
//Flags for specifying font style
|
||||
FONT_ITALIC = -2147483648,
|
||||
FONT_UNDERLINE = 1073741824,
|
||||
FONT_STRIKEOUT = 536870912,
|
||||
|
||||
//Flags for specifying font width
|
||||
FW_DONTCARE = 0,
|
||||
FW_THIN = 1,
|
||||
FW_EXTRALIGHT = 2,
|
||||
FW_ULTRALIGHT = 3,
|
||||
FW_LIGHT = 4,
|
||||
FW_NORMAL = 5,
|
||||
FW_REGULAR = 6,
|
||||
FW_MEDIUM = 7,
|
||||
FW_SEMIBOLD = 8,
|
||||
FW_DEMIBOLD = 9,
|
||||
FW_BOLD = 10,
|
||||
FW_EXTRABOLD = 11,
|
||||
FW_ULTRABOLD = 12,
|
||||
FW_HEAVY = 13,
|
||||
FW_BLACK = 14
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi
|
||||
namespace MtApi
|
||||
{
|
||||
public enum MarketInfoModeType
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace MtApi.Monitors
|
||||
public class TimeframeTradeMonitor : TradeMonitor
|
||||
{
|
||||
#region Fields
|
||||
private volatile bool _isStarted = false;
|
||||
private volatile bool _isStarted;
|
||||
#endregion
|
||||
|
||||
#region ctor
|
||||
@@ -23,13 +23,8 @@ namespace MtApi.Monitors
|
||||
// Returns:
|
||||
// true if PositionMonitor should check orders
|
||||
// otherwise, false.
|
||||
public override bool IsStarted
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isStarted;
|
||||
}
|
||||
}
|
||||
public override bool IsStarted => _isStarted;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace MtApi.Monitors
|
||||
#endregion
|
||||
|
||||
#region ctor
|
||||
public TradeMonitor(MtApiClient apiClient)
|
||||
protected TradeMonitor(MtApiClient apiClient)
|
||||
{
|
||||
if (apiClient == null)
|
||||
throw new ArgumentNullException(nameof(apiClient));
|
||||
@@ -73,13 +73,7 @@ namespace MtApi.Monitors
|
||||
protected abstract void OnMtConnected();
|
||||
protected abstract void OnMtDisconnected();
|
||||
|
||||
public bool IsMtConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _apiClient.ConnectionState == MtConnectionState.Connected;
|
||||
}
|
||||
}
|
||||
public bool IsMtConnected => _apiClient.ConnectionState == MtConnectionState.Connected;
|
||||
|
||||
protected void Check()
|
||||
{
|
||||
@@ -113,12 +107,12 @@ namespace MtApi.Monitors
|
||||
prevOrders = _prevOrders;
|
||||
}
|
||||
|
||||
if (_prevOrders != null) //skip checking on first load orders
|
||||
if (prevOrders != null) //skip checking on first load orders
|
||||
{
|
||||
//check open orders
|
||||
foreach (var order in tradesOrders)
|
||||
{
|
||||
if (_prevOrders.Find(a => a.Ticket == order.Ticket) == null)
|
||||
if (prevOrders.Find(a => a.Ticket == order.Ticket) == null)
|
||||
{
|
||||
openedOrders.Add(order);
|
||||
}
|
||||
@@ -126,7 +120,7 @@ namespace MtApi.Monitors
|
||||
|
||||
//check closed orders
|
||||
var closeOrdersTemp = new List<MtOrder>();
|
||||
foreach (var order in _prevOrders)
|
||||
foreach (var order in prevOrders)
|
||||
{
|
||||
if (tradesOrders.Find(a => a.Ticket == order.Ticket) == null)
|
||||
{
|
||||
@@ -180,10 +174,7 @@ namespace MtApi.Monitors
|
||||
_prevOrders = null;
|
||||
}
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
Check();
|
||||
});
|
||||
Task.Factory.StartNew(Check);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
+1
-6
@@ -5,12 +5,7 @@ namespace MtApi
|
||||
public class MqlRates
|
||||
{
|
||||
public int MtTime { get; set; }
|
||||
|
||||
public DateTime Time
|
||||
{
|
||||
get { return MtApiTimeConverter.ConvertFromMtTime(MtTime); }
|
||||
}
|
||||
|
||||
public DateTime Time => MtApiTimeConverter.ConvertFromMtTime(MtTime);
|
||||
public double Open { get; set; }
|
||||
public double High { get; set; }
|
||||
public double Low { get; set; }
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
public class MqlTick
|
||||
{
|
||||
public int MtTime { get; set; }
|
||||
public DateTime Time => MtApiTimeConverter.ConvertFromMtTime(MtTime);
|
||||
public double Bid { get; set; }
|
||||
public double Ask { get; set; }
|
||||
public double Last { get; set; }
|
||||
public ulong Volume { get; set; }
|
||||
}
|
||||
}
|
||||
+23
-1
@@ -58,11 +58,27 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChartEventArgs.cs" />
|
||||
<Compile Include="ChartPeriod.cs" />
|
||||
<Compile Include="EnumAlignMode.cs" />
|
||||
<Compile Include="EnumChartPropertyDouble.cs" />
|
||||
<Compile Include="EnumChartPropertyInteger.cs" />
|
||||
<Compile Include="EnumChartPropertyString.cs" />
|
||||
<Compile Include="EnumColorFormat.cs" />
|
||||
<Compile Include="EnumObject.cs" />
|
||||
<Compile Include="EnumObjectPropertyDouble.cs" />
|
||||
<Compile Include="EnumObjectPropertyInteger.cs" />
|
||||
<Compile Include="EnumObjectPropertyString.cs" />
|
||||
<Compile Include="EnumSeriesInfoInteger.cs" />
|
||||
<Compile Include="EnumSymbolInfoDouble.cs" />
|
||||
<Compile Include="EnumSymbolInfoInteger.cs" />
|
||||
<Compile Include="ExtensionMethods.cs" />
|
||||
<Compile Include="EnumTerminalInfoDouble.cs" />
|
||||
<Compile Include="EnumTerminalInfoInteger.cs" />
|
||||
<Compile Include="FlagFontStyle.cs" />
|
||||
<Compile Include="Monitors\AvailabilityOrdersEventArgs.cs" />
|
||||
<Compile Include="MqlRates.cs" />
|
||||
<Compile Include="MqlTick.cs" />
|
||||
<Compile Include="MtChartEvent.cs" />
|
||||
<Compile Include="MtConnectionEventArgs.cs" />
|
||||
<Compile Include="MtConnectionException.cs" />
|
||||
<Compile Include="MtConnectionState.cs" />
|
||||
@@ -92,16 +108,22 @@
|
||||
<Compile Include="Requests\OrderDeleteRequest.cs" />
|
||||
<Compile Include="Requests\OrderModifyRequest.cs" />
|
||||
<Compile Include="Requests\OrderSendRequest.cs" />
|
||||
<Compile Include="Requests\SeriesInfoIntegerRequest.cs" />
|
||||
<Compile Include="Requests\SessionRequest.cs" />
|
||||
<Compile Include="Requests\RequestBase.cs" />
|
||||
<Compile Include="Requests\RequestType.cs" />
|
||||
<Compile Include="Requests\SymbolInfoDoubleRequest.cs" />
|
||||
<Compile Include="Requests\SymbolInfoTickRequest.cs" />
|
||||
<Compile Include="Responses\CopyRatesResponse.cs" />
|
||||
<Compile Include="Responses\GetOrderResponse.cs" />
|
||||
<Compile Include="Responses\GetOrdersResponse.cs" />
|
||||
<Compile Include="Responses\ICustomResponse.cs" />
|
||||
<Compile Include="Responses\OrderSendResponse.cs" />
|
||||
<Compile Include="Responses\SeriesInfoIntegerResponse.cs" />
|
||||
<Compile Include="Responses\SessionResponse.cs" />
|
||||
<Compile Include="Responses\ResponseBase.cs" />
|
||||
<Compile Include="Responses\SymbolInfoDoubleResponse.cs" />
|
||||
<Compile Include="Responses\SymbolInfoTickResponse.cs" />
|
||||
<Compile Include="SeriesIdentifier.cs" />
|
||||
<Compile Include="TimeBarArgs.cs" />
|
||||
<Compile Include="Monitors\TimeframeTradeMonitor.cs" />
|
||||
|
||||
+1621
-206
File diff suppressed because it is too large
Load Diff
@@ -13,9 +13,9 @@ namespace MtApi
|
||||
return Color.FromArgb((byte)(color), (byte)(color >> 8), (byte)(color >> 16));
|
||||
}
|
||||
|
||||
public static int ConvertToMtColor(Color color)
|
||||
public static int ConvertToMtColor(Color? color)
|
||||
{
|
||||
return color == Color.Empty ? 0xffffff : (Color.FromArgb(color.B, color.G, color.R).ToArgb() & 0xffffff);
|
||||
return color == null || color == Color.Empty ? 0xffffff : (Color.FromArgb(color.Value.B, color.Value.G, color.Value.R).ToArgb() & 0xffffff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ namespace MtApi
|
||||
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
||||
}
|
||||
|
||||
public static int ConvertToMtTime(DateTime time)
|
||||
public static int ConvertToMtTime(DateTime? time)
|
||||
{
|
||||
int result = 0;
|
||||
if (time != DateTime.MinValue)
|
||||
if (time != null && time != DateTime.MinValue)
|
||||
{
|
||||
DateTime tmpTime = new DateTime(1970, 1, 1);
|
||||
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace MtApi
|
||||
{
|
||||
internal class MtChartEvent
|
||||
{
|
||||
public long ChartId { get; set; }
|
||||
public int EventId { get; set; }
|
||||
public long Lparam { get; set; }
|
||||
public double Dparam { get; set; }
|
||||
public string Sparam { get; set; }
|
||||
}
|
||||
}
|
||||
Executable → Regular
+95
-18
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi
|
||||
namespace MtApi
|
||||
{
|
||||
enum MtCommandType
|
||||
{
|
||||
@@ -58,9 +53,15 @@ namespace MtApi
|
||||
IsVisualMode = 37,
|
||||
UninitializeReason = 38,
|
||||
ErrorDescription = 39,
|
||||
TerminalCompany = 68,
|
||||
TerminalName = 69,
|
||||
TerminalPath = 70,
|
||||
TerminalInfoString = 153,
|
||||
TerminalInfoInteger = 204,
|
||||
TerminalInfoDouble = 205,
|
||||
|
||||
//Account Information
|
||||
AccountBalance = 40,
|
||||
AccountBalance = 40,
|
||||
AccountCredit = 41,
|
||||
AccountCompany = 42,
|
||||
AccountCurrency = 43,
|
||||
@@ -91,11 +92,6 @@ namespace MtApi
|
||||
SendMail = 66,
|
||||
Sleep = 67,
|
||||
|
||||
//Client Terminal
|
||||
TerminalCompany = 68,
|
||||
TerminalName = 69,
|
||||
TerminalPath = 70,
|
||||
|
||||
//Date and Time
|
||||
Day = 71,
|
||||
DayOfWeek = 72,
|
||||
@@ -115,6 +111,7 @@ namespace MtApi
|
||||
TimeSeconds = 86,
|
||||
TimeYear = 87,
|
||||
Year = 88,
|
||||
TimeGMT = 281,
|
||||
|
||||
//Global Variables
|
||||
GlobalVariableCheck = 89,
|
||||
@@ -139,8 +136,8 @@ namespace MtApi
|
||||
iBullsPower = 106,
|
||||
iCCI = 107,
|
||||
iCCIOnArray = 108,
|
||||
iCustom = 109,
|
||||
iCustom_d = 10109,
|
||||
//iCustom = 109,
|
||||
//iCustom_d = 10109,
|
||||
iDeMarker = 110,
|
||||
iEnvelopes = 111,
|
||||
iEnvelopesOnArray = 112,
|
||||
@@ -188,8 +185,6 @@ namespace MtApi
|
||||
//
|
||||
RefreshRates = 150,
|
||||
//
|
||||
TerminalInfoString = 153,
|
||||
SymbolInfoString = 154,
|
||||
|
||||
//Requests
|
||||
MtRequest = 155,
|
||||
@@ -197,10 +192,92 @@ namespace MtApi
|
||||
//Backtesting
|
||||
BacktestingReady = 156,
|
||||
|
||||
//Symbols
|
||||
//Market Info
|
||||
SymbolInfoString = 154,
|
||||
SymbolsTotal = 200,
|
||||
SymbolName = 201,
|
||||
SymbolSelect = 202,
|
||||
SymbolInfoInteger = 203
|
||||
SymbolInfoInteger = 203,
|
||||
|
||||
//Object Functions
|
||||
ObjectCreate = 208,
|
||||
ObjectName = 209,
|
||||
ObjectDelete = 210,
|
||||
ObjectsDeleteAll = 211,
|
||||
ObjectFind = 212,
|
||||
ObjectGetTimeByValue = 213,
|
||||
ObjectGetValueByTime = 214,
|
||||
ObjectMove = 215,
|
||||
ObjectsTotal = 216,
|
||||
ObjectGetDouble = 217,
|
||||
ObjectGetInteger = 218,
|
||||
ObjectGetString = 219,
|
||||
ObjectSetDouble = 220,
|
||||
ObjectSetInteger = 221,
|
||||
ObjectSetString = 222,
|
||||
TextSetFont = 223,
|
||||
TextOut = 224,
|
||||
TextGetSize = 225,
|
||||
ObjectDescription = 226,
|
||||
ObjectGet = 227,
|
||||
ObjectGetFiboDescription = 228,
|
||||
ObjectGetShiftByValue = 229,
|
||||
ObjectGetValueByShift = 230,
|
||||
ObjectSet = 231,
|
||||
ObjectSetFiboDescription = 232,
|
||||
ObjectSetText = 233,
|
||||
ObjectType = 234,
|
||||
|
||||
UnlockTicks = 235,
|
||||
|
||||
//Chart Operations
|
||||
ChartId = 206,
|
||||
ChartRedraw = 207,
|
||||
ChartApplyTemplate = 236,
|
||||
ChartSaveTemplate = 237,
|
||||
ChartWindowFind = 238,
|
||||
ChartTimePriceToXY = 239,
|
||||
ChartXYToTimePrice = 240,
|
||||
ChartOpen = 241,
|
||||
ChartFirst = 242,
|
||||
ChartNext = 243,
|
||||
ChartClose = 244,
|
||||
ChartSymbol = 245,
|
||||
ChartPeriod = 246,
|
||||
ChartSetDouble = 247,
|
||||
ChartSetInteger = 248,
|
||||
ChartSetString = 249,
|
||||
ChartGetDouble = 250,
|
||||
ChartGetInteger = 251,
|
||||
ChartGetString = 252,
|
||||
ChartNavigate = 253,
|
||||
ChartIndicatorDelete = 254,
|
||||
ChartIndicatorName = 255,
|
||||
ChartIndicatorsTotal = 256,
|
||||
ChartWindowOnDropped = 257,
|
||||
ChartPriceOnDropped = 258,
|
||||
ChartTimeOnDropped = 259,
|
||||
ChartXOnDropped = 260,
|
||||
ChartYOnDropped = 261,
|
||||
ChartSetSymbolPeriod = 262,
|
||||
ChartScreenShot = 263,
|
||||
WindowBarsPerChart = 264,
|
||||
WindowExpertName = 265,
|
||||
WindowFind = 266,
|
||||
WindowFirstVisibleBar = 267,
|
||||
WindowHandle = 268,
|
||||
WindowIsVisible = 269,
|
||||
WindowOnDropped = 270,
|
||||
WindowPriceMax = 271,
|
||||
WindowPriceMin = 272,
|
||||
WindowPriceOnDropped = 273,
|
||||
WindowRedraw = 274,
|
||||
WindowScreenShot = 275,
|
||||
WindowTimeOnDropped = 276,
|
||||
WindowsTotal = 277,
|
||||
WindowXOnDropped = 278,
|
||||
WindowYOnDropped = 279,
|
||||
|
||||
ChangeAccount = 280
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
public class MtConnectionEventArgs: EventArgs
|
||||
{
|
||||
public MtConnectionState Status { get; private set; }
|
||||
public String ConnectionMessage { get; private set; }
|
||||
public string ConnectionMessage { get; private set; }
|
||||
|
||||
public MtConnectionEventArgs(MtConnectionState status, string message)
|
||||
{
|
||||
|
||||
Regular → Executable
+85
-84
@@ -1,5 +1,6 @@
|
||||
namespace MtApi
|
||||
{
|
||||
// https://docs.mql4.com/constants/errorswarnings/errorcodes
|
||||
public enum MtErrorCode
|
||||
{
|
||||
MtApiCustomError = -1, // Error occurred in MtApi.
|
||||
@@ -10,91 +11,91 @@
|
||||
ServerBusy = 4, // Trade server is busy.
|
||||
OldVersion = 5, // Old version of the client terminal.
|
||||
NoConnection = 6, // No connection with trade server.
|
||||
NotEnoughRights = 7, // Not enough rights.
|
||||
TooFrequentRequests = 8, // Too frequent requests.
|
||||
MalfunctionalTrade = 9, // Malfunctional trade operation.
|
||||
NotEnoughRights = 7, // Not enough rights.
|
||||
TooFrequentRequests = 8, // Too frequent requests.
|
||||
MalfunctionalTrade = 9, // Malfunctional trade operation.
|
||||
AccountDisabled = 64, // Account disabled.
|
||||
InvalidAccount = 65, // Invalid account.
|
||||
TradeTimeout = 128, // Trade timeout.
|
||||
InvalidPrice = 129, // Invalid price.
|
||||
InvalidStops = 130, // Invalid stops.
|
||||
InvalidTradeVolume = 131, // Invalid trade volume.
|
||||
MarketClosed = 132, // Market is closed.
|
||||
TradeDisabled = 133, // Trade is disabled.
|
||||
NotEnoughMoney = 134, // Not enough money.
|
||||
PriceChanged = 135, // Price changed.
|
||||
OffQuotes = 136, // Off quotes.
|
||||
BrokerBusy = 137, // Broker is busy.
|
||||
Requote = 138, // Requote.
|
||||
OrderLocked = 139, // Order is locked.
|
||||
LongPositionsOnlyAllowed = 140, // Long positions only allowed.
|
||||
TooManyRequests = 141, // Too many requests.
|
||||
TradeModifyDenied = 145, // Modification denied because an order is too close to market.
|
||||
TradeContextBusy = 146, // Trade context is busy.
|
||||
TradeExpirationDenied = 147, // Expirations are denied by broker.
|
||||
TradeTooManyOrders = 148, // The amount of opened and pending orders has reached the limit set by a broker.
|
||||
InvalidAccount = 65, // Invalid account.
|
||||
TradeTimeout = 128, // Trade timeout.
|
||||
InvalidPrice = 129, // Invalid price.
|
||||
InvalidStops = 130, // Invalid stops.
|
||||
InvalidTradeVolume = 131, // Invalid trade volume.
|
||||
MarketClosed = 132, // Market is closed.
|
||||
TradeDisabled = 133, // Trade is disabled.
|
||||
NotEnoughMoney = 134, // Not enough money.
|
||||
PriceChanged = 135, // Price changed.
|
||||
OffQuotes = 136, // Off quotes.
|
||||
BrokerBusy = 137, // Broker is busy.
|
||||
Requote = 138, // Requote.
|
||||
OrderLocked = 139, // Order is locked.
|
||||
LongPositionsOnlyAllowed = 140, // Long positions only allowed.
|
||||
TooManyRequests = 141, // Too many requests.
|
||||
TradeModifyDenied = 145, // Modification denied because an order is too close to market.
|
||||
TradeContextBusy = 146, // Trade context is busy.
|
||||
TradeExpirationDenied = 147, // Expirations are denied by broker.
|
||||
TradeTooManyOrders = 148, // The amount of opened and pending orders has reached the limit set by a broker.
|
||||
|
||||
NoMqlerror = 4000, // No error.
|
||||
WrongFunctionPointer = 4001, // Wrong function pointer.
|
||||
ArrayIndexOutOfRange = 4002, // Array index is out of range.
|
||||
NoMemoryForFunctionCallStack = 4003, // No memory for function call stack.
|
||||
RecursiveStackOverflow = 4004, // Recursive stack overflow.
|
||||
NotEnoughStackForParameter = 4005, // Not enough stack for parameter.
|
||||
NoMemoryForParameterString = 4006, // No memory for parameter string.
|
||||
NoMemoryForTempString = 4007, // No memory for temp string.
|
||||
NotInitializedString = 4008, // Not initialized string.
|
||||
NotInitializedArraystring = 4009, // Not initialized string in an array.
|
||||
NoMemoryForArraystring = 4010, // No memory for an array string.
|
||||
TooLongString = 4011, // Too long string.
|
||||
RemainderFromZeroDivide = 4012, // Remainder from zero divide.
|
||||
ZeroDivide = 4013, // Zero divide.
|
||||
UnknownCommand = 4014, // Unknown command.
|
||||
WrongJump = 4015, // Wrong jump.
|
||||
NotInitializedArray = 4016, // Not initialized array.
|
||||
DllCallsNotAllowed = 4017, // DLL calls are not allowed.
|
||||
CannotLoadLibrary = 4018, // Cannot load library.
|
||||
CannotCallFunction = 4019, // Cannot call function.
|
||||
ExternalExpertCallsNotAllowed = 4020, // EA function calls are not allowed.
|
||||
NotEnoughMemoryForReturnedString = 4021, // Not enough memory for a string returned from a function.
|
||||
SystemBusy = 4022, // System is busy.
|
||||
InvalidFunctionParametersCount = 4050, // Invalid function parameters count.
|
||||
InvalidFunctionParameterValue = 4051, // Invalid function parameter value.
|
||||
StringFunctionInternalError = 4052, // String function internal error.
|
||||
SomeArrayError = 4053, // Some array error.
|
||||
IncorrectSeriesArrayUsing = 4054, // Incorrect series array using.
|
||||
CustomIndicatorError = 4055, // Custom indicator error.
|
||||
IncompatibleArrays = 4056, // Arrays are incompatible.
|
||||
GlobalVariablesProcessingError = 4057, // Global variables processing error.
|
||||
GlobalVariableNotFound = 4058, // Global variable not found.
|
||||
FunctionNotAllowedInTestingMode = 4059, // Function is not allowed in testing mode.
|
||||
FunctionNotConfirmed = 4060, // Function is not confirmed.
|
||||
SendMailError = 4061, // Mail sending error.
|
||||
StringParameterExpected = 4062, // String parameter expected.
|
||||
IntegerParameterExpected = 4063, // Integer parameter expected.
|
||||
DoubleParameterExpected = 4064, // Double parameter expected.
|
||||
ArrayAsParameterExpected = 4065, // Array as parameter expected.
|
||||
HistoryWillUpdated = 4066, // Requested history data in updating state.
|
||||
TradeError = 4067, // Some error in trade operation execution.
|
||||
EndOfFile = 4099, // End of a file.
|
||||
SomeFileError = 4100, // Some file error.
|
||||
WrongFileName = 4101, // Wrong file name.
|
||||
TooManyOpenedFiles = 4102, // Too many opened files.
|
||||
CannotOpenFile = 4103, // Cannot open file.
|
||||
IncompatibleAccessToFile = 4104, // Incompatible access to a file.
|
||||
NoOrderSelected = 4105, // No order selected.
|
||||
UnknownSymbol = 4106, // Unknown symbol.
|
||||
InvalidPriceParam = 4107, // Invalid price.
|
||||
InvalidTicket = 4108, // Invalid ticket.
|
||||
TradeNotAllowed = 4109, // Trade is not allowed.
|
||||
LongsNotAllowed = 4110, // Longs are not allowed.
|
||||
ShortsNotAllowed = 4111, // Shorts are not allowed.
|
||||
ObjectAlreadyExists = 4200, // Object already exists.
|
||||
UnknownObjectProperty = 4201, // Unknown object property.
|
||||
ObjectDoesNotExist = 4202, // Object does not exist.
|
||||
UnknownObjectType = 4203, // Unknown object type.
|
||||
NoObjectName = 4204, // No object name.
|
||||
ObjectCoordinatesError = 4205, // Object coordinates error.
|
||||
NoSpecifiedSubwindow = 4206, // No specified subwindow.
|
||||
SomeObjectError = 4207 // Some error in object operation.
|
||||
NoMqlerror = 4000, // No error.
|
||||
WrongFunctionPointer = 4001, // Wrong function pointer.
|
||||
ArrayIndexOutOfRange = 4002, // Array index is out of range.
|
||||
NoMemoryForFunctionCallStack = 4003, // No memory for function call stack.
|
||||
RecursiveStackOverflow = 4004, // Recursive stack overflow.
|
||||
NotEnoughStackForParameter = 4005, // Not enough stack for parameter.
|
||||
NoMemoryForParameterString = 4006, // No memory for parameter string.
|
||||
NoMemoryForTempString = 4007, // No memory for temp string.
|
||||
NotInitializedString = 4008, // Not initialized string.
|
||||
NotInitializedArraystring = 4009, // Not initialized string in an array.
|
||||
NoMemoryForArraystring = 4010, // No memory for an array string.
|
||||
TooLongString = 4011, // Too long string.
|
||||
RemainderFromZeroDivide = 4012, // Remainder from zero divide.
|
||||
ZeroDivide = 4013, // Zero divide.
|
||||
UnknownCommand = 4014, // Unknown command.
|
||||
WrongJump = 4015, // Wrong jump.
|
||||
NotInitializedArray = 4016, // Not initialized array.
|
||||
DllCallsNotAllowed = 4017, // DLL calls are not allowed.
|
||||
CannotLoadLibrary = 4018, // Cannot load library.
|
||||
CannotCallFunction = 4019, // Cannot call function.
|
||||
ExternalExpertCallsNotAllowed = 4020, // EA function calls are not allowed.
|
||||
NotEnoughMemoryForReturnedString = 4021, // Not enough memory for a string returned from a function.
|
||||
SystemBusy = 4022, // System is busy.
|
||||
InvalidFunctionParametersCount = 4050, // Invalid function parameters count.
|
||||
InvalidFunctionParameterValue = 4051, // Invalid function parameter value.
|
||||
StringFunctionInternalError = 4052, // String function internal error.
|
||||
SomeArrayError = 4053, // Some array error.
|
||||
IncorrectSeriesArrayUsing = 4054, // Incorrect series array using.
|
||||
CustomIndicatorError = 4055, // Custom indicator error.
|
||||
IncompatibleArrays = 4056, // Arrays are incompatible.
|
||||
GlobalVariablesProcessingError = 4057, // Global variables processing error.
|
||||
GlobalVariableNotFound = 4058, // Global variable not found.
|
||||
FunctionNotAllowedInTestingMode = 4059, // Function is not allowed in testing mode.
|
||||
FunctionNotConfirmed = 4060, // Function is not confirmed.
|
||||
SendMailError = 4061, // Mail sending error.
|
||||
StringParameterExpected = 4062, // String parameter expected.
|
||||
IntegerParameterExpected = 4063, // Integer parameter expected.
|
||||
DoubleParameterExpected = 4064, // Double parameter expected.
|
||||
ArrayAsParameterExpected = 4065, // Array as parameter expected.
|
||||
HistoryWillUpdated = 4066, // Requested history data in updating state.
|
||||
TradeError = 4067, // Some error in trade operation execution.
|
||||
EndOfFile = 4099, // End of a file.
|
||||
SomeFileError = 4100, // Some file error.
|
||||
WrongFileName = 4101, // Wrong file name.
|
||||
TooManyOpenedFiles = 4102, // Too many opened files.
|
||||
CannotOpenFile = 4103, // Cannot open file.
|
||||
IncompatibleAccessToFile = 4104, // Incompatible access to a file.
|
||||
NoOrderSelected = 4105, // No order selected.
|
||||
UnknownSymbol = 4106, // Unknown symbol.
|
||||
InvalidPriceParam = 4107, // Invalid price.
|
||||
InvalidTicket = 4108, // Invalid ticket.
|
||||
TradeNotAllowed = 4109, // Trade is not allowed.
|
||||
LongsNotAllowed = 4110, // Longs are not allowed.
|
||||
ShortsNotAllowed = 4111, // Shorts are not allowed.
|
||||
ObjectAlreadyExists = 4200, // Object already exists.
|
||||
UnknownObjectProperty = 4201, // Unknown object property.
|
||||
ObjectDoesNotExist = 4202, // Object does not exist.
|
||||
UnknownObjectType = 4203, // Unknown object type.
|
||||
NoObjectName = 4204, // No object name.
|
||||
ObjectCoordinatesError = 4205, // Object coordinates error.
|
||||
NoSpecifiedSubwindow = 4206, // No specified subwindow.
|
||||
SomeObjectError = 4207 // Some error in object operation.
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
{
|
||||
public enum MtEventTypes
|
||||
{
|
||||
LastTimeBar = 1
|
||||
LastTimeBar = 1,
|
||||
ChartEvent = 2
|
||||
}
|
||||
}
|
||||
|
||||
+10
-6
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi
|
||||
namespace MtApi
|
||||
{
|
||||
public class MtQuote
|
||||
{
|
||||
public string Instrument { get; private set; }
|
||||
public double Bid { get; private set; }
|
||||
public double Ask { get; private set; }
|
||||
public int ExpertHandle { get; private set; }
|
||||
|
||||
public MtQuote(string instrument, double bid, double ask)
|
||||
{
|
||||
@@ -17,5 +13,13 @@ namespace MtApi
|
||||
Bid = bid;
|
||||
Ask = ask;
|
||||
}
|
||||
|
||||
internal MtQuote(MTApiService.MtQuote quote)
|
||||
{
|
||||
Instrument = quote.Instrument;
|
||||
Bid = quote.Bid;
|
||||
Ask = quote.Ask;
|
||||
ExpertHandle = quote.ExpertHandle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
|
||||
+23
-29
@@ -1,29 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
public class MtSession
|
||||
{
|
||||
public string Symbol { get; set; }
|
||||
public DayOfWeek DayOfWeek { get; set; }
|
||||
public uint Index { get; set; }
|
||||
public int MtFromTime { get; set; }
|
||||
public DateTime From
|
||||
{
|
||||
get { return MtApiTimeConverter.ConvertFromMtTime(MtFromTime); }
|
||||
}
|
||||
public int MtToTime { get; set; }
|
||||
public DateTime To
|
||||
{
|
||||
get { return MtApiTimeConverter.ConvertFromMtTime(MtToTime); }
|
||||
}
|
||||
public bool HasData { get; set; }
|
||||
public SessionType Type { get; set; }
|
||||
}
|
||||
|
||||
public enum SessionType { Quote, Trade }
|
||||
}
|
||||
using System;
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
public class MtSession
|
||||
{
|
||||
public string Symbol { get; set; }
|
||||
public DayOfWeek DayOfWeek { get; set; }
|
||||
public uint Index { get; set; }
|
||||
public int MtFromTime { get; set; }
|
||||
public DateTime From => MtApiTimeConverter.ConvertFromMtTime(MtFromTime);
|
||||
public int MtToTime { get; set; }
|
||||
public DateTime To => MtApiTimeConverter.ConvertFromMtTime(MtToTime);
|
||||
public bool HasData { get; set; }
|
||||
public SessionType Type { get; set; }
|
||||
}
|
||||
|
||||
public enum SessionType
|
||||
{
|
||||
Quote,
|
||||
Trade
|
||||
}
|
||||
}
|
||||
|
||||
+2
-11
@@ -11,16 +11,7 @@ namespace MtApi
|
||||
public double Close { get; set; }
|
||||
public double High { get; set; }
|
||||
public double Low { get; set; }
|
||||
|
||||
public DateTime OpenTime
|
||||
{
|
||||
get { return MtApiTimeConverter.ConvertFromMtTime(MtOpenTime); }
|
||||
}
|
||||
|
||||
public DateTime CloseTime
|
||||
{
|
||||
get { return MtApiTimeConverter.ConvertFromMtTime(MtCloseTime); }
|
||||
}
|
||||
|
||||
public DateTime OpenTime => MtApiTimeConverter.ConvertFromMtTime(MtOpenTime);
|
||||
public DateTime CloseTime => MtApiTimeConverter.ConvertFromMtTime(MtCloseTime);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
namespace MtApi
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace MtApi
|
||||
{
|
||||
public enum ENUM_TERMINAL_INFO_STRING
|
||||
{
|
||||
|
||||
Executable → Regular
+2
-2
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.31.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.31.0")]
|
||||
[assembly: AssemblyVersion("1.0.40.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.40.0")]
|
||||
@@ -1,12 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MtApi.Requests
|
||||
namespace MtApi.Requests
|
||||
{
|
||||
public abstract class CopyRatesRequestBase : RequestBase
|
||||
internal abstract class CopyRatesRequestBase : RequestBase
|
||||
{
|
||||
public enum CopyRatesTypeEnum
|
||||
{
|
||||
@@ -15,10 +9,7 @@ namespace MtApi.Requests
|
||||
CopyRates_3 = 3,
|
||||
}
|
||||
|
||||
public override RequestType RequestType
|
||||
{
|
||||
get { return RequestType.CopyRates; }
|
||||
}
|
||||
public override RequestType RequestType => RequestType.CopyRates;
|
||||
|
||||
public abstract CopyRatesTypeEnum CopyRatesType { get; }
|
||||
|
||||
@@ -26,34 +17,25 @@ namespace MtApi.Requests
|
||||
public ENUM_TIMEFRAMES Timeframe { get; set; }
|
||||
}
|
||||
|
||||
public class CopyRates1Request : CopyRatesRequestBase
|
||||
internal class CopyRates1Request : CopyRatesRequestBase
|
||||
{
|
||||
public override CopyRatesTypeEnum CopyRatesType
|
||||
{
|
||||
get { return CopyRatesTypeEnum.CopyRates_1; }
|
||||
}
|
||||
public override CopyRatesTypeEnum CopyRatesType => CopyRatesTypeEnum.CopyRates_1;
|
||||
|
||||
public int StartPos { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
public class CopyRates2Request : CopyRatesRequestBase
|
||||
internal class CopyRates2Request : CopyRatesRequestBase
|
||||
{
|
||||
public override CopyRatesTypeEnum CopyRatesType
|
||||
{
|
||||
get { return CopyRatesTypeEnum.CopyRates_2; }
|
||||
}
|
||||
public override CopyRatesTypeEnum CopyRatesType => CopyRatesTypeEnum.CopyRates_2;
|
||||
|
||||
public int StartTime { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
public class CopyRates3Request : CopyRatesRequestBase
|
||||
internal class CopyRates3Request : CopyRatesRequestBase
|
||||
{
|
||||
public override CopyRatesTypeEnum CopyRatesType
|
||||
{
|
||||
get { return CopyRatesTypeEnum.CopyRates_3; }
|
||||
}
|
||||
public override CopyRatesTypeEnum CopyRatesType => CopyRatesTypeEnum.CopyRates_3;
|
||||
|
||||
public int StartTime { get; set; }
|
||||
public int StopTime { get; set; }
|
||||
|
||||
Regular → Executable
+2
-5
@@ -1,14 +1,11 @@
|
||||
namespace MtApi.Requests
|
||||
{
|
||||
public class GetOrderRequest: RequestBase
|
||||
internal class GetOrderRequest: RequestBase
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public int Select { get; set; }
|
||||
public int Pool { get; set; }
|
||||
|
||||
public override RequestType RequestType
|
||||
{
|
||||
get { return RequestType.GetOrder; }
|
||||
}
|
||||
public override RequestType RequestType => RequestType.GetOrder;
|
||||
}
|
||||
}
|
||||
Regular → Executable
+2
-5
@@ -1,12 +1,9 @@
|
||||
namespace MtApi.Requests
|
||||
{
|
||||
public class GetOrdersRequest: RequestBase
|
||||
internal class GetOrdersRequest: RequestBase
|
||||
{
|
||||
public int Pool { get; set; }
|
||||
|
||||
public override RequestType RequestType
|
||||
{
|
||||
get { return RequestType.GetOrders; }
|
||||
}
|
||||
public override RequestType RequestType => RequestType.GetOrders;
|
||||
}
|
||||
}
|
||||
Regular → Executable
+3
-8
@@ -1,10 +1,8 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
|
||||
namespace MtApi.Requests
|
||||
{
|
||||
public class ICustomRequest : RequestBase
|
||||
internal class ICustomRequest : RequestBase
|
||||
{
|
||||
public enum ParametersType
|
||||
{
|
||||
@@ -22,9 +20,6 @@ namespace MtApi.Requests
|
||||
public ArrayList Params { get; set; }
|
||||
public ParametersType ParamsType { get; set; }
|
||||
|
||||
public override RequestType RequestType
|
||||
{
|
||||
get { return RequestType.iCustom; }
|
||||
}
|
||||
public override RequestType RequestType => RequestType.iCustom;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user