internal CustomUIEventArgs(UIMode uiMode, SerializableException exception, Report report)
		{
			this.UIMode = uiMode;
			this.Report = report;
			this.Exception = exception;
			this.Result = new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.DoNotSend);
		}
Beispiel #2
0
		internal UIDialogResult ShowDialog(SerializableException exception, Report report)
		{
			this.Text = string.Format("{0} {1}", report.GeneralInfo.HostApplication, Settings.Resources.UI_Dialog_Full_Title);
			
			// Fill in the 'General' tab
			warningPictureBox.Image = SystemIcons.Warning.ToBitmap();
			this.exceptionTextBox.Text = exception.Type;
			this.exceptionMessageTextBox.Text = exception.Message;
			this.targetSiteTextBox.Text = exception.TargetSite;
			this.applicationTextBox.Text = report.GeneralInfo.HostApplication + " [" + report.GeneralInfo.HostApplicationVersion + "]";
			this.nbugTextBox.Text = report.GeneralInfo.NBugVersion;
			this.dateTimeTextBox.Text = report.GeneralInfo.DateTime;
			this.clrTextBox.Text = report.GeneralInfo.CLRVersion;
			
			// Fill in the 'Exception' tab
			this.exceptionDetails.Initialize(exception);
			
			// ToDo: Fill in the 'Report Contents' tab);

			this.BringToFront();
			this.ShowDialog();

			// Write back the user description (as we passed 'report' as a reference since it is a refence object anyway)
			report.GeneralInfo.UserDescription = this.descriptionTextBox.Text;
			return this.uiDialogResult;
		}
 public AnonymousData(string applicationGUID, string email, SerializableException exception, Report report)
 {
     Report = report;
     Exception = exception;
     ApplicationGUID = applicationGUID;
     ToEmail = email;
 }
Beispiel #4
0
		internal GeneralInfo(SerializableException serializableException)
		{
			// this.HostApplication = Settings.EntryAssembly.GetName().Name; // Does not get the extensions of the file!
			this.HostApplication = Settings.EntryAssembly.GetLoadedModules()[0].Name;

			// this.HostApplicationVersion = Settings.EntryAssembly.GetName().Version.ToString(); // Gets AssemblyVersion not AssemblyFileVersion
			this.HostApplicationVersion = this.NBugVersion = FileVersionInfo.GetVersionInfo(Settings.EntryAssembly.Location).ProductVersion;

			// this.NBugVersion = System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString(); // Gets AssemblyVersion not AssemblyFileVersion
			this.NBugVersion = FileVersionInfo.GetVersionInfo(Assembly.GetCallingAssembly().Location).ProductVersion;

			this.CLRVersion = Environment.Version.ToString();

            this.DateTime = System.DateTime.UtcNow;

			if (serializableException != null)
			{
				this.ExceptionType = serializableException.Type;

				if (!string.IsNullOrEmpty(serializableException.TargetSite))
				{
					this.TargetSite = serializableException.TargetSite;
				}
				else if (serializableException.InnerException != null && !string.IsNullOrEmpty(serializableException.InnerException.TargetSite))
				{
					this.TargetSite = serializableException.InnerException.TargetSite;
				}

				this.ExceptionMessage = serializableException.Message;
			}
		}
Beispiel #5
0
		internal static UIDialogResult ShowDialog(UIMode uiMode, SerializableException exception, Report report)
		{
			if (uiMode == UIMode.Minimal)
			{
				return new Minimal().ShowDialog(report);
			}
			else if (uiMode == UIMode.Normal)
			{
				using (var ui = new Normal())
				{
					return ui.ShowDialog(report);
				}
			}
			else if (uiMode == UIMode.Full)
			{
				using (var ui = new Full())
				{
					return ui.ShowDialog(exception, report);
				}
			}
			else
			{
				throw NBugConfigurationException.Create(() => Settings.UIMode, "Parameter supplied for settings property is invalid.");
			}
		}
Beispiel #6
0
        private void OnPostDisplayBugReportUI(NBug.Core.UI.UIDialogResult uiResult, Exception exc, SerializableException exception, Report report)
        {
            try
            {
                // We need to wait till end of SendAnonymousReport or report may be dropped due to application exit
                _sendAnonymousReportResult.Wait();

                // No interaction with user if he press Cancel
                if (uiResult.Report != UI.SendReport.Send)
                    return;

                byte[] context = GetContinueContext(_sendAnonymousReportResult.Result);
                if (context == null)
                    uiResult.Report = UI.SendReport.DoNotSend;
                else
                    report.ProtocolData = context;
            }
            catch (Exception ex)
            {
                // No interaction with user if he press Cancel
                if (uiResult.Report != UI.SendReport.Send)
                    return;
                throw new Exception("Failed to send report to Doctor Dump", ex);
            }
        }
Beispiel #7
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                if (uiDialogResult.Report == SendReport.Send)
                {
                    this.CreateReportZip(serializableException, report);
                }

                return uiDialogResult.Execution;
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                return ExecutionFlow.BreakExecution; // Since an internal exception occured
            }
        }
Beispiel #8
0
		internal void ShowDialog(UIMode uiMode, UIProvider uiProvider)
		{
			var exception =
				new SerializableException(new ArgumentException("Argument exception preview.", new Exception("Inner exception for argument exception.")));
			var report = new Report(exception);

			var consoleOut = new StringWriter();
			Console.SetOut(consoleOut);

			if (uiProvider == UIProvider.Console)
			{
				ConsoleUI.ShowDialog(uiMode, exception, report);
				this.consoleOutputTextBox.Text = consoleOut.ToString();
				this.ShowDialog();
			}
			else if (uiProvider == UIProvider.WinForms)
			{
				WinFormsUI.ShowDialog(uiMode, exception, report);
				this.Close();
			}
			else if (uiProvider == UIProvider.WPF)
			{
				WPFUI.ShowDialog(uiMode, exception, report);
				this.Close();
			}
			else if (uiProvider == UIProvider.Custom)
			{
				CustomUI.ShowDialog(uiMode, exception, report);
				this.Close();
			}
			else
			{
				throw new ArgumentException("Parameter supplied for UIProvider argument is invalid.");
			}
		}
Beispiel #9
0
		internal static UIDialogResult ShowDialog(UIMode uiMode, SerializableException exception, Report report)
		{
			if (uiMode == UIMode.Minimal)
			{
				// Do not interact with the user
				Console.WriteLine(Environment.NewLine + Settings.Resources.UI_Console_Minimal_Message);
				return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
			}
			else if (uiMode == UIMode.Normal)
			{
				// ToDo: Create normal console UI
				Console.WriteLine(Environment.NewLine + Settings.Resources.UI_Console_Normal_Message);
				return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
			}
			else if (uiMode == UIMode.Full)
			{
				// ToDo: Create full console UI
				Console.WriteLine(Environment.NewLine + Settings.Resources.UI_Console_Full_Message);
				return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
			}
			else
			{
				throw NBugConfigurationException.Create(() => Settings.UIMode, "Parameter supplied for settings property is invalid.");
			}
		}
		internal CustomSubmissionEventArgs(string fileName, Stream file, Report report, SerializableException exception)
		{
			this.FileName = fileName;
			this.File = file;
			this.Report = report;
			this.Exception = exception;
			this.Result = false;
		}
Beispiel #11
0
        public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
        {
            if (Settings.CustomSubmissionHandle == null)
                return false;

            var e = new CustomSubmissionEventArgs(fileName, file, report, exception);
            Settings.CustomSubmissionHandle.DynamicInvoke(this, e);
            return e.Result;
        }
 private static int GetHResult(SerializableException e)
 {
     if (e.ExtendedInformation == null || !e.ExtendedInformation.ContainsKey("HResult"))
         return 0;
     object hresult = e.ExtendedInformation["HResult"];
     if (hresult is int) // before serialization it is int
         return (int)hresult;
     if (hresult is string) // after deserialization it is string
         return int.Parse((string)hresult);
     return 0;
 }
 private static ExceptionInfo GetExceptionInfo(SerializableException e, bool anonymous)
 {
     return e == null ? null : new ExceptionInfo
     {
         Type = e.Type,
         HResult = GetHResult(e),
         StackTrace = e.StackTrace ?? string.Empty,
         Source = e.Source,
         Message = anonymous ? null : e.Message,
         InnerException = GetExceptionInfo(e.InnerException ?? (e.InnerExceptions != null && e.InnerExceptions.Count > 0 ? e.InnerExceptions[0] : null), anonymous)
     };
 }
Beispiel #14
0
		internal static UIDialogResult ShowDialog(UIMode uiMode, SerializableException exception, Report report)
		{
			if (Settings.CustomUIHandle != null)
			{
				var e = new CustomUIEventArgs(uiMode, exception, report);
				Settings.CustomUIHandle.DynamicInvoke(null, e);
				return e.Result;
			}
			else
			{
				throw NBugConfigurationException.Create(() => Settings.UIMode, "Parameter supplied for settings property is invalid.");
			}
		}
		// Connection string format (single line)
		// Warning: There should be no semicolon (;) or equals sign (=) used in any field except for password.
		// Warning: No field value value should contain the phrase 'password='******'ed

		/* Type=AzureBlobStorage;
		 * AccountName=youraccountname;
		 * ContainerName=yourcontainername;
		 * SharedAccessSignature=sr%3Dc%26si%3D16dacb22-asdf-asdf-asdf-e58fasdff3ed%26se%3D2098-12-31T23%253A00%253A00Z%26sig%3asdfIWtlasdfb98q0Kidp%252BasdffJcRm1ulFIjyks4E%253D
		 */
		public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
		{
			var cred = new StorageCredentials(Uri.UnescapeDataString(this.SharedAccessSignature));

			var blobUrl = new Uri(string.Format("https://{0}.blob.core.windows.net/{1}", this.AccountName, this.ContainerName));
			var container = new CloudBlobContainer(blobUrl, cred);

			var blob = container.GetBlockBlobReference(fileName);

			file.Position = 0;
			blob.UploadFromStream(file);
			return true;
		}
Beispiel #16
0
        public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
        {
            // Advanced method with ability to post variables along with file (do not forget to urlencode the query parameters)
            // http://www.codeproject.com/KB/cs/uploadfileex.aspx
            // http://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data
            // http://stackoverflow.com/questions/767790/how-do-i-upload-an-image-file-using-a-post-request-in-c
            // http://netomatix.com/HttpPostData.aspx

            /* upload.php file my look like the one below (note that uploaded files are not statically named in this case script may need modification)
             *
             * <?php
             * $uploadDir = 'Upload/';
             * $uploadFile = $uploadDir . basename($_FILES['file']['name']);
             * if (is_uploaded_file($_FILES['file']['tmp_name']))
             * {
             *     echo "File ". $_FILES['file']['name'] ." is successfully uploaded!\r\n";
             *     if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile))
             *     {
             *         echo "File is successfully stored! ";
             *     }
             *     else print_r($_FILES);
             * }
             * else
             * {
             *     echo "Upload Failed!";
             *     print_r($_FILES);
             * }
             * ?>
             */
            file.Position = 0;

            StreamUpload stream = StreamUpload.Create();
            if (PostReport)
            {
                stream.Add("report", report.ToString());
            }
            if (PostException)
            {
                stream.Add("exception", exception.ToString());
            }
            stream.Add(file, "file", fileName, "application/zip");
            string response = stream.Upload(this.Url).Response();

            Logger.Info("Response from HTTP server: " + response);
            file.Position = 0;

            return true;
        }
		internal void Initialize(SerializableException exception)
		{
			this.exceptionDetailsList.Add(this.exceptionTreeView.Nodes.Add(exception.Type), exception);

			if (exception.InnerException != null)
			{
				this.FillInnerExceptionTree(exception.InnerException, this.exceptionTreeView.Nodes[0]);
			}

			if (exception.InnerExceptions != null)
			{
				foreach (var innerException in exception.InnerExceptions)
				{
					this.FillInnerExceptionTree(innerException, this.exceptionTreeView.Nodes[0]);
				}
			}

			this.exceptionTreeView.ExpandAll();
			this.DisplayExceptionDetails(this.exceptionTreeView.Nodes[0]);
		}
Beispiel #18
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                if (uiDialogResult.Report == SendReport.Send)
                {
                    this.CreateReportZip(serializableException, report);
                }

                // If NBug is configured not to delay error reporting and user did not select to exit the app immediately,
                // start dispatching the bug report right away
                if (!Settings.DeferredReporting && uiDialogResult.Execution == ExecutionFlow.ContinueExecution)
                {
                    new NBug.Core.Submission.Dispatcher();
                }

                return uiDialogResult.Execution;
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                return ExecutionFlow.BreakExecution; // Since an internal exception occured
            }
        }
Beispiel #19
0
		public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
		{
			var request = (FtpWebRequest)WebRequest.Create(new Uri(this.Url + fileName));

			if (!string.IsNullOrEmpty(this.Usessl))
			{
				request.EnableSsl = Convert.ToBoolean(this.Usessl.ToLower());
			}

			if (!string.IsNullOrEmpty(this.Username))
			{
				request.Credentials = new NetworkCredential(this.Username, this.Password);
			}

			request.Method = WebRequestMethods.Ftp.UploadFile;
			request.Proxy = null; // Otherwise we'll get an exception: The requested FTP command is not supported when a HTTP proxy is used

			using (var requestStream = request.GetRequestStream())
			{
				file.Position = 0;
				file.CopyTo(requestStream);
				file.Position = 0;
			}

			using (var response = (FtpWebResponse)request.GetResponse())
			using (var reader = new StreamReader(response.GetResponseStream()))
			{
				var responseString = reader.ReadToEnd(); // Null on successful transfer
				if (!string.IsNullOrEmpty(responseString))
				{
					Logger.Info("Response from FTP server: " + responseString);
				}

				Logger.Info("Response from FTP server: " + response.StatusDescription);
			}

			return true;
		}
Beispiel #20
0
 internal Report(SerializableException serializableException)
 {
     this.GeneralInfo = new GeneralInfo(serializableException);
 }
		private void FillInnerExceptionTree(SerializableException innerException, TreeNode innerNode)
		{
			this.exceptionDetailsList.Add(innerNode.Nodes.Add(innerException.Type), innerException);

			if (innerException.InnerException != null)
			{
				this.FillInnerExceptionTree(innerException.InnerException, innerNode.Nodes[0]);
			}
		}
Beispiel #22
0
		internal static UIDialogResult DisplayBugReportUI(ExceptionThread exceptionThread, SerializableException serializableException, Report report)
		{
			if (exceptionThread == ExceptionThread.Task)
			{
				// Do not interfere with the default behaviour for continuation on background thread exceptions. Just log and send'em (no UI...)
				return new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send);
			}
			else if (Settings.UIMode == UIMode.Auto)
			{
				// First of, test to see if the call is from an UI thread and if so, use the same UI type (WinForms, WPF, etc.)
				if (exceptionThread == ExceptionThread.UI_WinForms)
				{
					return WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report);
				}
				else if (exceptionThread == ExceptionThread.UI_WPF)
				{
					return WPFUI.ShowDialog(UIMode.Minimal, serializableException, report);
				}
				else if (exceptionThread == ExceptionThread.Main)
				{
					// If the call is not from a non-UI thread like the main app thread, it may be from the current appdomain but
					// the application may still be using an UI. Or it may be coming from an exception filter where UI type is undefined yet.
					switch (DiscoverUI())
					{
						case UIProvider.WinForms:
							return WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report);
						case UIProvider.WPF:
							return WPFUI.ShowDialog(UIMode.Minimal, serializableException, report);
						case UIProvider.Console:
							return ConsoleUI.ShowDialog(UIMode.Minimal, serializableException, report);
						default:
							throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
					}
				}
				else
				{
					throw new NBugRuntimeException("Parameter supplied for '" + typeof(ExceptionThread).Name + "' is not valid.");
				}
			}
			else if (Settings.UIMode == UIMode.None)
			{
				// Do not display an UI for UIMode.None
				if (Settings.ExitApplicationImmediately)
				{
					return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
				}
				else
				{
					return new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send);
				}
			}
			else if (Settings.UIProvider == UIProvider.Console)
			{
				return ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report);
			}
			else if (Settings.UIProvider == UIProvider.WinForms)
			{
				return WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report);
			}
			else if (Settings.UIProvider == UIProvider.WPF)
			{
				return WPFUI.ShowDialog(Settings.UIMode, serializableException, report);
			}
			else if (Settings.UIProvider == UIProvider.Auto)
			{
				// In this case, UIProvider = Auto & UIMode != Auto so just discover the UI provider and use the selected UI mode
				switch (DiscoverUI())
				{
					case UIProvider.WinForms:
						return WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report);
					case UIProvider.WPF:
						return WPFUI.ShowDialog(Settings.UIMode, serializableException, report);
					case UIProvider.Console:
						return ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report);
					default:
						throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
				}
			}
			else
			{
				throw NBugConfigurationException.Create(() => Settings.UIProvider, "Parameter supplied for settings property is invalid.");
			}
		}
        public SerializableException(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException();
            }

            var oldCulture   = Thread.CurrentThread.CurrentCulture;
            var oldUICulture = Thread.CurrentThread.CurrentUICulture;

            try
            {
                // Prefer messages in English, instead of in language of the user.
                Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
                Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

                Type = exception.GetType().ToString();

                if (exception.Data.Count != 0)
                {
                    foreach (DictionaryEntry entry in exception.Data)
                    {
                        if (entry.Value != null)
                        {
                            // Assign 'Data' property only if there is at least one entry with non-null value
                            if (Data == null)
                            {
                                Data = new SerializableDictionary <object, object>();
                            }

                            Data.Add(entry.Key, entry.Value);
                        }
                    }
                }

                if (exception.HelpLink != null)
                {
                    HelpLink = exception.HelpLink;
                }

                if (exception.InnerException != null)
                {
                    InnerException = new SerializableException(exception.InnerException);
                }

                /*
                 *              if (exception is AggregateException)
                 *              {
                 *                      this.InnerExceptions = new List<SerializableException>();
                 *
                 *                      foreach (var innerException in ((AggregateException)exception).InnerExceptions)
                 *                      {
                 *                              this.InnerExceptions.Add(new SerializableException(innerException));
                 *                      }
                 *
                 *                      this.InnerExceptions.RemoveAt(0);
                 *              }*/

                Message = exception.Message != string.Empty ? exception.Message : string.Empty;

                if (exception.Source != null)
                {
                    Source = exception.Source;
                }

                if (exception.StackTrace != null)
                {
                    StackTrace = exception.StackTrace;
                }

                if (exception.TargetSite != null)
                {
                    TargetSite = string.Format("{0} @ {1}", exception.TargetSite, exception.TargetSite.DeclaringType);
                }

                ExtendedInformation = GetExtendedInformation(exception);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture   = oldCulture;
                Thread.CurrentThread.CurrentUICulture = oldUICulture;
            }
        }
Beispiel #24
0
        private void CreateReportZip(SerializableException serializableException, Report report)
        {
            // Test if it has NOT been more than x many days since entry assembly was last modified)
            if (Settings.StopReportingAfter < 0 || File.GetLastWriteTime(Settings.EntryAssembly.Location).AddDays(Settings.StopReportingAfter).CompareTo(DateTime.Now) > 0)
            {
                // Test if there is already more than enough queued report files
                if (Settings.MaxQueuedReports < 0 || Storer.GetReportCount() < Settings.MaxQueuedReports)
                {
                    var reportFileName = "Exception_" + DateTime.UtcNow.ToFileTime() + ".zip";
                    var minidumpFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Exception_MiniDump_" + DateTime.UtcNow.ToFileTime() + ".mdmp");

                    using (var storer = new Storer())
                    using (var zipStorer = ZipStorer.Create(storer.CreateReportFile(reportFileName), string.Empty))
                    using (var stream = new MemoryStream())
                    {
                        // Store the exception
                        var serializer = new XmlSerializer(typeof(SerializableException));
                        serializer.Serialize(stream, serializableException);
                        stream.Position = 0;
                        zipStorer.AddStream(ZipStorer.Compression.Deflate, StoredItemFile.Exception, stream, DateTime.UtcNow, string.Empty);

                        // Store the report
                        stream.SetLength(0);

                        try
                        {
                            serializer = report.CustomInfo != null ? new XmlSerializer(typeof(Report), new[] { report.CustomInfo.GetType() }) : new XmlSerializer(typeof(Report));

                            serializer.Serialize(stream, report);
                        }
                        catch (Exception exception)
                        {
                            Logger.Error(string.Format("The given custom info of type [{0}] cannot be serialized. Make sure that given type and inner types are XML serializable.", report.CustomInfo.GetType()), exception);
                            report.CustomInfo = null;
                            serializer = new XmlSerializer(typeof(Report));
                            serializer.Serialize(stream, report);
                        }

                        stream.Position = 0;
                        zipStorer.AddStream(ZipStorer.Compression.Deflate, StoredItemFile.Report, stream, DateTime.UtcNow, string.Empty);

                        // Add the memory minidump to the report file (only if configured so)
                        if (DumpWriter.Write(minidumpFilePath))
                        {
                            zipStorer.AddFile(ZipStorer.Compression.Deflate, minidumpFilePath, StoredItemFile.MiniDump, string.Empty);
                            File.Delete(minidumpFilePath);
                        }

                        // Add any user supplied files in the report (if any)
                        if (Settings.AdditionalReportFiles.Count != 0)
                        {
                            // ToDo: This needs a lot more work!
                            this.AddAdditionalFiles(zipStorer);
                        }
                    }

                    Logger.Trace("Created a new report file. Currently the number of report files queued to be send is: " + Storer.GetReportCount());
                }
                else
                {
                    Logger.Trace("Current report count is at its limit as per 'Settings.MaxQueuedReports (" +
                        Settings.MaxQueuedReports + ")' setting: Skipping bug report generation.");
                }
            }
            else
            {
                Logger.Trace("As per setting 'Settings.StopReportingAfter(" + Settings.StopReportingAfter +
                    ")', bug reporting feature was enabled for a certain amount of time which has now expired: Bug reporting is now disabled.");

                // ToDo: Completely eliminate this with SettingsOverride.DisableReporting = true; since enumerating filesystem adds overhead);
                if (Storer.GetReportCount() > 0)
                {
                    Logger.Trace("As per setting 'Settings.StopReportingAfter(" + Settings.StopReportingAfter +
                        ")', bug reporting feature was enabled for a certain amount of time which has now expired: Truncating all expired bug reports.");
                    Storer.TruncateReportFiles(0);
                }
            }
        }
Beispiel #25
0
 // Connection string format (single line)
 // Warning: There should be no semicolon (;) or equals sign (=) used in any field except for password
 // Warning: No field value value should contain the phrase 'password='
 // Warning: XML-RPC.NET assembly should be referenced
 // Note: Url should be a full url without a trailing slash (/), like: http://......
 // Note: Anononymous URL is: http://trac-hacks.org/xmlrpc and authenticated URL is: http://trac-hacks.org/login/xmlrpc
 /* Type=Trac;
  * Url=http://tracker.mydomain.com/xmlrpc;
  */
 public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
 {
     // ToDo: Check to see if XML-RPC.NET is referenced and if not, show a developer UI as a waning -or- even better, dynamically load the assembly and use that and not the referenced one!
     return true;
 }
Beispiel #26
0
		public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
		{
			//HttpWebRequest request; //suppress unused Warning

			return true;
		}
Beispiel #27
0
        public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
        {
            if (string.IsNullOrEmpty(this.From) || string.IsNullOrEmpty(this.To))
            {
                return false;
            }

            if (string.IsNullOrEmpty(this.ReplyTo))
            {
                this.ReplyTo = this.From;
            }

            if (this.Port <= 0)
            {
                this.Port = this.UseSsl ? 465 : 25;
            }

            if (!this.UseAttachment)
            {
                this.UseAttachment = false;
            }

            // Make sure that we can use authentication even with emtpy password
            if (!string.IsNullOrEmpty(this.Username))
            {
                this.UseAuthentication = true;
            }

            using (var smtpClient = new SmtpClient())
            using (var message = new MailMessage())
            {
                if (!string.IsNullOrEmpty(this.SmtpServer))
                {
                    smtpClient.Host = this.SmtpServer;
                }

                smtpClient.Port = this.Port;

                if (this.UseAuthentication)
                {
                    smtpClient.Credentials = new NetworkCredential(this.Username, this.Password);
                }

                smtpClient.EnableSsl = this.UseSsl;

                if (!string.IsNullOrEmpty(this.Cc))
                {
                    message.CC.Add(this.Cc);
                }

                if (!string.IsNullOrEmpty(this.Bcc))
                {
                    message.Bcc.Add(this.Bcc);
                }

                message.Priority = this.Priority;

                message.To.Add(this.To);
                message.ReplyToList.Add(this.ReplyTo);
                message.From = !string.IsNullOrEmpty(this.FromName) ? new MailAddress(this.From, this.FromName) : new MailAddress(this.From);

                if (this.UseAttachment)
                {
                    // ToDo: Report file name should be attached to the report file object itself, file shouldn't be accessed directly!
                    file.Position = 0;
                    message.Attachments.Add(new Attachment(file, fileName));
                }

                if (!string.IsNullOrEmpty(this.CustomSubject))
                {
                    message.Subject = this.CustomSubject;
                }
                else
                {
                    message.Subject = "NBug: " + report.GeneralInfo.HostApplication + " (" + report.GeneralInfo.HostApplicationVersion + "): "
                                      + report.GeneralInfo.ExceptionType + " @ " + report.GeneralInfo.TargetSite;
                }

                if (!string.IsNullOrEmpty(this.CustomBody))
                {
                    message.Body = this.CustomBody + Environment.NewLine + Environment.NewLine + report + Environment.NewLine + Environment.NewLine + exception;
                }
                else
                {
                    message.Body = report + Environment.NewLine + Environment.NewLine + exception;
                }

                smtpClient.Send(message);
                Logger.Trace("Submitted bug report email to: " + this.To);

                return true;
            }
        }
Beispiel #28
0
        public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
        {

            if (string.IsNullOrEmpty(Username) || Username.Trim().Length == 0)
                throw new ArgumentNullException("Username");

            if (string.IsNullOrEmpty(Password) || Password.Trim().Length == 0)
                throw new ArgumentNullException("Password");

            if (string.IsNullOrEmpty(Url) || Url.Trim().Length == 0)
                throw new ArgumentNullException("Url");

            if (ProjectId <= 0)
                throw new ArgumentNullException("ProjectId");

            if (string.IsNullOrEmpty(Category) || Category.Trim().Length == 0)
                throw new ArgumentNullException("Category");

            if (string.IsNullOrEmpty(Description) || Description.Trim().Length == 0)
            {
                Description = exception.ToString();
            }

            if (string.IsNullOrEmpty(Summary) || Summary.Trim().Length == 0)
            {
                Summary = report.GeneralInfo.ExceptionMessage + " @ " + report.GeneralInfo.TargetSite;
            }

            if (string.IsNullOrEmpty(AdditionalInformation) || AdditionalInformation.Trim().Length == 0)
            {
                AdditionalInformation = report.ToString();
            }

            var service = new MantisConnectService(new BasicHttpBinding(), new EndpointAddress(Url));
            var user = service.mc_login(Username, Password);
            Logger.Info(String.Format("Successfully logged in to Mantis bug tracker as {0}", user.account_data.real_name));
            var issue = new IssueData();
            issue.date_submitted = DateTime.Now;
            issue.date_submittedSpecified = true;
            issue.version = report.GeneralInfo.HostApplicationVersion;
            issue.os = Environment.OSVersion.ToString();
            issue.os_build = Environment.OSVersion.Version.ToString();
            issue.platform = Environment.OSVersion.Platform.ToString();
            issue.reporter = user.account_data;
            issue.project = new ObjectRef() { id = ProjectId.ToString(CultureInfo.InvariantCulture), name = String.Empty };
            issue.category = Category;
            issue.summary = Summary;
            issue.description = Description;
            issue.additional_information = AdditionalInformation;
            issue.steps_to_reproduce = StepsToReproduce;
            issue.severity = new ObjectRef() { id = Severity.ToString(CultureInfo.InvariantCulture), name = Severity.ToString(CultureInfo.InvariantCulture) };
            issue.status = new ObjectRef() { id = Status.ToString(CultureInfo.InvariantCulture), name = Status.ToString(CultureInfo.InvariantCulture) };
            bool success = false;

            if (AddVersionIfNotExists)
            {
                var versions = service.mc_project_get_versions(Username, Password, ProjectId.ToString(CultureInfo.InvariantCulture));
                if (versions.Count() == 0 ||
                    ! versions.Any(x => x.name == report.GeneralInfo.HostApplicationVersion.ToString(CultureInfo.InvariantCulture)))
                {
                    var version = new ProjectVersionData
                    {
                        name = report.GeneralInfo.HostApplicationVersion.ToString(CultureInfo.InvariantCulture),
                        project_id = ProjectId.ToString(CultureInfo.InvariantCulture),
                        released = true,
                        releasedSpecified =  true,
                        date_order = DateTime.Now,
                        date_orderSpecified = true,
                        description = "Added by NBug"
                    };
                    var versionId = service.mc_project_version_add(Username, Password, version);
                    Logger.Info(String.Format("Successfully added new version id {0} to Mantis bug tracker", versionId));
                }
            }

            int bugId;
            Int32.TryParse(service.mc_issue_add(Username, Password, issue), out bugId);

            if (bugId > 0)
            {
                Logger.Info(String.Format("Successfully added new issue id {0} to Mantis bug tracker", bugId));
                success = true;
                if (SendAttachment)
                {
                    if (file != null && file.Length > 0)
                    {
                        if (!SuccessIfAttachmentFails)
                            success = false;
                        try
                        {
                            var attachment = new byte[file.Length];
                            file.Position = 0;
                            file.Read(attachment, 0, Convert.ToInt32(file.Length));
                            var attachmentId = service.mc_issue_attachment_add(Username, Password, bugId.ToString(CultureInfo.InvariantCulture), fileName, "application/zip", attachment);
                            Logger.Info(String.Format("Successfully added attachment id {0} for isssue id {1} to Mantis bug tracker", attachmentId, bugId));
                            success = true;                         
                        }
                        catch (Exception ex)
                        {
                            Logger.Error(String.Format("Failed to upload attachment with issue id {0} to Mantis bug tracker{1}{2}", bugId, Environment.NewLine, ex.Message));
                            if (!SuccessIfAttachmentFails)
                                throw;
                        }
                    }
                }
            }
      
            return success;
        }
 public Response SendAdditionalData(byte[] context, string applicationGUID, string email, System.IO.Stream file, SerializableException exception, Report report)
 {
     var data = new PrivateData(applicationGUID, email, file, exception, report);
     return _uploader.SendAdditionalData(context, data.GetDetailedExceptionDescription());
 }
 public PrivateData(string applicationGUID, string email, System.IO.Stream file, SerializableException exception, Report report)
     : base(applicationGUID, email, exception, report)
 {
     var buf = new byte[file.Length];
     file.Read(buf, 0, buf.Length);
     ZipReport = buf;
 }
 public Response SendAnonymousReport(string applicationGUID, string email, SerializableException exception, Report report)
 {
     var anonymousData = new AnonymousData(applicationGUID, email, exception, report);
     return _uploader.SendAnonymousReport(
         anonymousData.GetClientLib(),
         anonymousData.GetApplication(),
         anonymousData.GetExceptionDescription(anonymous: true));
 }