private static void LogOwnError(Exception ex) { try { var issueTracker = new Client.IssueTracker(); issueTracker.Post(new Issue { Text = ex.Message, ServerVariables = null, Source = "IssueTracker.Pop3Fetcher", StackTrace = ex.ToString(), Version = typeof(Program).Assembly.GetName().Version.ToString() }); } catch (Exception innerException) { Console.WriteLine("Unable to log own error: " + innerException); } }
private static void Main() { try { Console.WriteLine("Posting issue ..."); var issueTracker = new Client.IssueTracker(); issueTracker.Configuration.IssueTrackerUrl = "http://localhost:59416"; var issue = new Client.Issue { ServerVariables = "Server Variables" + Environment.NewLine + "Server Variables", Source = "Source", StackTrace = "Stack Trace" + Environment.NewLine + "Stack Trace", Text = "Text" + Environment.NewLine + "Text", Version = typeof (Program).Assembly.GetName().Version.ToString() }; issueTracker.Post(issue); Console.WriteLine("Issue posted with ID " + issue.Id); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.ReadLine(); }
private static bool PushToIssueTracker(Message message) { Console.WriteLine("\t\tPushing message '{0}' to IssueTracker ...", message.Headers.Subject); try { var messageBody = message.FindFirstHtmlVersion().GetBodyAsText(); var creator = GetMatch(messageBody, "Creator: (.*?)<br"); var text = GetMatch(messageBody, "Text:<pre>(.*?)</pre>"); var stackTrace = GetMatch(messageBody, "Stack Trace:<pre>(.*?)</pre>"); var serverVariables = GetMatch(messageBody, "Server Variables:<pre>(.*?)</pre>"); if (text.StartsWith("IssueTracker unreachable - ")) text = text.Substring("IssueTracker unreachable - ".Length); creator = HttpUtility.HtmlDecode(creator); text = HttpUtility.HtmlDecode(text); stackTrace = HttpUtility.HtmlDecode(stackTrace); serverVariables = HttpUtility.HtmlDecode(serverVariables); if (creator.IsNoE() && text.IsNoE() && stackTrace.IsNoE() && serverVariables.IsNoE()) return false; if (message.Headers.Sender != null && message.Headers.Sender.Address.HasValue()) creator += " (" + message.Headers.Sender.Address + ")"; else if (message.Headers.ReplyTo != null && message.Headers.ReplyTo.Address.HasValue()) creator += " (" + message.Headers.ReplyTo.Address + ")"; try { var issueTracker = new Client.IssueTracker(); issueTracker.Post(new Issue { Text = text, ServerVariables = serverVariables, Source = creator, StackTrace = stackTrace, Version = "" }); Console.WriteLine("\t\tMessage pushed."); } catch (Exception ex) { Console.WriteLine("\t\tUnable to push message: " + ex); LogOwnError(new ApplicationException("Unable to push message: " + ex.Message, ex)); } return true; } catch { Console.WriteLine("\t\tMessage seems not to be an issue report."); return false; } }