コード例 #1
0
        /// <summary>
        /// This method exports the Json file to the users desktop
        /// </summary>
        private void ExportJsonFile()
        {
            try
            {
                menuValidation.RetrieveStoredList();

                // Sets a string as the path for where to store the JSON file.
                string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "/EustonLeisureMessages.json";

                jsonClass.Serialize(menuValidation.listOfMessages, path);

                MessageBox.Show("JSON Exported");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #2
0
        /// <summary>
        /// This click event method deals with how the message is saved
        /// </summary>
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            // Sets the path as a string
            string path = @".\EustonLeisureMessages.json";

            // If the message is a Tweet, then the method SearchForHashTagsAndMentions() is called
            if (validation.Header.StartsWith("T"))
            {
                processing.SearchForHashTagsAndMentions(processedText);
            }

            // If the message is an Email, then the method SearchForSIR() is called
            if (validation.Header.StartsWith("E") && validation.Subject.StartsWith("SIR"))
            {
                processing.SearchForSIR(processedText);
            }

            // Adds the message to a list
            validation.AddMessageToList(processedText);

            // Converts the whole list of messages into JSON and stores it
            json.Serialize(validation.listOfMessages, path);

            // Sets the save button to IsEnabled = false
            saveButton.IsEnabled = false;

            validation.EndOfCycle();

            // Clears the textboxes
            convertedMessageHeaderTxt.Text  = string.Empty;
            convertedMessageSenderTxt.Text  = string.Empty;
            convertedMessageSubjectTxt.Text = string.Empty;
            convertedMessageBodyTxt.Text    = string.Empty;
            messageHeaderTxt.Text           = string.Empty;
            messageBodyTxt.Text             = string.Empty;
        }