Automated Error Reporting to Bugtracker

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, Alex.Davies, melvyn.harbour

Automated Error Reporting to Bugtracker

Postby kimpenhaus » Sun Feb 13, 2011 4:57 pm

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 :-)

Greetings,
Marcus
kimpenhaus
 
Posts: 11
Joined: Sun Feb 13, 2011 4:50 pm
Location: Germany

Postby Brian Donahue » Mon Feb 14, 2011 6:18 pm

Hello,

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.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby kimpenhaus » Mon Feb 14, 2011 7:17 pm

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.

Greetings,
Marcus
kimpenhaus
 
Posts: 11
Joined: Sun Feb 13, 2011 4:50 pm
Location: Germany

Postby Alex.Davies » Tue Feb 15, 2011 3:01 pm

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.

Cheers,
Alex
Developer,
Red Gate .NET Tools
Alex.Davies
 
Posts: 335
Joined: Tue Dec 02, 2008 12:23 pm
Location: Cambridge, uk

Postby Brian Donahue » Tue Feb 15, 2011 3:42 pm

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.
Code: Select all
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);
            Console.WriteLine(exceptionReport.InnerXml);
            saDatabase.Close();
            saDatabase.Dispose();
        }
    }
    /// <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;
            try
            {
                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\");
                reader.Close();
            }
            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 ID=@1\", 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();
                    exceptionReport.LoadXml(System.Text.Encoding.UTF8.GetString(SDK.Helpers.Unzip(data)));
                }

            }

            return exceptionReport;
        }
    }
}
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby kimpenhaus » Tue Feb 15, 2011 3:55 pm

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,
Marcus.
kimpenhaus
 
Posts: 11
Joined: Sun Feb 13, 2011 4:50 pm
Location: Germany


Return to SmartAssembly 5

Who is online

Users browsing this forum: No registered users and 1 guest