private void LoadRoadmapStatusDetails(RoadmapStatus status) { var mitigations = _model.Mitigations? .Where(x => x.GetStatus() == status) .OrderBy(x => x.Name) .ToArray(); if (mitigations?.Any() ?? false) { var container = new GridRow(status.GetEnumLabel()); _roadmapDetails.PrimaryGrid.Rows.Add(container); var panel = new GridPanel { Name = status.GetEnumLabel(), AllowRowDelete = false, AllowRowInsert = false, AllowRowResize = true, ShowRowDirtyMarker = false, ShowTreeButtons = false, ShowTreeLines = false, ShowRowHeaders = false, InitialActiveRow = RelativeRow.None, InitialSelection = RelativeSelection.None }; panel.Columns.Add(new GridColumn("Name") { HeaderText = "Mitigation Name", AutoSizeMode = ColumnAutoSizeMode.Fill, DataType = typeof(string), AllowEdit = false }); panel.Columns.Add(new GridColumn("ControlType") { HeaderText = "Control Type", DataType = typeof(string), AllowEdit = false, Width = 75 }); container.Rows.Add(panel); foreach (var mitigation in mitigations) { panel.Rows.Add(new GridRow(mitigation.Name, mitigation.ControlType.GetEnumLabel()) { Tag = mitigation }); } } }
private void Append(IEnumerable <IMitigation> mitigations, RoadmapStatus phase, List <Cell> destination) { if (mitigations?.Any() ?? false) { var selected = GetMitigations(mitigations, phase); if (selected?.Any() ?? false) { var cells = GetCells(selected, phase)?.ToArray(); if (cells?.Any() ?? false) { destination.AddRange(cells); } } } }
private void ShowRoadmapStatus(RoadmapStatus status) { bool ok = false; var mitigations = _model.Mitigations?.ToArray(); if (mitigations?.Any() ?? false) { var selectedMitigations = new List <Guid>(); switch (status) { case RoadmapStatus.ShortTerm: UpdateSelectedMitigations(selectedMitigations, mitigations, RoadmapStatus.ShortTerm); break; case RoadmapStatus.MidTerm: UpdateSelectedMitigations(selectedMitigations, mitigations, RoadmapStatus.ShortTerm); UpdateSelectedMitigations(selectedMitigations, mitigations, RoadmapStatus.MidTerm); break; case RoadmapStatus.LongTerm: UpdateSelectedMitigations(selectedMitigations, mitigations, RoadmapStatus.ShortTerm); UpdateSelectedMitigations(selectedMitigations, mitigations, RoadmapStatus.MidTerm); UpdateSelectedMitigations(selectedMitigations, mitigations, RoadmapStatus.LongTerm); break; } var schemaManager = new ResidualRiskEstimatorPropertySchemaManager(_model); var projected = schemaManager.SelectedEstimator?.GetProjectedThreatTypesResidualRisk(_model, selectedMitigations); if (projected?.Any() ?? false) { _chart.RefreshChart(_model, projected); _currentStatus = status; _chartName.Text = status.GetEnumLabel(); ok = true; } } _previous.Visible = ok; _next.Visible = ok; _chartName.Visible = ok; }
private RoadmapStatus GetStatusFromProperties(IMitigation mitigation) { RoadmapStatus result = RoadmapStatus.NotAssessed; var propertyType = GetPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType); if (property != null && Enum.TryParse <RoadmapStatus>(property.StringValue, out var status)) { result = status; } } return(result); }
public static void SetStatus(this IMitigation mitigation, RoadmapStatus status) { var model = mitigation?.Model; if (model != null) { var schemaManager = new RoadmapPropertySchemaManager(model); var propertyType = schemaManager.GetPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType); if (property == null) { mitigation.AddProperty(propertyType, status.ToString()); } else { property.StringValue = status.ToString(); } } } }
private static RoadmapStatus GetStatusFromProperties(IMitigation mitigation) { RoadmapStatus result = RoadmapStatus.NotAssessed; var model = mitigation?.Model; if (model != null) { var schemaManager = new RoadmapPropertySchemaManager(model); var propertyType = schemaManager.GetPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType); if (property != null && Enum.TryParse <RoadmapStatus>(property.StringValue, out var status)) { result = status; } } } return(result); }
private static void UpdateSelectedMitigations(List <Guid> selectedMitigations, [NotNull] IEnumerable <IMitigation> mitigations, RoadmapStatus status) { var toBeAdded = mitigations .Where(x => x.GetStatus() == status) .Select(x => x.Id) .ToArray(); if (toBeAdded.Any()) { selectedMitigations.AddRange(toBeAdded); } }
private void ExportCsv([Required] string fileName, RoadmapStatus requiredStatus = RoadmapStatus.NotAssessed) { var mitigations = _model?.GetUniqueMitigations()?.OrderBy(x => x.Name).ToArray(); if (mitigations?.Any() ?? false) { using (var engine = new ExcelReportEngine()) { var page = engine.AddPage("Report"); List <string> fields = new List <string> { "Work Item Type", "Title", "Description", "State", "Priority" }; engine.AddHeader(page, fields.ToArray()); var schema = new RoadmapPropertySchemaManager(_model); foreach (var mitigation in mitigations) { var status = mitigation.GetStatus(); switch (requiredStatus) { case RoadmapStatus.ShortTerm: if (status == RoadmapStatus.ShortTerm) { engine.AddRow(page, new[] { "Task", mitigation.Name, TextToHtml(mitigation.Description), "To Do", ((int)status).ToString() }); } break; case RoadmapStatus.MidTerm: if (status == RoadmapStatus.MidTerm) { engine.AddRow(page, new[] { "Task", mitigation.Name, TextToHtml(mitigation.Description), "To Do", ((int)status).ToString() }); } break; case RoadmapStatus.LongTerm: if (status == RoadmapStatus.LongTerm) { engine.AddRow(page, new[] { "Task", mitigation.Name, TextToHtml(mitigation.Description), "To Do", ((int)status).ToString() }); } break; default: if (status == RoadmapStatus.ShortTerm || status == RoadmapStatus.MidTerm || status == RoadmapStatus.LongTerm) { engine.AddRow(page, new[] { "Task", mitigation.Name, TextToHtml(mitigation.Description), "To Do", ((int)status).ToString() }); } break; } } try { engine.Save(fileName); ShowMessage?.Invoke("CSV for ADO created successfully."); } catch (Exception exc) { ShowWarning?.Invoke(exc.Message); } } } }
private IEnumerable <Cell> GetCells([NotNull] IEnumerable <IMitigation> mitigations, RoadmapStatus status) { IEnumerable <Cell> result = null; if (mitigations.Any()) { var list = new List <Cell>(); list.Add(new Cell(status.GetEnumLabel(), null, null, true)); list.Add(new Cell(string.Empty)); foreach (var mitigation in mitigations) { list.Add(new Cell(mitigation.Name, null, null, new [] { mitigation.Id })); list.Add(new Cell(GetLines(mitigation))); } result = list; } return(result); }
private IEnumerable <IMitigation> GetMitigations([NotNull] IEnumerable <IMitigation> mitigations, RoadmapStatus status) { return(mitigations .Where(x => x.GetStatus() == status) .OrderBy(x => x.Name)); }