private void LoadModel()
        {
            try
            {
                _loading = true;
                ClearPalettes();

                var schemaManager       = new RoadmapPropertySchemaManager(_model);
                var devOpsSchemaManager = new DevOpsPropertySchemaManager(_model);
                var connector           = DevOpsManager.GetConnector(_model);
                IEnumerable <IMitigation> mitigations;
                if (_filter == RoadmapStatus.NoActionRequired)
                {
                    mitigations = _model?.GetUniqueMitigations()?
                                  .Where(x => (schemaManager.GetStatus(x) != RoadmapStatus.NoActionRequired) ||
                                         (connector != null && devOpsSchemaManager.GetDevOpsInfo(x, connector) != null))
                                  .OrderBy(x => x.Name).ToArray();
                }
                else
                {
                    mitigations = _model?.GetUniqueMitigations()?
                                  .Where(x => schemaManager.GetStatus(x) == _filter)
                                  .OrderBy(x => x.Name).ToArray();
                }

                if (mitigations?.Any() ?? false)
                {
                    var summaries = DevOpsManager.GetMitigationsSummary(_model);

                    foreach (var mitigation in mitigations)
                    {
                        if (summaries?.ContainsKey(mitigation) ?? false)
                        {
                            var summary = summaries[mitigation];
                            AddItem(mitigation, summary.Status, summary.AssignedTo);
                        }
                        else
                        {
                            AddItem(mitigation, WorkItemStatus.Unknown, null);
                        }
                    }

                    RefreshNodes();
                }
            }
            finally
            {
                _loading = false;
            }
        }
Example #2
0
        public async void ExecuteCustomAction([NotNull] IActionDefinition action)
        {
            string text    = null;
            bool   warning = false;

            try
            {
                switch (action.Name)
                {
                case "Sync":
                    if ((await DevOpsManager.UpdateAsync(_model)) > 0)
                    {
                        LoadModel();
                    }
                    break;

                case "Auto":
                    var summaries     = DevOpsManager.GetMitigationsSummary(_model);
                    var schemaManager = new RoadmapPropertySchemaManager(_model);
                    var mitigations   = _model?.GetUniqueMitigations()?
                                        .Where(x => (schemaManager.GetStatus(x) != RoadmapStatus.NoActionRequired) &&
                                               !(summaries?.ContainsKey(x) ?? false))
                                        .OrderBy(x => x.Name).ToArray();
                    if (mitigations?.Any() ?? false)
                    {
                        var connector           = DevOpsManager.GetConnector(_model);
                        var devOpsSchemaManager = new DevOpsPropertySchemaManager(_model);
                        _countdown = new CountdownEvent(mitigations.Length);
                        foreach (var mitigation in mitigations)
                        {
                            AutoLoad(mitigation, connector, devOpsSchemaManager);
                        }

                        ShowMessage?.Invoke("Automatic Load in progress...");
                        AutomaticLoadCompletion();
                    }
                    else
                    {
                        ShowWarning?.Invoke("Automatic Load has not identified any action to do.");
                    }
                    break;

                case "ShortTerm":
                    _filter = RoadmapStatus.ShortTerm;
                    LoadModel();
                    break;

                case "MidTerm":
                    _filter = RoadmapStatus.MidTerm;
                    LoadModel();
                    break;

                case "LongTerm":
                    _filter = RoadmapStatus.LongTerm;
                    LoadModel();
                    break;

                case "All":
                    _filter = RoadmapStatus.NoActionRequired;
                    LoadModel();
                    break;

                case "Refresh":
                    LoadModel();
                    break;
                }

                //if (warning)
                //    ShowWarning?.Invoke(text);
                //else if (text != null)
                //    ShowMessage?.Invoke($"{text} has been executed successfully.");
            }
            catch
            {
                //ShowWarning?.Invoke($"An error occurred during the execution of the action.");
                throw;
            }
        }