From 57f9d2cf1c0003dca968ee7af565d2733a103c7d Mon Sep 17 00:00:00 2001 From: Jonas Rapp Date: Tue, 6 Sep 2022 11:51:58 +0200 Subject: [PATCH] Starting to show a few history --- CustomActionTester/CAT.cs | 8 +++++-- CustomActionTester/CATcode.cs | 42 +++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/CustomActionTester/CAT.cs b/CustomActionTester/CAT.cs index 1d04f57..57eafa6 100644 --- a/CustomActionTester/CAT.cs +++ b/CustomActionTester/CAT.cs @@ -111,9 +111,13 @@ private void llCallHistory_LinkClicked(object sender, LinkLabelLinkClickedEventA private void picHistory_Click(object sender, EventArgs e) { - splitRight.Panel2Collapsed = sender == picHistoryClose; + splitRight.Panel2Collapsed = !splitRight.Panel2Collapsed; picHistoryOpen.Visible = splitRight.Panel2Collapsed; - picHistoryClose.Left = picHistoryClose.Parent.Width - 19; + picHistoryClose.Visible = !splitRight.Panel2Collapsed; + if (!splitRight.Panel2Collapsed) + { + LoadHistory(); + } } private void rbFormatResult_CheckedChanged(object sender, EventArgs e) diff --git a/CustomActionTester/CATcode.cs b/CustomActionTester/CATcode.cs index 08af3a5..fe75746 100644 --- a/CustomActionTester/CATcode.cs +++ b/CustomActionTester/CATcode.cs @@ -205,12 +205,18 @@ private void ExecuteCA() private void SaveHistory(CATRequest catreq) { - if (!SettingsManager.Instance.TryLoad(typeof(CustomActionTester), out List catreqshistory, catTool.Target + " History")) + if (catreq.Execution == null) { - catreqshistory = new List(); + catreq.Execution = new ExecutionInfo(); } - catreqshistory.Add(catreq); - catreqshistory = catreqshistory.OrderBy(req => req.Execution?.RunTime).Reverse().ToList(); + catreq.Execution.Environment = ConnectionDetail.ConnectionName; + if (cmbSolution.SelectedRecord?.TryGetAttributeValue("uniquename", out string solution) == true) + { + catreq.Execution.Solution = solution; + } + + var catreqshistory = GetHistory(); + catreqshistory.Insert(0, catreq); SettingsManager.Instance.Save(typeof(CustomActionTester), catreqshistory, catTool.Target + " History"); } @@ -933,6 +939,34 @@ private bool HandleInput(Entity input) return true; } + private void LoadHistory() + { + listHistory.Items.Clear(); + var history = GetHistory(); + listHistory.Items.AddRange(history + .Select(h => new ListViewItem( + new string[] { + h.Execution?.RunTime.ToString(), + h.Name, + h.Execution?.Duration.ToString(), + h.Execution?.Environment, + h.Execution?.Solution, + } + )).ToArray()); + listHistory.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); + } + + private List GetHistory() + { + if (!SettingsManager.Instance.TryLoad(typeof(CustomActionTester), out List catreqshistory, catTool.Target + " History")) + { + catreqshistory = new List(); + } + catreqshistory = catreqshistory.OrderBy(req => req.Execution?.RunTime).Reverse().ToList(); + + return catreqshistory; + } + #endregion Private Methods } } \ No newline at end of file