Exemplo n.º 1
0
 public static OrgChargEmp MapToOrgChargEmp(this LdapEmployee emp)
 {
     if (emp != null)
     {
         return(new OrgChargEmp
         {
             Id = emp.DistinguishedName,
             FirstName = emp.FirstName,
             LastName = emp.LastName,
             Photo = emp.Photo,
             JobTitle = emp.JobTitle,
             IsCurrent = emp.IsCurrent,
             Tel = emp.Phone,
             Email = emp.EMail
         });
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        private async Task<LdapEmployee> loadDetails(LdapEmployee emp)
        {
            try
            {
                //Manager laden
                if (!string.IsNullOrEmpty(emp.ManagerPath))
                {
                    var manager = await LoadEmployeeWithPath(emp.ManagerPath, true);
                    if (manager != null)
                    {
                        emp.Manager = manager;
                    }
                    else
                    {
                        throw new Exception($"Error loading the manager! (Found no manager)");
                    }
                }

                //Surrogates laden
                if (emp.DirectReportPaths.Count == 0)
                {
                    //Der Mitarbeiter hat keine Mitarbeiter -> Die vom Manager holen
                    emp.Manager.DirectReports.Clear();
                    foreach (var dp in emp.Manager.DirectReportPaths)
                    {
                        if (emp.DistinguishedName != dp)
                        {
                            var e = await LoadEmployeeWithPath(dp, true);
                            if (e != null)
                            {
                                emp.Manager.DirectReports.Add(e);
                            }
                            else
                            {
                                throw new Exception($"Error loading the direct report employee! (Found no employee)");
                            }
                        }
                        else
                        {
                            emp.Manager.DirectReports.Add(emp);
                        }
                    }

                    //In diesem Fall auch den Manager vom Manager laden
                    var mm = await LoadEmployeeWithPath(emp.Manager.ManagerPath, true);
                    if (mm != null)
                    {
                        emp.Manager.Manager = mm;
                    }
                    else
                    {
                        throw new Exception($"Error loading the manager of the manager! (Found no manager)");
                    }
                }
                else
                {
                    //Die Mitarbeiter des Mitarbeiter laden
                    foreach (var dp in emp.DirectReportPaths)
                    {
                        var e = await LoadEmployeeWithPath(dp, true);
                        if (e != null)
                        {
                            emp.Manager.DirectReports.Add(e);
                        }
                        else
                        {
                            throw new Exception($"Error loading the direct report employee! (Found no employee)");
                        }
                    }
                }
                return emp;
            }
            catch (Exception ex)
            {
                throw new Exception($"Error loading the details for employee {emp.DistinguishedName}: {ex.Message}");
            }
        }