Skip to content

Commit

Permalink
Filter by RequestID
Browse files Browse the repository at this point in the history
  • Loading branch information
fowl2 committed Feb 16, 2022
1 parent 5691d2e commit 7c71ad4
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 4 deletions.
33 changes: 30 additions & 3 deletions PluginTraceViewer/Controls/FilterControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions PluginTraceViewer/Controls/FilterControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ private void chkCorrelation_CheckedChanged(object sender, EventArgs e)
textCorrelationId.Enabled = chkCorrelation.Checked;
}

private void chkRequestId_CheckedChanged(object sender, EventArgs e)
{
textRequestId.Enabled = chkRequestId.Checked;
}

private void chkDurationMin_CheckedChanged(object sender, EventArgs e)
{
numDurationMin.Enabled = chkDuration.Checked;
Expand Down Expand Up @@ -141,6 +146,39 @@ private List<Guid> GetCurrentCorrelationIdFilter(bool silent)
return results;
}

internal void AddRequestIdFilter(Guid newReqId)
{
if (!newReqId.Equals(Guid.Empty))
{
var reqIds = GetCurrentRequestIdFilter(true);
if (!reqIds.Contains(newReqId))
{
reqIds.Add(newReqId);
}
chkRequestId.Checked = true;
textRequestId.Text = string.Join(", ", reqIds);
ptv.LogUse("AddRequestIdFilter");
}
}

private List<Guid> GetCurrentRequestIdFilter(bool silent)
{
var results = new List<Guid>();
foreach (var idstr in textRequestId.Text.Split(',').Select(i => i.Trim()))
{
var id = Guid.Empty;
if (Guid.TryParse(idstr, out id) && !results.Contains(id))
{
results.Add(id);
}
else if (!silent)
{
MessageBox.Show($"\"{idstr}\" is not a valid guid.", "Request Id", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
return results;
}

internal void ApplyFilter(PTVFilter filter)
{
checkDateFrom.Checked = !filter.DateFrom.Equals(DateTime.MinValue);
Expand All @@ -161,6 +199,8 @@ internal void ApplyFilter(PTVFilter filter)
comboEntity.Text = filter.Entity;
chkCorrelation.Checked = !string.IsNullOrEmpty(filter.CorrelationId);
textCorrelationId.Text = filter.CorrelationId;
chkRequestId.Checked = !string.IsNullOrEmpty(filter.RequestId);
textRequestId.Text = filter.RequestId;
chkExceptions.Checked = filter.Exceptions;
chkOperPlugins.Checked = filter.OperationPlugin;
chkOperWF.Checked = filter.OperationWF;
Expand Down Expand Up @@ -192,6 +232,7 @@ internal PTVFilter GetFilter()
Message = chkMessage.Checked ? comboMessage.Text : string.Empty,
Entity = chkEntity.Checked ? comboEntity.Text : string.Empty,
CorrelationId = chkCorrelation.Checked ? textCorrelationId.Text : string.Empty,
RequestId = chkRequestId.Checked ? textRequestId.Text : string.Empty,
Exceptions = chkExceptions.Checked,
OperationPlugin = chkOperPlugins.Checked,
OperationWF = chkOperWF.Checked,
Expand Down Expand Up @@ -294,6 +335,11 @@ internal void GetQueryFilter(QueryExpression QEplugintracelog, bool refreshOnly)
var ids = GetCurrentCorrelationIdFilter(false);
QEplugintracelog.Criteria.AddCondition("correlationid", ConditionOperator.In, ids.Select(i => i.ToString()).ToArray());
}
if (chkRequestId.Checked)
{
var ids = GetCurrentRequestIdFilter(false);
QEplugintracelog.Criteria.AddCondition(Const.PluginTraceLog.RequestId, ConditionOperator.In, ids.Select(i => i.ToString()).ToArray());
}
if (chkExceptions.Checked)
{
QEplugintracelog.Criteria.AddCondition("exceptiondetails", ConditionOperator.NotNull);
Expand Down
12 changes: 11 additions & 1 deletion PluginTraceViewer/Controls/GridControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions PluginTraceViewer/Controls/GridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ private void tsmiFilterByCorrelation_Click(object sender, EventArgs e)
ptv.filterControl.AddCorrelationFilter(GetSelectedCorrelationId());
}

private void tsmiFilterByRequestId_Click(object sender, EventArgs e)
{
ptv.filterControl.AddRequestIdFilter(GetSelectedRequestId());
}

private void tsmiCorrelationSelectThis_Click(object sender, EventArgs e)
{
SelectCurrentCorrelation();
Expand Down Expand Up @@ -492,6 +497,18 @@ private Guid GetSelectedCorrelationId()
return Guid.Empty;
}

private Guid GetSelectedRequestId()
{
var result = Guid.Empty;
var entities = crmGridView.SelectedCellRecords;
var ids = entities?.Select(e => (Guid)e[PluginTraceLog.RequestId]).Distinct();
if (ids?.Count() == 1)
{
return ids.FirstOrDefault();
}
return Guid.Empty;
}

private Task Delete(Entity entity)
{
return new Task(() =>
Expand Down
1 change: 1 addition & 0 deletions PluginTraceViewer/PTVFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class PTVFilter
public string Message { get; set; }
public string Entity { get; set; }
public string CorrelationId { get; set; }
public string RequestId { get; set; }
public bool Exceptions { get; set; }
public bool OperationPlugin { get; set; } = true;
public bool OperationWF { get; set; } = true;
Expand Down
3 changes: 3 additions & 0 deletions PluginTraceViewer/PluginTraceViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ private PTVFilter ParseFilterArgs(string strarg)
case "correlationid":
result.CorrelationId = value;
break;
case PluginTraceLog.RequestId:
result.RequestId = value;
break;
case "exceptionsonly":
if (bool.TryParse(value, out bool exceptions))
{
Expand Down

0 comments on commit 7c71ad4

Please sign in to comment.