本文整理汇总了C#中EventContext.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# EventContext.SetProperty方法的具体用法?C# EventContext.SetProperty怎么用?C# EventContext.SetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventContext
的用法示例。
在下文中一共展示了EventContext.SetProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override void Process(EventContext ctx) {
if (String.IsNullOrEmpty(ctx.Event.StackId)) {
if (_stackRepository == null)
throw new InvalidOperationException("You must pass a non-null stackRepository parameter to the constructor.");
// only add default signature info if no other signature info has been added
if (ctx.StackSignatureData.Count == 0) {
ctx.StackSignatureData.Add("Type", ctx.Event.Type);
if (!String.IsNullOrEmpty(ctx.Event.Source))
ctx.StackSignatureData.Add("Source", ctx.Event.Source);
}
string signatureHash = ctx.StackSignatureData.Values.Any(v => v != null) ? ctx.StackSignatureData.Values.ToSHA1() : null;
ctx.SetProperty("__SignatureHash", signatureHash);
ctx.Event.SummaryHtml = _pluginManager.GetEventSummaryHtml(ctx.Event);
ctx.StackInfo = _stackRepository.GetStackInfoBySignatureHash(ctx.Event.ProjectId, signatureHash);
if (ctx.StackInfo == null) {
Log.Trace().Message("Creating new error stack.").Write();
ctx.IsNew = true;
var stack = new Stack {
OrganizationId = ctx.Event.OrganizationId,
ProjectId = ctx.Event.ProjectId,
SignatureInfo = new SettingsDictionary(ctx.StackSignatureData),
SignatureHash = signatureHash,
Title = _pluginManager.GetStackTitle(ctx.Event),
SummaryHtml = _pluginManager.GetStackSummaryHtml(ctx.Event),
Tags = ctx.Event.Tags ?? new TagSet(),
TotalOccurrences = 1,
FirstOccurrence = ctx.Event.Date.UtcDateTime,
LastOccurrence = ctx.Event.Date.UtcDateTime
};
ctx.Stack = _stackRepository.Add(stack, true);
ctx.StackInfo = new StackInfo {
Id = stack.Id,
DateFixed = stack.DateFixed,
OccurrencesAreCritical = stack.OccurrencesAreCritical
};
// new 404 stack id added, invalidate 404 id cache
if (ctx.Event.IsNotFound())
_stackRepository.InvalidateNotFoundIdsCache(ctx.Event.ProjectId);
}
Log.Trace().Message("Updating error's ErrorStackId to: {0}", ctx.StackInfo.Id).Write();
ctx.Event.StackId = ctx.StackInfo.Id;
} else {
ctx.Stack = _stackRepository.GetById(ctx.Event.StackId);
// TODO: Update unit tests to work with this check.
//if (stack == null || stack.ProjectId != error.ProjectId)
// throw new InvalidOperationException("Invalid ErrorStackId.");
if (ctx.Stack == null)
return;
if (ctx.Event.Tags != null && ctx.Event.Tags.Count > 0) {
if (ctx.Stack.Tags == null)
ctx.Stack.Tags = new TagSet();
List<string> newTags = ctx.Event.Tags.Where(t => !ctx.Stack.Tags.Contains(t)).ToList();
if (newTags.Count > 0) {
ctx.Stack.Tags.AddRange(newTags);
_stackRepository.Save(ctx.Stack);
}
}
ctx.StackInfo = new StackInfo {
Id = ctx.Stack.Id,
DateFixed = ctx.Stack.DateFixed,
OccurrencesAreCritical = ctx.Stack.OccurrencesAreCritical,
IsHidden = ctx.Stack.IsHidden
};
}
// sync the fixed and hidden flags to the error occurrence
ctx.Event.IsFixed = ctx.StackInfo.DateFixed.HasValue;
ctx.Event.IsHidden = ctx.StackInfo.IsHidden;
}