From b3c9d8791c6993c6eb40b5820ee6f7f23d37040e Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 26 Apr 2012 22:06:37 +0000 Subject: [PATCH] Eliminate Annotation changes from Change Reports Dialog for Email Error Log --- .../Volian.Controls.Library/DisplayHistory.cs | 6 +- .../frmSendErrorLog.Designer.cs | 266 ++++++++++++++++++ .../frmSendErrorLog.cs | 167 +++++++++++ .../frmSendErrorLog.resx | 120 ++++++++ 4 files changed, 558 insertions(+), 1 deletion(-) create mode 100644 PROMS/Volian.Controls.Library/frmSendErrorLog.Designer.cs create mode 100644 PROMS/Volian.Controls.Library/frmSendErrorLog.cs create mode 100644 PROMS/Volian.Controls.Library/frmSendErrorLog.resx diff --git a/PROMS/Volian.Controls.Library/DisplayHistory.cs b/PROMS/Volian.Controls.Library/DisplayHistory.cs index 5df81846..391ae191 100644 --- a/PROMS/Volian.Controls.Library/DisplayHistory.cs +++ b/PROMS/Volian.Controls.Library/DisplayHistory.cs @@ -593,6 +593,8 @@ namespace Volian.Controls.Library RefreshList(); //if (lbChanges.Items.Count > 0) //{ + //jcb added 20120425 to suppress annotations in report + _AnnotationList = AnnotationAuditInfoList.GetChronology(0, 0); OnChronologyPrintRequest(new DisplayHistoryReportEventArgs(Volian.Base.Library.VlnSettings.TemporaryFolder + @"\MyChronology.pdf", MyItemInfo.MyProcedure, _ChronologyAuditList, _AnnotationList)); //} } @@ -601,7 +603,9 @@ namespace Volian.Controls.Library RefreshList(); //if (lbChanges.Items.Count > 0) //{ - OnSummaryPrintRequest(new DisplayHistoryReportEventArgs(Volian.Base.Library.VlnSettings.TemporaryFolder + @"\MySummary.pdf", MyItemInfo.MyProcedure, _SummaryAuditList, _AnnotationList)); + //jcb added 20120425 to suppress annotations in report + _AnnotationList = AnnotationAuditInfoList.GetChronology(0, 0); + OnSummaryPrintRequest(new DisplayHistoryReportEventArgs(Volian.Base.Library.VlnSettings.TemporaryFolder + @"\MySummary.pdf", MyItemInfo.MyProcedure, _SummaryAuditList, _AnnotationList)); //} } private void btnRefresh_Click(object sender, EventArgs e) diff --git a/PROMS/Volian.Controls.Library/frmSendErrorLog.Designer.cs b/PROMS/Volian.Controls.Library/frmSendErrorLog.Designer.cs new file mode 100644 index 00000000..d3a8b780 --- /dev/null +++ b/PROMS/Volian.Controls.Library/frmSendErrorLog.Designer.cs @@ -0,0 +1,266 @@ +namespace Volian.Controls.Library +{ + partial class frmSendErrorLog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnSend = new DevComponents.DotNetBar.ButtonX(); + this.btnCancel = new DevComponents.DotNetBar.ButtonX(); + this.gpEmailSettings = new DevComponents.DotNetBar.Controls.GroupPanel(); + this.rbOutlook = new System.Windows.Forms.RadioButton(); + this.rbManual = new System.Windows.Forms.RadioButton(); + this.tbServer = new System.Windows.Forms.TextBox(); + this.tbUsername = new System.Windows.Forms.TextBox(); + this.tbPassword = new System.Windows.Forms.TextBox(); + this.lblServer = new System.Windows.Forms.Label(); + this.lblUsername = new System.Windows.Forms.Label(); + this.lblPassword = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.tbContent = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.gpEmailSettings.SuspendLayout(); + this.SuspendLayout(); + // + // btnSend + // + this.btnSend.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnSend.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnSend.Location = new System.Drawing.Point(306, 299); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(75, 23); + this.btnSend.TabIndex = 0; + this.btnSend.Text = "Send"; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // btnCancel + // + this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(387, 299); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 1; + this.btnCancel.Text = "Cancel"; + // + // gpEmailSettings + // + this.gpEmailSettings.CanvasColor = System.Drawing.SystemColors.Control; + this.gpEmailSettings.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; + this.gpEmailSettings.Controls.Add(this.panel1); + this.gpEmailSettings.Controls.Add(this.lblPassword); + this.gpEmailSettings.Controls.Add(this.lblUsername); + this.gpEmailSettings.Controls.Add(this.lblServer); + this.gpEmailSettings.Controls.Add(this.tbPassword); + this.gpEmailSettings.Controls.Add(this.tbUsername); + this.gpEmailSettings.Controls.Add(this.tbServer); + this.gpEmailSettings.Controls.Add(this.rbManual); + this.gpEmailSettings.Controls.Add(this.rbOutlook); + this.gpEmailSettings.Location = new System.Drawing.Point(12, 169); + this.gpEmailSettings.Name = "gpEmailSettings"; + this.gpEmailSettings.Size = new System.Drawing.Size(450, 124); + // + // + // + this.gpEmailSettings.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2; + this.gpEmailSettings.Style.BackColorGradientAngle = 90; + this.gpEmailSettings.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; + this.gpEmailSettings.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; + this.gpEmailSettings.Style.BorderBottomWidth = 1; + this.gpEmailSettings.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; + this.gpEmailSettings.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; + this.gpEmailSettings.Style.BorderLeftWidth = 1; + this.gpEmailSettings.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; + this.gpEmailSettings.Style.BorderRightWidth = 1; + this.gpEmailSettings.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; + this.gpEmailSettings.Style.BorderTopWidth = 1; + this.gpEmailSettings.Style.CornerDiameter = 4; + this.gpEmailSettings.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded; + this.gpEmailSettings.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center; + this.gpEmailSettings.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; + this.gpEmailSettings.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near; + // + // + // + this.gpEmailSettings.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; + // + // + // + this.gpEmailSettings.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this.gpEmailSettings.TabIndex = 2; + this.gpEmailSettings.Text = "Email Settings"; + // + // rbOutlook + // + this.rbOutlook.AutoSize = true; + this.rbOutlook.BackColor = System.Drawing.Color.Transparent; + this.rbOutlook.Checked = true; + this.rbOutlook.Location = new System.Drawing.Point(4, 4); + this.rbOutlook.Name = "rbOutlook"; + this.rbOutlook.Size = new System.Drawing.Size(62, 17); + this.rbOutlook.TabIndex = 0; + this.rbOutlook.TabStop = true; + this.rbOutlook.Text = "Outlook"; + this.rbOutlook.UseVisualStyleBackColor = false; + this.rbOutlook.CheckedChanged += new System.EventHandler(this.emailSettingChanged); + // + // rbManual + // + this.rbManual.AutoSize = true; + this.rbManual.BackColor = System.Drawing.Color.Transparent; + this.rbManual.Location = new System.Drawing.Point(4, 27); + this.rbManual.Name = "rbManual"; + this.rbManual.Size = new System.Drawing.Size(101, 17); + this.rbManual.TabIndex = 1; + this.rbManual.Text = "Manual Settings"; + this.rbManual.UseVisualStyleBackColor = false; + // + // tbServer + // + this.tbServer.Enabled = false; + this.tbServer.Location = new System.Drawing.Point(201, 26); + this.tbServer.Name = "tbServer"; + this.tbServer.Size = new System.Drawing.Size(240, 20); + this.tbServer.TabIndex = 2; + // + // tbUsername + // + this.tbUsername.Enabled = false; + this.tbUsername.Location = new System.Drawing.Point(201, 53); + this.tbUsername.Name = "tbUsername"; + this.tbUsername.Size = new System.Drawing.Size(240, 20); + this.tbUsername.TabIndex = 3; + // + // tbPassword + // + this.tbPassword.Enabled = false; + this.tbPassword.Location = new System.Drawing.Point(201, 80); + this.tbPassword.Name = "tbPassword"; + this.tbPassword.PasswordChar = '*'; + this.tbPassword.Size = new System.Drawing.Size(240, 20); + this.tbPassword.TabIndex = 4; + // + // lblServer + // + this.lblServer.AutoSize = true; + this.lblServer.BackColor = System.Drawing.Color.Transparent; + this.lblServer.Enabled = false; + this.lblServer.Location = new System.Drawing.Point(111, 29); + this.lblServer.Name = "lblServer"; + this.lblServer.Size = new System.Drawing.Size(84, 13); + this.lblServer.TabIndex = 5; + this.lblServer.Text = "Outgoing Server"; + // + // lblUsername + // + this.lblUsername.AutoSize = true; + this.lblUsername.BackColor = System.Drawing.Color.Transparent; + this.lblUsername.Enabled = false; + this.lblUsername.Location = new System.Drawing.Point(138, 56); + this.lblUsername.Name = "lblUsername"; + this.lblUsername.Size = new System.Drawing.Size(55, 13); + this.lblUsername.TabIndex = 6; + this.lblUsername.Text = "Username"; + // + // lblPassword + // + this.lblPassword.AutoSize = true; + this.lblPassword.BackColor = System.Drawing.Color.Transparent; + this.lblPassword.Enabled = false; + this.lblPassword.Location = new System.Drawing.Point(142, 83); + this.lblPassword.Name = "lblPassword"; + this.lblPassword.Size = new System.Drawing.Size(53, 13); + this.lblPassword.TabIndex = 7; + this.lblPassword.Text = "Password"; + // + // panel1 + // + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Location = new System.Drawing.Point(0, 23); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(447, 1); + this.panel1.TabIndex = 3; + // + // tbContent + // + this.tbContent.Location = new System.Drawing.Point(12, 38); + this.tbContent.Multiline = true; + this.tbContent.Name = "tbContent"; + this.tbContent.Size = new System.Drawing.Size(450, 115); + this.tbContent.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(165, 13); + this.label1.TabIndex = 4; + this.label1.Text = "Add additional comments below..."; + // + // frmSendErrorLog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(474, 334); + this.Controls.Add(this.label1); + this.Controls.Add(this.tbContent); + this.Controls.Add(this.gpEmailSettings); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnSend); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "frmSendErrorLog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Send Error Log to Volian Support"; + this.gpEmailSettings.ResumeLayout(false); + this.gpEmailSettings.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private DevComponents.DotNetBar.ButtonX btnSend; + private DevComponents.DotNetBar.ButtonX btnCancel; + private DevComponents.DotNetBar.Controls.GroupPanel gpEmailSettings; + private System.Windows.Forms.RadioButton rbManual; + private System.Windows.Forms.RadioButton rbOutlook; + private System.Windows.Forms.Label lblPassword; + private System.Windows.Forms.Label lblUsername; + private System.Windows.Forms.Label lblServer; + private System.Windows.Forms.TextBox tbPassword; + private System.Windows.Forms.TextBox tbUsername; + private System.Windows.Forms.TextBox tbServer; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TextBox tbContent; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/frmSendErrorLog.cs b/PROMS/Volian.Controls.Library/frmSendErrorLog.cs new file mode 100644 index 00000000..39b83cdc --- /dev/null +++ b/PROMS/Volian.Controls.Library/frmSendErrorLog.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using LBOutlookLibrary; +using System.Reflection; +using VEPROMS.CSLA.Library; +using System.Text.RegularExpressions; +using System.Net.Mail; +using System.Net; +using System.IO; + +namespace Volian.Controls.Library +{ + public partial class frmSendErrorLog : Form + { + private string _ErrorLogPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\ErrorLog.txt"; + public bool OutlookEmail + { + get { return rbOutlook.Checked; } + set + { + if (value) + rbOutlook.Checked = true; + else + rbManual.Checked = true; + } + } + public string SMTPServer + { + get { return tbServer.Text; } + set { tbServer.Text = value; } + } + public string SMTPUser + { + get { return tbUsername.Text; } + set { tbUsername.Text = value; } + } + public frmSendErrorLog(bool outlookEmail, string smtpServer, string smtpUser) + { + InitializeComponent(); + tbPassword.PasswordChar = '\u25CF'; + OutlookEmail = outlookEmail; + SMTPServer = smtpServer; + SMTPUser = smtpUser; + } + + private void emailSettingChanged(object sender, EventArgs e) + { + tbServer.Enabled = tbUsername.Enabled = tbPassword.Enabled = + lblServer.Enabled = lblUsername.Enabled = lblPassword.Enabled = rbManual.Checked; + } + + private void btnSend_Click(object sender, EventArgs e) + { + if (OutlookEmail) + { + if (SendOutlookEmail()) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } + } + else + { + if (SendSMTPEmail()) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } + } + } + private bool SendSMTPEmail() + { + FileStream fs = null; + try + { + MailMessage mm = new MailMessage(); + mm.From = new MailAddress(SMTPUser); + mm.To.Add("support@volian.com"); + //mm.To.Add("rmark@epix.net"); + //mm.To.Add("jcbodine@gmail.com"); + mm.Subject = "PROMS Error Log " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"); + mm.Body = Header + "\r\n\r\n" + tbContent.Text; + fs = File.Open(_ErrorLogPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + mm.Attachments.Add(new Attachment(fs, "ErrorLog.txt")); + SmtpClient sc = new SmtpClient(SMTPServer); + sc.EnableSsl = true; + sc.Credentials = new NetworkCredential(SMTPUser, tbPassword.Text); + sc.Send(mm); + return true; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return false; + } + finally + { + fs.Close(); + } + } + public string Header + { + get + { + StringBuilder sb = new StringBuilder(); + //sb.Append("PROMS\t\tVersion: "); + sb.AppendLine("PROMS"); + sb.Append("Version: "); + sb.Append(AssemblyVersion); + DateTime buildDateTime = new System.IO.FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime; + sb.AppendLine(String.Format("\t\tBuild Date: {0}", buildDateTime.ToString())); + string connectionString = Database.VEPROMS_Connection; + Match mServer = Regex.Match(connectionString, ".*Data Source=([^;]*).*"); + string server = (mServer.Success) ? mServer.Groups[1].Value : "unknown"; + if (server.StartsWith(@".\")) server = @"Local \ " + server.Substring(2); + string databaseName = Database.SelectedDatabase; + sb.Append(string.Format("SQL Server: {0}", server)); + sb.AppendLine(string.Format("\t\tDatabase: {0}", databaseName)); + if (OutlookEmail) + sb.AppendLine("sent via outlook"); + else + sb.AppendLine("sent via manual settings"); + return sb.ToString(); + } + } + private bool SendOutlookEmail() + { + try + { + LBApplicationClass app = new LBApplicationClass(); + LBMailItemClass msg = app.CreateMailItem(); + msg.Recipients.Add("support@volian.com"); + //msg.Recipients.Add("rmark@epix.net"); + //msg.Recipients.Add("jcbodine@gmail.com"); + //msg.To = "jcbodine@gmail.com";//"rmark@epix.net"; + //msg.Recipients.Add("jcbodine@gmail.com"); + msg.Subject = "PROMS Error Log " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"); + msg.BodyFormat = LBOlBodyFormat.olFormatPlain; + msg.Body = Header + "\r\n\r\n" + tbContent.Text; + msg.AddAttachment(_ErrorLogPath); + msg.Send(); + return true; + } + catch (Exception ex) + { + if (ex.Message.ToLower().Contains("failed due to the following error: 80080005")) + MessageBox.Show("You cannot send email via a running instance of Outlook from VE PROMS running from within Visual Studio."); + else + MessageBox.Show(string.Format("{0} - {1}", ex.GetType().Name, ex.Message)); + return false; + } + } + public string AssemblyVersion + { + get + { + return Application.ProductVersion; + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + } + } +} \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/frmSendErrorLog.resx b/PROMS/Volian.Controls.Library/frmSendErrorLog.resx new file mode 100644 index 00000000..19dc0dd8 --- /dev/null +++ b/PROMS/Volian.Controls.Library/frmSendErrorLog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file