Ejemplo n.º 1
0
        public Deployment NewDeployment(string loc, Vehicle[] veh, Resource[] res, FireFighter[] Ff, string com, int num)
        {
            Deployer.DeployerProgram tmp   = new Deployer.DeployerProgram();
            Deployer.Deployment      test  = tmp.Main();
            DeploymentFactory        tempo = new DeploymentFactory();
            Deployment temporary           = tempo.NewDeployment(test.Location, null, null, null, test.Comment, test.Id);

            return(temporary);
        }
Ejemplo n.º 2
0
        public void UserMode(string sel)
        {
            string toDisplay;
            int    DeployCount;

            switch (sel)
            {
            case "-v":
                DeployCount = GetListDeployments().Count();
                _t.Display("Viewing Deployments(" + DeployCount + "):\n" +
                           "(1)List last X Deployments.\n" +
                           "(2)List by X.\n");
                if (DeployCount == 0)
                {
                    _t.Display("The deployment file seems to be empty.\nBefore you view deployments you should create one!\n");
                    return;
                }
                int UserChoice = ValidInputRange(_t.GetInt(), 1, 2);
                int howMany;
                if (UserChoice == 1)
                {
                    _t.Display("How many deployments do you wish to view?(" + DeployCount + ") \n");
                    howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);
                    _t.Display("Last " + howMany + " Deployments: \n");
                    toDisplay = "";

                    for (int i = 0; i < howMany; i++)
                    {
                        toDisplay += "(" + (i + 1) + ") At: " + GetListDeployments().ElementAt((DeployCount - 1) - i).Location + " Time: " + GetListDeployments().ElementAt((DeployCount - 1) - i).DateAndTime + "\n";
                    }
                    _t.Display(toDisplay);
                    _t.Display("To go into detail type corresponding number.\n");
                    howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);
                    _t.Display(GetListDeployments().ElementAt((DeployCount - 1) - (howMany - 1)).ToString() + "\n");
                }
                else
                {
                    _t.Display("List by:\n" +
                               "(1)List by Firefighter.\n" +
                               "(2)List by Vehicle.\n");
                    UserChoice = ValidInputRange(_t.GetInt(), 1, 2);
                    _t.Display("How many deployments do you wish to view?(" + DeployCount + ") \n");
                    howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);

                    List <Deployment> deploys = GetListDeployments();
                    if (UserChoice == 1 && GetListFireFighter().Count == 0)
                    {
                        _t.Display("Seems like you dont have any Firefighters in your basedata!\n");
                        return;
                    }

                    if (UserChoice == 1)
                    {
                        List <FireFighter> firefighters = GetListFireFighter();
                        FireFighter        tmp;
                        _t.Display("Select for which Firefighter you wish to search:\n");
                        ViewList(firefighters);
                        UserChoice = ValidInputRange(_t.GetInt(), 1, firefighters.Count());
                        tmp        = firefighters.ElementAt(UserChoice - 1);

                        int amountD = deploys.Count();
                        int amountF;
                        int counter = 0;
                        for (int k = 0; k < amountD; k++)
                        {
                            amountF = deploys.ElementAt(k).FireFighters.Length;
                            for (int j = 0; j < amountF; j++)
                            {
                                if (deploys.ElementAt(k).FireFighters[j].Equals(tmp) && counter < howMany)
                                {
                                    _t.Display("(" + (k + 1) + ") At: " + deploys.ElementAt(k).Location + " Time: " + deploys.ElementAt(k).DateAndTime + "\n");
                                    counter++;
                                }
                            }
                        }
                        if (!(counter == 0))
                        {
                            _t.Display("To go into detail type corresponding number.\n");
                            UserChoice = ValidInputRange(_t.GetInt(), 1, counter);
                            _t.Display(GetListDeployments().ElementAt(UserChoice - 1).ToString() + "\n");
                        }
                        else
                        {
                            _t.Display("Couldnt find any Deployments with your selection.\n");
                        }
                    }
                    if (UserChoice == 2 && GetListVehicles().Count == 0)
                    {
                        _t.Display("Seems like you dont have any Vehicles in your basedata!\n");
                        return;
                    }
                    if (UserChoice == 2)
                    {
                        List <Vehicle> vehicles = GetListVehicles();
                        Vehicle        tmp;
                        _t.Display("Select for which car you wish to search:\n");
                        ViewList(vehicles);
                        UserChoice = ValidInputRange(_t.GetInt(), 1, vehicles.Count());
                        tmp        = vehicles.ElementAt(UserChoice - 1);

                        int amountD = deploys.Count();
                        int amountC;
                        int counter = 0;
                        for (int k = 0; k < amountD; k++)
                        {
                            amountC = deploys.ElementAt(k).Cars.Length;
                            for (int j = 0; j < amountC; j++)
                            {
                                if (deploys.ElementAt(k).Cars[j].Equals(tmp) && counter < howMany)
                                {
                                    _t.Display("(" + (k + 1) + ") At: " + deploys.ElementAt(k).Location + " Time: " + deploys.ElementAt(k).DateAndTime + "\n");
                                    counter++;
                                }
                            }
                        }
                        if (!(counter == 0))
                        {
                            _t.Display("To go into detail type corresponding number.\n");
                            UserChoice = ValidInputRange(_t.GetInt(), 1, counter);
                            _t.Display(GetListDeployments().ElementAt(UserChoice - 1).ToString() + "\n");
                        }
                        else
                        {
                            _t.Display("Couldnt find any Deployments with your selection.\n");
                        }
                    }
                }

                break;

            case "-d":
                int number = 0;

                Vehicle[]     v = new Vehicle[number];
                FireFighter[] p = new FireFighter[number];
                Resources[]   r = new Resources[number];

                List <Deployment> liste = GetListDeployments();

                _t.Display("Where was the Deployment?\n");
                string loc = _t.GetString();
                _t.Display("How many Vehicles participated in the Deployment?\n");
                List <Vehicle> cars = GetListVehicles();
                if (cars.Count == 0)
                {
                    _t.Display("It appears as if you have no vehicles in your basedata\n" +
                               "You might wish to ask your local admin to create some for you.\n\n");
                }
                else
                {
                    number = ValidInputRange(_t.GetInt(), 0, cars.Count);
                    v      = new Vehicle[number];
                    for (int i = 0; i < number; i++)
                    {
                        v[i] = cars.ElementAt(ObjectSelection(cars) - 1);
                    }
                }
                _t.Display("How much staff participated in the Deployment?\n");
                List <FireFighter> staff = GetListFireFighter();
                if (staff.Count == 0)
                {
                    _t.Display("It appears as if you have no staff in your basedata\n" +
                               "You might wish to ask your local admin to create some for you.\n\n");
                }
                else
                {
                    number = ValidInputRange(_t.GetInt(), 0, staff.Count);
                    p      = new FireFighter[number];
                    for (int i = 0; i < number; i++)
                    {
                        p[i] = staff.ElementAt(ObjectSelection(staff) - 1);
                    }
                }
                _t.Display("How many resources were used in the Deployment?\n");
                List <Resources> res = GetListResources();
                if (res.Count == 0)
                {
                    _t.Display("It appears as if you have no resources in your basedata\n" +
                               "You might wish to ask your local admin to create some for you.\n\n");
                }
                else
                {
                    number = ValidInputRange(_t.GetInt(), 0, res.Count);
                    r      = new Resources[number];
                    for (int i = 0; i < number; i++)
                    {
                        r[i] = res.ElementAt(ObjectSelection(res) - 1);
                    }
                }
                _t.Display("Any comments?\n");
                string com = _t.GetString();

                DeploymentFactory DF   = new DeploymentFactory();
                Deployment        test = DF.NewDeployment(loc, v, r, p, com, AllDeployments.Count() + 1);
                liste.Add(test);
                GasExaminationCheck();
                break;

            case "-g":
                GasExaminationCheck();
                break;

            case "-w":

                DeployCount = GetListDeployments().Count();
                if (DeployCount == 0)
                {
                    _t.Display("The deployment file seems to be empty.\nBefore you view deployments you should create one!\n");
                    return;
                }
                _t.Display("How many deployments do you wish to view?(" + DeployCount + ") \n");
                howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);
                _t.Display("Last " + howMany + " Deployments: \n");
                toDisplay = "";

                for (int i = 0; i < howMany; i++)
                {
                    toDisplay += "(" + (i + 1) + ") At: " + GetListDeployments().ElementAt((DeployCount - 1) - i).Location + " Time: " + GetListDeployments().ElementAt((DeployCount - 1) - i).DateAndTime + "\n";
                }
                _t.Display(toDisplay);
                howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);
                _t.Display(GetListDeployments().ElementAt((DeployCount - 1) - (howMany - 1)).GenerateWebReport() + "\n");
                break;

            case "-q":
                System.Environment.Exit(1);
                break;
            }
        }
Ejemplo n.º 3
0
        public void UserMode(string sel)
        {
            string toDisplay;
            int    DeployCount;

            switch (sel)    //Nutzermenü
            {
            case "-v":
                DeployCount = GetListDeployments().Count();
                _t.Display("Viewing Deployments(" + DeployCount + "):<br />" +
                           "(1)List last X Deployments.<br />" +
                           "(2)List by X.<br />");
                if (DeployCount == 0)       //Checkt die Anzahl der Einsätze
                {
                    _t.Display("The deployment file seems to be empty.<br />Before you view deployments you should create one!<br />");
                    return;
                }
                int UserChoice = ValidInputRange(_t.GetInt(), 1, 2);        //untersucht ob die Angabe 1/2 oder dazwischen ist
                int howMany;
                if (UserChoice == 1)
                {
                    _t.Display("How many deployments do you wish to view?(" + DeployCount + ") <br />");
                    howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);     //ist die gesuchte zahl zwischen 1 und der existierenden Anzahl?
                    _t.Display("Last " + howMany + " Deployments: <br />");
                    toDisplay = "";

                    for (int i = 0; i < howMany; i++)       //fügt die Einsätze einem String hinzu-
                    {
                        toDisplay += "(" + (i + 1) + ") At: " + GetListDeployments().ElementAt((DeployCount - 1) - i).Location + " Time: " + GetListDeployments().ElementAt((DeployCount - 1) - i).DateAndTime + "<br />";
                    }
                    _t.Display(toDisplay);      //-stellt diesen String dar
                    _t.Display("To go into detail type corresponding number.<br />");
                    howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);
                    _t.Display(GetListDeployments().ElementAt((DeployCount - 1) - (howMany - 1)).ToString() + "<br />");
                }
                else
                {
                    _t.Display("List by:<br />" +
                               "(1)List by Firefighter.<br />" +
                               "(2)List by Vehicle.<br />");
                    UserChoice = ValidInputRange(_t.GetInt(), 1, 2);
                    _t.Display("How many deployments do you wish to view?(" + DeployCount + ") <br />");
                    howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);

                    List <Deployment> deploys = GetListDeployments();    // fügt der liste "deploys" alle einsätze hinzu
                    if (UserChoice == 1 && GetListFireFighter().Count == 0)
                    {
                        _t.Display("Seems like you dont have any Firefighters in your basedata!<br />");
                        return;
                    }

                    if (UserChoice == 1)
                    {
                        List <FireFighter> firefighters = GetListFireFighter();
                        FireFighter        tmp;
                        _t.Display("Select for which Firefighter you wish to search:<br />");
                        ViewList(firefighters);
                        UserChoice = ValidInputRange(_t.GetInt(), 1, firefighters.Count());
                        tmp        = firefighters.ElementAt(UserChoice - 1); //-1 da listen(und arrays) bei 0 anfangen

                        int amountD = deploys.Count();
                        int amountF;
                        int counter = 0;
                        for (int k = 0; k < amountD; k++)
                        {
                            amountF = deploys.ElementAt(k).FireFighters.Length;
                            for (int j = 0; j < amountF; j++)
                            {
                                if (deploys.ElementAt(k).FireFighters[j].Equals(tmp) && counter < howMany)
                                {
                                    _t.Display("(" + (k + 1) + ") At: " + deploys.ElementAt(k).Location + " Time: " + deploys.ElementAt(k).DateAndTime + "<br />");     //gibt nacheinander Feuerwehrmitglieder an
                                    counter++;
                                }
                            }
                        }
                        if (!(counter == 0))
                        {
                            _t.Display("To go into detail type corresponding number.<br />");
                            UserChoice = ValidInputRange(_t.GetInt(), 1, counter);
                            _t.Display(GetListDeployments().ElementAt(UserChoice - 1).ToString() + "<br />");       //sucht Einsatz nach ID heraus (-1 da [siehe bei vorletztem "if"])
                        }
                        else
                        {
                            _t.Display("Couldnt find any Deployments with your selection.<br />");
                        }
                    }
                    if (UserChoice == 2 && GetListVehicles().Count == 0)
                    {
                        _t.Display("Seems like you dont have any Vehicles in your basedata!<br />");
                        return;
                    }
                    if (UserChoice == 2)
                    {
                        List <Vehicle> vehicles = GetListVehicles();
                        Vehicle        tmp;
                        _t.Display("Select for which car you wish to search:<br />");
                        ViewList(vehicles);
                        UserChoice = ValidInputRange(_t.GetInt(), 1, vehicles.Count());     //sucht Fahrzeug nach ID
                        tmp        = vehicles.ElementAt(UserChoice - 1);

                        int amountD = deploys.Count();
                        int amountC;
                        int counter = 0;
                        for (int k = 0; k < amountD; k++)
                        {
                            amountC = deploys.ElementAt(k).Cars.Length;
                            for (int j = 0; j < amountC; j++)
                            {
                                if (deploys.ElementAt(k).Cars[j].Equals(tmp) && counter < howMany)
                                {
                                    _t.Display("(" + (k + 1) + ") At: " + deploys.ElementAt(k).Location + " Time: " + deploys.ElementAt(k).DateAndTime + "<br />");     //sucht nach Einsätzen mit gewähltem Fahrzeug
                                    counter++;
                                }
                            }
                        }
                        if (!(counter == 0))
                        {
                            _t.Display("To go into detail type corresponding number.<br />");
                            UserChoice = ValidInputRange(_t.GetInt(), 1, counter);
                            _t.Display(GetListDeployments().ElementAt(UserChoice - 1).ToString() + "<br />");
                        }
                        else
                        {
                            _t.Display("Couldnt find any Deployments with your selection.<br />");
                        }
                    }
                }
                break;

            case "-d":
            {
                List <Deployment> liste = GetListDeployments();
                int number = 0;         //erstellt einen Einsatzeintrag

                Vehicle[]     v = new Vehicle[number];
                FireFighter[] p = new FireFighter[number];
                Resource[]    r = new Resource[number];

                _t.Display("Where was the Deployment?<br />");
                string loc = _t.GetString();
                _t.Display("How many Vehicles participated in the Deployment?<br />");
                List <Vehicle> cars = GetListVehicles();
                if (cars.Count == 0)
                {
                    _t.Display("It appears as if you have no vehicles in your basedata<br />" +
                               "You might wish to ask your local admin to create some for you.<br /><br />");
                }
                else
                {
                    number = ValidInputRange(_t.GetInt(), 0, cars.Count);           //ist die Zahl der Fahrzeuge valide?
                    v      = new Vehicle[number];
                    for (int i = 0; i < number; i++)
                    {
                        v[i] = cars.ElementAt(ObjectSelection(cars) - 1);
                    }
                }
                _t.Display("How much staff participated in the Deployment?<br />");
                List <FireFighter> staff = GetListFireFighter();
                if (staff.Count == 0)
                {
                    _t.Display("It appears as if you have no staff in your basedata<br />" +
                               "You might wish to ask your local admin to create some for you.<br /><br />");
                }
                else
                {
                    number = ValidInputRange(_t.GetInt(), 0, staff.Count);          //ist die Zahl der Feuerwehrmänner valide?
                    p      = new FireFighter[number];
                    for (int i = 0; i < number; i++)
                    {
                        p[i] = staff.ElementAt(ObjectSelection(staff) - 1);
                    }
                }
                _t.Display("How many resources were used in the Deployment?<br />");
                List <Resource> res = GetListResources();
                if (res.Count == 0)
                {
                    _t.Display("It appears as if you have no resources in your basedata<br />" +
                               "You might wish to ask your local admin to create some for you.<br /><br />");
                }
                else
                {
                    number = ValidInputRange(_t.GetInt(), 0, res.Count);            //ist die zahl der resourcen valide?
                    r      = new Resource[number];
                    for (int i = 0; i < number; i++)
                    {
                        r[i] = res.ElementAt(ObjectSelection(res) - 1);
                    }
                }
                _t.Display("Any comments?<br />");
                string com = _t.GetString();

                if (Globals.DLL == false)
                {
                    DeploymentFactory DF   = new DeploymentFactory();
                    Deployment        test = DF.NewDeployment(loc, v, r, p, com, AllDeployments.Count() + 1);
                    liste.Add(test);
                }
                else
                {
#pragma warning disable CS0162 // Unreachable code detected
                    var DeploymentDLL = new DeploymentDLL();
#pragma warning restore CS0162 // Unreachable code detected
                    var        DF  = DeploymentDLL.NewDeployment(loc, v, r, p, com, AllDeployments.Count() + 1);
                    Deployment tmp = new Deployment(DF.Location, DF.Cars, DF.Resources, DF.FireFighters, DF.Comment, DF.Id);
                    liste.Add(tmp);
                }
            }
                GasExaminationCheck();
                break;

            case "-g":
                GasExaminationCheck();
                break;

            case "-w":

                DeployCount = GetListDeployments().Count();
                if (DeployCount == 0)
                {
                    _t.Display("The deployment file seems to be empty.<br />Before you view deployments you should create one!<br />");
                    return;
                }
                _t.Display("How many deployments do you wish to view?(" + DeployCount + ") <br />");
                howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);
                _t.Display("Last " + howMany + " Deployments: <br />");
                toDisplay = "";

                for (int i = 0; i < howMany; i++)
                {
                    toDisplay += "(" + (i + 1) + ") At: " + GetListDeployments().ElementAt((DeployCount - 1) - i).Location + " Time: " + GetListDeployments().ElementAt((DeployCount - 1) - i).DateAndTime + "<br />";
                }
                _t.Display(toDisplay);
                howMany = ValidInputRange(_t.GetInt(), 1, DeployCount);
                _t.Display(GetListDeployments().ElementAt((DeployCount - 1) - (howMany - 1)).GenerateWebReport() + "<br />");
                break;

            case "-q":
                System.Environment.Exit(1);
                break;
            }
        }