Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                ClientDatabaseManager.ConnectionStatusChanged += ClientDataManager_ConnectionStatusChanged;

                if (Settings.Default.L.X < 0 || Settings.Default.L.Y < 0) Settings.Default.L = new Point(0, 0);
                if (Settings.Default.S.Width < 0 || Settings.Default.S.Height < 0)
                    Settings.Default.S = new Size(800, 500);

                Size = Settings.Default.S;
                Location = Settings.Default.L;
                _emeilAfterFinishing= Settings.Default.IsSendReports;
                UpdateControlsSizeAndLocation();

                _logger = Logger.GetInstance(listViewLogger);
                _logger.LogAdd("Application Start", Category.Information);
                _missingBarManager = new MissingBarManager(_logger);

                _missingBarManager.MissingBarStart += DataCollector_MissingBarStart;
                _missingBarManager.MissingBarEnd += DataCollector_MissingBarEnd;

                _missingBarManager.Finished += DataCollector_Finished;
                _missingBarManager.Progress += _missingBarManager_Progress;

                ui_home_textBoxX_db.Text = Settings.Default.MainDB;
                ui_home_textBoxX_db_bar.Text = Settings.Default.dbBar;
                ui_home_textBoxX_db_historical.Text = Settings.Default.dbHistorical;
                ui_home_textBoxX_uid.Text = Settings.Default.User;
                ui_home_textBoxX_pwd.Text = Settings.Default.Password;
                ui_home_textBoxX_host.Text = Settings.Default.Host;
                //nudEndBar.Value = Settings.Default.valFinish;
                checkBoxX1.Checked = Settings.Default.SavePass;
                //**
                metroShell1.SelectedTab = metroTabItem1;

                ResetColorMarks();
                // todo
                _cel = new CQGCEL();
                _cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                _cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                _cel.APIConfiguration.CollectionsThrowException = false;
                _cel.APIConfiguration.LogSeverity = eLogSeverity.lsDebug;
                _cel.APIConfiguration.MessageProcessingTimeout = 30000;

                _cel.DataConnectionStatusChanged += CEL_DataConnectionStatusChanged;
                CEL_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);
                _cel.DataError += CEL_DataError;
                _cel.IncorrectSymbol += CEL_IncorrectSymbol;
                _cel.HistoricalSessionsResolved += CEL_HistoricalSessionsResolved;
                _cel.InstrumentSubscribed += CEL_InstrumentSubscribed;

                FormAddSymbolsGroups.RefreshSYmbolsGroups += RefreshGridSymbolsGroups;
                FormAutocollect.RefreshGroups += RefreshGridGroups;

                //todo

                _pingTimer = new Timer();
                _pingTimer.Tick += TimerTick;
                _pingTimer.Interval = 1000;
                _pingTimer.Enabled = true;
                _onlineServerSymbol = _startControl.uiServerOnlineFakeSymbol.Symbol;
                _offlineServerSymbol = _startControl.uiOfflineFakeSymbol.Symbol;

                //todo
                //groupList4.ItemStateChanged +=groupList4_ItemStateChanged;

                //todo subscribe

                FormSettings.EmeilAfterFinishing += EmailChange;
                FormSettings.IsAutocollect += AutocollectChange;
                FormSettings.BarEnd += barEndChange;

                CQGDataCollectorManager.ItemStateChanged += CQGDataCollectorManager_ItemStateChanged;
                CQGDataCollectorManager.CollectedSymbolCountChanged +=
                    CQGDataCollectorManager_CollectedSymbolCountChanged;
                CQGDataCollectorManager.RunnedStateChanged += CQGDataCollectorManager_RunnedStateChanged;
                CQGDataCollectorManager.StartTimeChanged += CQGDataCollectorManager_StartTimeChanged;
                CQGDataCollectorManager.CQGStatusChanged += CQGDataCollectorManager_CQGStatusChanged;

                CQGDataCollectorManager.UnsuccessfulSymbol += CQGDataCollectorManager_UnsuccessfulSymbol;
                CQGDataCollectorManager.TickInsertingStarted += CQGDataCollectorManager_TickInsertingStarted;
                CQGDataCollectorManager.ProgressBarChanged += CQGDataCollectorManager_ProgressBarChanched;

                CQGDataCollectorManager.SendReport += CQGDataCollectorManager_SendReport;
                //todo
                Thread.Sleep(1000); // Fixed bug with closeing while starting//do not remove this
                _cel.Startup();

                //Restarting after crashing
                if (Settings.Default.IsCrashed)
                {
                    LoginToServer(Settings.Default.scUser1, Settings.Default.scPassword, Settings.Default.scHostSlave,
                        _nowIsMaster);

                }
                dataSet.Relations.Add("1", dataSet.Tables["my_tbl"].Columns["ID"],
                                        dataSet.Tables["tbl_sym"].Columns["ID"], false);
                //superGridControl1.DefaultVisualStyles.RowStyles.SelectedMouseOver.Background.Color1 = Color.Red;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _logger.LogAdd("Error in loading. " + ex.Message, Category.Error);
                Close();
            }
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                slidePanelSymbols.IsOpen = false;
                ClientDatabaseManager.ConnectionStatusChanged += ClientDataManager_ConnectionStatusChanged;

                if (Settings.Default.L.X < 0 || Settings.Default.L.Y < 0) Settings.Default.L = new Point(0, 0);
                if (Settings.Default.S.Width < 0 || Settings.Default.S.Height < 0)
                    Settings.Default.S = new Size(800, 500);

                Size = Settings.Default.S;
                Location = Settings.Default.L;
                checkBox_emailMe.Checked = Settings.Default.IsSendReports;
                UpdateControlsSizeAndLocation();

                _logger = Logger.GetInstance(listViewLogger);
                _logger.LogAdd("Application Start", Category.Information);
                _missingBarManager = new MissingBarManager(_logger);

                _missingBarManager.MissingBarStart += DataCollector_MissingBarStart;
                _missingBarManager.MissingBarEnd += DataCollector_MissingBarEnd;

                _missingBarManager.Finished += DataCollector_Finished;
                _missingBarManager.Progress += _missingBarManager_Progress;

                ui_home_textBoxX_db.Text = Settings.Default.MainDB;
                ui_home_textBoxX_db_bar.Text = Settings.Default.dbBar;
                ui_home_textBoxX_db_historical.Text = Settings.Default.dbHistorical;
                ui_home_textBoxX_uid.Text = Settings.Default.User;
                ui_home_textBoxX_pwd.Text = Settings.Default.Password;
                ui_home_textBoxX_host.Text = Settings.Default.Host;
                nudEndBar.Value = Settings.Default.valFinish;
                ui_checkBoxAuto_CheckForMissedBars.Value = Settings.Default.AutoMissingBarReport;
                checkBoxX1.Checked = Settings.Default.SavePass;
                //**
                metroShell1.SelectedTab = metroTabItem1;

                cmbContinuationType.Items.Clear();
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctNoContinuation);
                cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctStandard);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctStandardByMonth);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctActive);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctActiveByMonth);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctAdjusted);
                //cmbContinuationType.Items.Add(eTimeSeriesContinuationType.tsctAdjustedByMonth);
                cmbContinuationType.SelectedIndex = 1;
                cmbHistoricalPeriod.SelectedIndex = 0;

                ResetColorMarks();
                // todo
                _cel = new CQGCEL();
                _cel.APIConfiguration.TimeZoneCode = eTimeZone.tzGMT;
                _cel.APIConfiguration.ReadyStatusCheck = eReadyStatusCheck.rscOff;
                _cel.APIConfiguration.CollectionsThrowException = false;
                _cel.APIConfiguration.LogSeverity = eLogSeverity.lsDebug;
                _cel.APIConfiguration.MessageProcessingTimeout = 30000;

                _cel.DataConnectionStatusChanged += CEL_DataConnectionStatusChanged;
                CEL_DataConnectionStatusChanged(eConnectionStatus.csConnectionDown);
                _cel.DataError += CEL_DataError;
                _cel.IncorrectSymbol += CEL_IncorrectSymbol;
                _cel.HistoricalSessionsResolved += CEL_HistoricalSessionsResolved;
                _cel.InstrumentSubscribed += CEL_InstrumentSubscribed;

                //todo

                //currStatus = DEFAULT_STATUS;
                dateTimeInputStart.Value = DateTime.Now.AddDays(-1);
                dateTimeInputEnd.Value = DateTime.Now;

                _pingTimer = new Timer();
                _pingTimer.Tick += TimerTick;
                _pingTimer.Interval = 1000;
                _pingTimer.Enabled = true;
                _onlineServerSymbol = _startControl.uiServerOnlineFakeSymbol.Symbol;
                _offlineServerSymbol = _startControl.uiOfflineFakeSymbol.Symbol;

                //todo
                groupList4.ItemStateChanged +=groupList4_ItemStateChanged;
                CQGDataCollectorManager.ItemStateChanged += CQGDataCollectorManager_ItemStateChanged;
                CQGDataCollectorManager.CollectedSymbolCountChanged +=
                    CQGDataCollectorManager_CollectedSymbolCountChanged;
                CQGDataCollectorManager.RunnedStateChanged += CQGDataCollectorManager_RunnedStateChanged;
                CQGDataCollectorManager.StartTimeChanged += CQGDataCollectorManager_StartTimeChanged;
                CQGDataCollectorManager.CQGStatusChanged += CQGDataCollectorManager_CQGStatusChanged;

                CQGDataCollectorManager.UnsuccessfulSymbol += CQGDataCollectorManager_UnsuccessfulSymbol;
                CQGDataCollectorManager.TickInsertingStarted += CQGDataCollectorManager_TickInsertingStarted;
                CQGDataCollectorManager.ProgressBarChanged += CQGDataCollectorManager_ProgressBarChanched;

                CQGDataCollectorManager.SendReport += CQGDataCollectorManager_SendReport;
                //todo
                Thread.Sleep(1000); // Fixed bug with closeing while starting//do not remove this
                _cel.Startup();

                //Restarting after crashing
                if (Settings.Default.IsCrashed)
                {
                    LoginToServer(Settings.Default.scUser1, Settings.Default.scPassword, Settings.Default.scHostSlave,
                        _nowIsMaster);

                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _logger.LogAdd("Error in loading. " + ex.Message, Category.Error);
                Close();
            }
        }