static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: AccountInfo.exe address login password"); return; } try { if (!Directory.Exists(LogPath)) { Directory.CreateDirectory(LogPath); } string address = args[0]; string login = args[1]; string password = args[2]; // Create data trade interface var trade = new DataTrade { SynchOperationTimeout = 30000 }; // Create connection string FixConnectionStringBuilder builder = CreateBuilder(address, login, password); var connectionString = builder.ToString(); // Initialize data trade interface trade.Initialize(connectionString); // Subscribe to data trade events trade.Logon += OnLogon; trade.Logout += OnLogout; trade.AccountInfo += OnAccountInfo; // Start data trade trade.Start(); Console.WriteLine("DataTrade started!"); Console.WriteLine("Please wait for login status..."); // Wait for exit Console.ReadKey(); // Stop data trade trade.Stop(); } catch (Exception ex) { Console.WriteLine(ex); } }
public void Connect(string address, string username, string password, string logPath) { EnsureDirectoriesCreated(logPath); // Create builder SetupBuilder(address, username, password, logPath); var connectionString = Builder.ToString(); Trade = new DataTrade(); Trade.Initialize(connectionString); var isConnected = Trade.Start(30000); if (!isConnected) { Trade.Stop(); throw new TimeoutException(); } }