-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added debuggingebuging * updates * update bindings * unanet changes * updates * updates * updates * updates * update * updates * updates * updates * updatest * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * updates * async * 2.0 * updates * updates * updates * updates * final * updates * updates * updates * updates * updates * updates * updates * updates * updates
- Loading branch information
Sky Morey
authored
Oct 20, 2020
1 parent
9c98074
commit d81f67f
Showing
22 changed files
with
1,039 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using OpenQA.Selenium; | ||
using System; | ||
using System.Net; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automa.IO.Adp | ||
{ | ||
/// <summary> | ||
/// AdpAutomation | ||
/// </summary> | ||
public class AdpAutomation : Automation | ||
{ | ||
const string WorkforcenowAdpUri = "https://workforcenow.adp.com"; | ||
const string EwalletAdpUri = "https://ewallet.adp.com"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AdpAutomation" /> class. | ||
/// </summary> | ||
/// <param name="client">The client.</param> | ||
/// <param name="automa">The automa.</param> | ||
public AdpAutomation(AutomaClient client, IAutoma automa) : base(client, automa) { } | ||
|
||
/// <summary> | ||
/// Goes to URL. | ||
/// </summary> | ||
/// <param name="url">The URL.</param> | ||
/// <param name="cancellationToken">The cancellation token.</param> | ||
/// <returns> | ||
/// System.String. | ||
/// </returns> | ||
/// <exception cref="LoginRequiredException"></exception> | ||
public override Task<string> GoToUrlAsync(string url, CancellationToken? cancellationToken = null) | ||
{ | ||
_driver.Navigate().GoToUrl(url); | ||
var newUrl = _driver.Url; | ||
if (newUrl != $"{WorkforcenowAdpUri}/public/index.htm") | ||
throw new LoginRequiredException(); | ||
return Task.FromResult(newUrl); | ||
} | ||
|
||
/// <summary> | ||
/// Logins the specified cookies. | ||
/// </summary> | ||
/// <param name="cookies">The cookies.</param> | ||
/// <param name="credential">The credential.</param> | ||
/// <param name="tag">The tag.</param> | ||
/// <param name="cancellationToken">The cancellation token.</param> | ||
/// <returns></returns> | ||
/// <exception cref="LoginRequiredException"> | ||
/// </exception> | ||
public override Task LoginAsync(Func<CookieCollection, Task<CookieCollection>> cookies, NetworkCredential credential, object tag = null, CancellationToken? cancellationToken = null) | ||
{ | ||
_driver.Navigate().GoToUrl($"{WorkforcenowAdpUri}/portal/admin.jsp"); | ||
var url = _driver.Url; | ||
if (!url.StartsWith($"{EwalletAdpUri}/auth/enroll/adpLogin.faces")) | ||
throw new LoginRequiredException(); | ||
// login | ||
var loginContainer = _driver.FindElement(By.ClassName("user-id")); | ||
var loginElement = loginContainer.FindElement(By.TagName("input")); | ||
loginElement.SendKeys(credential.UserName); | ||
loginElement.SendKeys(Keys.Return); | ||
// password | ||
//var passwordContainer = WaitForElement(1000, By.ClassName("password")); | ||
//if (passwordContainer == null) | ||
// throw new LoginRequiredException(); | ||
if (!_driver.WaitForDisplay(out var elements, 1000, By.ClassName("password"))) | ||
throw new LoginRequiredException(); | ||
var passwordElement = elements[0].FindElement(By.TagName("input")); | ||
passwordElement.SendKeys(credential.Password); | ||
passwordElement.SendKeys(Keys.Return); | ||
// done | ||
if (!_driver.WaitForUrl(2000, $"{WorkforcenowAdpUri}/theme/index.html", $"{WorkforcenowAdpUri}/theme/admin.html")) | ||
throw new LoginRequiredException(); | ||
cookies(_automa.Cookies); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Bogus" Version="31.0.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Automa.IO\Automa.IO.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automa.IO.Adp.Records | ||
{ | ||
public class DepartmentRecord | ||
{ | ||
public string Id { get; set; } | ||
public string Title { get; set; } | ||
public bool Disabled { get; set; } | ||
|
||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automa.IO.Adp.Records | ||
{ | ||
public class LocationRecord | ||
{ | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
public bool Disabled { get; set; } | ||
|
||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Bogus; | ||
using ExcelTrans.Services; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automa.IO.Adp.Records | ||
{ | ||
public class PersonEmergencyContactRecord | ||
{ | ||
public string AssociateId { get; set; } | ||
public string Primary { get; set; } | ||
public string EmergencyName { get; set; } | ||
public string EmergencyRelationship { get; set; } | ||
public string EmergencyPhone { get; set; } | ||
public string EmergencyEmail { get; set; } | ||
|
||
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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Bogus; | ||
using ExcelTrans.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automa.IO.Adp.Records | ||
{ | ||
public class PersonEmploymentRecord | ||
{ | ||
public string AssociateId { get; set; } | ||
public string Status { get; set; } | ||
public DateTime StatusEffectiveDate { get; set; } | ||
public DateTime? StatusEffectiveEndDate { get; set; } | ||
public DateTime? HireDate { get; set; } | ||
public string HireReason { get; set; } | ||
public DateTime? RehireDate { get; set; } | ||
public string RehireReason { get; set; } | ||
public DateTime? LoaStartDate { get; set; } | ||
public string LoaStartReason { get; set; } | ||
public DateTime? LoaReturnDate { get; set; } | ||
public string LoaReturnReason { get; set; } | ||
public DateTime? TerminationDate { get; set; } | ||
public string TerminationReason { get; set; } | ||
public string PositionId { get; set; } | ||
public string LocationId { get; set; } | ||
public string WorkerCategory { get; set; } | ||
public string WorkEmail { get; set; } | ||
|
||
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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using ExcelTrans.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automa.IO.Adp.Records | ||
{ | ||
public class PersonManagerRecord | ||
{ | ||
public string PersonId { get; set; } | ||
public string WorkEmail { get; set; } | ||
public string ManagerId { get; set; } | ||
public DateTime? Date { get; set; } | ||
public DateTime? EndDate { get; set; } | ||
|
||
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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using ExcelTrans.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automa.IO.Adp.Records | ||
{ | ||
public class PersonPositionRecord | ||
{ | ||
public string PersonId { get; set; } | ||
public string WorkEmail { get; set; } | ||
public DateTime Date { get; set; } | ||
public string PositionId { get; set; } | ||
public string LocationId { get; set; } | ||
public string DepartmentId { get; set; } | ||
public decimal? ScheduledHours { get; set; } | ||
|
||
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(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.