Beispiel #1
0
        static void Main(string[] args)
        {
            try
            {
                Bday              bday                  = new Bday();
                PeselCorrectness  peselCorrectness      = new PeselCorrectness();
                GenderCorrectness genderCorrectness     = new GenderCorrectness();
                bool              continuePeselChecking = true;

                do
                {
                    Console.WriteLine("Enter the option. M for manual and F for file");
                    var option = Console.ReadLine() ?? string.Empty;

                    switch (option.ToLower())
                    {
                    case "m":
                        Console.WriteLine("Enter your date of birth (DD/MM/YYYY)");
                        int[] bdayArray = bday.BdayToArray(Console.ReadLine());

                        Console.WriteLine("Enter your gender (F/M)");
                        string gender = Console.ReadLine();
                        genderCorrectness.GenderCorrectnessChecking(gender);

                        Console.WriteLine("Enter your PESEL number");
                        string pesel = Console.ReadLine();
                        Console.WriteLine(peselCorrectness.CorrectnessChecinkg(bdayArray, gender, pesel));
                        break;

                    case "f":
                        PeselCorrectnessFromFile.CorrectnessCheckingFromFile();
                        Console.WriteLine("File updated");
                        break;

                    default:
                        Console.WriteLine("Error!");
                        break;
                    }
                    Console.WriteLine("Do you want to continue? Y/N");
                    string decision = Console.ReadLine();

                    if (decision.ToLower() == "n")
                    {
                        continuePeselChecking = false;
                    }
                } while (continuePeselChecking);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #2
0
        public static void CorrectnessCheckingFromFile()
        {
            Bday              bday              = new Bday();
            PeselCorrectness  peselCorrectness  = new PeselCorrectness();
            GenderCorrectness genderCorrectness = new GenderCorrectness();

            string currentLine;

            string[] separatedData = new string[3];
            int[]    bdayArrayFile = new int[6];
            string   genderFile;
            string   peselFile;
            string   result;

            using (var w = new StreamWriter("PESELListChecked.csv"))
            {
                using (StreamReader sr = new StreamReader("PESELListToCheck.csv"))
                {
                    // currentLine will be null when the StreamReader reaches the end of file
                    while ((currentLine = sr.ReadLine()) != null)
                    {
                        //Console.WriteLine(currentLine);
                        separatedData = currentLine.Split(";");
                        bdayArrayFile = bday.BdayToArray(separatedData[1]);
                        genderFile    = separatedData[2];
                        peselFile     = separatedData[0];
                        genderCorrectness.GenderCorrectnessChecking(genderFile);
                        result = peselCorrectness.CorrectnessChecinkg(bdayArrayFile, genderFile, peselFile);

                        var line = string.Format("{0};{1}", currentLine, result);
                        w.WriteLine(line);
                        w.Flush();
                    }
                }
            }
        }