Ejemplo n.º 1
0
        private void readParticipantFile(string fileName)
        {
            if (File.Exists(GetParticipantPath(fileName)))
            {
                StreamReader  tr;
                string        line;
                string[]      linesInstruction;
                List <string> config = new List <string>();

                tr     = new StreamReader(GetParticipantPath(fileName), Encoding.Default, true);
                line   = tr.ReadLine();
                line   = FileManipulation.EncodeLatinText(line);
                config = line.Split().ToList();

                this.registrationID           = int.Parse(config[0]);
                this.name                     = config[1];
                this.age                      = int.Parse(config[2]);
                this.sex                      = int.Parse(config[3]);
                this.livingLocation           = config[4];
                this.DegreeOfSchooling        = int.Parse(config[5]);
                this.birthDate                = DateTime.Parse(config[6]);
                this.lastPeriodDate           = DateTime.Parse(config[7]);
                this.reasonForNotMenstruating = int.Parse(config[8]);
                this.wearGlasses              = bool.Parse(config[9]);
                this.usesMedication           = bool.Parse(config[10]);
                this.goodLastNightOfSleep     = bool.Parse(config[11]);
                this.consumedAlcohol          = bool.Parse(config[12]);
                this.usedRelaxant             = bool.Parse(config[13]);
                this.consumedDrugs            = bool.Parse(config[14]);
                this.consumedEnergizers       = bool.Parse(config[15]);

                this.glassesEspecification    = FileManipulation.EncodeLatinText(tr.ReadLine());
                this.medicationEspecification = FileManipulation.EncodeLatinText(tr.ReadLine());
                this.relaxantEspecification   = FileManipulation.EncodeLatinText(tr.ReadLine());
                this.sleepEspecification      = FileManipulation.EncodeLatinText(tr.ReadLine());
                this.alcoholEspecification    = FileManipulation.EncodeLatinText(tr.ReadLine());
                this.drugsEspecification      = FileManipulation.EncodeLatinText(tr.ReadLine());
                this.energizersEspecification = FileManipulation.EncodeLatinText(tr.ReadLine());
                tr.Close();
                linesInstruction = File.ReadAllLines(GetParticipantPath(fileName));
                if (linesInstruction.Length > 8) // read instructions if any
                {
                    for (int i = 8; i < linesInstruction.Length; i++)
                    {
                        this.observations.Add(linesInstruction[i]);
                    }
                }
                else
                {
                    this.observations = null;
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }