Automated Error Reporting to Bugtracker

kimpenhauskimpenhaus Posts: 14 Bronze 1
edited February 15, 2011 9:55AM in SmartAssembly 5
Hi there,

are there any further samples or Docs regarding AER SDK?

What I am trying is to integrate AER into an ASP.NET MVC app. On that point where an exception is thrown it should be reported to a custom WCF service which does sort of consolidation (lookup if same ticket is already existent and if so - maybe it is already fixed in a later version). If a new ticket has to be created the service will do so. (containing stacktrace and logs as attachments on the ticket).

Is this a scenario which can be performed with SmartAssembly SDK?

Any help would be appreciated :-)



  • Brian DonahueBrian Donahue Posts: 6,590 New member

    I'm afraid I don't have any specific examples for SmartAssembly SDK that would be useful to you, but what you want to do is entirely possible. You can build a webservice that downloads error reports and examines the database to work out what information is needed to autolog a bug.

    There is an SA SDK wiki that has some more information that may be helpful. This is pretty much in its' infancy and is a stopgap until the documentation can be improved, but there is a class reference doc and a few examples there.
  • Hey Brian,

    thanks for your feedback - will checkout the wiki :)

    I' m not sure what you mean with "that downloads error reports" - I thought that the AER sends active to an web-service.

    My first thought was to use SaveReport instead of SendReport and send it to a custom non-sa webservice - which will query the bugtracker and in case of inserting a new ticket it stores the report in a shared folder from which sa could receive it (probably to deobfuscate the stack-trace e.g.)

    Or am I able to customize the custom sa webservice more that just self-host it? That's what I understood in download the complete custom web-service from sa-site.

    Thanks for your patience.

  • We have a scheduled task here that syncs error reports into our bug tracker, which is a JIRA 4. I'll email you the source so you can use it as a starting point.

    Red Gate .NET Tools
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    There aren't any options for customizing the SA webservice but you can host it if you want.

    To get reports so that you can do something useful with them, you use the Database class. There is a detailed example of this in the SDK samples, but I have stripped the basic functionality down so you can see how to connect to the database and get a report as an XmlDocument.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using SmartAssembly.SDK;
    using System.Data.Common;
    using System.Xml;
    namespace SmartAssembly.SASDKDownloadReport
        public class Program
            static void Main(string[] args)
                SmartAssemblyDatabase saDatabase = new SmartAssemblyDatabase();
                // Get the latest one report identifier
                string latestExceptionId = saDatabase.GetLatestExceptionId();
                // Get the exception data for the report id. You can query this using XPath if needed.
                XmlDocument exceptionReport=saDatabase.GetExceptionReport(latestExceptionId);
        /// <summary>
        /// Due to the protection level of the Database class, all Database functions need to 
        /// be wrapped up in a class that derived from Database. When the class is constructed,
        /// it automatically connects to the SA database, so do not forget to invoke
        /// Close() and Dispose()!
        /// </summary>
        public class SmartAssemblyDatabase : SmartAssembly.SDK.Database
            public SmartAssemblyDatabase()
            /// <summary>
            /// For the purposes of this demo, we will just retrieve the latest 1 exception ID from the database.
            /// </summary>
            /// <returns>a GUID, in string form, or NULL</returns>
            public string GetLatestExceptionId(){
                string latestExceptionId = null;
                    DbDataReader reader = this.ExecuteReader("SELECT ID FROM ExceptionReports ORDER BY CreationDate DESC", new object[] { "ID" });
                    if (reader.Read())
                    latestExceptionId = ((Guid)reader.GetValue(0)).ToString("B");
                catch { }
                return latestExceptionId;
            /// <summary>
            /// If the exception ID is known, get the Exception data, unzip it, and convert it to XML
            /// </summary>
            /// <param name="ReportId">The report ID</param>
            /// <returns>an XmlDocument with the exception information, or NULL</returns>
            public XmlDocument GetExceptionReport(string ReportId)
                XmlDocument exceptionReport = null;
                using (
                   DbDataReader reader = this.ExecuteReader("SELECT Data FROM ExceptionReports WHERE [email protected]", ReportId))
                    if (reader.Read())
                        int length = (int)reader.GetBytes(0, 0, null, 0, 0);
                        byte[] data = new byte[length];
                        reader.GetBytes(0, 0, data, 0, length);
                        exceptionReport = new XmlDocument();
                return exceptionReport;
  • Hey Alex, hey Brian,

    thanks for the code - especially Alex for the existing code as JIRA adapter. Guess that will help me much out :)

    I will let you know!

    Kind regards,
Sign In or Register to comment.