Ejemplo n.º 1
0
        /// <summary>
        /// This method allows a user to choose country, domain, city
        /// and create them
        /// and to edit info city file.
        /// It shoudbe be used a recursion next time.
        /// </summary>
        public void ShowGeographyInfo()
        {
            if (!File.Exists(manifestAddress))
            {
                Console.WriteLine("Manifest address is not correct.");
            }
            else
            {
                Utilities.Parser parser = new Utilities.Parser();
                parser.parse(manifestAddress, countries, this);
                Utilities.FileServis fileServis = new Utilities.FileServis();

                while (true)
                {
                    int domainNumber;
                    int cityNumber = -1;

                    int countryNumber = chooseCountry();
                    if (countryNumber == 0)
                    {
                        return;
                    }

                    if (countryNumber == 1)
                    {
                        fileServis.createCountry(this);
                    }
                    else if (countryNumber > 1)
                    {
                        domainNumber = chooseDomain(countries[countryNumber - 2]);
                        if (domainNumber == 0)
                        {
                            continue;
                        }
                        else if (domainNumber == 1)
                        {
                            fileServis.createDomain(countries[countryNumber - 2], this);
                        }
                        else if (domainNumber > 1)
                        {
                            cityNumber = chooseCity(countries[countryNumber - 2].domains[domainNumber - 2]);
                            if (cityNumber == 0)
                            {
                                continue;
                            }
                            else if (cityNumber == 1)
                            {
                                fileServis.createFile(countries[countryNumber - 2].domains[domainNumber - 2], this);
                            }
                            else if (cityNumber > 1)
                            {
                                string thePath = countries[countryNumber - 2].domains[domainNumber - 2].cities[cityNumber - 2].PathToFile;
                                actWithCities(thePath, editor, fileServis);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method directs a user choice.
        /// </summary>
        /// <param name="thePath">this is path to the file of chosen city</param>
        /// <param name="editor">name of editor</param>
        /// <param name="fileServis">class of file servis</param>
        private void actWithCities(string thePath, string editor, Utilities.FileServis fileServis)
        {
            int actionNumber = chooseAction();

            switch (actionNumber)
            {
            case 0:
                return;

            case 1:
                showCityInfo(thePath);
                break;

            case 2:
                fileServis.writeCommandToManifest(thePath, this);
                System.Diagnostics.Process.Start(editor, thePath);
                break;
            }
        }