예제 #1
0
        /// <summary>
        /// Загрузка списка отработанных часов по конкретному сотруднику из файла.
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>Список строк.</returns>
        public List <string> LoadListOfWorkingHoursForSpecificEmployee(Employee employee)
        {
            // Список строк отработанных часов по конкретному сотруднику.
            List <string> listHoursWorked = new List <string>();

            try
            {
                using (StreamReader sr = new StreamReader(_path))
                {
                    string line;

                    // Считываем строку из файла пока строки не закончатся.
                    while ((line = sr.ReadLine()) != null)
                    {
                        ReportLine reportLine = new ReportLine();

                        if (reportLine.CompareNameAndSurname(line, employee))
                        {
                            listHoursWorked.Add(line);
                        }
                    }

                    return(listHoursWorked);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(listHoursWorked);
        }