public static List <EmployeeExp> ParseEmployeeExp(string[] lines, string delimiter, string dateFormat)
        {
            List <EmployeeExp> retCollection = new List <EmployeeExp>();

            if (string.IsNullOrEmpty(delimiter))
            {
                delimiter = ",";
            }

            foreach (string line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                string[] values = line.Split(new string[] { delimiter }, StringSplitOptions.None);
                if (values.Length != 4)
                {
                    continue;
                }

                EmployeeExp tmpObj = new EmployeeExp
                {
                    EmpID     = int.Parse(values[0]),
                    ProjectID = int.Parse(values[1]),
                    DateFrom  = values[2].ToDate(dateFormat),
                    DateTo    = values[3].ToDate(dateFormat)
                };

                retCollection.Add(tmpObj);
            }

            return(retCollection);
        }
        public static List <TeamWork> GetTeamWorkPeriods(List <EmployeeExp> employeeExps)
        {
            List <TeamWork> result = new List <TeamWork>();

            for (int i = 0; i < employeeExps.Count; i++)
            {
                EmployeeExp empExp1 = employeeExps[i];
                for (int j = i; j < employeeExps.Count; j++)
                {
                    EmployeeExp empExp2 = employeeExps[j];

                    if (empExp1.EmpID == empExp2.EmpID || empExp1.ProjectID != empExp2.ProjectID)
                    {
                        // Continue, if the experiance is for same person or the project is differents
                        continue;
                    }

                    Work work = CalculateTeamWork(empExp1, empExp2);

                    if (work.DateFrom != null)
                    {
                        TeamWork teamWork = new TeamWork(empExp1.EmpID, empExp2.EmpID);

                        if (result.Any(x => x.TeamKey == teamWork.TeamKey))
                        {
                            result
                            .First(x => x.TeamKey == teamWork.TeamKey)
                            .WorkTogether.Add(work);
                        }
                        else
                        {
                            teamWork.WorkTogether.Add(work);
                            result.Add(teamWork);
                        }
                    }
                }
            }

            return(result);
        }
        private static Work CalculateTeamWork(EmployeeExp empExp1, EmployeeExp empExp2)
        {
            if (empExp1.DateFrom > empExp1.DateTo)
            {
                throw new Exception(string.Format(Constants.InvalidIntervalMsg, empExp1.EmpID, empExp1.ProjectID));
            }
            else if (empExp2.DateFrom > empExp2.DateTo)
            {
                throw new Exception(string.Format(Constants.InvalidIntervalMsg, empExp2.EmpID, empExp2.ProjectID));
            }

            (DateTime, DateTime)dateIntersection =
                GetDateRangesIntersection(empExp1.DateFrom, empExp1.DateTo, empExp2.DateFrom, empExp2.DateTo);

            return
                (new Work()
            {
                ProjectId = empExp1.ProjectID,
                DateFrom = dateIntersection.Item1,
                DateTo = dateIntersection.Item2
            });
        }