using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Configuration;

namespace VoServices.Footprint.Web
{
	/// <summary>
	/// Summary description for _default.
	/// </summary>
	public partial class error : BasePageTemplated
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			TitleLabel.Text = "Spectrum Service Error Report";

			System.Exception ex = ((System.Exception) Session["Error"]);
			ErrorMessage.Text = ex.Message;

			//Session["Error"] = null;
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion

		protected void Ok_Click(object sender, System.EventArgs e)
		{
			System.Exception ex = ((System.Exception) Session["Error"]);

			string body = "";

			System.Exception bx = ex;
			while (bx != null)
			{
				body += "Error Message: " + bx.Message + "\r\n";
				bx = bx.InnerException;
			}

			body += "On page:       " + this.OriginalReferer + "\r\n";
			body += "Error Source:  " + ex.Source + "\r\n";
			body += "Stack Trace:\r\n" + ex.StackTrace + "\r\n";
			body += "\r\nComments:\r\n\r\n" + Message.Text;

			SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["ErrorReportSmtp"];

			SmtpMail.Send(Email.Text,
						  ConfigurationSettings.AppSettings["ErrorReportAddress"],
						  "Spectrum Service Error Report",
						  body);

			Response.Redirect("errorresult.aspx");
		}
	}
}
