Esempio n. 1
0
        public TaskFile(string path)
        {
            TaskTickets = new List <TaskTicket>();
            filePath    = path;

            try
            {
                StreamReader sr = new StreamReader(filePath);
                sr.ReadLine();
                while (!sr.EndOfStream)
                {
                    TaskTicket ticket = new TaskTicket();
                    string     line   = sr.ReadLine();

                    int idx = line.IndexOf('"');
                    if (idx == -1)
                    {
                        string[] ticketDetails = line.Split(',');
                        ticket.ticketID    = (ticketDetails[0]);
                        ticket.summary     = ticketDetails[1];
                        ticket.status      = ticketDetails[2];
                        ticket.priority    = ticketDetails[3];
                        ticket.submit      = ticketDetails[4];
                        ticket.assign      = ticketDetails[5];
                        ticket.watchers    = ticketDetails[6].Split('|').ToList();
                        ticket.projectName = ticketDetails[7];
                        ticket.dueDate     = ticketDetails[8];
                    }
                    else
                    {
                        ticket.ticketID    = (line.Substring(0, idx - 1));
                        line               = line.Substring(idx + 1);
                        idx                = line.IndexOf('"');
                        ticket.summary     = line.Substring(0, idx);
                        line               = line.Substring(idx + 2);
                        ticket.status      = line.Substring(0, idx);
                        line               = line.Substring(idx + 3);
                        ticket.priority    = line.Substring(0, idx);
                        line               = line.Substring(idx + 4);
                        ticket.submit      = line.Substring(0, idx);
                        line               = line.Substring(idx + 5);
                        ticket.assign      = line.Substring(0, idx);
                        line               = line.Substring(idx + 6);
                        ticket.watchers    = line.Split('|').ToList();
                        line               = line.Substring(idx + 7);
                        ticket.projectName = line.Substring(0, idx);
                        line               = line.Substring(idx + 8);
                        ticket.dueDate     = line.Substring(0, idx);
                        line               = line.Substring(idx + 9);
                    }
                    TaskTickets.Add(ticket);
                }
                sr.Close();
                logger.Info("Tickets in file {Count}", TaskTickets.Count);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Esempio n. 2
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);
     }
 }
Esempio n. 3
0
        public static TaskTicket createTicketFromFile(string line)
        {
            TaskTicket taskTicket = new TaskTicket();

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

            taskTicket.ticketId    = Int32.Parse(fieldsArr[0]);
            taskTicket.summary     = fieldsArr[1];
            taskTicket.status      = fieldsArr[2];
            taskTicket.priority    = fieldsArr[3];
            taskTicket.submitter   = fieldsArr[4];
            taskTicket.assigned    = fieldsArr[5];
            taskTicket.watchers    = Ticket.createWatchersFromString(fieldsArr[6]);
            taskTicket.projectName = fieldsArr[7];
            taskTicket.dueDate     = DateTime.Parse(fieldsArr[8]);
            return(taskTicket);
        }
Esempio n. 4
0
        public static TaskTicket 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 project name");
            string projectName = Console.ReadLine();

            Console.WriteLine("Enter a due date, ( 3/21/2021 )");
            string     dueDate    = Console.ReadLine();
            TaskTicket taskTicket = new TaskTicket();

            taskTicket.ticketId    = ticketId;
            taskTicket.summary     = summary;
            taskTicket.status      = status;
            taskTicket.priority    = priority;
            taskTicket.submitter   = submitter;
            taskTicket.assigned    = assigned;
            taskTicket.watchers    = watchers;
            taskTicket.projectName = projectName;
            taskTicket.dueDate     = DateTime.Parse(dueDate);;

            return(taskTicket);
        }
Esempio n. 5
0
 public void AddTicket(TaskTicket ticket)
 {
     try
     {
         ticket.ticketID = TaskTickets.Max(m => m.ticketID) + 1;
         string       summary  = ticket.summary;
         string       status   = ticket.status;
         string       priority = ticket.priority;
         string       submit   = ticket.submit;
         string       assgin   = ticket.assign;
         string       project  = ticket.projectName;
         StreamWriter sw       = new StreamWriter(filePath, true);
         sw.WriteLine($"{ticket.ticketID},{summary},{status},{priority},{submit},{assgin},{string.Join("|", ticket.watchers)}," +
                      $"{project}, {ticket.dueDate}");
         sw.Close();
         TaskTickets.Add(ticket);
         logger.Info("Ticket id {Id} added", ticket.ticketID);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
     }
 }
Esempio n. 6
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 == "");
        }
Esempio n. 7
0
        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");
        }