/// <summary> /// Post Message from User Input /// </summary> private void btnPost_Click(object sender, EventArgs e) { //Create Message from Client Input var message = new messagerequest { From = new address { Type = addresstype.Direct, Value = messageControl.From }, To = parseAddress(messageControl.To), CC = parseAddress(messageControl.CC), Subject = messageControl.Subject, Body = messageControl.Body, Attachments = attachmentControl.Attachments }; Cursor = Cursors.WaitCursor; try { // Post service call var guid = SendMessageHelper.Post(message, getCertificate()); //Update UI with returned guid tbResults.Text = string.Format("Successful Message Post.\r\nMessage Id = {0}", guid); messageControl.MessageId = guid.ToString(); } catch (Exception exception) { tbResults.Text = string.Empty; SecureMessagingHelper.ShowErrorForm(exception); } finally { Cursor = Cursors.Default; } }
/// <summary> /// Clear Grids if an error occurrs and Show Error Form. /// </summary> private void displayError(Exception exception) { gvMessages.DataSource = null; gvAttachments.DataSource = null; gvDispositions.DataSource = null; messageControl.ClearForm(); SecureMessagingHelper.ShowErrorForm(exception); }
/// <summary> /// Retrieve Certificate from Parent Form /// </summary> /// <returns></returns> private X509Certificate2 getCertificate() { return(SecureMessagingHelper.GetCertificate((MainForm)MdiParent)); }