/// <summary> /// Updates available backtests in the backtest data grid for a specific project /// </summary> /// <param name="projectId">Target project id</param> private async void UpdateAvailableBacktests(int projectId) { VsUtils.DisplayInStatusBar(ServiceProvider.GlobalProvider, "Loading project backtests..."); if (await _authenticationCommand.Login(ServiceProvider.GlobalProvider, false)) { try { var backtestsList = await System.Threading.Tasks.Task.Run(() => { var api = AuthorizationManager.GetInstance().GetApi(); var result = api.ListBacktests(projectId); return(result.Backtests); }); var selectedItem = projectNameBox.SelectedItem as ComboboxProjectItem; // Verify the backtest are from the selected project if (selectedItem?.Id == projectId) { lock (_dataGridCollection) { _dataGridCollection.Clear(); // Setting a limit of _maximumBacktestToShow backtests in the table... for (var i = 0; i < backtestsList.Count && i < _maximumBacktestToShow; i++) { _dataGridCollection.Add(new DataGridItem { Name = backtestsList[i].Name, Progress = backtestsList[i].Progress, ProjectId = projectId, Date = backtestsList[i].Created, BacktestId = backtestsList[i].BacktestId, Status = string.IsNullOrEmpty(backtestsList[i].Error) ? DataGridItem.BacktestSucceeded : DataGridItem.BacktestFailed, Note = backtestsList[i].Note }); } } VsUtils.DisplayInStatusBar(ServiceProvider.GlobalProvider, "Successfully loaded backtests"); } } catch (Exception exception) { VsUtils.ShowErrorMessageBox(ServiceProvider.GlobalProvider, "QuantConnect Exception", exception.ToString()); } } }
/// <summary> /// This function is the callback used to execute the command when the menu item Login is clicked. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void LoginCallback(object sender, EventArgs e) { _authenticationCommand.Login(_serviceProvider, true); }