Example #1
0
        static void Main(string[] args)
        {
            loadSettings();
            loadEventHandlers();

            log.StartLogging(sAppDir + "log" + DateTime.Now.ToString("yyMMdd") + ".txt");

            TXmlConnector.statusTimeout = session_timeout * 1000;
            TXmlConnector.ConnectorSetCallback(OnNewFormData, OnNewSecurity, OnNewTimeframe, OnNewStatus);
            TXmlConnector.FormReady = true;
            if (TXmlConnector.ConnectorInitialize(sLogPath, 3))
            {
                TXmlConnector.statusDisconnected.Set();
            }

            OportunityMonitor.init();
            OportunityMonitor.PositionPublisherCallback(PositionPublisherCall);

            MyTcpServer tcpServer = new MyTcpServer();

            tcpServer.start();
        }
Example #2
0
        public MainWindowViewModel(IDialogCoordinator dialog, IHubProxy hub, HubConnection connection, Window window)
        {
            Connection               = connection;
            Connection.Reconnected  += ConnectionOnReconnected;
            Connection.StateChanged += ConnectionOnStateChanged;
            Hub                    = hub;
            Dialog                 = dialog;
            AdminViewModel         = new AdminViewModel(Hub, DialogCoordinator.Instance);
            _flashWindowHelper     = new FlashWindowHelper(Application.Current);
            _thisWindow            = window;
            MenuItemConnectCommand = new Command(arg => Show_LoginForm());
            SecurityChooseCommand  = new Command(SecurityChoose);
            SecuritiesCommand      = new Command(arg => GetSecurities());
            OpenWindowCommand      = new Command(OpenWindow);
            ChangePassCommand      = new Command(arg => ChangePass());
            SleepCommand           = new Command(arg => SelfSleep());
            SaveWorkspaceCommand   = new Command(arg => SaveWorkspace());
            LoadWorkspaceCommand   = new Command(arg => LoadWorkspace());
            Status                 = "Status: Disconnected";
            //get watchlists collection and initialize watcher to monitor changes in the watchlists' folder
            GetWatchlists();
            InitializeWatcher();
            SecVm.WatchListsCollection = WatchListsCollection;
            //Subscribing to events
            TXmlConnector.SendNewFormData += XmlConnector_OnSendNewFormData; //general data
            /*TXmlConnector.SendNewStatus += XmlConnector_OnSendNewStatus;*/ //status
            TXmlConnector.SendStatus      += XmlConnector_OnSendNewStatus;
            TXmlConnector.SendNewSecurity += XmlConnector_OnSendNewSecurity; //securities
            TXmlConnector.ConnectorSetCallback();
            TXmlConnector.FormReady = true;

            //Initializing the connector dll
            var path = (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Inside MMA\\logs\\" + ClientInfo.InsideLogin).Replace("\\", "//");

            Directory.CreateDirectory(path);
            foreach (var file in new DirectoryInfo(path).GetFiles())
            {
                file.Delete();
            }
            //loading settings
            WindowDataHandler.GetWindowData();
            Settings.Default.Reload();
            Level2Settings.Default.Reload();
            //path = path.Substring(0, path.LastIndexOf('\\') + 1) + "\0";
            if (TXmlConnector.ConnectorInitialize(path, (short)Settings.Default.LogLevel))
            {
                TXmlConnector.StatusDisconnected.Set();
            }

            //setting the number decimal separator to a point
            var customCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();

            customCulture.NumberFormat.NumberDecimalSeparator = ".";
            CultureInfo.DefaultThreadCurrentCulture           = customCulture;
            Thread.CurrentThread.CurrentCulture = customCulture;

            //subbing for singlar events
            Hub?.On("Sleep", Sleep);
            Hub?.On("Unsleep", Unsleep);
            Hub?.On("SelectWindows", WindowAvailabilityManager.SelectWindows);
            Hub?.On("Disconnect", DisconnectByServer);
            Hub?.On("DisplayMessage", DisplayMessage);
            Hub?.On("CancelOrders", ClientOrdersViewModel.CancelAllOrdersMethod);
            Hub?.On("CancelStoporders", ClientOrdersViewModel.CancelAllStopordersMethod);
            Hub?.On("CloseBalance", ClientsViewModel.CloseBalanceMethod);
            //requesting license exp date
            Hub?.On("License", GetLicense);
            Hub?.Invoke("GetLicense");
            //setting the stoporder manager
            new OrderManager(ClientOrdersViewModel.ClientStoporders, ClientOrdersViewModel.ClientOrders);
            //setting the report manager
            ReportManager.Set();
            ShowPatchnotes();
        }