using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using LoggingTool.models; using System.Text.RegularExpressions; namespace LoggingTool.interfaces { class TeamUpLogic : ILoggerLogic { List questionnaires; List events; List rawInput; /* **************************************************************** * constructor TeamUpLogic * @description: Creates a TeamUpLogic object to act as the mediator * between Input and Output * ****************************************************************/ public TeamUpLogic() { questionnaires = new List(); events = new List(); rawInput = new List(); } /* **************************************************************** * function addInput * @param input : String * @description : Appends the input into the raw string array * ****************************************************************/ public void addInput(String input) { rawInput.Add(input); } /* ********************************************************************* * function createModels * @description: Parses all the raw input and creates objects out of it. * *********************************************************************/ public void createModels() { //Loop through all the inputs foreach (String input in rawInput) { //If there are more than 4 |'s, this is a questionnaire. if ((input.Split('|').Count() - 1) > 4) questionnaires.Add(new TeamUpQuestionnaire(input)); //Else, this is an TeamUpEvent else events.Add(new TeamUpEvent(input)); } rawInput = new List(); } /* ********************************************************************** * function formatModels * @return: List * @description: Takes the models in the lists (attributes) and formats * them into messages. * **********************************************************************/ public List formatModels() { List resultSet = new List(); foreach (TeamUpQuestionnaire questionnaire in questionnaires) { TeamUpSpreadsheetMessage message = new TeamUpSpreadsheetMessage(TeamUpSpreadsheetMessage.QUESTIONNAIRE, questionnaire.toStringArray()); resultSet.Add(message); } foreach (TeamUpEvent e in events) { TeamUpSpreadsheetMessage message = new TeamUpSpreadsheetMessage(TeamUpSpreadsheetMessage.EVENT, e.toStringArray()); resultSet.Add(message); } return resultSet; } } }