本文整理汇总了C#中ErrorLevel.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorLevel.Equals方法的具体用法?C# ErrorLevel.Equals怎么用?C# ErrorLevel.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorLevel
的用法示例。
在下文中一共展示了ErrorLevel.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
/// <summary>
/// Отпавляет сообщение с ошибкой в YouTrack
/// </summary>
/// <param name="error"> Ошибка </param>
/// <param name="severity"> Уровень ошибки </param>
/// <param name="title"> Заголовок ошибки </param>
/// <param name="advancedParameters"> Дополнительные параметры </param>
/// <returns> Уникальный ключ сообщения </returns>
public string Send(Exception error, ErrorLevel severity, object advancedParameters, string title = "") {
var myapi = ResolveService<IYouTrackGeneralIssueApi>(null, ConnectionName);
var message = Regex.Replace(error.ToString(), @"(([\s\S]{60}[\s\S]*?(?<!line)\s)|(\sin\s))",
"$0" + Environment.NewLine,
RegexOptions.Compiled);
if(message.Length > 2300 ) {
message = message.Substring(0, 2300);
}
var desc = "{code}" + message+ "{code}";
var result = myapi.Create(ProjectName, title + ": " + error.Message, desc, "");
var priority = "Normal";
if (severity.Equals(ErrorLevel.Error)) {
priority = "Major";
}
else if (severity.Equals(ErrorLevel.Fatal)) {
priority = "Critical";
}
myapi.ApplyCommand(result.Id, "Priority " + priority, disableNotifications: true);
var comment = "";
foreach (var p in advancedParameters.ToDict()) {
var val = p.Value.ToStr();
if (val.IsNotEmpty()) {
bool trycomand = true;
if(p.Key=="fullurl") {
if(val.Length<=50)continue;
trycomand = false;
}
try {
if(trycomand) {
myapi.ApplyCommand(result.Id, p.Key + " " + p.Value, "", "All Users");
}else {
comment += p.Key + ": " + p.Value + "\n\n";
}
}
catch (YouTrackApiException) {
comment += p.Key + ": " + p.Value + "\n\n";
}
}
}
myapi.ApplyComment(result.Id, comment);
return result.Url;
}