public CardholderServiceTest() { this.service = new CardholderService(); this.createOptions = new CardholderCreateOptions() { Billing = new BillingOptions { Address = new AddressOptions { City = "city", Country = "US", Line1 = "line1", PostalCode = "90210", State = "CA", }, Name = "Billing Name", }, Name = "John Doe", Type = "individual", }; this.updateOptions = new CardholderUpdateOptions() { Metadata = new Dictionary <string, string>() { { "key", "value" }, }, }; this.listOptions = new CardholderListOptions() { Limit = 1, }; }
public CardholderServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new CardholderService(this.StripeClient); this.createOptions = new CardholderCreateOptions { Billing = new BillingOptions { Address = new AddressOptions { City = "city", Country = "US", Line1 = "line1", PostalCode = "90210", State = "CA", }, }, Company = new CardholderCompanyOptions { TaxId = "123", }, Individual = new CardholderIndividualOptions { Dob = new CardholderIndividualDobOptions { Day = 1, Month = 1, Year = 1980, }, FirstName = "John", LastName = "Doe", Verification = new CardholderIndividualVerificationOptions { Document = new CardholderIndividualVerificationDocumentOptions { Back = "file_123", Front = "file_234", }, }, }, Name = "John Doe", Type = "individual", }; this.updateOptions = new CardholderUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new CardholderListOptions { Limit = 1, }; }
static List <string> GetCardholderRecord(ManagementBaseObject obj) { var items = new List <string>(); if (string.IsNullOrEmpty(obj["SSNO"] as string)) { return(null); } var today = DateTime.Now.ToString("yyyyMMdd"); if (!string.IsNullOrEmpty(obj["USERFIELD85"] as string)) { var activate = obj["FLDDATE1059"] as string; if (!string.IsNullOrEmpty(activate)) { activate = activate.Substring(0, 8); if (activate == today) { items.Add($"\"{obj["SSNO"]}\",\"GB\",\"{DateToOutputDate(activate)}\",\"{obj["USERFIELD85"]}\""); } } } var badges = CardholderService.GetCardholderBadgesBySSNO(obj["SSNO"] as string); foreach (var badge in badges) { var searcher = new ManagementObjectSearcher("root\\OnGuard", $"SELECT * FROM Lnl_Badge WHERE ID = {badge.BadgeId}"); foreach (var badgeObj in searcher.Get()) { var activate = badgeObj["ACTIVATE"] as string; if (string.IsNullOrEmpty(activate)) { break; } activate = activate.Substring(0, 8); if (activate == today) { items.Add($"\"{obj["SSNO"]}\",\"BA\",\"{DateToOutputDate(activate)}\",\"{obj["ID"]}\""); } } } return(items); }
public CardholderServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new CardholderService(this.StripeClient); this.createOptions = new CardholderCreateOptions { Billing = new BillingOptions { Address = new AddressOptions { City = "city", Country = "US", Line1 = "line1", PostalCode = "90210", State = "CA", }, Name = "Billing Name", }, Name = "John Doe", Type = "individual", }; this.updateOptions = new CardholderUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new CardholderListOptions { Limit = 1, }; }
public CardholderServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new CardholderService(this.StripeClient); this.createOptions = new CardholderCreateOptions { Billing = new CardholderBillingOptions { Address = new AddressOptions { City = "city", Country = "US", Line1 = "line1", PostalCode = "90210", State = "CA", }, }, Individual = new CardholderIndividualOptions { Dob = new CardholderIndividualDobOptions { Day = 1, Month = 1, Year = 1980, }, FirstName = "John", LastName = "Doe", Verification = new CardholderIndividualVerificationOptions { Document = new CardholderIndividualVerificationDocumentOptions { Back = "file_123", Front = "file_234", }, }, }, Name = "John Doe", SpendingControls = new CardholderSpendingControlsOptions { SpendingLimits = new List <CardholderSpendingControlsSpendingLimitOptions> { new CardholderSpendingControlsSpendingLimitOptions { Amount = 1000, Categories = new List <string> { "financial_institutions", }, Interval = "all_time", }, }, }, Type = "individual", }; this.updateOptions = new CardholderUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new CardholderListOptions { Limit = 1, }; }
private static bool ProcessFile() { DataPipelineService dataPipelineService = null; try { dataPipelineService = CreateDataPipelineService(); var csvDataReaderService = CreateCsvDataReaderService(); dataPipelineService.PrepareForProcessing(); if (dataPipelineService.CurrentFileLocation == null) { return(false); } List <Employee> employees = csvDataReaderService.ReadData( dataPipelineService.CurrentFileLocation, Settings.WithKronosNumber ).ToList(); var cardholderService = CreateLenelService <Cardholder>("Lnl_Cardholder"); var badgeService = CreateLenelService <Badge>("Lnl_Badge"); var departmentService = CreateLenelService <Department>("Lnl_Department"); var locationService = CreateLenelService <Location>("Lnl_Location"); var cardholders = GetCardholders(cardholderService); var badges = GetBadges(badgeService); var departments = GetDepartments(departmentService); var locations = GetLocations(locationService); for (var i = 0; i < employees.Count(); i++) { var employee = employees[i]; var cardholder = employee.ToCardholder(); var badge = employee.ToBadge(); ManagementBaseObject existedCardholder = null; ManagementBaseObject existedDepartment = null; ManagementBaseObject existedBadge = null; ManagementBaseObject existedLocation = null; if (!string.IsNullOrEmpty(cardholder.Location)) { locations.TryGetValue(cardholder.Location, out existedLocation); } if (!string.IsNullOrEmpty(cardholder.DepartmentDescription)) { departments.TryGetValue(cardholder.DepartmentDescription, out existedDepartment); } if (!string.IsNullOrEmpty(cardholder.Id)) { cardholders.TryGetValue(cardholder.Id, out existedCardholder); } if (existedDepartment == null || existedLocation == null) { var departmentAdded = false; var locationAdded = false; if (existedDepartment == null) { departmentAdded = departmentService.AddInstance(new Department { Name = cardholder.DepartmentDescription }); } if (existedLocation == null) { locationAdded = locationService.AddInstance(new Location { Name = cardholder.Location }); } if (departmentAdded || locationAdded) { cardholderService = CreateLenelService <Cardholder>("Lnl_Cardholder"); badgeService = CreateLenelService <Badge>("Lnl_Badge"); departmentService = CreateLenelService <Department>("Lnl_Department"); locationService = CreateLenelService <Location>("Lnl_Location"); cardholders = GetCardholders(cardholderService); badges = GetBadges(badgeService); departments = GetDepartments(departmentService); locations = GetLocations(locationService); i--; continue; } else { _report.Add($"{cardholder.Id}: failed - Can't add {(departmentAdded ? "department" : "location")} {cardholder.Location}"); } } if (existedLocation != null) { var id = existedLocation["ID"] as int?; if (id.HasValue) { cardholder.SuperLocation = id.Value; } } if (existedDepartment != null) { var id = existedDepartment["ID"] as int?; if (id.HasValue) { cardholder.DeptId = id.Value; } } var isSuccess = existedCardholder == null ? cardholderService.AddInstance(cardholder) : cardholderService.UpdateInstance(existedCardholder, cardholder); if (!isSuccess) { _report.Add($"{cardholder.Id}: failed - Generic failure"); continue; } var personBadges = CardholderService.GetCardholderBadgesBySSNO(cardholder.Id).ToList(); var existedPersonBadges = new Dictionary <int, ManagementBaseObject>(); foreach (var personBadge in personBadges) { if (badges.TryGetValue(personBadge.BadgeId, out existedBadge)) { existedPersonBadges.Add(personBadge.BadgeId, existedBadge); } } if (cardholder.Status == 1 && existedPersonBadges.Count > 0 && existedPersonBadges.Where((x) => { var status = x.Value["STATUS"] as int?; return(status.HasValue && status.Value == 1); }).Count() == 0) { var item = existedPersonBadges.First(); var id = item.Value["ID"] as long?; if (id.HasValue) { badge.ExtendedId = $"0x{id.Value}"; isSuccess = badgeService.UpdateInstance(item.Value, badge); } } if (cardholder.Status == 5) { foreach (var item in existedPersonBadges) { var id = item.Value["ID"] as long?; if (id.HasValue) { badge.ExtendedId = $"0x{id.Value}"; isSuccess = badgeService.UpdateInstance(item.Value, badge); } } } if (isSuccess) { _report.Add($"{cardholder.Id}: proceed - Success"); } else { _report.Add($"{cardholder.Id}: failed - Update badge failure"); } } dataPipelineService.SaveDataToProcessed(); } catch (Exception e) { _logger.Error(e); dataPipelineService?.SaveDataToError(_logger.GetLogs()); } return(true); }