Example #1
0
 public static async Task <IEnumerable <LocationRecord> > GetLocationsAsync(AdpClient adp) =>
 (await adp.GetValidationTablesAsync("location", null, x => new LocationRecord
 {
     Id = (string)x["code"],
     Name = ((string)x["description"]).Trim(),
     Disabled = !(bool)x["active"],
 })).ToList();
Example #2
0
 public static async Task <IEnumerable <PositionRecord> > GetPositionsAsync(AdpClient adp) =>
 await adp.GetValidationTablesAsync("jobtitle", "/allData", x => new PositionRecord
 {
     Id       = (string)x["code"],
     Title    = ((string)x["description"])?.Trim(),
     Disabled = !(bool)x["active"],
 });
Example #3
0
        public static async Task <IEnumerable <PersonRecord> > GetPeopleAsync(AdpClient adp, bool bogus)
        {
            var faker = bogus ? new Faker() : null;

            using (var stream = new MemoryStream())
            {
                var file = await adp.GetSingleReportAsync(AdpClient.ReportType.Custom, "People Report", AdpClient.ReportOptions.Standard, stream, deleteAfter : true);

                return(CsvReader.Read(stream, x => new PersonRecord
                {
                    Tag = x[21],
                    Disabled = !string.IsNullOrEmpty(x[31]),
                    Id = x[26],
                    FirstName = x[4],
                    LastName = x[5],
                    MiddleName = x[2],
                    PreferredFirstName = x[0],
                    PreferredLastName = x[1],
                    Gender = x[6],
                    Race = x[7],
                    SSN4_EIN = !string.IsNullOrEmpty(x[8]) ? faker?.Random.Number(9999).ToString().PadLeft(4, '0') ?? ((int)decimal.Parse(x[8])).ToString("0000") : null,
                    WorkEmail = x[9],
                    PersonalEmail = faker?.Internet.Email() ?? x[10],
                    OfficePhone = x[11],
                    HomePhone = faker?.Phone.PhoneNumber() ?? x[12],
                    MobilePhone = faker?.Phone.PhoneNumber() ?? x[13],
                    PrimaryStreet = faker?.Address.StreetAddress() ?? x[14],
                    PrimaryStreet2 = faker != null ? null : x[15],
                    PrimaryCity = faker?.Address.City() ?? x[16],
                    PrimaryState = faker?.Address.StateAbbr() ?? x[17],
                    PrimaryPostalCode = faker?.Address.ZipCode() ?? x[18],
                    PrimaryCountry = x[19],
                    Timezone = null,
                    UserPrincipalName = x[9],
                    Birthdate = x[20] != null ? DateTime.Parse(x[20]).AddYears(-DateTime.Parse(x[20]).Year + 2000).ToString() : null,
                    PositionId = x[28],
                    ManagerId = x[27],
                    EmergencyName = faker.Name.FullName() ?? x[22],
                    EmergencyRelationship = faker != null ? "SomeRelation" : x[23],
                    EmergencyPhone = faker?.Phone.PhoneNumber() ?? x[24],
                    EmergencyEmail = faker?.Internet.Email() ?? x[25],
                    ExemptStatus = x[29],
                }).ToList());
            }
        }
        public static async Task <IEnumerable <PersonSalaryRecord> > GetPersonSalariesAsync(AdpClient adp, bool allRecords, bool bogus, Func <IEnumerable <SalaryRecord>, IEnumerable <PersonSalaryRecord> > secure)
        {
            var faker = new Faker();

            using (var stream = new MemoryStream())
            {
                var range = allRecords
                    ? AdpClient.ReportOptions.AllRecords
                    : AdpClient.ReportOptions.Standard;
                var file = await adp.GetSingleReportAsync(AdpClient.ReportType.Custom, "Salary Report", range, stream, deleteAfter : true);

                var salaries = CsvReader.Read(stream, x => new SalaryRecord
                {
                    PersonId     = x[0],
                    WorkEmail    = x[1],
                    Date         = DateTime.Parse(x[2]),
                    RateType     = x[6],
                    Frequency    = x[4],
                    Amount       = !string.IsNullOrEmpty(x[5]) ? (decimal?)decimal.Parse(x[5], NumberStyles.Currency) : null,
                    AnnualAmount = !string.IsNullOrEmpty(x[7]) ? (decimal?)decimal.Parse(x[7], NumberStyles.Currency) : null,
                    Reason       = x[8],
                }).Where(x => x != null).ToList();
                if (bogus)
                {
                    var bogusValues = salaries.Select(x => x.Amount).Union(salaries.Select(x => x.AnnualAmount)).Where(x => x != null).GroupBy(x => x)
                                      .ToDictionary(x => x.Key, y => faker.Random.Decimal(10, 250000));
                    foreach (var salary in salaries)
                    {
                        if (salary.Amount != null && bogusValues.TryGetValue(salary.Amount, out var z))
                        {
                            salary.Amount = z;
                        }
                        if (salary.AnnualAmount != null && bogusValues.TryGetValue(salary.AnnualAmount, out z))
                        {
                            salary.AnnualAmount = z;
                        }
                    }
                }
                return(secure(salaries));
            }
        }
Example #5
0
        public static async Task <IEnumerable <PersonTimeOffRecord> > GetPersonTimeOffsAsync(AdpClient adp)
        {
            using (var stream = new MemoryStream())
            {
                var file = await adp.GetSingleReportAsync(AdpClient.ReportType.Custom, "Time Off", AdpClient.ReportOptions.Standard, stream, deleteAfter : true);

                return(CsvReader.Read(stream, x => new PersonTimeOffRecord
                {
                    AssociateId = x[0],
                    WorkEmail = x[1],
                    Date = DateTime.TryParse($"{x[2]} {x[3]}", out var date) ? date : throw new InvalidOperationException("Report must return only records with data."),
                    Duration = x[4],
                    AbsenceType = x[5],
                    Status = x[6],
                    SubmittedDate = DateTime.Parse(x[7]),
                }).ToList());
Example #6
0
        public static async Task <IEnumerable <PersonManagerRecord> > GetPersonManagersAsync(AdpClient adp)
        {
            using (var stream = new MemoryStream())
            {
                var file = await adp.GetSingleReportAsync(AdpClient.ReportType.Custom, "Manager Report", AdpClient.ReportOptions.AllRecords, stream, deleteAfter : true);

                return(CsvReader.Read(stream, x => new PersonManagerRecord
                {
                    PersonId = x[0],
                    WorkEmail = x[1],
                    ManagerId = x[2],
                    Date = !string.IsNullOrEmpty(x[3]) ? (DateTime?)DateTime.Parse(x[3]) : null,
                    EndDate = !string.IsNullOrEmpty(x[4]) ? (DateTime?)DateTime.Parse(x[4]) : null,
                }).ToList());
            }
        }
Example #7
0
 public static async Task <IEnumerable <DepartmentRecord> > GetDepartmentsAsync(AdpClient adp) =>
 (await adp.GetValidationTablesAsync("department", "/BXC", x => new DepartmentRecord
 {
     Id = (string)x["code"],
     Title = ((string)x["description"]).Trim(),
     Disabled = !(bool)x["active"],
 })).ToList();
        public static async Task <IEnumerable <PersonEmergencyContactRecord> > GetPersonEmergencyContactsAsync(AdpClient adp, bool bogus)
        {
            var faker = bogus ? new Faker() : null;

            using (var stream = new MemoryStream())
            {
                var file = await adp.GetSingleReportAsync(AdpClient.ReportType.Custom, "Emergency Contact Report", AdpClient.ReportOptions.AllRecords, stream, deleteAfter : true);

                return(CsvReader.Read(stream, x => new PersonEmergencyContactRecord
                {
                    AssociateId = x[5],
                    Primary = x[0],
                    EmergencyName = faker?.Name.FullName() ?? x[1],
                    EmergencyRelationship = faker != null ? "SomeRelation" : x[2],
                    EmergencyPhone = faker?.Phone.PhoneNumber() ?? x[3],
                    EmergencyEmail = faker?.Internet.Email() ?? x[4],
                }).ToList());
            }
        }
        public static async Task <IEnumerable <PersonEmploymentRecord> > GetPersonEmploymentsAsync(AdpClient adp, bool bogus)
        {
            var faker = bogus ? new Faker() : null;

            using (var stream = new MemoryStream())
            {
                var file = await adp.GetSingleReportAsync(AdpClient.ReportType.Custom, "Employment Report", AdpClient.ReportOptions.AllRecords, stream, deleteAfter : true);

                return(CsvReader.Read(stream, x => new PersonEmploymentRecord
                {
                    AssociateId = x[0],
                    Status = x[1] ?? string.Empty,
                    StatusEffectiveDate = DateTime.Parse(x[2]),
                    StatusEffectiveEndDate = string.IsNullOrWhiteSpace(x[3]) ? (DateTime?)null : DateTime.Parse(x[3]),
                    HireDate = string.IsNullOrWhiteSpace(x[4]) ? (DateTime?)null : DateTime.Parse(x[4]),
                    HireReason = x[5],
                    RehireDate = string.IsNullOrWhiteSpace(x[6]) ? (DateTime?)null : DateTime.Parse(x[6]),
                    RehireReason = x[7],
                    LoaStartDate = !string.IsNullOrEmpty(x[8]) ? (DateTime?)DateTime.Parse(x[8]) : null,
                    LoaStartReason = faker?.Lorem.Sentence() ?? x[9] ?? string.Empty,
                    LoaReturnDate = !string.IsNullOrEmpty(x[10]) ? (DateTime?)DateTime.Parse(x[10]) : null,
                    LoaReturnReason = faker?.Lorem.Sentence() ?? x[11] ?? string.Empty,
                    TerminationDate = !string.IsNullOrEmpty(x[12]) ? (DateTime?)DateTime.Parse(x[12]) : null,
                    TerminationReason = faker?.Lorem.Sentence() ?? x[13] ?? string.Empty,
                    WorkEmail = x[14] ?? string.Empty,
                    PositionId = x[15] ?? string.Empty,
                    LocationId = x[17] ?? string.Empty,
                    WorkerCategory = x[20] ?? string.Empty,
                }).ToList());
            }
        }
        public static async Task <IEnumerable <PersonPositionRecord> > GetPersonPositionsAsync(AdpClient adp)
        {
            using (var stream = new MemoryStream())
            {
                var file = await adp.GetSingleReportAsync(AdpClient.ReportType.Custom, "Position Report", AdpClient.ReportOptions.AllRecords, stream, deleteAfter : true);

                return(CsvReader.Read(stream, x => new PersonPositionRecord
                {
                    PersonId = x[0],
                    WorkEmail = x[1],
                    Date = DateTime.Parse(x[2]),
                    PositionId = x[3] ?? string.Empty,
                    LocationId = x[5] ?? string.Empty,
                    DepartmentId = x[7] ?? string.Empty,
                    ScheduledHours = !string.IsNullOrEmpty(x[9]) ? (decimal?)decimal.Parse(x[9]) : null,
                }).ToList());
            }
        }