Click here to Skip to main content
Click here to Skip to main content

Bug Submitter Dialog

, 28 Apr 2009 GPL3
Rate this:
Please Sign up or sign in to vote.
Dialog that enables user to submit various types of bugs via a webservice

Introduction

This dialog enables user to submit various types of bugs with build in validation. The submitted information is then sent to a webservice.

bugreporter_form.gif

Background

I have a few small applications that I developed to improve my coding knowledge. An easy way for users to submit feedback on my applications and report bugs would be very useful in all of them. I created this dialog for this purpose, while keeping in mind that it should be stable, user friendly, and very easy to implement in any of my applications.

Using the Code

The dialog itself can be integrated without much work into your application, but the webservice will require some attention.

Here you have a simple example of showing the dialog:

With New BugSubmitter
    .SubmitterFile = "BN+converter-pro.php"
    .SubmitterPath = "http://service.bn2vs.com/bugs"
    .ApplicationVersion = GetAppVersion("[M].[m].[b].[r]")

    .ShowDialog()
End With

GetAppVersion is a simple sub that returns the application version formatted as a string. You can also manually get the version data or use a static value.

''' <summary>Returns the version of the application</summary>
''' <param name="format">The format of the version.
''' [M]: Major
''' [m]: Minor
''' [b]: Build
''' [r]: Revision</param>
Public Function GetAppVersion(Optional ByVal format As String = _
						"v[M].[m].[b]") As String
    With My.Application.Info
        GetAppVersion = format.Replace("[M]", .Version.Major.ToString)
        GetAppVersion = GetAppVersion.Replace("[m]", .Version.Minor.ToString)
        GetAppVersion = GetAppVersion.Replace("[b]", .Version.Build.ToString)
        GetAppVersion = GetAppVersion.Replace("[r]", .Version.Revision.ToString)
    End With
End Function 

That's all the code you need to display the dialog! Now let's have a closer look at some of the properties.

Before the bug report is submitted, the information is validated. This can be either done with an error provider when the user hits the submit button, or with live validation that will only enable the submit button when all fields are valid.

''' <summary>Gets or sets if an error provider should be used 
''' to notify a user of errors.
''' When false, live validation will only enable the submit button when all fields 
''' are valid</summary>
Public Property UseErrorProvider() As Boolean
    Get
        Return m_useErrorProvider
    End Get
    Set(ByVal value As Boolean)
        m_useErrorProvider = value
    End Set
End Property

The dialog has some events related to the submission progress, but you don't need to bother about these in most cases. There are three steps in the submission progress:

  1. Creation of the bug report (see screenshot at the top of this article)
  2. Submission
  3. Success screen (see screenshot underneath) 

Every state will be clearly indicated to the user.

bugreporter_complete.gif

Now you can work with the dialog and understand how it works. Let's have a look at the webservice.  

The Webservice

In my applications, I have chosen to use a PHP webservice that generates an email with the submitted data and then sends it over to my inbox. The example here follows the same principle, but keep in mind you can handle the submitted data any way you want, like for example storing it in a database. Also note you can use ASP or any other server script to write the webservice in.

This is a little script I created to easily construct multiple email webservices for different applications: 

<?php

/**
 * BN+ bug report mailer
 * 
 * common.php
 * Version 1.0.0
 * 
 * By De Dauw Jeroen - jeroendedauw@gmail.com
 * April 2009
 */

// Deny access when one of the arguments is not provided
if (empty($_GET['type']) || empty($_GET['description']) || 
		empty($_GET['version'])) die("Hack attempt");

// Get the URL arguments
$type = $_GET['type'];
$description = str_replace("[amp]", "&", $_GET['description']);
$email = strlen($_GET['email']) > 0 ? $_GET['email'] : "None provided";
$version = $_GET['version'];

// Include the phpmailer class
require_once '../includes/phpMailer/class.phpmailer.php';

// Create a new instance of a phpmailer
$mail = new PHPMailer();  

// Set the sender data
$mail->From     = "bug-report@your-server.com";  
$mail->FromName = "Bug reporter @ your-server.com";    

// Create the mail with a simple layout
$body = "
<table border='1' width='100%'>

<tr bgcolor='gray'>
<td colspan='2'><u>Bug report for $app_name</u></td>
</tr>

<tr><td width='200'>Application version:</td><td>$version</td></tr>

<tr><td>Bug type:</td><td>$type</td></tr>

<tr><td>Bug description:</td><td>$description</td></tr>

<tr><td>User email:</td><td>$email</td></tr>

<tr bgcolor='gray'>
<td colspan='2'>Report send on ".date("F j, Y, g:i a")." (unix: ".time().")</td>
</tr>

</table>
";

// Set the mail subject, body and the address of the receiver(s)
$mail->Subject = "$mail_subject $type"; 
$mail->Body    = $body;  
$mail->AltBody = "Your client does not support html emails. Data cannot be accessed.";  
$mail->AddAddress("your-mail@your-server.com", "yourName"); 

// Send the email, and display either a success message and the mail contents, 
// or in case of failure the error details
// Displaying this is not required. You can also just send the mail with $mail->Send()
if ($mail->Send()) {
    echo "Mail send successfully.<br />\n\n\n\n\n\n\n\n";
    echo $body;
}
else {
    echo "Error sending mail. ".$mail->ErrorInfo;
}

?> 

A mail sent by this script will look similar to this one: 

bugReporter-email.gif

Now only a few lines of code are needed for each BugSubmitter:

<?php

/**
 * BugSubmitter demo bug report mailer
 * 
 * your-application-webservice.php
 * Version 1.0.0
 * 
 * By De Dauw Jeroen - jeroendedauw@gmail.com
 * April 2009
 */

$app_name = "BugSubmitter demo application";
$mail_subject = "BUG REPORT: BugSubmitter demo:";

require_once 'common.php';

?>

Note that in this example, I assume you are either using this webservice only once, or sending all mails to the same address. If this is not the case, you can easily add a new variable in your-application-webservice.php, before you include common.php, containing the address for that webservice, and then add it to the mailer address list in common.php

Points of Interest  

This was a nice exercise for me in creating a .NET dialog that loosely communicates with a webservice. I'm very happy with the result, and I'm now using this dialog in all of my .NET applications. I also got quite some positive feedback from people, and the request to better document this dialog, which prompted me to create this article.

History

  • April 28th 2009: Published article on The Code Project with webservice example
  • April 13th 2009: Published version 1.0.0 

References

  • Dutch support for this class can be found here.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Jeroen De Dauw
Software Developer
Belgium Belgium
I am a free and open source software enthusiast and freelance software developer with multiple years of experience in both web and desktop development. Currently my primarily focus is on MediaWiki and Semantic MediaWiki work. I'm in the all time top 10 MediaWiki comitters and am one of the WikiWorks consultants. You can contact me at jeroendedauw at gmail for development jobs and questions related to my work.
 
More info can be found on my website [0] and my blog [1]. You can also follow me on twitter [2] and identi.ca [3].
 
[0] http://www.jeroendedauw.com/
[1] http://blog.bn2vs.com/
[2] https://twitter.com/#!/JeroenDeDauw
[3] http://identi.ca/jeroendedauw
Follow on   Twitter

Comments and Discussions

 
GeneralGREAT!!! PinmemberAnt210025-May-09 2:54 
GeneralRe: GREAT!!! Pinmemberbn2vs25-May-09 23:04 
Generalnice work PinmemberDonsw19-May-09 5:44 
GeneralRe: nice work Pinmemberbn2vs25-May-09 23:02 
GeneralLicence PinmemberMember 427711910-May-09 11:22 
GeneralRe: Licence Pinmemberbn2vs25-May-09 23:00 
Hey,
 
As long as the copyright in the source code remains and you don't go claim you wrote the dialog I'm happy. Since this is open source you can use it in whatever application (inc commercial ones) that you want Smile | :)
 
Cheers
BN
 
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 28 Apr 2009
Article Copyright 2009 by Jeroen De Dauw
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid