Red Gate forums :: View topic - Automated Error Reporting to Bugtracker
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 5
SmartAssembly 5 forum

Automated Error Reporting to Bugtracker

Search in SmartAssembly 5 forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
kimpenhaus



Joined: 13 Feb 2011
Posts: 11
Location: Germany

PostPosted: Sun Feb 13, 2011 4:57 pm    Post subject: Automated Error Reporting to Bugtracker Reply with quote

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 Smile

Greetings,
Marcus
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6643

PostPosted: Mon Feb 14, 2011 6:18 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kimpenhaus



Joined: 13 Feb 2011
Posts: 11
Location: Germany

PostPosted: Mon Feb 14, 2011 7:17 pm    Post subject: Reply with quote

Hey Brian,

thanks for your feedback - will checkout the wiki Smile

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
Back to top
View user's profile Send private message
Alex.Davies



Joined: 02 Dec 2008
Posts: 335
Location: Cambridge, uk

PostPosted: Tue Feb 15, 2011 3:01 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6643

PostPosted: Tue Feb 15, 2011 3:42 pm    Post subject: Reply with quote

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:
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;
        }
    }
}
Back to top
View user's profile Send private message
kimpenhaus



Joined: 13 Feb 2011
Posts: 11
Location: Germany

PostPosted: Tue Feb 15, 2011 3:55 pm    Post subject: Reply with quote

Hey Alex, hey Brian,

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

I will let you know!

Kind regards,
Marcus.
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group