// This method contains the functionality to be executed when button is pressed. // It ensures all fields are filled before sending, creates and saves an EMail object, // Removes and quarantines URL's, and serialises information from certain textboxes private void SendButtonClick() { List <string> CsvLines = new List <String>(); // Create a list to hold SORT CODE List <string> CsvLines2 = new List <String>(); // Create a list to hold combo box values // If statement prompts user to fill in all fields before message can be sent, by checking if the // component is empty if (string.IsNullOrWhiteSpace(HeaderTextBox) || string.IsNullOrWhiteSpace(SenderTextBox) || string.IsNullOrWhiteSpace(SubjectTextBox) || string.IsNullOrWhiteSpace(SortTextBox) || string.IsNullOrWhiteSpace(BodyTextBox)) { MessageBox.Show("Please Enter All Values"); return; } // Split up the values held in the sortcode box var links = SortTextBox.Split("\t\n ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(s => s.StartsWith("0") || s.StartsWith("1") || s.StartsWith("2") || s.StartsWith("3") || s.StartsWith("4") || s.StartsWith("5") || s.StartsWith("6") || s.StartsWith("7") || s.StartsWith("8") || s.StartsWith("9")); // Feed sort code values into trends file foreach (string s in links) { CsvLines.Add(s); File.AppendAllLines("Data/trends.csv", CsvLines); } // Feed value fromincident box into trends list CsvLines2.Add(IncidentCombo); File.AppendAllLines("Data/trends.csv", CsvLines2); QuarantineURL(); // Call method which quarantines URL's // If statement checks if body contains textspeak abbreviation, if true creates new object and adds // textspeak, then saves to json file if (saveRegular == true) { Email emailMessage = new Email() { Header = HeaderTextBox, Sender = SenderTextBox, Subject = SubjectTextBox, Incident = IncidentCombo, SortCode = SortTextBox, Body = QuarantineURL() }; SaveToFile save = new SaveToFile(); // If cannot be saved display error message, otherwise save file if (!save.ToJsonEMail(emailMessage)) { MessageBox.Show("Error While Saving\n" + save.ErrorCode); } else { MessageBox.Show("Order Saved"); save = null; } } // If statement checks if body contains textspeak abbreviation, if false creates new object and saves standard body, // then saves to json file if (saveRegular == false) { Email emailMessage = new Email() { Header = HeaderTextBox, Sender = SenderTextBox, Subject = SubjectTextBox, Incident = IncidentCombo, Body = BodyTextBox }; SaveToFile save = new SaveToFile(); // If cannot be saved display error message, otherwise save file if (!save.ToJsonEMail(emailMessage)) { MessageBox.Show("Error While Saving\n" + save.ErrorCode); } else { MessageBox.Show("Order Saved"); save = null; } } }