static void Main(string[] args) { string file = "ticketSystem.csv"; string enhancedfile = "Enhancements.csv"; string taskfile = "Task.csv"; logger.Info("Program started"); TicketFile ticketFile = new TicketFile(file); EnhancementFile enhancement = new EnhancementFile(enhancedfile); TaskFile task = new TaskFile(taskfile); string choice = ""; do { Console.WriteLine("1) Create a bug ticket file."); Console.WriteLine("a) Read bug Ticket data from file."); Console.WriteLine("2) Create a Enhanced Ticket file"); Console.WriteLine("b) Read Enhanced Ticket data from file."); Console.WriteLine("3) Create a Task Ticket file"); Console.WriteLine("c) Read task Ticket data from file."); Console.WriteLine("Enter to quit"); choice = Console.ReadLine(); logger.Info("User choice: {Choice}", choice); if (choice == "1") { Ticket ticket = new Ticket(); for (int i = 0; i < 10; i++) { Console.WriteLine("Enter a ticket (Y/N)?"); string resp = Console.ReadLine().ToUpper(); logger.Info("User Response {Response}", resp); if (resp != "Y") { break; } Console.WriteLine("Enter the Ticket ID: "); ticket.ticketID = Console.ReadLine(); Console.WriteLine("Please enter summary: "); ticket.summary = Console.ReadLine(); Console.WriteLine("Please enter the status of ticket: "); ticket.status = Console.ReadLine(); Console.WriteLine("Level of priority: "); ticket.priority = Console.ReadLine(); Console.WriteLine("Please enter the submitter: "); ticket.submit = Console.ReadLine(); Console.WriteLine("Who is assigned this ticket: "); ticket.assign = Console.ReadLine(); string input; do { Console.WriteLine("Who is watching (or done to quit): "); input = Console.ReadLine(); if (input != "done" && input.Length > 0) { ticket.watchers.Add(input); } } while (input != "done"); if (ticket.watchers.Count == 0) { ticket.watchers.Add("(no watchers watching this ticket)"); } ticketFile.AddTicket(ticket); } } else if (choice == "a") { foreach (Ticket t in ticketFile.Tickets) { Console.WriteLine(t.Display()); } } else if (choice == "2") { EnhancementTicket enhancementTicket = new EnhancementTicket(); for (int i = 0; i < 10; i++) { Console.WriteLine("Enter a ticket (Y/N)?"); string resp = Console.ReadLine().ToUpper(); logger.Info("User Response {Response}", resp); if (resp != "Y") { break; } Console.WriteLine("Enter the Ticket ID: "); enhancementTicket.ticketID = Console.ReadLine(); Console.WriteLine("Please enter summary: "); enhancementTicket.summary = Console.ReadLine(); Console.WriteLine("Please enter the status of ticket: "); enhancementTicket.status = Console.ReadLine(); Console.WriteLine("Level of priority: "); enhancementTicket.priority = Console.ReadLine(); Console.WriteLine("Please enter the submitter: "); enhancementTicket.submit = Console.ReadLine(); Console.WriteLine("Who is assigned this ticket: "); enhancementTicket.assign = Console.ReadLine(); Console.WriteLine("What is software for this ticket: "); enhancementTicket.software = Console.ReadLine(); Console.WriteLine("How much is this ticket: "); enhancementTicket.cost = double.Parse(Console.ReadLine()); Console.WriteLine("What is the reason for this ticket: "); enhancementTicket.reason = Console.ReadLine(); Console.WriteLine("What is the estimate of this ticket: "); enhancementTicket.estimate = Console.ReadLine(); string input; do { Console.WriteLine("Who is watching (or done to quit): "); input = Console.ReadLine(); if (input != "done" && input.Length > 0) { enhancementTicket.watchers.Add(input); } } while (input != "done"); if (enhancementTicket.watchers.Count == 0) { enhancementTicket.watchers.Add("(no watchers watching this ticket)"); } enhancement.AddTicket(enhancementTicket); } } else if (choice == "b") { foreach (EnhancementTicket e in enhancement.EnhancedTickets) { Console.WriteLine(e.Display()); } } else if (choice == "3") { TaskTicket taskTicket = new TaskTicket(); for (int i = 0; i < 10; i++) { Console.WriteLine("Enter a ticket (Y/N)?"); string resp = Console.ReadLine().ToUpper(); logger.Info("User Response {Response}", resp); if (resp != "Y") { break; } Console.WriteLine("Enter the Ticket ID: "); taskTicket.ticketID = Console.ReadLine(); Console.WriteLine("Please enter summary: "); taskTicket.summary = Console.ReadLine(); Console.WriteLine("Please enter the status of ticket: "); taskTicket.status = Console.ReadLine(); Console.WriteLine("Level of priority: "); taskTicket.priority = Console.ReadLine(); Console.WriteLine("Please enter the submitter: "); taskTicket.submit = Console.ReadLine(); Console.WriteLine("Who is assigned this ticket: "); taskTicket.assign = Console.ReadLine(); Console.WriteLine("What is name of the project for this ticket: "); taskTicket.projectName = Console.ReadLine(); Console.WriteLine("What is the due date of this task: "); taskTicket.dueDate = Console.ReadLine(); string input; do { Console.WriteLine("Who is watching (or done to quit): "); input = Console.ReadLine(); if (input != "done" && input.Length > 0) { taskTicket.watchers.Add(input); } } while (input != "done"); if (taskTicket.watchers.Count == 0) { taskTicket.watchers.Add("(no watchers watching this ticket)"); } task.AddTicket(taskTicket); } } else if (choice == "c") { foreach (TaskTicket t in task.TaskTickets) { Console.WriteLine(t.Display()); } } } while (choice == "1" || choice == "a" || choice == "2" || choice == "b" || choice == "3" || choice == "c"); logger.Info("Program ended"); }
static void Main(string[] args) { NLog.Logger logger = NLog.Web.NLogBuilder.ConfigureNLog(Directory.GetCurrentDirectory() + "\\nlog.config").GetCurrentClassLogger(); logger.Info("Program Started"); // create ticket files for each type TicketFile defects = new TicketFile("Tickets.csv", "Defect"); TicketFile enhancements = new TicketFile("Enhancements.csv", "Enhancement"); TicketFile tasks = new TicketFile("Task.csv", "Task"); string userChoice; do { Console.Write("\n1. Read data from file\n2. Add data to file\n3. Search for ticket\nEnter any key to exit\n>"); userChoice = Console.ReadLine(); // choice 1 - read data if (userChoice == "1") { //ask what file to read from Console.Write("\nWhich type of ticket do you wish to look at?\n1. Bugs/Defects\n2. Enhancements\n3. Tasks\n>"); int readFrom; while (!Int32.TryParse(Console.ReadLine(), out readFrom)) { Console.Write("\nAnswer must be an integer\n1. Bugs/Defects\n2. Enhancements\n3. Tasks\n>"); } //read from that file if (readFrom == 1) { foreach (Defect defect in defects.Tickets) { Console.WriteLine("\n" + defect.Display()); } logger.Info("Defects Displayed"); } else if (readFrom == 2) { foreach (Enhancement en in enhancements.Tickets) { Console.WriteLine("\n" + en.Display()); } logger.Info("Enhancements Displayed"); } else if (readFrom == 3) { foreach (Task task in tasks.Tickets) { Console.WriteLine("\n" + task.Display()); } logger.Info("Tasks Displayed"); } } // choice 2 - add data else if (userChoice == "2") { //ask what file to write to Console.Write("\nWhich type of ticket do you wish to write?\n1. Bug/Defect\n2. Enhancement\n3. Task\n>"); int toWrite; while (!Int32.TryParse(Console.ReadLine(), out toWrite)) { Console.Write("\nAnswer must be an integer\n1. Bugs/Defect\n2. Enhancement\n3. Task\n>"); } //collect information //summary, status, priority, submitter, assigned, watching Console.Write("Enter Summary: "); string summary = Console.ReadLine(); Console.Write("Enter Status: "); string status = Console.ReadLine(); Console.Write("Enter Priority: "); string priority = Console.ReadLine(); Console.Write("Enter Submitter: "); string submitter = Console.ReadLine(); Console.Write("Enter Assigned: "); string assigned = Console.ReadLine(); List <string> watchers = new List <string>(); string watcher; do { Console.Write("Enter Watching (or done to quit): "); watcher = Console.ReadLine(); if (!watcher.Equals("done")) { watchers.Add(watcher); } } while(!watcher.Equals("done")); //defect - id, severity, create the new ticket if (toWrite == 1) { //create ticket Defect defect = new Defect(); // add id + severity defect.id = defects.getNewID(); Console.Write("Enter Severity: "); defect.severity = Console.ReadLine(); //add everything else defect.summary = summary; defect.status = status; defect.priority = priority; defect.submitter = submitter; defect.assigned = assigned; defect.watching = watchers; defects.AddTicket(defect, toWrite); } //enhancement - id, software, cost, reason, estimate, create the new ticket else if (toWrite == 2) { //create ticket Enhancement en = new Enhancement(); //add id, software, cost, reason, estimate en.id = enhancements.getNewID(); Console.Write("Enter Software: "); en.software = Console.ReadLine(); Console.Write("Enter Cost: "); en.cost = Double.Parse(Console.ReadLine()); Console.Write("Enter Reason: "); en.reason = Console.ReadLine(); Console.Write("Enter Estimate: "); en.estimate = Double.Parse(Console.ReadLine()); //add everything else en.summary = summary; en.status = status; en.priority = priority; en.submitter = submitter; en.assigned = assigned; en.watching = watchers; enhancements.AddTicket(en, toWrite); } //task - id, project name, due date, create the new ticket else if (toWrite == 3) { //create ticket Task task = new Task(); //add id, project name, due date task.id = tasks.getNewID(); Console.Write("Enter Project Name: "); task.projectName = Console.ReadLine(); Console.Write("Enter Due Date (mm/dd/yyyy): "); DateTime dueDate; while (!DateTime.TryParse(Console.ReadLine(), out dueDate)) { logger.Info("Invalid date"); Console.Write("Plese enter date(mm/dd/yyyy): "); } task.dueDate = dueDate; //add everything else task.summary = summary; task.status = status; task.priority = priority; task.submitter = submitter; task.assigned = assigned; task.watching = watchers; tasks.AddTicket(task, toWrite); } } else if (userChoice == "3") { //status, priority, or submitter Console.Write("Search by:\n1. Status\n2. Priority\n3. Submitter\n>"); int searchBy; Int32.TryParse(Console.ReadLine(), out searchBy); //search term Console.Write("Search For\n>"); string searchTerm = Console.ReadLine(); //search List <Ticket> ticketsBySearch = new List <Ticket>(); switch (searchBy) { case 1: //status ticketsBySearch.AddRange(defects.Tickets.Where(t => t.status.Equals(searchTerm, StringComparison.OrdinalIgnoreCase)) .Concat(enhancements.Tickets.Where(t => t.status.Equals(searchTerm, StringComparison.OrdinalIgnoreCase))) .Concat(tasks.Tickets.Where(t => t.status.Equals(searchTerm, StringComparison.OrdinalIgnoreCase))).ToList()); break; case 2: //priority ticketsBySearch.AddRange(defects.Tickets.Where(t => t.priority.Equals(searchTerm, StringComparison.OrdinalIgnoreCase)) .Concat(enhancements.Tickets.Where(t => t.priority.Equals(searchTerm, StringComparison.OrdinalIgnoreCase))) .Concat(tasks.Tickets.Where(t => t.priority.Equals(searchTerm, StringComparison.OrdinalIgnoreCase))).ToList()); break; case 3: //submitter ticketsBySearch.AddRange(defects.Tickets.Where(t => t.submitter.Equals(searchTerm, StringComparison.OrdinalIgnoreCase)) .Concat(enhancements.Tickets.Where(t => t.submitter.Equals(searchTerm, StringComparison.OrdinalIgnoreCase))) .Concat(tasks.Tickets.Where(t => t.submitter.Equals(searchTerm, StringComparison.OrdinalIgnoreCase))).ToList()); break; } //result logger.Info($"{ticketsBySearch.Count()} tickets with \"{searchTerm}\" search term"); Console.Write($"The {ticketsBySearch.Count()} tickets with \"{searchTerm}\" search term:"); foreach (Ticket ticket in ticketsBySearch) { Console.WriteLine("\n" + ticket.Display()); } } } while (userChoice == "1" || userChoice == "2" || userChoice == "3"); logger.Info("Program Ended"); }
static void Main(string[] args) { string ticketFilePath = Directory.GetCurrentDirectory() + "\\tickets.csv"; logger.Info("Program started"); TicketFile ticketFile = new TicketFile(ticketFilePath); string choice = ""; do { Console.WriteLine("1) Add Ticket"); Console.WriteLine("2) Display All Tickets"); Console.WriteLine("Enter to quit"); choice = Console.ReadLine(); logger.Info("User choice: {Choice}", choice); if (choice == "1") { Ticket ticket = new Ticket(); Console.WriteLine("Enter ticket summary"); ticket.summary = Console.ReadLine(); Console.WriteLine("Enter ticket status"); ticket.status = Console.ReadLine(); Console.WriteLine("Enter ticket priority"); ticket.priority = Console.ReadLine(); Console.WriteLine("Enter ticket submitter"); ticket.submitter = Console.ReadLine(); Console.WriteLine("Enter ticket asignee"); ticket.assigned = Console.ReadLine(); string input; do { Console.WriteLine("Enter watcher (or done to quit)"); input = Console.ReadLine(); if (input != "done" && input.Length > 0) { ticket.watching.Add(input); } }while (input != "done"); if (ticket.watching.Count == 0) { ticket.watching.Add("(no watchers listed)"); } ticketFile.AddTicket(ticket); } else if (choice == "2") { foreach (Ticket m in ticketFile.Tickets) { Console.WriteLine(m.Display()); } } } while (choice == "1" || choice == "2"); logger.Info("Program ended"); }