Exemple #1
0
        private void addTicket(string file)
        {
            string       summary      = promptForString("Summary");
            Status       status       = statusSelector();
            Level        priority     = prioritySelector("priority");
            string       submitter    = promptForString("Submitter");
            string       assigned     = promptForString("Assigned");
            string       watching     = promptForString("Watching");
            StreamWriter streamWriter = new StreamWriter(file, append: true);

            Models.Ticket ticket;
            bool          isValid = true;

            do
            {
                char ticketType = Char.Parse(promptForString("(B)ug, (E)nhancment, (T)ask").ToUpper());
                switch (ticketType)
                {
                case 'B':
                    Level severity = prioritySelector("severity");
                    ticket = new Bug(summary, status, priority, submitter, assigned, watching, severity);
                    Console.WriteLine(ticket.CSV());
                    streamWriter.WriteLine(ticket.CSV());
                    Tickets.Add(ticket);
                    break;

                case 'E':
                    string software = promptForString("Software");
                    int    cost     = Int32.Parse(promptForString("Cost"));
                    string reason   = promptForString("Reason");
                    int    estimate = Int32.Parse(promptForString("Estimate"));
                    ticket = new Enhancement(summary, status, priority, submitter, assigned, watching, software, cost, reason, estimate);
                    Console.WriteLine(ticket.CSV());
                    streamWriter.WriteLine(ticket.CSV());

                    Tickets.Add(ticket);
                    break;

                case 'T':
                    string projectName = promptForString("project name");
                    Console.WriteLine(DateTime.Today);
                    DateTime dueDate = DateTime.Parse(promptForString("dueDate"));
                    ticket = new Task(summary, status, priority, submitter, assigned, watching, projectName, dueDate);
                    Console.WriteLine(ticket.CSV());
                    streamWriter.WriteLine(ticket.CSV());

                    Tickets.Add(ticket);

                    break;

                default:
                    Console.WriteLine("Invalid Entry");
                    isValid = false;
                    break;
                }
            } while (!isValid);


            streamWriter.Close();
        }
        public EnhancementFile(string path)
        {
            EnhancementTickets = new List <Enhancement>();
            filePath           = path;

            if (File.Exists(path))
            {
                StreamReader sr = new StreamReader(filePath);
                while (!sr.EndOfStream)
                {
                    Enhancement EnhancementTicket = new Enhancement();
                    string      line = sr.ReadLine();

                    string[] ticketDetails = line.Split(',');
                    EnhancementTicket.TicketID       = Int32.Parse(ticketDetails[0]);
                    EnhancementTicket.TicketSummary  = ticketDetails[1];
                    EnhancementTicket.TicketStatus   = ticketDetails[2];
                    EnhancementTicket.TicketPriority = ticketDetails[3];
                    EnhancementTicket.SubmittedBy    = ticketDetails[4];
                    EnhancementTicket.AssignedTo     = ticketDetails[5];
                    EnhancementTicket.Watching       = ticketDetails[6];
                    EnhancementTicket.Software       = ticketDetails[7];
                    EnhancementTicket.Cost           = ticketDetails[8];
                    EnhancementTicket.Reason         = ticketDetails[9];
                    EnhancementTicket.Estimate       = ticketDetails[10];

                    EnhancementTickets.Add(EnhancementTicket);
                }
                sr.Close();
            }
        }
        public void AddTicket(Enhancement EnhancementTicket)
        {
            EnhancementTicket.TicketID = EnhancementTickets.Count == 0 ? 1 : EnhancementTickets.Max(e => e.TicketID) + 1;
            StreamWriter sw = new StreamWriter(filePath, true);

            sw.WriteLine($"{EnhancementTicket.TicketID},{EnhancementTicket.TicketSummary},{EnhancementTicket.TicketStatus},{EnhancementTicket.TicketPriority}," +
                         $"{EnhancementTicket.SubmittedBy}, {EnhancementTicket.AssignedTo}, {EnhancementTicket.Watching}, {EnhancementTicket.Software}, {EnhancementTicket.Cost}, {EnhancementTicket.Reason}, {EnhancementTicket.Estimate}");
            sw.Close();
            EnhancementTickets.Add(EnhancementTicket);
        }
Exemple #4
0
        private void printTickets(string file)
        {
            if (File.Exists(file))
            {
                StreamReader streamReader = new StreamReader(file);
                while (!streamReader.EndOfStream)
                {
                    string   line = streamReader.ReadLine();
                    string[] arr  = line.Split(',');
                    if (!arr.Contains("TicketID"))
                    {
                        Status status   = (Status)Enum.Parse(typeof(Status), arr[3]);
                        Level  priority = (Level)Enum.Parse(typeof(Level), arr[4]);

                        if (arr[0].Equals("Bug"))
                        {
                            Level         severity = (Level)Enum.Parse(typeof(Level), arr[8]);
                            Models.Ticket bug      = new Bug(arr[2], status, priority, arr[5], arr[6], arr[7], severity);
                            Tickets.Add(bug);
                        }
                        else if (arr[0].Equals("Task"))
                        {
                            DateTime dueDate = DateTime.Parse(arr[9]);

                            Models.Ticket task = new Task(arr[2], status, priority, arr[5], arr[6], arr[7], arr[8],
                                                          dueDate);
                            Tickets.Add(task);
                        }
                        else if (arr[0].Equals("Enhancment"))
                        {
                            int cost     = Int32.Parse(arr[9]);
                            int estimate = Int32.Parse(arr[11]);

                            Models.Ticket enhancement = new Enhancement(arr[2], status, priority, arr[5], arr[6],
                                                                        arr[7], arr[8], cost, arr[10], estimate);
                            Tickets.Add(enhancement);
                        }
                    }
                }

                streamReader.Close();
            }
            else
            {
                Console.WriteLine("File does not exist");
            }
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            List <Ticket> Tickets = new List <Ticket>();

            String          ticketFileName      = AppDomain.CurrentDomain.BaseDirectory + "Tickets.txt";
            String          EnhancementFileName = AppDomain.CurrentDomain.BaseDirectory + "Enhancements.txt";
            String          TaskFileName        = AppDomain.CurrentDomain.BaseDirectory + "Tasks.txt";
            String          choice;
            TicketFile      TicketFile      = new TicketFile(ticketFileName);
            EnhancementFile enhancementFile = new EnhancementFile(EnhancementFileName);
            TaskFile        taskFile        = new TaskFile(TaskFileName);



            do
            {
                Console.WriteLine("\n");
                Console.WriteLine("1) Add Bug Ticket");
                Console.WriteLine("2) Display Bug Tickets");
                Console.WriteLine("3) Add Enhancement Ticket");
                Console.WriteLine("4) Display Enhancement Tickets");
                Console.WriteLine("5) Add Task Ticket");
                Console.WriteLine("6) Display Task Tickets");
                Console.WriteLine("7) Search tickets by status");
                Console.WriteLine("Enter to quit");
                // input response
                choice = Console.ReadLine();

                switch (choice)
                {
                case "1":



                    Bug BugTicket = new Bug();


                    // prompt for ticket summary
                    Console.WriteLine("Enter a summary: ");
                    // save ticket summary
                    BugTicket.TicketSummary = Console.ReadLine();

                    // prompt for ticket status
                    Console.WriteLine("Enter the status: ");
                    // save ticket status
                    BugTicket.TicketStatus = Console.ReadLine();

                    // prompt for priority
                    Console.WriteLine("Enter priority level: ");
                    // save priority
                    BugTicket.TicketPriority = Console.ReadLine();

                    // prompt for submitter name
                    Console.WriteLine("Enter name: ");
                    // save name
                    BugTicket.SubmittedBy = Console.ReadLine();

                    // prompt for assigned
                    Console.WriteLine("Enter name of person the ticket is assigned to: ");
                    // save assigned
                    BugTicket.AssignedTo = Console.ReadLine();

                    // prompt for watcher
                    Console.WriteLine("Enter name of person watching: ");
                    // save watcher
                    BugTicket.Watching = Console.ReadLine();


                    // prompt for severity
                    Console.WriteLine("Enter severity: ");
                    // save severity
                    BugTicket.Severity = Console.ReadLine();


                    TicketFile.AddTicket(BugTicket);
                    Console.WriteLine("Ticket created.");

                    break;

                case "2":
                    foreach (Bug b in TicketFile.BugTickets)
                    {
                        Console.WriteLine(b.Display());
                    }
                    break;

                case "3":
                    Enhancement EnhancementTicket = new Enhancement();


                    // prompt for ticket summary
                    Console.WriteLine("Enter a summary: ");
                    // save ticket summary
                    EnhancementTicket.TicketSummary = Console.ReadLine();

                    // prompt for ticket status
                    Console.WriteLine("Enter the status: ");
                    // save ticket status
                    EnhancementTicket.TicketStatus = Console.ReadLine();

                    // prompt for priority
                    Console.WriteLine("Enter priority level: ");
                    // save priority
                    EnhancementTicket.TicketPriority = Console.ReadLine();

                    // prompt for submitter name
                    Console.WriteLine("Enter name: ");
                    // save name
                    EnhancementTicket.SubmittedBy = Console.ReadLine();

                    // prompt for assigned
                    Console.WriteLine("Enter name of person the ticket is assigned to: ");
                    // save assigned
                    EnhancementTicket.AssignedTo = Console.ReadLine();

                    // prompt for watcher
                    Console.WriteLine("Enter name of person watching: ");
                    // save watcher
                    EnhancementTicket.Watching = Console.ReadLine();

                    //prompt for software
                    Console.WriteLine("Enter name of software: ");
                    // save software
                    EnhancementTicket.Software = Console.ReadLine();

                    //prompt for cost
                    Console.WriteLine("Enter cost: ");
                    // save cost
                    EnhancementTicket.Cost = Console.ReadLine();

                    //prompt for reason
                    Console.WriteLine("Enter reason: ");
                    // save reason
                    EnhancementTicket.Reason = Console.ReadLine();

                    //prompt for estimate
                    Console.WriteLine("Enter estimate: ");
                    // save restimate
                    EnhancementTicket.Estimate = Console.ReadLine();


                    enhancementFile.AddTicket(EnhancementTicket);
                    Console.WriteLine("Ticket created.");
                    break;

                case "4":
                    foreach (Enhancement e in enhancementFile.EnhancementTickets)
                    {
                        Console.WriteLine(e.Display());
                    }
                    break;

                case "5":
                    Task TaskTicket = new Task();



                    // prompt for ticket summary
                    Console.WriteLine("Enter a summary: ");
                    // save ticket summary
                    TaskTicket.TicketSummary = Console.ReadLine();

                    // prompt for ticket status
                    Console.WriteLine("Enter the status: ");
                    // save ticket status
                    TaskTicket.TicketStatus = Console.ReadLine();

                    // prompt for priority
                    Console.WriteLine("Enter priority level: ");
                    // save priority
                    TaskTicket.TicketPriority = Console.ReadLine();

                    // prompt for submitter name
                    Console.WriteLine("Enter name: ");
                    // save name
                    TaskTicket.SubmittedBy = Console.ReadLine();

                    // prompt for assigned
                    Console.WriteLine("Enter name of person the ticket is assigned to: ");
                    // save assigned
                    TaskTicket.AssignedTo = Console.ReadLine();

                    // prompt for watcher
                    Console.WriteLine("Enter name of person watching: ");
                    // save watcher
                    TaskTicket.Watching = Console.ReadLine();

                    //prompt for project name
                    Console.WriteLine("Enter name of project: ");
                    // save project name
                    TaskTicket.projectName = Console.ReadLine();

                    //prompt for Due Date
                    Console.WriteLine("Enter Due Date: ");
                    // save cost
                    TaskTicket.DueDate = Console.ReadLine();


                    taskFile.AddTicket(TaskTicket);
                    Console.WriteLine("Ticket created.");
                    break;


                case "6":


                    foreach (Task t in taskFile.TaskTickets)
                    {
                        Console.WriteLine(t.Display());
                    }
                    break;

                case "7":
                    Console.WriteLine("Enter the status you would like to search (Open/Closed)");
                    var searchString = Console.ReadLine();
                    var results      = new List <Ticket>();

                    results.AddRange(taskFile.Search(searchString));
                    results.AddRange(enhancementFile.Search(searchString));
                    results.AddRange(TicketFile.Search(searchString));

                    foreach (var item in results)
                    {
                        Console.WriteLine(item.Display());
                    }
                    break;
                }
            }while (choice == "1" || choice == "2" || choice == "3" || choice == "4" || choice == "5" || choice == "6" || choice == "7");
        }