예제 #1
0
 public void loadTicketsFromFile(string ticketType, string filename)
 {
     if (File.Exists(filename))
     {
         StreamReader sr1       = new StreamReader(filename);
         Boolean      firstLine = true;
         while (!sr1.EndOfStream)
         {
             string line = sr1.ReadLine();
             if (firstLine)
             {
                 if (ticketType == "bugTicket")
                 {
                     this.bugHeaders = line;
                 }
                 else if (ticketType == "taskTicket")
                 {
                     this.taskHeaders = line;
                 }
                 else if (ticketType == "enhancementTicket")
                 {
                     this.enhancementHeaders = line;
                 }
                 firstLine = false;
             }
             else
             {
                 if (ticketType == "bugTicket")
                 {
                     this.bugTickets.Add(BugTicket.createTicketFromFile(line));
                 }
                 else if (ticketType == "taskTicket")
                 {
                     this.taskTickets.Add(TaskTicket.createTicketFromFile(line));
                 }
                 else if (ticketType == "enhancementTicket")
                 {
                     this.enhancementTickets.Add(EnhancementTicket.createTicketFromFile(line));
                 }
                 else
                 {
                 }
                 //this.tickets.Add();
             }
         }
         sr1.Close();
     }
     else
     {
         Console.WriteLine("File does not exist" + filename);
     }
 }
예제 #2
0
        public static BugTicket createTicketFromFile(string line)
        {
            BugTicket bugTicket = new BugTicket();

            string[] fieldsArr = line.Split(',');

            bugTicket.ticketId  = Int32.Parse(fieldsArr[0]);
            bugTicket.summary   = fieldsArr[1];
            bugTicket.status    = fieldsArr[2];
            bugTicket.priority  = fieldsArr[3];
            bugTicket.submitter = fieldsArr[4];
            bugTicket.assigned  = fieldsArr[5];
            bugTicket.watchers  = Ticket.createWatchersFromString(fieldsArr[6]);
            bugTicket.severity  = fieldsArr[7];
            return(bugTicket);
        }
예제 #3
0
        public static BugTicket createTicket(int ticketId)
        {
            // BASE PORTION
            Console.WriteLine("Enter a summary");
            string summary = Console.ReadLine();

            Console.WriteLine("Enter the status (Open/Closed)");
            string status = Console.ReadLine();

            Console.WriteLine("Enter the priority (Low/Medium/High)");
            string priority = Console.ReadLine();

            Console.WriteLine("Enter the submitter");
            string submitter = Console.ReadLine();

            Console.WriteLine("Enter the assigned");
            string assigned = Console.ReadLine();

            Console.WriteLine("Enter the watching");
            List <string> watchers = new List <string>();
            string        watching = Console.ReadLine();

            // while loop to add more
            watchers.Add(watching);

            Console.WriteLine("Enter a severity (Low/Medium/High)");
            string severity = Console.ReadLine();

            BugTicket bugTicket = new BugTicket();

            bugTicket.ticketId  = ticketId;
            bugTicket.summary   = summary;
            bugTicket.status    = status;
            bugTicket.priority  = priority;
            bugTicket.submitter = submitter;
            bugTicket.assigned  = assigned;
            bugTicket.watchers  = watchers;
            bugTicket.severity  = severity;
            return(bugTicket);
        }
예제 #4
0
        static void Main(string[] args)
        {
            TicketManager manager = new TicketManager();

            manager.loadTicketsFromFile("bugTicket", "bugTickets.csv");
            manager.loadTicketsFromFile("taskTicket", "taskTickets.csv");
            manager.loadTicketsFromFile("enhancementTicket", "enhancementTickets.csv");


            string typeSelected = "";
            string filename     = "";

            do
            {
                Console.WriteLine("Please Select Type Of Ticket To Manage\n 1 - Bug Tickets\n 2 - Task Tickets\n 3 - Enhancement Tickets");
                string typeChoice = Console.ReadLine();
                if (typeChoice == "1")
                {
                    typeSelected = "bugTicket";
                    filename     = "bugTickets.csv";
                }
                else if (typeChoice == "2")
                {
                    typeSelected = "taskTicket";
                    filename     = "taskTickets.csv";
                }
                else if (typeChoice == "3")
                {
                    typeSelected = "enhancementTicket";
                    filename     = "enhancementTickets.csv";
                }
                else
                {
                    typeSelected = "no Choice";
                }

                string choice;
                if (typeSelected != "no Choice")
                {
                    do
                    {
                        // ask user a question
                        Console.WriteLine("\n1) List Tickets From File.");
                        Console.WriteLine("2) Create New Ticket And Write To File.");
                        Console.WriteLine("Enter any other key to exit.");
                        // input response
                        choice = Console.ReadLine();

                        if (choice == "1")
                        {
                            manager.listTickets(typeSelected);
                        }
                        else if (choice == "2")
                        {
                            if (typeSelected == "bugTicket")
                            {
                                int id = manager.bugTickets[manager.bugTickets.Count - 1].ticketId + 1;
                                manager.bugTickets.Add(BugTicket.createTicket(id));
                                manager.writeTicketsToFile("bugTicket", "bugTickets.csv");
                            }
                            else if (typeSelected == "taskTicket")
                            {
                                int id = manager.taskTickets[manager.taskTickets.Count - 1].ticketId + 1;
                                manager.taskTickets.Add(TaskTicket.createTicket(id));
                                manager.writeTicketsToFile("taskTicket", "taskTickets.csv");
                            }
                            else if (typeSelected == "enhancementTicket")
                            {
                                int id = manager.enhancementTickets[manager.enhancementTickets.Count - 1].ticketId + 1;
                                manager.enhancementTickets.Add(EnhancementTicket.createTicket(id));
                                manager.writeTicketsToFile("enhancementTicket", "enhancementTickets.csv");
                            }
                            manager.writeTicketsToFile(typeSelected, filename);
                        }
                        else
                        {
                            typeSelected = "";
                        }
                    } while (choice == "1" || choice == "2");
                }
                else
                {
                    Console.WriteLine("Please Make a Valid Choice");
                    typeSelected = "";
                }
            } while (typeSelected == "");
        }