/// <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; }
public bool Equals(ErrorData other) { if (Object.ReferenceEquals(other, null)) { return(false); } if (Object.ReferenceEquals(this, other)) { return(true); } //Check whether the ErrorData's properties are equal. return(Description.Equals(other.Description) && ErrorLevel.Equals(other.ErrorLevel)); }
public static IEnumerable <ValidationError> GetErrors(this IResult validationResult, ErrorLevel errorLevel) { EnsureArg.IsNotNull(validationResult, nameof(validationResult)); return(validationResult.Exceptions.Where(error => errorLevel.Equals(error.Level))); }