Ejemplo n.º 1
0
 public static ValidFile getInstance()
 {
     if (instance == null)
     {
         instance = new ValidFile();
     }
     return(instance);
 }
Ejemplo n.º 2
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            //try catch to require information from all text boxes
            try
            {
                MessageFilter mf = new MessageFilter();

                Messages m = new Messages(txtName.Text, txtEmail.Text, txtMessage.Text);

                if (mf.Reader(m.InputMessage) == true)
                {
                    //send to quarantine file

                    MessageBox.Show("Unacceptable word(s) detected");
                    QuarantineFile quarantine = QuarantineFile.getInstance();
                    quarantine.MessageList.Add(m);

                    //clear the message box
                    txtMessage.Clear();
                }
                else
                {
                    //send to valid file
                    MessageBox.Show("Message sent");

                    ValidFile valid = ValidFile.getInstance();
                    valid.MessageList.Add(m);

                    //take all areas of valid message from message box and process
                    KeywordFilter keywords      = new KeywordFilter();
                    var           qualification = keywords.LevelSelect(m.InputMessage);
                    var           subject       = keywords.subjectFilter(m.InputMessage);
                    var           uni           = keywords.institutionFilter(m.InputMessage);
                    var           name          = m.Name;
                    var           email         = m.Email;


                    MessageBox.Show("You have chosen: " + qualification);

                    txtMessage.Clear();
                    txtName.Clear();
                    txtEmail.Clear();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please fill all required fields");
            }
        }