Skip to content

Commit

Permalink
Starting to show a few history
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Sep 6, 2022
1 parent 404f5f5 commit 57f9d2c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
8 changes: 6 additions & 2 deletions CustomActionTester/CAT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 38 additions & 4 deletions CustomActionTester/CATcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,18 @@ private void ExecuteCA()

private void SaveHistory(CATRequest catreq)
{
if (!SettingsManager.Instance.TryLoad(typeof(CustomActionTester), out List<CATRequest> catreqshistory, catTool.Target + " History"))
if (catreq.Execution == null)
{
catreqshistory = new List<CATRequest>();
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<string>("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");
}

Expand Down Expand Up @@ -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<CATRequest> GetHistory()
{
if (!SettingsManager.Instance.TryLoad(typeof(CustomActionTester), out List<CATRequest> catreqshistory, catTool.Target + " History"))
{
catreqshistory = new List<CATRequest>();
}
catreqshistory = catreqshistory.OrderBy(req => req.Execution?.RunTime).Reverse().ToList();

return catreqshistory;
}

#endregion Private Methods
}
}

0 comments on commit 57f9d2c

Please sign in to comment.