diff --git a/FirstCom/Connected Services/ServiceReference1/Reference.cs b/FirstCom/Connected Services/ServiceReference1/Reference.cs index 8dfc6f6e..93b8e4bc 100644 --- a/FirstCom/Connected Services/ServiceReference1/Reference.cs +++ b/FirstCom/Connected Services/ServiceReference1/Reference.cs @@ -149,7 +149,7 @@ public string text [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="https://api.1pcom.net/")] - public partial class SMSLongcodeRoute + public partial struct SMSLongcodeRoute { private string routeField; diff --git a/FirstCom/FirstCom/FirstCom.cs b/FirstCom/FirstCom/FirstCom.cs index a2f6260b..bfbee24f 100644 --- a/FirstCom/FirstCom/FirstCom.cs +++ b/FirstCom/FirstCom/FirstCom.cs @@ -16,7 +16,7 @@ public class FirstPointCom /// The FirstPointCom username. /// The FirstPointCom password. /// - public static async Task GetValidNumbersByNPAAsync(string username, string password, int[] areaCodes) + public static async Task GetValidNumbersByNPAAsync(ReadOnlyMemory username, ReadOnlyMemory password, int[] areaCodes) { var numbers = new List(); @@ -24,7 +24,7 @@ public static async Task GetValidNumbersByNPAAsync(string usernam { try { - numbers.AddRange(await NpaNxxFirstPointCom.GetAsync(code.ToString().AsMemory(), string.Empty.AsMemory(), string.Empty.AsMemory(), username.AsMemory(), password.AsMemory())); + numbers.AddRange(await NpaNxxFirstPointCom.GetAsync(code.ToString().AsMemory(), string.Empty.AsMemory(), string.Empty.AsMemory(), username, password)); Log.Information($"[FirstPointCom] Found {numbers.Count} Phone Numbers"); } catch (Exception ex) diff --git a/FirstCom/FirstCom/FirstPointComOwnedPhoneNumber.cs b/FirstCom/FirstCom/FirstPointComOwnedPhoneNumber.cs index 817abdba..f59225ed 100644 --- a/FirstCom/FirstCom/FirstPointComOwnedPhoneNumber.cs +++ b/FirstCom/FirstCom/FirstPointComOwnedPhoneNumber.cs @@ -1,23 +1,24 @@ using ServiceReference1; +using System; using System.Threading.Tasks; namespace FirstCom { public class FirstPointComOwnedPhoneNumber { - public static async Task GetAsync(string npa, string username, string password) + public static async Task GetAsync(ReadOnlyMemory npa, ReadOnlyMemory username, ReadOnlyMemory password) { var Auth = new Credentials { - Username = username, - Password = password + Username = username.ToString(), + Password = password.ToString() }; var DIDSearch = new DIDOrderQuery { DID = string.Empty, - NPA = npa, + NPA = npa.ToString(), NXX = string.Empty, RateCenter = string.Empty }; diff --git a/FirstCom/FirstCom/FirstPointComSMS.cs b/FirstCom/FirstCom/FirstPointComSMS.cs index 0bd413a3..1c9b095f 100644 --- a/FirstCom/FirstCom/FirstPointComSMS.cs +++ b/FirstCom/FirstCom/FirstPointComSMS.cs @@ -1,5 +1,6 @@ using ServiceReference1; +using System; using System.Threading.Tasks; namespace FirstCom @@ -13,17 +14,17 @@ public class FirstPointComSMS /// /// /// - public static async Task GetSMSRoutingByDialedNumberAsync(string dialedNumber, string username, string password) + public static async Task GetSMSRoutingByDialedNumberAsync(ReadOnlyMemory dialedNumber, ReadOnlyMemory username, ReadOnlyMemory password) { var Auth = new Credentials { - Username = username, - Password = password + Username = username.ToString(), + Password = password.ToString() }; using var client = new DIDManagementSoapClient(DIDManagementSoapClient.EndpointConfiguration.DIDManagementSoap); - return await client.LongCodeShowRoutingAsync(Auth, dialedNumber).ConfigureAwait(false); + return await client.LongCodeShowRoutingAsync(Auth, dialedNumber.ToString()); } public static async Task EnableSMSByDialedNumberAsync(string dialedNumber, string username, string password) diff --git a/FirstCom/Startup.cs b/FirstCom/Startup.cs index 2a6e4701..02246f95 100644 --- a/FirstCom/Startup.cs +++ b/FirstCom/Startup.cs @@ -7,6 +7,7 @@ using ServiceReference; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -49,7 +50,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) var numbers = new List(); - var results = await FirstPointComOwnedPhoneNumber.GetAsync("206", username, password).ConfigureAwait(false); + var results = await FirstPointComOwnedPhoneNumber.GetAsync("206".AsMemory(), username.AsMemory(), password.AsMemory()).ConfigureAwait(false); await Task.Delay(1000); }); diff --git a/Messaging/Program.cs b/Messaging/Program.cs index 767f3533..3626ff64 100644 --- a/Messaging/Program.cs +++ b/Messaging/Program.cs @@ -974,7 +974,7 @@ public static async Task, BadRequest, BadRequest, BadRequest, Not registration.AsDialed = dialedNumber; // Verify that this number is routed through our upstream provider. - var checkRouted = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync(dialedNumber, appSettings.ConnectionStrings.PComNetUsername, appSettings.ConnectionStrings.PComNetPassword); + var checkRouted = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync(dialedNumber.AsMemory(), appSettings.ConnectionStrings.PComNetUsername.AsMemory(), appSettings.ConnectionStrings.PComNetPassword.AsMemory()); registration.RegisteredUpstream = checkRouted.QueryResult.code is 0 && checkRouted.epid is 265; - registration.UpstreamStatusDescription = $"{checkRouted?.eptype} {checkRouted?.additional} {checkRouted?.QueryResult.text}".Trim(); + registration.UpstreamStatusDescription = $"{checkRouted.eptype} {checkRouted.additional} {checkRouted.QueryResult.text}".Trim(); // Don't pollute the registrations with 1 prefixed numbers. registration.AsDialed = asDialedNumber.DialedNumber; diff --git a/NumberSearch.DataAccess/BulkVS/OrderTn.cs b/NumberSearch.DataAccess/BulkVS/OrderTn.cs index 91a5c139..b5c45b60 100644 --- a/NumberSearch.DataAccess/BulkVS/OrderTn.cs +++ b/NumberSearch.DataAccess/BulkVS/OrderTn.cs @@ -26,7 +26,7 @@ public class OrderTn public string Mrc { get; set; } = string.Empty; public string Nrc { get; set; } = string.Empty; - public static async Task GetRawAsync(string npa, string nxx, string username, string password) + public static async Task GetRawAsync(string npa, string nxx, ReadOnlyMemory username, ReadOnlyMemory password) { string baseUrl = "https://portal.bulkvs.com/api/v1.0/"; string endpoint = "orderTn"; @@ -35,7 +35,7 @@ public static async Task GetRawAsync(string npa, string nxx, string u string route = $"{baseUrl}{endpoint}{npaParameter}{nxxParameter}"; try { - return await route.WithBasicAuth(username, password).GetJsonAsync().ConfigureAwait(false); + return await route.WithBasicAuth(username.ToString(), password.ToString()).GetJsonAsync().ConfigureAwait(false); } catch (FlurlHttpException ex) { @@ -45,7 +45,7 @@ public static async Task GetRawAsync(string npa, string nxx, string u } } - public static async Task GetAsync(int inNpa, string username, string password) + public static async Task GetAsync(int inNpa, ReadOnlyMemory username, ReadOnlyMemory password) { var results = await GetRawAsync(inNpa.ToString("000"), string.Empty, username, password).ConfigureAwait(false); var output = new List(); @@ -82,7 +82,7 @@ public static async Task GetAsync(int inNpa, string username, str return [.. output]; } - public static async Task GetAsync(int inNpa, int inNxx, string username, string password) + public static async Task GetAsync(int inNpa, int inNxx, ReadOnlyMemory username, ReadOnlyMemory password) { var results = await GetRawAsync(inNpa.ToString("000"), inNxx.ToString("000"), username, password).ConfigureAwait(false); var output = new List(); diff --git a/NumberSearch.DataAccess/BulkVS/PortTn.cs b/NumberSearch.DataAccess/BulkVS/PortTn.cs index 842e3485..60f929f3 100644 --- a/NumberSearch.DataAccess/BulkVS/PortTn.cs +++ b/NumberSearch.DataAccess/BulkVS/PortTn.cs @@ -4,6 +4,7 @@ using Serilog; +using System; using System.Text.Json.Serialization; using System.Threading.Tasks; @@ -24,7 +25,7 @@ public class PortTn public PortTnNote[] Notes { get; set; } = []; - public static async Task GetAsync(string orderId, string username, string password) + public static async Task GetAsync(ReadOnlyMemory orderId, ReadOnlyMemory username, ReadOnlyMemory password) { string baseUrl = "https://portal.bulkvs.com/api/v1.0/"; string endpoint = "portTn"; @@ -32,7 +33,7 @@ public static async Task GetAsync(string orderId, string username, strin string route = $"{baseUrl}{endpoint}{orderIdParameter}"; try { - return await route.WithBasicAuth(username, password).GetJsonAsync().ConfigureAwait(false); + return await route.WithBasicAuth(username.ToString(), password.ToString()).GetJsonAsync(); } catch (FlurlHttpException ex) { @@ -43,14 +44,14 @@ public static async Task GetAsync(string orderId, string username, strin } } - public static async Task GetAllAsync(string username, string password) + public static async Task GetAllAsync(ReadOnlyMemory username, ReadOnlyMemory password) { string baseUrl = "https://portal.bulkvs.com/api/v1.0/"; string endpoint = "portTn"; string route = $"{baseUrl}{endpoint}"; try { - return await route.WithBasicAuth(username, password).GetJsonAsync().ConfigureAwait(false); + return await route.WithBasicAuth(username.ToString(), password.ToString()).GetJsonAsync(); } catch (FlurlHttpException ex) { @@ -92,17 +93,17 @@ public class EndUserInfo public string Pin { get; set; } = string.Empty; } - public class TNList - { - public string OrderId { get; set; } = string.Empty; - public string ReferenceId { get; set; } = string.Empty; - public string TN { get; set; } = string.Empty; - [JsonPropertyName("LNP Status")] - [JsonProperty("LNP Status")] - public string LNPStatus { get; set; } = string.Empty; - public string RDD { get; set; } = string.Empty; - public string Reason { get; set; } = string.Empty; - } + public readonly record struct TNList + ( + string OrderId, + string ReferenceId, + string TN, + [property: JsonPropertyName("LNP Status")] + [property: JsonProperty("LNP Status")] + string LNPStatus, + string RDD, + string Reason + ); public class PortTnAttachment { diff --git a/NumberSearch.DataAccess/BulkVS/TnRecord.cs b/NumberSearch.DataAccess/BulkVS/TnRecord.cs index 75500c54..3c425e4d 100644 --- a/NumberSearch.DataAccess/BulkVS/TnRecord.cs +++ b/NumberSearch.DataAccess/BulkVS/TnRecord.cs @@ -14,60 +14,56 @@ namespace NumberSearch.DataAccess.BulkVS { - public class TnRecord + public readonly record struct TnRecord + ( + string TN, + string Status, + string Lidb, + [property: JsonPropertyName("Portout Pin")] + [property: JsonProperty("Portout Pin")] + string PortoutPin, + TnRecord.TnRecordRouting Routing, + TnRecord.TnRecordMessaging Messaging, + [property: JsonPropertyName("TN Details")] + [property: JsonProperty("TN Details")] + TnRecord.TnRecordTNDetails TNDetails + ) { - public string TN { get; set; } = string.Empty; - public string Status { get; set; } = string.Empty; - public string Lidb { get; set; } = string.Empty; - [JsonPropertyName("Portout Pin")] - [JsonProperty("Portout Pin")] - public string PortoutPin { get; set; } = string.Empty; - public TnRecordRouting Routing { get; set; } = new(); - public TnRecordMessaging Messaging { get; set; } = new(); - [JsonPropertyName("TN Details")] - [JsonProperty("TN Details")] - public TnRecordTNDetails TNDetails { get; set; } = new(); - - public class TnRecordRouting - { - [JsonPropertyName("Trunk Group")] - [JsonProperty("Trunk Group")] - public string TrunkGroup { get; set; } = string.Empty; - [JsonPropertyName("Custom URI")] - [JsonProperty("Custom URI")] - public string CustomURI { get; set; } = string.Empty; - [JsonPropertyName("Call Forward")] - [JsonProperty("Call Forward")] - public object CallForward { get; set; } = new(); - } - - public class TnRecordMessaging - { - public bool Sms { get; set; } - public bool Mms { get; set; } - } - - public class TnRecordTNDetails - { - [JsonPropertyName("Rate Center")] - [JsonProperty("Rate Center")] - public string RateCenter { get; set; } = string.Empty; - public string State { get; set; } = string.Empty; - public string Tier { get; set; } = string.Empty; - public bool Cnam { get; set; } - [JsonPropertyName("Activation Date")] - [JsonProperty("Activation Date")] - public string ActivationDate { get; set; } = string.Empty; - } - public static async Task GetRawAsync(string username, string password) + public readonly record struct TnRecordRouting + ( + [property: JsonPropertyName("Trunk Group")] + [property: JsonProperty("Trunk Group")] + string TrunkGroup, + [property: JsonPropertyName("Custom URI")] + [property: JsonProperty("Custom URI")] + string CustomURI, + [property: JsonPropertyName("Call Forward")] + [property: JsonProperty("Call Forward")] + object CallForward); + + + public readonly record struct TnRecordMessaging(bool Sms, bool Mms); + + public readonly record struct TnRecordTNDetails( + [property: JsonPropertyName("Rate Center")] + [property: JsonProperty("Rate Center")] + string RateCenter, + string State, + string Tier, + bool Cnam, + [property: JsonPropertyName("Activation Date")] + [property: JsonProperty("Activation Date")] + string ActivationDate); + + public static async Task GetRawAsync(ReadOnlyMemory username, ReadOnlyMemory password) { string baseUrl = "https://portal.bulkvs.com/api/v1.0/"; string endpoint = "tnRecord"; string route = $"{baseUrl}{endpoint}"; try { - return await route.WithBasicAuth(username, password).GetJsonAsync().ConfigureAwait(false); + return await route.WithBasicAuth(username.ToString(), password.ToString()).GetJsonAsync(); } catch (FlurlHttpException ex) { @@ -77,7 +73,7 @@ public static async Task GetRawAsync(string username, string passwor } } - public static async Task GetByDialedNumberAsync(string dialedNumber, string username, string password) + public static async Task GetByDialedNumberAsync(ReadOnlyMemory dialedNumber, ReadOnlyMemory username, ReadOnlyMemory password) { string baseUrl = "https://portal.bulkvs.com/api/v1.0/"; string endpoint = "tnRecord"; @@ -85,8 +81,8 @@ public static async Task GetByDialedNumberAsync(string dialedNumber, s string route = $"{baseUrl}{endpoint}{numberParameter}"; try { - var results = await route.WithBasicAuth(username, password).GetJsonAsync().ConfigureAwait(false); - return results.FirstOrDefault() ?? new(); + var results = await route.WithBasicAuth(username.ToString(), password.ToString()).GetJsonAsync(); + return results.FirstOrDefault(); } catch (FlurlHttpException ex) { @@ -96,7 +92,7 @@ public static async Task GetByDialedNumberAsync(string dialedNumber, s } } - public static async Task GetAsync(string username, string password) + public static async Task GetAsync(ReadOnlyMemory username, ReadOnlyMemory password) { var results = await GetRawAsync(username, password).ConfigureAwait(false); var output = new List(); @@ -134,7 +130,7 @@ public static async Task GetAsync(string username, string passwor return [.. output]; } - public static async Task GetOwnedAsync(string username, string password) + public static async Task GetOwnedAsync(ReadOnlyMemory username, ReadOnlyMemory password) { var results = await GetRawAsync(username, password).ConfigureAwait(false); var output = new List(); diff --git a/NumberSearch.DataAccess/FusionPBX/DestinationDetails.cs b/NumberSearch.DataAccess/FusionPBX/DestinationDetails.cs index eee2f2f7..26fb1669 100644 --- a/NumberSearch.DataAccess/FusionPBX/DestinationDetails.cs +++ b/NumberSearch.DataAccess/FusionPBX/DestinationDetails.cs @@ -44,26 +44,22 @@ public class DestinationDetails public string destination_order { get; set; } = string.Empty; public string destination_distinctive_ring { get; set; } = string.Empty; public string destination_conditions { get; set; } = string.Empty; - public DestinationAction[] destination_actions { get; set; } = Array.Empty(); + public DestinationAction[] destination_actions { get; set; } = []; public string insert_date { get; set; } = string.Empty; public string insert_user { get; set; } = string.Empty; public string update_date { get; set; } = string.Empty; public string update_user { get; set; } = string.Empty; - public class DestinationAction - { - public string destination_app { get; set; } = string.Empty; - public string destination_data { get; set; } = string.Empty; - } + public readonly record struct DestinationAction(string destination_app,string destination_data); - public static async Task GetByDialedNumberAsync(string dialedNumber, string username, string password) + public static async Task GetByDialedNumberAsync(ReadOnlyMemory dialedNumber, ReadOnlyMemory username, ReadOnlyMemory password) { string baseUrl = "https://acceleratenetworks.sip.callpipe.com/app/rest_api/rest.php"; string url = $"{baseUrl}"; var response = await url - .WithBasicAuth(username, password) - .PostJsonAsync(new { action = "destination-details", number = dialedNumber }); + .WithBasicAuth(username.ToString(), password.ToString()) + .PostJsonAsync(new { action = "destination-details", number = dialedNumber.ToString() }); //var s = await response.GetStringAsync(); @@ -71,28 +67,26 @@ public static async Task GetByDialedNumberAsync(string diale } } - - public class DomainDetails + public readonly record struct DomainDetails( + string domain_uuid, + string domain_parent_uuid, + string domain_name, + bool domain_enabled, + string domain_description, + string insert_date, + string insert_user, + string update_date, + string update_user + ) { - public string domain_uuid { get; set; } = string.Empty; - public string domain_parent_uuid { get; set; } = string.Empty; - public string domain_name { get; set; } = string.Empty; - public bool domain_enabled { get; set; } = false; - public string domain_description { get; set; } = string.Empty; - public string insert_date { get; set; } = string.Empty; - public string insert_user { get; set; } = string.Empty; - public string update_date { get; set; } = string.Empty; - public string update_user { get; set; } = string.Empty; - - - public static async Task GetByDomainIdAsync(string dialedNumber, string username, string password) + public static async Task GetByDomainIdAsync(ReadOnlyMemory domainUUID, ReadOnlyMemory username, ReadOnlyMemory password) { string baseUrl = "https://acceleratenetworks.sip.callpipe.com/app/rest_api/rest.php"; string url = $"{baseUrl}"; var response = await url - .WithBasicAuth(username, password) - .PostJsonAsync(new { action = "domain-details", domain_uuid = dialedNumber }); + .WithBasicAuth(username.ToString(), password.ToString()) + .PostJsonAsync(new { action = "domain-details", domain_uuid = domainUUID.ToString() }); return await response.GetJsonAsync(); } diff --git a/NumberSearch.Ingest/Orders.cs b/NumberSearch.Ingest/Orders.cs index 7e732d07..d0d49bbd 100644 --- a/NumberSearch.Ingest/Orders.cs +++ b/NumberSearch.Ingest/Orders.cs @@ -39,7 +39,7 @@ public static async Task EmailDailyAsync(Owned.SMSRouteChange[ }; - if (await combined.PostAsync(appConfig.Postgresql).ConfigureAwait(false)) + if (await combined.PostAsync(appConfig.Postgresql.ToString())) { Log.Information($"[DailyEmails] Sent out the emails {DateTime.Now}."); } @@ -53,7 +53,7 @@ public static async Task EmailDailyAsync(Owned.SMSRouteChange[ public static async Task DailyBriefingEmailAsync(Owned.SMSRouteChange[] smsRouteChanges, IngestConfiguration appConfig) { // Gather all of the info to put into the daily email. - var orders = await Order.GetAllAsync(appConfig.Postgresql); + var orders = await Order.GetAllAsync(appConfig.Postgresql.ToString()); var ordersToMarkCompleted = new List(); var ordersWithCompletedPortRequests = new List(); @@ -77,7 +77,7 @@ public static async Task DailyBriefingEmailAsync(Owned.SMSRouteChange[] sm // Orders that should be marked as complete now that the port requests are complete? else if (order.Quote is false && order.Completed is false) { - var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, appConfig.Postgresql); + var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, appConfig.Postgresql.ToString()); if (portRequest is not null && portRequest?.State is "COMPLETE") { ordersWithCompletedPortRequests.Add(order); @@ -86,7 +86,7 @@ public static async Task DailyBriefingEmailAsync(Owned.SMSRouteChange[] sm // Orders that have unfinished port requests else if (order.Quote is false && order.Completed is false) { - var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, appConfig.Postgresql); + var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, appConfig.Postgresql.ToString()); if (portRequest is not null && portRequest?.State is not "COMPLETE" && portRequest?.DateSubmitted > order.DateSubmitted) { ordersWithUnfinishedPortRequests.Add(order); @@ -95,7 +95,7 @@ public static async Task DailyBriefingEmailAsync(Owned.SMSRouteChange[] sm // Orders that have unsubmitted port requests else if (order.Quote is false && order.Completed is false) { - var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, appConfig.Postgresql); + var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, appConfig.Postgresql.ToString()); if (portRequest is not null && portRequest?.State is not "COMPLETE" && portRequest?.DateSubmitted < order.DateSubmitted) { ordersWithUnsubmittedPortRequests.Add(order); @@ -339,8 +339,8 @@ public static async Task DailyBriefingEmailAsync(Owned.SMSRouteChange[] sm var notificationEmail = new Email { - PrimaryEmailAddress = appConfig.EmailDan, - CarbonCopy = appConfig.EmailTom, + PrimaryEmailAddress = appConfig.EmailDan.ToString(), + CarbonCopy = appConfig.EmailTom.ToString(), SalesEmailAddress = "support@acceleratenetworks.com", DateSent = DateTime.Now, Subject = $"[Ingest] Daily Briefing for {DateTime.Now.ToShortDateString()}", @@ -349,17 +349,17 @@ public static async Task DailyBriefingEmailAsync(Owned.SMSRouteChange[] sm Completed = false }; - var checkSend = await notificationEmail.SendEmailAsync(appConfig.SmtpUsername, appConfig.SmtpPassword).ConfigureAwait(false); - var checkSave = await notificationEmail.PostAsync(appConfig.Postgresql).ConfigureAwait(false); + var checkSend = await notificationEmail.SendEmailAsync(appConfig.SmtpUsername.ToString(), appConfig.SmtpPassword.ToString()).ConfigureAwait(false); + var checkSave = await notificationEmail.PostAsync(appConfig.Postgresql.ToString()).ConfigureAwait(false); return checkSend && checkSave; } - public async static Task CheckForQuoteConversionsAsync(string postgresql, string invoiceNinjaToken, string emailUsername, string emailPassword) + public async static Task CheckForQuoteConversionsAsync(ReadOnlyMemory postgresql, ReadOnlyMemory invoiceNinjaToken, ReadOnlyMemory emailUsername, ReadOnlyMemory emailPassword) { Log.Information($"[Quote Conversion] Looking for quotes that were converted to invoices in the billing system."); - var orders = await Order.GetAllQuotesAsync(postgresql).ConfigureAwait(false); + var orders = await Order.GetAllQuotesAsync(postgresql.ToString()); // Don't both checking orders that are from before we upgraded to the current version of invoiceNinja. foreach (var order in orders.Where(x => x.DateSubmitted > DateTime.Parse("02/01/2023"))) @@ -371,11 +371,11 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string { try { - var upfront = await Invoice.GetQuoteByIdAsync(order.BillingInvoiceId, invoiceNinjaToken); + var upfront = await Invoice.GetQuoteByIdAsync(order.BillingInvoiceId, invoiceNinjaToken.ToString()); if (upfront is not null && upfront.id == order.BillingInvoiceId && !string.IsNullOrWhiteSpace(upfront.invoice_id)) { - var convertedInvoice = await Invoice.GetByIdAsync(upfront.invoice_id, invoiceNinjaToken); + var convertedInvoice = await Invoice.GetByIdAsync(upfront.invoice_id, invoiceNinjaToken.ToString()); string newUpfrontLink = convertedInvoice.invitations.FirstOrDefault()?.link ?? string.Empty; @@ -392,7 +392,7 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string } var invoiceStatus = convertedInvoice.status_id is "4" ? "paid" : "approved"; - var checkUpdate = await order.PutAsync(postgresql); + var checkUpdate = await order.PutAsync(postgresql.ToString()); string name = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName; var message = new Email { @@ -405,12 +405,12 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string }; // Send the message the email server. - var checkSend = await message.SendEmailAsync(emailUsername, emailPassword).ConfigureAwait(false); + var checkSend = await message.SendEmailAsync(emailUsername.ToString(), emailPassword.ToString()); // If it didn't work try it again. if (!checkSend) { - checkSend = await message.SendEmailAsync(emailUsername, emailPassword).ConfigureAwait(false); + checkSend = await message.SendEmailAsync(emailUsername.ToString(), emailPassword.ToString()); } // Mark it as sent. @@ -419,7 +419,7 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string message.Completed = checkSend; // Update the database with the email's new status. - var checkSave = await message.PostAsync(postgresql).ConfigureAwait(false); + var checkSave = await message.PostAsync(postgresql.ToString()); // Log the success or failure of the operation. if (checkSend && checkSave) @@ -437,7 +437,7 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string if (ex.StatusCode is 404) { // Maybe it's an invoice rather than a Quote - var convertedInvoice = await Invoice.GetByIdAsync(order.BillingInvoiceId, invoiceNinjaToken); + var convertedInvoice = await Invoice.GetByIdAsync(order.BillingInvoiceId, invoiceNinjaToken.ToString()); if (convertedInvoice is not null && convertedInvoice.id == order.BillingInvoiceId && !string.IsNullOrWhiteSpace(convertedInvoice.id)) { @@ -458,7 +458,7 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string order.UpfrontInvoiceLink = string.IsNullOrWhiteSpace(newUpfrontLink) ? order.UpfrontInvoiceLink : newUpfrontLink; - var checkUpdate = await order.PutAsync(postgresql); + var checkUpdate = await order.PutAsync(postgresql.ToString()); string name = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName; var invoiceStatus = convertedInvoice.status_id is "4" ? "paid" : "converted from a quote"; var message = new Email @@ -472,12 +472,12 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string }; // Send the message the email server. - var checkSend = await message.SendEmailAsync(emailUsername, emailPassword).ConfigureAwait(false); + var checkSend = await message.SendEmailAsync(emailUsername.ToString(), emailPassword.ToString()); // If it didn't work try it again. if (!checkSend) { - checkSend = await message.SendEmailAsync(emailUsername, emailPassword).ConfigureAwait(false); + checkSend = await message.SendEmailAsync(emailUsername.ToString(), emailPassword.ToString()); } // Mark it as sent. @@ -486,7 +486,7 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string message.Completed = checkSend; // Update the database with the email's new status. - var checkSave = await message.PostAsync(postgresql).ConfigureAwait(false); + var checkSave = await message.PostAsync(postgresql.ToString()); // Log the success or failure of the operation. if (checkSend && checkSave) @@ -528,11 +528,11 @@ public async static Task CheckForQuoteConversionsAsync(string postgresql, string } } - public async static Task CheckForInvoicePaymentAsync(string postgresql, string invoiceNinjaToken, string emailUsername, string emailPassword) + public async static Task CheckForInvoicePaymentAsync(ReadOnlyMemory postgresql, ReadOnlyMemory invoiceNinjaToken, ReadOnlyMemory emailUsername, ReadOnlyMemory emailPassword) { Log.Information($"[Invoice Payment] Looking for invoices that were paid in the billing system."); - var orders = await Order.GetAllAsync(postgresql).ConfigureAwait(false); + var orders = await Order.GetAllAsync(postgresql.ToString()); // Don't both checking orders that are from before we upgraded to the current version of invoiceNinja. foreach (var order in orders.Where(x => x.DateSubmitted > DateTime.Parse("02/01/2023"))) @@ -542,7 +542,7 @@ public async static Task CheckForInvoicePaymentAsync(string postgresql, string i { if (!string.IsNullOrWhiteSpace(order.BillingInvoiceId) && order.DateUpfrontInvoicePaid is null) { - var upfrontInvoice = await Invoice.GetByIdAsync(order.BillingInvoiceId, invoiceNinjaToken); + var upfrontInvoice = await Invoice.GetByIdAsync(order.BillingInvoiceId, invoiceNinjaToken.ToString()); if (upfrontInvoice is not null && upfrontInvoice.id == order.BillingInvoiceId && !string.IsNullOrWhiteSpace(upfrontInvoice.id)) { @@ -561,7 +561,7 @@ public async static Task CheckForInvoicePaymentAsync(string postgresql, string i } string newUpfrontLink = upfrontInvoice.invitations.FirstOrDefault()?.link ?? string.Empty; order.UpfrontInvoiceLink = string.IsNullOrWhiteSpace(newUpfrontLink) ? order.UpfrontInvoiceLink : newUpfrontLink; - var checkUpdate = await order.PutAsync(postgresql); + var checkUpdate = await order.PutAsync(postgresql.ToString()); // Only send the email of the invoice has actually been paid. if (order.DateUpfrontInvoicePaid is not null && upfrontInvoice.status_id is "4") @@ -578,12 +578,12 @@ public async static Task CheckForInvoicePaymentAsync(string postgresql, string i }; // Send the message the email server. - var checkSend = await message.SendEmailAsync(emailUsername, emailPassword).ConfigureAwait(false); + var checkSend = await message.SendEmailAsync(emailUsername.ToString(), emailPassword.ToString()); // If it didn't work try it again. if (!checkSend) { - checkSend = await message.SendEmailAsync(emailUsername, emailPassword).ConfigureAwait(false); + checkSend = await message.SendEmailAsync(emailUsername.ToString(), emailPassword.ToString()); } // Mark it as sent. @@ -592,7 +592,7 @@ public async static Task CheckForInvoicePaymentAsync(string postgresql, string i message.Completed = checkSend; // Update the database with the email's new status. - var checkSave = await message.PostAsync(postgresql).ConfigureAwait(false); + var checkSave = await message.PostAsync(postgresql.ToString()); // Log the success or failure of the operation. if (checkSend && checkSave) diff --git a/NumberSearch.Ingest/Owned.cs b/NumberSearch.Ingest/Owned.cs index 405e872c..c7b2ce22 100644 --- a/NumberSearch.Ingest/Owned.cs +++ b/NumberSearch.Ingest/Owned.cs @@ -28,7 +28,7 @@ public static async Task OwnedDailyAsync(IngestConfiguration a { // Prevent another run from starting while this is still going. - var lockingStats = new IngestStatistics + IngestStatistics lockingStats = new() { IngestedFrom = "OwnedNumbers", StartDate = DateTime.Now, @@ -42,11 +42,11 @@ public static async Task OwnedDailyAsync(IngestConfiguration a Lock = true }; - await lockingStats.PostAsync(appConfig.Postgresql).ConfigureAwait(false); - var smsRouteChanges = await Owned.IngestAsync(appConfig); + await lockingStats.PostAsync(appConfig.Postgresql.ToString()).ConfigureAwait(false); + SMSRouteChange[] smsRouteChanges = await Owned.IngestAsync(appConfig); // Remove the lock from the database to prevent it from getting cluttered with blank entries. - await lockingStats.DeleteAsync(appConfig.Postgresql).ConfigureAwait(false); + await lockingStats.DeleteAsync(appConfig.Postgresql.ToString()).ConfigureAwait(false); return smsRouteChanges; } @@ -60,7 +60,7 @@ public async static Task IngestAsync(IngestConfiguration confi // Ingest all owned numbers from the providers. try { - var firstComNumbers = await FirstPointComAsync(configuration.PComNetUsername, configuration.PComNetPassword).ConfigureAwait(false); + var firstComNumbers = await FirstPointComAsync(configuration.PComNetUsername, configuration.PComNetPassword); if (firstComNumbers != null) { allNumbers.AddRange(firstComNumbers); @@ -118,12 +118,12 @@ public async static Task IngestAsync(IngestConfiguration confi try { Log.Information("[OwnedNumbers] Looking for LRN changes on owned numbers."); - var changedNumbers = await VerifyServiceProvidersAsync(configuration.BulkVSAPIKEY, configuration.Postgresql).ConfigureAwait(false); + var changedNumbers = await VerifyServiceProvidersAsync(configuration.BulkVSAPIKEY, configuration.Postgresql); if (changedNumbers != null && changedNumbers.Any()) { Log.Information($"[OwnedNumbers] Emailing out a notification that {changedNumbers.Count()} numbers LRN updates."); - var checkSend = await SendPortingNotificationEmailAsync(changedNumbers, configuration.SmtpUsername, configuration.SmtpPassword, configuration.EmailDan, configuration.EmailOrders, configuration.Postgresql).ConfigureAwait(false); + var checkSend = await SendPortingNotificationEmailAsync(changedNumbers, configuration.SmtpUsername, configuration.SmtpPassword, configuration.EmailDan, configuration.EmailOrders, configuration.Postgresql); } } catch (Exception ex) @@ -133,28 +133,28 @@ public async static Task IngestAsync(IngestConfiguration confi } // Offer unassigned phone numbers we own for purchase on the website. - _ = await OfferUnassignedNumberForSaleAsync(configuration.Postgresql).ConfigureAwait(false); + _ = await OfferUnassignedNumberForSaleAsync(configuration.Postgresql); // Match up owned numbers and their billingClients. - _ = await MatchOwnedNumbersToBillingClientsAsync(configuration.Postgresql).ConfigureAwait(false); + _ = await MatchOwnedNumbersToBillingClientsAsync(configuration.Postgresql); // Link up E911 registrations to owned numbers. - await VerifyEmergencyInformationAsync(configuration.Postgresql, configuration.BulkVSUsername, configuration.BulkVSPassword).ConfigureAwait(false); + await VerifyEmergencyInformationAsync(configuration.Postgresql, configuration.BulkVSUsername, configuration.BulkVSPassword); // Match numbers to destinations and domains in FusionPBX. await MatchOwnedNumbersToFusionPBXAsync(configuration.Postgresql, configuration.FusionPBXUsername, configuration.FusionPBXPassword); // Verify SMS routing with Endstream. - var smsRouteChanges = await VerifySMSRoutingAsync(configuration.Postgresql, configuration.PComNetUsername, configuration.PComNetPassword); + SMSRouteChange[] smsRouteChanges = await VerifySMSRoutingAsync(configuration.Postgresql, configuration.PComNetUsername, configuration.PComNetPassword); // Update the statuses on old or orphaned port requests and ported numbers. await PortRequests.UpdatePortRequestsAndNumbersByExternalIdAsync(configuration); // Remove the lock from the database to prevent it from getting cluttered with blank entries. - var lockEntry = await IngestStatistics.GetLockAsync("OwnedNumbers", configuration.Postgresql).ConfigureAwait(false); + var lockEntry = await IngestStatistics.GetLockAsync("OwnedNumbers", configuration.Postgresql.ToString()); if (lockEntry is not null) { - _ = await lockEntry.DeleteAsync(configuration.Postgresql).ConfigureAwait(false); + _ = await lockEntry.DeleteAsync(configuration.Postgresql.ToString()); } // Remove all of the old numbers from the database. @@ -175,7 +175,7 @@ public async static Task IngestAsync(IngestConfiguration confi Priority = false }; - if (await combined.PostAsync(configuration.Postgresql).ConfigureAwait(false)) + if (await combined.PostAsync(configuration.Postgresql.ToString())) { Log.Information("[OwnedNumbers] Completed the ingest process."); } @@ -189,20 +189,20 @@ public async static Task IngestAsync(IngestConfiguration confi public record SMSRouteChange(string DialedNumber, string OldRoute, string NewRoute, string Message); - public static async Task VerifySMSRoutingAsync(string connectionString, string pComNetUsername, string pComNetPassword) + public static async Task VerifySMSRoutingAsync(ReadOnlyMemory connectionString, ReadOnlyMemory pComNetUsername, ReadOnlyMemory pComNetPassword) { Log.Information($"[OwnedNumbers] Verifying SMS Routing for Owned Phone numbers."); var changes = new List(); - var ownedNumbers = await OwnedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); + var ownedNumbers = await OwnedPhoneNumber.GetAllAsync(connectionString.ToString()); foreach (var number in ownedNumbers.Where(x => x.Status is "Active")) { bool updated = false; try { - var checkSMSRouting = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync($"1{number.DialedNumber}", pComNetUsername, pComNetPassword); + var checkSMSRouting = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync($"1{number.DialedNumber}".AsMemory(), pComNetUsername, pComNetPassword); if (!string.IsNullOrWhiteSpace(checkSMSRouting.route)) { // Update the owned number with the route. @@ -232,7 +232,7 @@ public static async Task VerifySMSRoutingAsync(string connecti if (updated) { - var checkUpdate = await number.PutAsync(connectionString); + var checkUpdate = await number.PutAsync(connectionString.ToString()); Log.Information($"[OwnedNumbers] Updated SMS routing for {number.DialedNumber} with FirstPointCom."); } } @@ -242,15 +242,15 @@ public static async Task VerifySMSRoutingAsync(string connecti return [.. changes]; } - public static async Task MatchOwnedNumbersToFusionPBXAsync(string connectionString, string fusionPBXUsername, string fusionPBXPassword) + public static async Task MatchOwnedNumbersToFusionPBXAsync(ReadOnlyMemory connectionString, ReadOnlyMemory fusionPBXUsername, ReadOnlyMemory fusionPBXPassword) { Log.Information($"[OwnedNumbers] Matching FusionPBX data for Owned Phone numbers."); - var ownedNumbers = await OwnedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); + var ownedNumbers = await OwnedPhoneNumber.GetAllAsync(connectionString.ToString()).ConfigureAwait(false); try { - var destination = await DestinationDetails.GetByDialedNumberAsync("2068588757", fusionPBXUsername, fusionPBXPassword); + var destination = await DestinationDetails.GetByDialedNumberAsync("2068588757".AsMemory(), fusionPBXUsername, fusionPBXPassword); // If we aren't getting good data back from FusionPBX then skip this updating process. if (destination is not null && !string.IsNullOrWhiteSpace(destination.domain_uuid)) @@ -261,7 +261,7 @@ public static async Task MatchOwnedNumbersToFusionPBXAsync(string connectionStri try { - destination = await DestinationDetails.GetByDialedNumberAsync(ownedNumber.DialedNumber, fusionPBXUsername, fusionPBXPassword); + destination = await DestinationDetails.GetByDialedNumberAsync(ownedNumber.DialedNumber.AsMemory(), fusionPBXUsername, fusionPBXPassword); if (destination is not null && !string.IsNullOrWhiteSpace(destination.domain_uuid)) { @@ -273,9 +273,9 @@ public static async Task MatchOwnedNumbersToFusionPBXAsync(string connectionStri updated = true; } - var domain = await DomainDetails.GetByDomainIdAsync(destination.domain_uuid, fusionPBXUsername, fusionPBXPassword); + var domain = await DomainDetails.GetByDomainIdAsync(destination.domain_uuid.AsMemory(), fusionPBXUsername, fusionPBXPassword); - if (domain is not null && !string.IsNullOrWhiteSpace(domain.domain_name)) + if (!string.IsNullOrWhiteSpace(domain.domain_name)) { if (ownedNumber.FPBXDomainName != domain.domain_name) { @@ -318,7 +318,7 @@ public static async Task MatchOwnedNumbersToFusionPBXAsync(string connectionStri if (updated) { ownedNumber.DateUpdated = DateTime.Now; - _ = await ownedNumber.PutAsync(connectionString); + _ = await ownedNumber.PutAsync(connectionString.ToString()); Log.Information("[OwnedNumbers] Updated FusionPBX data for Owned Phone number {@OwnedNumber}", ownedNumber); } } @@ -333,7 +333,7 @@ public static async Task MatchOwnedNumbersToFusionPBXAsync(string connectionStri Log.Information($"[OwnedNumbers] Updated FusionPBX data for Owned Phone numbers."); } - public static async Task> FirstPointComAsync(string username, string password) + public static async Task> FirstPointComAsync(ReadOnlyMemory username, ReadOnlyMemory password) { var numbers = new List(); @@ -341,7 +341,7 @@ public static async Task> FirstPointComAsync(strin { try { - var results = await FirstPointComOwnedPhoneNumber.GetAsync(npa.ToString(), username, password).ConfigureAwait(false); + var results = await FirstPointComOwnedPhoneNumber.GetAsync(npa.ToString().AsMemory(), username, password).ConfigureAwait(false); Log.Information($"[OwnedNumbers] [FirstPointCom] Retrieved {results.DIDOrder.Length} owned numbers."); @@ -377,7 +377,7 @@ public static async Task> FirstPointComAsync(strin return numbers.Count != 0 ? numbers.ToArray() : new List(); } - public static async Task SubmitOwnedNumbersAsync(IEnumerable newlyIngested, string connectionString, string bulkVSUsername, string bulkVSPassword) + public static async Task SubmitOwnedNumbersAsync(IEnumerable newlyIngested, ReadOnlyMemory connectionString, ReadOnlyMemory bulkVSUsername, ReadOnlyMemory bulkVSPassword) { var start = DateTime.Now; var ingestedNew = 0; @@ -385,10 +385,10 @@ public static async Task SubmitOwnedNumbersAsync(IEnumerable x.DialedNumber).ToDictionary(x => x.DialedNumber, x => x); var newAsDict = newlyIngested.ToDictionary(x => x.DialedNumber, x => x); - var portedPhoneNumbers = await PortedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); + var portedPhoneNumbers = await PortedPhoneNumber.GetAllAsync(connectionString.ToString()); foreach (var item in newlyIngested) { @@ -399,8 +399,8 @@ public static async Task SubmitOwnedNumbersAsync(IEnumerable x.PortedDialedNumber == item.DialedNumber).FirstOrDefault(); if (matchingPort is not null && !string.IsNullOrWhiteSpace(matchingPort.RequestStatus) && matchingPort.RequestStatus is not "COMPLETE") { - var externalStatus = await TnRecord.GetByDialedNumberAsync(item.DialedNumber, bulkVSUsername, bulkVSPassword); - if (externalStatus?.Status is not "Active") + var externalStatus = await TnRecord.GetByDialedNumberAsync(item.DialedNumber.AsMemory(), bulkVSUsername, bulkVSPassword); + if (externalStatus.Status is not "Active") { // If it is a ported number and the port has not complete mark it as ported in. item.Status = "Porting In"; @@ -417,7 +417,7 @@ public static async Task SubmitOwnedNumbersAsync(IEnumerable SubmitOwnedNumbersAsync(IEnumerable x.PortedDialedNumber == item.DialedNumber).FirstOrDefault(); if (matchingPort is not null && !string.IsNullOrWhiteSpace(matchingPort.RequestStatus) && matchingPort.RequestStatus is not "COMPLETE") { - var externalStatus = await TnRecord.GetByDialedNumberAsync(item.DialedNumber, bulkVSUsername, bulkVSPassword); - if (externalStatus?.Status is not "Active") + var externalStatus = await TnRecord.GetByDialedNumberAsync(item.DialedNumber.AsMemory(), bulkVSUsername, bulkVSPassword); + if (externalStatus.Status is not "Active") { // If it is a ported number and the port has not complete mark it as ported in. number.Status = "Porting In"; @@ -456,7 +456,7 @@ public static async Task SubmitOwnedNumbersAsync(IEnumerable SubmitOwnedNumbersAsync(IEnumerable SubmitOwnedNumbersAsync(IEnumerable OfferUnassignedNumberForSaleAsync(string connectionString) + public static async Task OfferUnassignedNumberForSaleAsync(ReadOnlyMemory connectionString) { var start = DateTime.Now; var ingestedNew = 0; var updatedExisting = 0; - var numbers = await OwnedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); + var numbers = await OwnedPhoneNumber.GetAllAsync(connectionString.ToString()); List newUnassigned = []; @@ -548,7 +548,7 @@ public static async Task OfferUnassignedNumberForSaleAsync(str { if (item?.Notes is not null && item?.Notes.Trim() == "Unassigned") { - var number = await DataAccess.Models.PhoneNumber.GetAsync(item.DialedNumber, connectionString).ConfigureAwait(false); + var number = await DataAccess.Models.PhoneNumber.GetAsync(item.DialedNumber, connectionString.ToString()); if (number is null || item.DialedNumber != number.DialedNumber) { @@ -583,7 +583,7 @@ public static async Task OfferUnassignedNumberForSaleAsync(str number.IngestedFrom = "OwnedNumber"; number.Purchased = false; - _ = await number.PutAsync(connectionString); + _ = await number.PutAsync(connectionString.ToString()); updatedExisting++; Log.Information($"[Ingest] [OwnedNumber] Continued offering unassigned number {item.DialedNumber} up for sale."); @@ -593,7 +593,7 @@ public static async Task OfferUnassignedNumberForSaleAsync(str DataAccess.Models.PhoneNumber[] typedNumbers = Services.AssignNumberTypes([..newUnassigned]); DataAccess.Models.PhoneNumber[] locations = await Services.AssignRatecenterAndRegionAsync(typedNumbers); - _ = await Services.SubmitPhoneNumbersAsync(locations, connectionString.AsMemory()); + _ = await Services.SubmitPhoneNumbersAsync(locations, connectionString); DateTime end = DateTime.Now; @@ -615,14 +615,14 @@ public static async Task OfferUnassignedNumberForSaleAsync(str return stats; } - public static async Task MatchOwnedNumbersToBillingClientsAsync(string connectionString) + public static async Task MatchOwnedNumbersToBillingClientsAsync(ReadOnlyMemory connectionString) { var start = DateTime.Now; var updatedExisting = 0; - var numbers = await OwnedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); - var purchased = await PurchasedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); - var ported = await PortedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); + var numbers = await OwnedPhoneNumber.GetAllAsync(connectionString.ToString()); + var purchased = await PurchasedPhoneNumber.GetAllAsync(connectionString.ToString()); + var ported = await PortedPhoneNumber.GetAllAsync(connectionString.ToString()); foreach (var number in numbers) { @@ -639,7 +639,7 @@ public static async Task MatchOwnedNumbersToBillingClientsAsyn continue; } - var order = await Order.GetByIdAsync(match2.OrderId ?? Guid.NewGuid(), connectionString).ConfigureAwait(false); + var order = await Order.GetByIdAsync(match2.OrderId ?? Guid.NewGuid(), connectionString.ToString()); //var badLink = $"https://billing.acceleratenetworks.com/clients/{number.BillingClientId}/edit"; //var checkLink = badLink.GetStringAsync(); @@ -649,7 +649,7 @@ public static async Task MatchOwnedNumbersToBillingClientsAsyn number.BillingClientId = order.BillingClientId; number.OwnedBy = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName; - var checkUpdate = await number.PutAsync(connectionString).ConfigureAwait(false); + var checkUpdate = await number.PutAsync(connectionString.ToString()); updatedExisting++; Log.Information($"[OwnedNumbers] [ClientMatch] Associated Owned Number {match2?.PortedDialedNumber} with billing client id {order?.BillingClientId}"); @@ -661,14 +661,14 @@ public static async Task MatchOwnedNumbersToBillingClientsAsyn } else { - var order = await Order.GetByIdAsync(match.OrderId, connectionString).ConfigureAwait(false); + var order = await Order.GetByIdAsync(match.OrderId, connectionString.ToString()); if (order is not null && !string.IsNullOrWhiteSpace(order?.BillingClientId)) { number.BillingClientId = order.BillingClientId; number.OwnedBy = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName; - var checkUpdate = await number.PutAsync(connectionString).ConfigureAwait(false); + var checkUpdate = await number.PutAsync(connectionString.ToString()); updatedExisting++; Log.Information($"[OwnedNumbers] [ClientMatch] Associated Owned Number {match?.DialedNumber} with billing client id {order?.BillingClientId}"); @@ -680,9 +680,9 @@ public static async Task MatchOwnedNumbersToBillingClientsAsyn } } - var end = DateTime.Now; + DateTime end = DateTime.Now; - var stats = new IngestStatistics + IngestStatistics stats = new() { StartDate = start, EndDate = end, @@ -700,19 +700,19 @@ public static async Task MatchOwnedNumbersToBillingClientsAsyn return stats; } - public class ServiceProviderChanged - { - public string DialedNumber { get; set; } = string.Empty; - public string OldSPID { get; set; } = string.Empty; - public string CurrentSPID { get; set; } = string.Empty; - public string OldSPIDName { get; set; } = string.Empty; - public string CurrentSPIDName { get; set; } = string.Empty; - public string RawQuery { get; set; } = string.Empty; - } - - public static async Task> VerifyServiceProvidersAsync(string bulkApiKey, string connectionString) + public readonly record struct ServiceProviderChanged + ( + string DialedNumber, + string OldSPID, + string CurrentSPID, + string OldSPIDName, + string CurrentSPIDName, + string RawQuery + ); + + public static async Task VerifyServiceProvidersAsync(ReadOnlyMemory bulkApiKey, ReadOnlyMemory connectionString) { - var owned = await OwnedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); + var owned = await OwnedPhoneNumber.GetAllAsync(connectionString.ToString()); var serviceProviderChanged = new List(); // Only query data for numbers with a status of Active. @@ -729,7 +729,7 @@ public static async Task> VerifyServiceProvi } else { - var result = await LrnBulkCnam.GetAsync(number.DialedNumber, bulkApiKey).ConfigureAwait(false); + var result = await LrnBulkCnam.GetAsync(number.DialedNumber, bulkApiKey.ToString()); var provider = "BulkVS"; var newSpid = result?.spid ?? string.Empty; @@ -753,7 +753,7 @@ public static async Task> VerifyServiceProvi // Update the SPID to the current value. number.SPID = newSpid; number.SPIDName = newSpidName; - var checkUpdate = await number.PutAsync(connectionString).ConfigureAwait(false); + var checkUpdate = await number.PutAsync(connectionString.ToString()); if (checkUpdate) { Log.Information($"[OwnedNumbers] Updated {newSpidName}, {newSpid} for {number.DialedNumber} from [{provider}]."); @@ -779,18 +779,18 @@ public static async Task> VerifyServiceProvi Log.Information($"[OwnedNumbers] Found {serviceProviderChanged.Count} numbers whose Service Provider has changed since the last ingest."); - return serviceProviderChanged; + return [..serviceProviderChanged]; } - public static async Task VerifyEmergencyInformationAsync(string connectionString, string bulkVSUsername, string bulkVSPassword) + public static async Task VerifyEmergencyInformationAsync(ReadOnlyMemory connectionString, ReadOnlyMemory bulkVSUsername, ReadOnlyMemory bulkVSPassword) { - var emergencyInformation = await EmergencyInformation.GetAllAsync(connectionString).ConfigureAwait(false); + var emergencyInformation = await EmergencyInformation.GetAllAsync(connectionString.ToString()); Log.Information($"[OwnedNumbers] Verifying Emergency Information for {emergencyInformation?.Count()} Owned Phone numbers."); - var ownedNumbers = await OwnedPhoneNumber.GetAllAsync(connectionString).ConfigureAwait(false); + var ownedNumbers = await OwnedPhoneNumber.GetAllAsync(connectionString.ToString()); - var e911Registrations = await E911Record.GetAllAsync(bulkVSUsername, bulkVSPassword); + var e911Registrations = await E911Record.GetAllAsync(bulkVSUsername.ToString(), bulkVSPassword.ToString()); foreach (var record in e911Registrations) { @@ -815,7 +815,7 @@ public static async Task VerifyEmergencyInformationAsync(string connectionString existing.State = existing.State != record.State ? record.State : existing.State; existing.Zip = existing.Zip != record.Zip ? record.Zip : existing.Zip; - var checkUpdate = await existing.PutAsync(connectionString); + var checkUpdate = await existing.PutAsync(connectionString.ToString()); if (!checkUpdate) { @@ -844,8 +844,8 @@ public static async Task VerifyEmergencyInformationAsync(string connectionString ownedNumber.EmergencyInformationId = registration.EmergencyInformationId; - var checkCreate = await registration.PostAsync(connectionString); - var checkUpdate = await ownedNumber.PutAsync(connectionString); + var checkCreate = await registration.PostAsync(connectionString.ToString()); + var checkUpdate = await ownedNumber.PutAsync(connectionString.ToString()); if (!checkCreate && !checkUpdate) { @@ -875,8 +875,8 @@ public static async Task VerifyEmergencyInformationAsync(string connectionString ownedNumber.EmergencyInformationId = registration.EmergencyInformationId; - var checkCreate = await registration.PostAsync(connectionString); - var checkUpdate = await ownedNumber.PutAsync(connectionString); + var checkCreate = await registration.PostAsync(connectionString.ToString()); + var checkUpdate = await ownedNumber.PutAsync(connectionString.ToString()); if (!checkCreate && !checkUpdate) { @@ -888,15 +888,15 @@ public static async Task VerifyEmergencyInformationAsync(string connectionString } } - public static async Task SendPortingNotificationEmailAsync(IEnumerable changes, string smtpUsername, string smtpPassword, string emailPrimary, string emailCC, string connectionString) + public static async Task SendPortingNotificationEmailAsync(ServiceProviderChanged[] changes, ReadOnlyMemory smtpUsername, ReadOnlyMemory smtpPassword, ReadOnlyMemory emailPrimary, ReadOnlyMemory emailCC, ReadOnlyMemory connectionString) { - if ((changes is null) || !changes.Any()) + if (changes.Length is 0) { // Successfully did nothing. return true; } - var options = new JsonSerializerOptions + JsonSerializerOptions options = new() { WriteIndented = true }; @@ -907,17 +907,17 @@ public static async Task SendPortingNotificationEmailAsync(IEnumerable x.TN == $"1{number.PortedDialedNumber}").FirstOrDefault(); - if (matchingNumber is not null) + if (matchingNumber.OrderId == request.OrderId) { var checkRDDParse = DateTime.TryParse(matchingNumber.RDD, out var FOCDate); @@ -61,8 +62,8 @@ public async static Task UpdateStatusesBulkVSAsync(IngestConfiguration configura } } - var checkPortedNumberUpdate = await number.PutAsync(configuration.Postgresql).ConfigureAwait(false); - Log.Information($"[BulkVS] [PortRequests] Updated BulkVS Port Request {request?.OrderId} - {number?.PortedDialedNumber} - {number?.RequestStatus} - {number?.DateFirmOrderCommitment?.ToShortDateString()}"); + var checkPortedNumberUpdate = await number.PutAsync(configuration.Postgresql.ToString()); + Log.Information($"[BulkVS] [PortRequests] Updated BulkVS Port Request {request.OrderId} - {number?.PortedDialedNumber} - {number?.RequestStatus} - {number?.DateFirmOrderCommitment?.ToShortDateString()}"); } } } @@ -76,7 +77,7 @@ public async static Task UpdateStatusesBulkVSAsync(IngestConfiguration configura if (portedNumbers.FirstOrDefault() is not null) { - var portRequest = await PortRequest.GetByOrderIdAsync(portedNumbers.FirstOrDefault()?.OrderId ?? Guid.Empty, configuration.Postgresql).ConfigureAwait(false); + var portRequest = await PortRequest.GetByOrderIdAsync(portedNumbers.FirstOrDefault()?.OrderId ?? Guid.Empty, configuration.Postgresql.ToString()); if (portRequest is not null && portRequest.OrderId == portedNumbers.FirstOrDefault()?.OrderId) { @@ -117,11 +118,11 @@ public async static Task UpdateStatusesBulkVSAsync(IngestConfiguration configura } // Update the request in the database. - var checkUpdate = await portRequest.PutAsync(configuration.Postgresql).ConfigureAwait(false); + var checkUpdate = await portRequest.PutAsync(configuration.Postgresql.ToString()); Log.Information($"[BulkVS] [PortRequests] Updated BulkVS Port Request {portRequest?.BulkVSId} - {portRequest?.RequestStatus} - {portRequest?.DateCompleted?.ToShortDateString()}"); // Get the original order and the numbers associated with the outstanding Port Request. - var originalOrder = await Order.GetByIdAsync(portRequest!.OrderId, configuration.Postgresql).ConfigureAwait(false); + var originalOrder = await Order.GetByIdAsync(portRequest!.OrderId, configuration.Postgresql.ToString()); if (originalOrder is not null) { @@ -129,7 +130,7 @@ public async static Task UpdateStatusesBulkVSAsync(IngestConfiguration configura { PrimaryEmailAddress = originalOrder.Email, SalesEmailAddress = string.IsNullOrWhiteSpace(originalOrder?.SalesEmail) ? string.Empty : originalOrder.SalesEmail, - CarbonCopy = configuration.EmailOrders, + CarbonCopy = configuration.EmailOrders.ToString(), OrderId = originalOrder!.OrderId }; @@ -169,8 +170,8 @@ Accelerate Networks
206-858-8757 (call or text)"; - var checkSend = await notificationEmail.SendEmailAsync(configuration.SmtpUsername, configuration.SmtpPassword).ConfigureAwait(false); - var checkSave = await notificationEmail.PostAsync(configuration.Postgresql).ConfigureAwait(false); + var checkSend = await notificationEmail.SendEmailAsync(configuration.SmtpUsername.ToString(), configuration.SmtpPassword.ToString()); + var checkSave = await notificationEmail.PostAsync(configuration.Postgresql.ToString()); if (checkSend && checkSave) { @@ -211,8 +212,8 @@ Accelerate Networks
206-858-8757 (call or text)"; - var checkSend = await notificationEmail.SendEmailAsync(configuration.SmtpUsername, configuration.SmtpPassword).ConfigureAwait(false); - var checkSave = await notificationEmail.PostAsync(configuration.Postgresql).ConfigureAwait(false); + var checkSend = await notificationEmail.SendEmailAsync(configuration.SmtpUsername.ToString(), configuration.SmtpPassword.ToString()); + var checkSave = await notificationEmail.PostAsync(configuration.Postgresql.ToString()); if (checkSend && checkSave) { @@ -235,24 +236,24 @@ public async static Task UpdatePortRequestsAndNumbersByExternalIdAsync(IngestCon { Log.Information("[BulkVS] [PortRequests] Ingesting Port Request statuses using the external OrderId."); - var portRequests = await PortRequest.GetAllAsync(configuration.Postgresql); + var portRequests = await PortRequest.GetAllAsync(configuration.Postgresql.ToString()); var notCompleted = portRequests.Where(x => x.VendorSubmittedTo is "BulkVS" && x.RequestStatus is not "COMPLETE" && x.DateCompleted is null && !string.IsNullOrWhiteSpace(x.BulkVSId)).ToArray(); foreach (var request in notCompleted) { string[] OrderIds = request.BulkVSId.Replace(" ", "").Split(","); foreach (var orderId in OrderIds) { - PortTn bulkVSPortRequest = await PortTn.GetAsync(orderId, configuration.BulkVSUsername, configuration.BulkVSPassword); + PortTn bulkVSPortRequest = await PortTn.GetAsync(orderId.AsMemory(), configuration.BulkVSUsername, configuration.BulkVSPassword); var firstNumber = bulkVSPortRequest.TNList.FirstOrDefault(); - if (bulkVSPortRequest.OrderDetails.OrderId == orderId && firstNumber is not null && !string.IsNullOrWhiteSpace(firstNumber.LNPStatus)) + if (bulkVSPortRequest.OrderDetails.OrderId == orderId && !string.IsNullOrWhiteSpace(firstNumber.LNPStatus)) { request.RequestStatus = firstNumber.LNPStatus; - var related = await PortedPhoneNumber.GetByPortRequestIdAsync(request.PortRequestId, configuration.Postgresql); + var related = await PortedPhoneNumber.GetByPortRequestIdAsync(request.PortRequestId, configuration.Postgresql.ToString()); foreach (var port in related) { var match = bulkVSPortRequest.TNList.FirstOrDefault(x => x.TN.Contains(port.PortedDialedNumber)); - if (match is not null && !string.IsNullOrWhiteSpace(match.LNPStatus) && port.RequestStatus != match.LNPStatus) + if (!string.IsNullOrWhiteSpace(match.LNPStatus) && port.RequestStatus != match.LNPStatus) { port.RequestStatus = match.LNPStatus; port.ExternalPortRequestId = bulkVSPortRequest.OrderDetails.OrderId; @@ -261,28 +262,28 @@ public async static Task UpdatePortRequestsAndNumbersByExternalIdAsync(IngestCon { port.DateFirmOrderCommitment = FOCDate; } - var checkUpdate = await port.PutAsync(configuration.Postgresql); + var checkUpdate = await port.PutAsync(configuration.Postgresql.ToString()); } } } // If there is no first number then BulkVS returned a 404, which means the port request has been removed from their system and we won't be able to get updates on it. - if (firstNumber is null) + if (string.IsNullOrWhiteSpace(firstNumber.LNPStatus)) { request.DateCompleted = DateTime.Now; request.DateUpdated = DateTime.Now; request.RequestStatus = "404"; } } - var checkUpdated = await request.PutAsync(configuration.Postgresql); + var checkUpdated = await request.PutAsync(configuration.Postgresql.ToString()); } - var portedNumbers = await PortedPhoneNumber.GetAllAsync(configuration.Postgresql); + var portedNumbers = await PortedPhoneNumber.GetAllAsync(configuration.Postgresql.ToString()); var inComplete = portedNumbers.Where(x => x.RequestStatus is not "COMPLETE" && x.RequestStatus is not "404" && !string.IsNullOrWhiteSpace(x.ExternalPortRequestId)).ToArray(); foreach (var number in inComplete) { - PortTn bulkVSPortRequest = await PortTn.GetAsync(number.ExternalPortRequestId, configuration.BulkVSUsername, configuration.BulkVSPassword); + PortTn bulkVSPortRequest = await PortTn.GetAsync(number.ExternalPortRequestId.AsMemory(), configuration.BulkVSUsername, configuration.BulkVSPassword); var match = bulkVSPortRequest.TNList.FirstOrDefault(x => x.TN.Contains(number.PortedDialedNumber)); - if (bulkVSPortRequest.OrderDetails.OrderId == number.ExternalPortRequestId && match is not null && !string.IsNullOrWhiteSpace(match.LNPStatus) && number.RequestStatus != match.LNPStatus) + if (bulkVSPortRequest.OrderDetails.OrderId == number.ExternalPortRequestId && !string.IsNullOrWhiteSpace(match.LNPStatus) && number.RequestStatus != match.LNPStatus) { number.RequestStatus = match.LNPStatus; number.ExternalPortRequestId = bulkVSPortRequest.OrderDetails.OrderId; @@ -291,15 +292,15 @@ public async static Task UpdatePortRequestsAndNumbersByExternalIdAsync(IngestCon { number.DateFirmOrderCommitment = FOCDate; } - var checkUpdate = await number.PutAsync(configuration.Postgresql); + var checkUpdate = await number.PutAsync(configuration.Postgresql.ToString()); } // If there is no first number then BulkVS returned a 404, which means the port request has been removed from their system and we won't be able to get updates on it. - if (match is null) + if (string.IsNullOrWhiteSpace(match.LNPStatus)) { number.DateIngested = DateTime.Now; number.RequestStatus = "404"; number.Completed = false; - var checkUpdate = await number.PutAsync(configuration.Postgresql); + var checkUpdate = await number.PutAsync(configuration.Postgresql.ToString()); } } } diff --git a/NumberSearch.Ingest/Program.cs b/NumberSearch.Ingest/Program.cs index b7529297..8ea381d8 100644 --- a/NumberSearch.Ingest/Program.cs +++ b/NumberSearch.Ingest/Program.cs @@ -20,21 +20,21 @@ public static async Task Main() .AddUserSecrets("328593cf-cbb9-48e9-8938-e38a44c8291d") .Build(); - var appConfig = new IngestConfiguration + var appConfig = new IngestConfiguration() { - Postgresql = string.IsNullOrWhiteSpace(config.GetConnectionString("PostgresqlProd")) ? throw new Exception("PostgresqlProd config key is blank.") : config.GetConnectionString("PostgresqlProd") ?? string.Empty, - BulkVSAPIKEY = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPIKEY")) ? throw new Exception("BulkVSAPIKEY config key is blank.") : config.GetConnectionString("BulkVSAPIKEY") ?? string.Empty, - BulkVSAPISecret = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPISecret")) ? throw new Exception("BulkVSAPISecret config key is blank.") : config.GetConnectionString("BulkVSAPISecret") ?? string.Empty, - BulkVSUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSUsername")) ? throw new Exception("BulkVSUsername config key is blank.") : config.GetConnectionString("BulkVSUsername") ?? string.Empty, - BulkVSPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSPassword")) ? throw new Exception("BulkVSPassword config key is blank.") : config.GetConnectionString("BulkVSPassword") ?? string.Empty, - PComNetUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetUsername")) ? throw new Exception("PComNetUsername config key is blank.") : config.GetConnectionString("PComNetUsername") ?? string.Empty, - PComNetPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetPassword")) ? throw new Exception("PComNetPassword config key is blank.") : config.GetConnectionString("PComNetPassword") ?? string.Empty, - SmtpUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpUsername")) ? throw new Exception("SmtpUsername config key is blank.") : config.GetConnectionString("SmtpUsername") ?? string.Empty, - SmtpPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpPassword")) ? throw new Exception("SmtpPassword config key is blank.") : config.GetConnectionString("SmtpPassword") ?? string.Empty, - EmailOrders = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailOrders")) ? throw new Exception("EmailOrders config key is blank.") : config.GetConnectionString("EmailOrders") ?? string.Empty, - EmailDan = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailDan")) ? throw new Exception("EmailDan config key is blank.") : config.GetConnectionString("EmailDan") ?? string.Empty, - EmailTom = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("EmailTom config key is blank.") : config.GetConnectionString("EmailTom") ?? string.Empty, - InvoiceNinjaToken = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("InvoiceNinjaToken config key is blank.") : config.GetConnectionString("InvoiceNinjaToken") ?? string.Empty, + Postgresql = string.IsNullOrWhiteSpace(config.GetConnectionString("PostgresqlProd")) ? throw new Exception("PostgresqlProd config key is blank.") : config.GetConnectionString("PostgresqlProd").AsMemory(), + BulkVSAPIKEY = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPIKEY")) ? throw new Exception("BulkVSAPIKEY config key is blank.") : config.GetConnectionString("BulkVSAPIKEY").AsMemory(), + BulkVSAPISecret = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPISecret")) ? throw new Exception("BulkVSAPISecret config key is blank.") : config.GetConnectionString("BulkVSAPISecret").AsMemory(), + BulkVSUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSUsername")) ? throw new Exception("BulkVSUsername config key is blank.") : config.GetConnectionString("BulkVSUsername").AsMemory(), + BulkVSPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSPassword")) ? throw new Exception("BulkVSPassword config key is blank.") : config.GetConnectionString("BulkVSPassword").AsMemory(), + PComNetUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetUsername")) ? throw new Exception("PComNetUsername config key is blank.") : config.GetConnectionString("PComNetUsername").AsMemory(), + PComNetPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetPassword")) ? throw new Exception("PComNetPassword config key is blank.") : config.GetConnectionString("PComNetPassword").AsMemory(), + SmtpUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpUsername")) ? throw new Exception("SmtpUsername config key is blank.") : config.GetConnectionString("SmtpUsername").AsMemory(), + SmtpPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpPassword")) ? throw new Exception("SmtpPassword config key is blank.") : config.GetConnectionString("SmtpPassword").AsMemory(), + EmailOrders = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailOrders")) ? throw new Exception("EmailOrders config key is blank.") : config.GetConnectionString("EmailOrders").AsMemory(), + EmailDan = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailDan")) ? throw new Exception("EmailDan config key is blank.") : config.GetConnectionString("EmailDan").AsMemory(), + EmailTom = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("EmailTom config key is blank.") : config.GetConnectionString("EmailTom").AsMemory(), + InvoiceNinjaToken = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("InvoiceNinjaToken config key is blank.") : config.GetConnectionString("InvoiceNinjaToken").AsMemory(), }; Log.Logger = new LoggerConfiguration() @@ -126,7 +126,7 @@ await Provider.VerifyAddToCartAsync(AreaCode.Priority, "Executive", appConfig.Po Log.Information("[Heartbeat] Cycle complete. Daily Timer {Elapsed:000} ms of {Limit:000} ms. ({percentP:P2})", dailyTimer.ElapsedMilliseconds, dailyCycle.TotalMilliseconds, (dailyTimer.ElapsedMilliseconds / dailyCycle.TotalMilliseconds)); // Limit this to 1 request every 10 seconds to the database. - await Task.Delay(10000).ConfigureAwait(false); + await Task.Delay(10000); } } catch (Exception ex) @@ -144,8 +144,8 @@ await Provider.VerifyAddToCartAsync(AreaCode.Priority, "Executive", appConfig.Po // Notify someone that there's been a failure. var notificationEmail = new Email { - PrimaryEmailAddress = appConfig.EmailTom, - CarbonCopy = appConfig.EmailDan, + PrimaryEmailAddress = appConfig.EmailTom.ToString(), + CarbonCopy = appConfig.EmailDan.ToString(), DateSent = DateTime.Now, Subject = $"[Ingest] App is down.", MessageBody = $"Something has gone wrong and the ingest app is down at {DateTime.Now}. Please capture the logs and then restart or redeploy the ingest application to restore service.", @@ -153,42 +153,40 @@ await Provider.VerifyAddToCartAsync(AreaCode.Priority, "Executive", appConfig.Po Completed = true }; - var checkSend = await notificationEmail.SendEmailAsync(appConfig.SmtpUsername, appConfig.SmtpPassword).ConfigureAwait(false); - var checkSave = await notificationEmail.PostAsync(appConfig.Postgresql).ConfigureAwait(false); + var checkSend = await notificationEmail.SendEmailAsync(appConfig.SmtpUsername.ToString(), appConfig.SmtpPassword.ToString()); + var checkSave = await notificationEmail.PostAsync(appConfig.Postgresql.ToString()); // Save the log. await Log.CloseAndFlushAsync(); } } - public class IngestConfiguration - { - public string CallFlow { get; set; } = string.Empty; - public string ChannelGroup { get; set; } = string.Empty; - public string PComNetUsername { get; set; } = string.Empty; - public string PComNetPassword { get; set; } = string.Empty; - public string BulkVSAPIKEY { get; set; } = string.Empty; - public string BulkVSAPISecret { get; set; } = string.Empty; - public string BulkVSUsername { get; set; } = string.Empty; - public string BulkVSPassword { get; set; } = string.Empty; - public string Postgresql { get; set; } = string.Empty; - public string PostgresqlProd { get; set; } = string.Empty; - public string SmtpUsername { get; set; } = string.Empty; - public string SmtpPassword { get; set; } = string.Empty; - public string MicrosoftClientId { get; set; } = string.Empty; - public string MicrosoftClientSecret { get; set; } = string.Empty; - public string InvoiceNinjaToken { get; set; } = string.Empty; - public string Data247Username { get; set; } = string.Empty; - public string Data247Password { get; set; } = string.Empty; - public string EmailOrders { get; set; } = string.Empty; - public string EmailDan { get; set; } = string.Empty; - public string EmailTom { get; set; } = string.Empty; - public string AzureStorageAccount { get; set; } = string.Empty; - public string TeleDynamicsUsername { get; set; } = string.Empty; - public string TeleDynamicsPassword { get; set; } = string.Empty; - public string CallWithUsAPIKEY { get; set; } = string.Empty; - public string FusionPBXUsername { get; set; } = string.Empty; - public string FusionPBXPassword { get; set; } = string.Empty; - } + public readonly record struct IngestConfiguration( + ReadOnlyMemory CallFlow, + ReadOnlyMemory ChannelGroup, + ReadOnlyMemory PComNetUsername, + ReadOnlyMemory PComNetPassword, + ReadOnlyMemory BulkVSAPIKEY, + ReadOnlyMemory BulkVSAPISecret, + ReadOnlyMemory BulkVSUsername, + ReadOnlyMemory BulkVSPassword, + ReadOnlyMemory Postgresql, + ReadOnlyMemory PostgresqlProd, + ReadOnlyMemory SmtpUsername, + ReadOnlyMemory SmtpPassword, + ReadOnlyMemory MicrosoftClientId, + ReadOnlyMemory MicrosoftClientSecret, + ReadOnlyMemory InvoiceNinjaToken, + ReadOnlyMemory Data247Username, + ReadOnlyMemory Data247Password, + ReadOnlyMemory EmailOrders, + ReadOnlyMemory EmailDan, + ReadOnlyMemory EmailTom, + ReadOnlyMemory AzureStorageAccount, + ReadOnlyMemory TeleDynamicsUsername, + ReadOnlyMemory TeleDynamicsPassword, + ReadOnlyMemory CallWithUsAPIKEY, + ReadOnlyMemory FusionPBXUsername, + ReadOnlyMemory FusionPBXPassword); } } \ No newline at end of file diff --git a/NumberSearch.Ingest/Provider.cs b/NumberSearch.Ingest/Provider.cs index f22767d4..82afb679 100644 --- a/NumberSearch.Ingest/Provider.cs +++ b/NumberSearch.Ingest/Provider.cs @@ -25,7 +25,7 @@ public class Provider /// The FirstPointCom password. /// the connection string for the database. /// - public static async Task FirstPointComAsync(string username, string password, int[] areaCodes, string connectionString) + public static async Task FirstPointComAsync(ReadOnlyMemory username, ReadOnlyMemory password, int[] areaCodes, ReadOnlyMemory connectionString) { DateTime start = DateTime.Now; @@ -35,7 +35,7 @@ public static async Task FirstPointComAsync(string username, s PhoneNumber[] typedNumbers = Services.AssignNumberTypes(locations); - IngestStatistics stats = await Services.SubmitPhoneNumbersAsync(typedNumbers, connectionString.AsMemory()).ConfigureAwait(false); + IngestStatistics stats = await Services.SubmitPhoneNumbersAsync(typedNumbers, connectionString); DateTime end = DateTime.Now; stats.StartDate = start; @@ -52,7 +52,7 @@ public static async Task FirstPointComAsync(string username, s /// The bulkVS API secret. /// The connection string for the database. /// - public static async Task BulkVSAsync(string username, string password, int[] areaCodes, string connectionString) + public static async Task BulkVSAsync(ReadOnlyMemory username, ReadOnlyMemory password, int[] areaCodes, ReadOnlyMemory connectionString) { var start = DateTime.Now; @@ -75,7 +75,7 @@ public static async Task BulkVSAsync(string username, string p PhoneNumber[] typedNumbers = Services.AssignNumberTypes(locations); - IngestStatistics stats = await Services.SubmitPhoneNumbersAsync(typedNumbers, connectionString.AsMemory()); + IngestStatistics stats = await Services.SubmitPhoneNumbersAsync(typedNumbers, connectionString); DateTime end = DateTime.Now; stats.StartDate = start; @@ -101,7 +101,7 @@ public static async Task BulkVSCompleteAsync(TimeSpan cycle, I UpdatedExisting = 0, Lock = true }; - _ = await lockingStats.PostAsync(appConfig.Postgresql).ConfigureAwait(false); + _ = await lockingStats.PostAsync(appConfig.Postgresql.ToString()); // Ingest all available phones numbers from the BulkVs API. Log.Information("Ingesting data from BulkVS"); @@ -110,20 +110,20 @@ public static async Task BulkVSCompleteAsync(TimeSpan cycle, I var groups = PhoneNumbersNA.AreaCode.All.Chunk(50); foreach (var group in groups) { - var BulkVSStats = await Provider.BulkVSAsync(appConfig.BulkVSUsername, appConfig.BulkVSPassword, group, appConfig.Postgresql).ConfigureAwait(false); + var BulkVSStats = await Provider.BulkVSAsync(appConfig.BulkVSUsername, appConfig.BulkVSPassword, group, appConfig.Postgresql); allStats.Add(BulkVSStats); } // Remove the lock from the database to prevent it from getting cluttered with blank entries. - var lockEntry = await IngestStatistics.GetLockAsync("BulkVS", appConfig.Postgresql).ConfigureAwait(false); + var lockEntry = await IngestStatistics.GetLockAsync("BulkVS", appConfig.Postgresql.ToString()); if (lockEntry is not null) { - _ = await lockEntry.DeleteAsync(appConfig.Postgresql).ConfigureAwait(false); + _ = await lockEntry.DeleteAsync(appConfig.Postgresql.ToString()); } // Remove all of the old numbers from the database. Log.Information("[BulkVS] Removing old numbers from the database."); - var bulkVSCleanUp = await PhoneNumber.DeleteOldByProvider(lockingStats.StartDate, cycle.Multiply(2), "BulkVS", appConfig.Postgresql).ConfigureAwait(false); + var bulkVSCleanUp = await PhoneNumber.DeleteOldByProvider(lockingStats.StartDate, cycle.Multiply(2), "BulkVS", appConfig.Postgresql.ToString()); var combined = new IngestStatistics { @@ -140,7 +140,7 @@ public static async Task BulkVSCompleteAsync(TimeSpan cycle, I Priority = false }; - if (await combined.PostAsync(appConfig.Postgresql).ConfigureAwait(false)) + if (await combined.PostAsync(appConfig.Postgresql.ToString())) { Log.Information($"[BulkVS] Completed the ingest process {DateTime.Now}."); } @@ -179,11 +179,11 @@ public static async Task BulkVSPriorityAsync(TimeSpan cycle, I // Remove stale priority numbers foreach (var code in AreaCode.Priority) { - var removedNumbers = await PhoneNumber.DeleteOldByProviderAndAreaCode(start, cycle.Multiply(2), code, "BulkVS", appConfig.Postgresql).ConfigureAwait(false); + var removedNumbers = await PhoneNumber.DeleteOldByProviderAndAreaCode(start, cycle.Multiply(2), code, "BulkVS", appConfig.Postgresql.ToString()); combined.Removed += removedNumbers.Removed; } - if (await combined.PostAsync(appConfig.Postgresql).ConfigureAwait(false)) + if (await combined.PostAsync(appConfig.Postgresql.ToString())) { Log.Information($"[BulkVS] Completed the priority ingest process {DateTime.Now}."); } @@ -208,7 +208,7 @@ public static async Task FirstPointComPriorityAsync(TimeSpan c // Ingest priority numbers in the FirsPointCom API. Log.Information("[FirstPointCom] Ingesting priority data from FirstPointCom"); - var FirstPointComStats = await Provider.FirstPointComAsync(appConfig.PComNetUsername, appConfig.PComNetPassword, AreaCode.Priority, appConfig.Postgresql).ConfigureAwait(false); + var FirstPointComStats = await Provider.FirstPointComAsync(appConfig.PComNetUsername, appConfig.PComNetPassword, AreaCode.Priority, appConfig.Postgresql); var combined = new IngestStatistics { @@ -228,11 +228,11 @@ public static async Task FirstPointComPriorityAsync(TimeSpan c // Remove stale priority numbers foreach (var code in AreaCode.Priority) { - var removedNumbers = await PhoneNumber.DeleteOldByProviderAndAreaCode(start, cycle.Multiply(2), code, "FirstPointCom", appConfig.Postgresql).ConfigureAwait(false); + var removedNumbers = await PhoneNumber.DeleteOldByProviderAndAreaCode(start, cycle.Multiply(2), code, "FirstPointCom", appConfig.Postgresql.ToString()); combined.Removed += removedNumbers.Removed; } - if (await combined.PostAsync(appConfig.Postgresql).ConfigureAwait(false)) + if (await combined.PostAsync(appConfig.Postgresql.ToString())) { Log.Information($"[FirstPointCom] Completed the priority ingest process {DateTime.Now}."); } @@ -261,22 +261,22 @@ public static async Task FirstPointComCompleteAsync(TimeSpan c Lock = true }; - _ = await lockingStats.PostAsync(appConfig.Postgresql).ConfigureAwait(false); + _ = await lockingStats.PostAsync(appConfig.Postgresql.ToString()); // Ingest all available numbers in the FirsPointCom API. Log.Information("[FirstPointCom] Ingesting data from FirstPointCom"); - var FirstPointComStats = await Provider.FirstPointComAsync(appConfig.PComNetUsername, appConfig.PComNetPassword, PhoneNumbersNA.AreaCode.All, appConfig.Postgresql).ConfigureAwait(false); + var FirstPointComStats = await Provider.FirstPointComAsync(appConfig.PComNetUsername, appConfig.PComNetPassword, PhoneNumbersNA.AreaCode.All, appConfig.Postgresql); // Remove the lock from the database to prevent it from getting cluttered with blank entries. - var lockEntry = await IngestStatistics.GetLockAsync("FirstPointCom", appConfig.Postgresql).ConfigureAwait(false); + var lockEntry = await IngestStatistics.GetLockAsync("FirstPointCom", appConfig.Postgresql.ToString()); if (lockEntry is not null) { - _ = await lockEntry.DeleteAsync(appConfig.Postgresql).ConfigureAwait(false); + _ = await lockEntry.DeleteAsync(appConfig.Postgresql.ToString()); } // Remove all of the old numbers from the database. Log.Information("[FirstPointCom] Removing old FirstPointCom numbers from the database."); - var firstPointComCleanUp = await PhoneNumber.DeleteOldByProvider(lockingStats.StartDate, cycle.Multiply(2), "FirstPointCom", appConfig.Postgresql).ConfigureAwait(false); + var firstPointComCleanUp = await PhoneNumber.DeleteOldByProvider(lockingStats.StartDate, cycle.Multiply(2), "FirstPointCom", appConfig.Postgresql.ToString()); var combined = new IngestStatistics { @@ -293,7 +293,7 @@ public static async Task FirstPointComCompleteAsync(TimeSpan c Priority = false }; - if (await combined.PostAsync(appConfig.Postgresql).ConfigureAwait(false)) + if (await combined.PostAsync(appConfig.Postgresql.ToString())) { Log.Information($"[FirstPointCom] Completed the FirstPointCom ingest process {DateTime.Now}."); } @@ -304,12 +304,12 @@ public static async Task FirstPointComCompleteAsync(TimeSpan c return combined; } - public static async Task VerifyAddToCartAsync(int[] areaCodes, string numberType, string _postgresql, string _bulkVSusername, - string _bulkVSpassword, string _fpcusername, string _fpcpassword) + public static async Task VerifyAddToCartAsync(int[] areaCodes, string numberType, ReadOnlyMemory _postgresql, ReadOnlyMemory _bulkVSusername, + ReadOnlyMemory _bulkVSpassword, ReadOnlyMemory _fpcusername, ReadOnlyMemory _fpcpassword) { foreach (var code in areaCodes) { - var numbers = await PhoneNumber.GetAllByAreaCodeAsync(code, _postgresql); + var numbers = await PhoneNumber.GetAllByAreaCodeAsync(code, _postgresql.ToString()); numbers = numbers.Where(x => x.NumberType == numberType); @@ -334,7 +334,7 @@ public static async Task VerifyAddToCartAsync(int[] areaCodes, string numberType Log.Warning($"[BulkVS] Failed to find {phoneNumber.DialedNumber} in {doesItStillExist.Length} results returned for {npanxx}."); // Remove numbers that are unpurchasable. - var checkRemove = await phoneNumber.DeleteAsync(_postgresql).ConfigureAwait(false); + var checkRemove = await phoneNumber.DeleteAsync(_postgresql.ToString()).ConfigureAwait(false); } } catch (Exception ex) @@ -349,7 +349,7 @@ public static async Task VerifyAddToCartAsync(int[] areaCodes, string numberType // Verify that tele has the number. try { - var results = await NpaNxxFirstPointCom.GetAsync(phoneNumber.NPA.ToString(new CultureInfo("en-US")).AsMemory(), phoneNumber.NXX.ToString(new CultureInfo("en-US")).AsMemory(), string.Empty.AsMemory(), _fpcusername.AsMemory(), _fpcpassword.AsMemory()).ConfigureAwait(false); + var results = await NpaNxxFirstPointCom.GetAsync(phoneNumber.NPA.ToString(new CultureInfo("en-US")).AsMemory(), phoneNumber.NXX.ToString(new CultureInfo("en-US")).AsMemory(), string.Empty.AsMemory(), _fpcusername, _fpcpassword); var matchingNumber = results?.Where(x => x?.DialedNumber == phoneNumber?.DialedNumber)?.FirstOrDefault(); if (matchingNumber is not null && matchingNumber?.DialedNumber == phoneNumber.DialedNumber) { @@ -360,7 +360,7 @@ public static async Task VerifyAddToCartAsync(int[] areaCodes, string numberType Log.Warning($"[FirstPointCom] Failed to find {phoneNumber.DialedNumber} in {results?.Count()} results returned for {phoneNumber.NPA}, {phoneNumber.NXX}."); // Remove numbers that are unpurchasable. - var checkRemove = await phoneNumber.DeleteAsync(_postgresql).ConfigureAwait(false); + var checkRemove = await phoneNumber.DeleteAsync(_postgresql.ToString()).ConfigureAwait(false); } } catch (Exception ex) @@ -372,7 +372,7 @@ public static async Task VerifyAddToCartAsync(int[] areaCodes, string numberType else if (phoneNumber.IngestedFrom is "OwnedNumber") { // Verify that we still have the number. - var matchingNumber = await OwnedPhoneNumber.GetByDialedNumberAsync(phoneNumber.DialedNumber, _postgresql).ConfigureAwait(false); + var matchingNumber = await OwnedPhoneNumber.GetByDialedNumberAsync(phoneNumber.DialedNumber, _postgresql.ToString()).ConfigureAwait(false); if (matchingNumber is not null && matchingNumber?.DialedNumber == phoneNumber.DialedNumber) { Log.Information($"[OwnedNumber] Found {phoneNumber.DialedNumber}."); @@ -382,13 +382,13 @@ public static async Task VerifyAddToCartAsync(int[] areaCodes, string numberType Log.Warning($"[OwnedNumber] Failed to find {phoneNumber.DialedNumber}."); // Remove numbers that are unpurchasable. - var checkRemove = await phoneNumber.DeleteAsync(_postgresql).ConfigureAwait(false); + var checkRemove = await phoneNumber.DeleteAsync(_postgresql.ToString()).ConfigureAwait(false); } } else { // Remove numbers that are unpurchasable. - var checkRemove = await phoneNumber.DeleteAsync(_postgresql).ConfigureAwait(false); + var checkRemove = await phoneNumber.DeleteAsync(_postgresql.ToString()).ConfigureAwait(false); } } } diff --git a/NumberSearch.Mvc/Controllers/CartAPIController.cs b/NumberSearch.Mvc/Controllers/CartAPIController.cs index 16577a83..91840c95 100644 --- a/NumberSearch.Mvc/Controllers/CartAPIController.cs +++ b/NumberSearch.Mvc/Controllers/CartAPIController.cs @@ -633,14 +633,14 @@ public async Task BuyPhoneNumberAsync(string dialedPhoneNumber) return BadRequest(ModelState); } - var phoneNumber = await DataAccess.Models.PhoneNumber.GetAsync(dialedPhoneNumber, _postgresql).ConfigureAwait(false); + var phoneNumber = await DataAccess.Models.PhoneNumber.GetAsync(dialedPhoneNumber, _postgresql); var productOrder = new ProductOrder { ProductOrderId = Guid.NewGuid(), DialedNumber = phoneNumber.DialedNumber, Quantity = 1 }; // Check that the number is still avalible from the provider. if (phoneNumber.IngestedFrom == "BulkVS") { var npanxx = $"{phoneNumber.NPA}{phoneNumber.NXX}"; - var doesItStillExist = await OrderTn.GetAsync(phoneNumber.NPA, phoneNumber.NXX, _bulkVSusername, _bulkVSpassword).ConfigureAwait(false); + var doesItStillExist = await OrderTn.GetAsync(phoneNumber.NPA, phoneNumber.NXX, _bulkVSusername.AsMemory(), _bulkVSpassword.AsMemory()); var checkIfExists = doesItStillExist.Where(x => x.DialedNumber == phoneNumber.DialedNumber).FirstOrDefault(); if (checkIfExists != null && checkIfExists?.DialedNumber == phoneNumber.DialedNumber) { diff --git a/NumberSearch.Ops/Controllers/MessagingController.cs b/NumberSearch.Ops/Controllers/MessagingController.cs index 2a26a49b..56ef62ea 100644 --- a/NumberSearch.Ops/Controllers/MessagingController.cs +++ b/NumberSearch.Ops/Controllers/MessagingController.cs @@ -228,7 +228,7 @@ public async Task MessagingToEmailAsync([Bind("DialedNumber,Email try { // Verify that this number is routed through our upstream provider. - var checkRouted = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync(dialedNumber, _config.PComNetUsername, _config.PComNetPassword); + var checkRouted = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync(dialedNumber.AsMemory(), _config.PComNetUsername.AsMemory(), _config.PComNetPassword.AsMemory()); Log.Information(System.Text.Json.JsonSerializer.Serialize(checkRouted)); registeredUpstream = checkRouted.QueryResult.code is 0; upstreamStatusDescription = checkRouted.QueryResult.text; @@ -237,7 +237,7 @@ public async Task MessagingToEmailAsync([Bind("DialedNumber,Email // Enabled routing and set the EPID if the number is not already routed. var enableSMS = await FirstPointComSMS.EnableSMSByDialedNumberAsync(dialedNumber, _config.PComNetUsername, _config.PComNetPassword); Log.Information(System.Text.Json.JsonSerializer.Serialize(enableSMS)); - var checkRoutedAgain = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync(dialedNumber, _config.PComNetUsername, _config.PComNetPassword); + var checkRoutedAgain = await FirstPointComSMS.GetSMSRoutingByDialedNumberAsync(dialedNumber.AsMemory(), _config.PComNetUsername.AsMemory(), _config.PComNetPassword.AsMemory()); Log.Information(System.Text.Json.JsonSerializer.Serialize(checkRouted)); registeredUpstream = checkRouted.QueryResult.code is 0; upstreamStatusDescription = checkRouted.QueryResult.text; diff --git a/NumberSearch.Tests/Ingest.cs b/NumberSearch.Tests/Ingest.cs index bb64fa03..27ea4805 100644 --- a/NumberSearch.Tests/Ingest.cs +++ b/NumberSearch.Tests/Ingest.cs @@ -65,21 +65,21 @@ public FunctionalIngest(ITestOutputHelper output) var appConfig = new IngestConfiguration { - Postgresql = string.IsNullOrWhiteSpace(config.GetConnectionString("PostgresqlProd")) ? throw new Exception("PostgresqlProd config key is blank.") : config.GetConnectionString("PostgresqlProd") ?? string.Empty, - BulkVSAPIKEY = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPIKEY")) ? throw new Exception("BulkVSAPIKEY config key is blank.") : config.GetConnectionString("BulkVSAPIKEY") ?? string.Empty, - BulkVSAPISecret = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPISecret")) ? throw new Exception("BulkVSAPISecret config key is blank.") : config.GetConnectionString("BulkVSAPISecret") ?? string.Empty, - BulkVSUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSUsername")) ? throw new Exception("BulkVSUsername config key is blank.") : config.GetConnectionString("BulkVSUsername") ?? string.Empty, - BulkVSPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSPassword")) ? throw new Exception("BulkVSPassword config key is blank.") : config.GetConnectionString("BulkVSPassword") ?? string.Empty, - PComNetUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetUsername")) ? throw new Exception("PComNetUsername config key is blank.") : config.GetConnectionString("PComNetUsername") ?? string.Empty, - PComNetPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetPassword")) ? throw new Exception("PComNetPassword config key is blank.") : config.GetConnectionString("PComNetPassword") ?? string.Empty, - SmtpUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpUsername")) ? throw new Exception("SmtpUsername config key is blank.") : config.GetConnectionString("SmtpUsername") ?? string.Empty, - SmtpPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpPassword")) ? throw new Exception("SmtpPassword config key is blank.") : config.GetConnectionString("SmtpPassword") ?? string.Empty, - EmailOrders = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailOrders")) ? throw new Exception("EmailOrders config key is blank.") : config.GetConnectionString("EmailOrders") ?? string.Empty, - EmailDan = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailDan")) ? throw new Exception("EmailDan config key is blank.") : config.GetConnectionString("EmailDan") ?? string.Empty, - EmailTom = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("EmailTom config key is blank.") : config.GetConnectionString("EmailTom") ?? string.Empty, - FusionPBXUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("FusionPBXUsername")) ? throw new Exception("FusionPBXUsername config key is blank.") : config.GetConnectionString("FusionPBXUsername") ?? string.Empty, - FusionPBXPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("FusionPBXPassword")) ? throw new Exception("FusionPBXPassword config key is blank.") : config.GetConnectionString("FusionPBXPassword") ?? string.Empty, - InvoiceNinjaToken = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("InvoiceNinjaToken config key is blank.") : config.GetConnectionString("InvoiceNinjaToken") ?? string.Empty, + Postgresql = string.IsNullOrWhiteSpace(config.GetConnectionString("PostgresqlProd")) ? throw new Exception("PostgresqlProd config key is blank.") : config.GetConnectionString("PostgresqlProd").AsMemory(), + BulkVSAPIKEY = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPIKEY")) ? throw new Exception("BulkVSAPIKEY config key is blank.") : config.GetConnectionString("BulkVSAPIKEY").AsMemory(), + BulkVSAPISecret = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSAPISecret")) ? throw new Exception("BulkVSAPISecret config key is blank.") : config.GetConnectionString("BulkVSAPISecret").AsMemory(), + BulkVSUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSUsername")) ? throw new Exception("BulkVSUsername config key is blank.") : config.GetConnectionString("BulkVSUsername").AsMemory(), + BulkVSPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("BulkVSPassword")) ? throw new Exception("BulkVSPassword config key is blank.") : config.GetConnectionString("BulkVSPassword").AsMemory(), + PComNetUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetUsername")) ? throw new Exception("PComNetUsername config key is blank.") : config.GetConnectionString("PComNetUsername").AsMemory(), + PComNetPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("PComNetPassword")) ? throw new Exception("PComNetPassword config key is blank.") : config.GetConnectionString("PComNetPassword").AsMemory(), + SmtpUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpUsername")) ? throw new Exception("SmtpUsername config key is blank.") : config.GetConnectionString("SmtpUsername").AsMemory(), + SmtpPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("SmtpPassword")) ? throw new Exception("SmtpPassword config key is blank.") : config.GetConnectionString("SmtpPassword").AsMemory(), + EmailOrders = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailOrders")) ? throw new Exception("EmailOrders config key is blank.") : config.GetConnectionString("EmailOrders").AsMemory(), + EmailDan = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailDan")) ? throw new Exception("EmailDan config key is blank.") : config.GetConnectionString("EmailDan").AsMemory(), + EmailTom = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("EmailTom config key is blank.") : config.GetConnectionString("EmailTom").AsMemory(), + FusionPBXUsername = string.IsNullOrWhiteSpace(config.GetConnectionString("FusionPBXUsername")) ? throw new Exception("FusionPBXUsername config key is blank.") : config.GetConnectionString("FusionPBXUsername").AsMemory(), + FusionPBXPassword = string.IsNullOrWhiteSpace(config.GetConnectionString("FusionPBXPassword")) ? throw new Exception("FusionPBXPassword config key is blank.") : config.GetConnectionString("FusionPBXPassword").AsMemory(), + InvoiceNinjaToken = string.IsNullOrWhiteSpace(config.GetConnectionString("EmailTom")) ? throw new Exception("InvoiceNinjaToken config key is blank.") : config.GetConnectionString("InvoiceNinjaToken").AsMemory(), }; ingestConfiguration = appConfig; } diff --git a/NumberSearch.Tests/Integration.cs b/NumberSearch.Tests/Integration.cs index fa74730a..d93b210b 100644 --- a/NumberSearch.Tests/Integration.cs +++ b/NumberSearch.Tests/Integration.cs @@ -492,7 +492,7 @@ public async Task GetDestinationDetailsAsync() // Arrange // Act - var result = await DestinationDetails.GetByDialedNumberAsync("4254541206", _configuration.FusionPBXUsername, _configuration.FusionPBXPassword); + var result = await DestinationDetails.GetByDialedNumberAsync("4254541206".AsMemory(), _configuration.FusionPBXUsername.AsMemory(), _configuration.FusionPBXPassword.AsMemory()); // Assert Assert.True(result.destination_enabled); @@ -506,7 +506,7 @@ public async Task GetDomainDetailsAsync() // Arrange // Act - var result = await DomainDetails.GetByDomainIdAsync("f86cace8-9d5c-47df-b084-48e6cb58a95d", _configuration.FusionPBXUsername, _configuration.FusionPBXPassword); + var result = await DomainDetails.GetByDomainIdAsync("f86cace8-9d5c-47df-b084-48e6cb58a95d".AsMemory(), _configuration.FusionPBXUsername.AsMemory(), _configuration.FusionPBXPassword.AsMemory()); // Assert Assert.False(string.IsNullOrWhiteSpace(result.domain_name)); @@ -577,7 +577,7 @@ public async Task PComNetDIDInventorySearchAsyncTestAsync() [Fact] public async Task FirstComGetRoutingTestAsync() { - var result = await FirstCom.FirstPointComSMS.GetSMSRoutingByDialedNumberAsync("12069574634", pComNetCredentials.Username, pComNetCredentials.Password); + var result = await FirstCom.FirstPointComSMS.GetSMSRoutingByDialedNumberAsync("12069574634".AsMemory(), pComNetCredentials.Username.AsMemory(), pComNetCredentials.Password.AsMemory()); Assert.NotNull(result); Assert.True(result.QueryResult.text is "OK"); @@ -614,7 +614,7 @@ public async Task BulkVSRESTNpaNxxGetAsyncTestAsync() var npa = 206; // Act - var results = await OrderTn.GetAsync(npa, bulkVSUsername, bulkVSPassword); + var results = await OrderTn.GetAsync(npa, bulkVSUsername.AsMemory(), bulkVSPassword.AsMemory()); // Assert Assert.NotNull(results); @@ -739,7 +739,7 @@ public async Task BulkVSRESTGetAllOwnedNumbersAsync() // Arrange // Act - var results = await TnRecord.GetAsync(bulkVSUsername, bulkVSPassword); + var results = await TnRecord.GetAsync(bulkVSUsername.AsMemory(), bulkVSPassword.AsMemory()); // Assert Assert.NotNull(results); @@ -778,7 +778,7 @@ public async Task BulkVSRESTGetAllOwnedNumbersAsOwnedAsync() // Arrange // Act - var results = await TnRecord.GetOwnedAsync(bulkVSUsername, bulkVSPassword); + var results = await TnRecord.GetOwnedAsync(bulkVSUsername.AsMemory(), bulkVSPassword.AsMemory()); // Assert Assert.NotNull(results); @@ -793,7 +793,7 @@ public async Task BulkVSRESTGetAllPortRequestsAsync() // Arrange // Act - var results = await PortTn.GetAllAsync(bulkVSUsername, bulkVSPassword); + var results = await PortTn.GetAllAsync(bulkVSUsername.AsMemory(), bulkVSPassword.AsMemory()); // Assert Assert.NotNull(results); @@ -856,13 +856,13 @@ public async Task BulkVSRESTGetPortRequestsAsync() // Arrange // Act - var results = await PortTn.GetAllAsync(bulkVSUsername, bulkVSPassword); + var results = await PortTn.GetAllAsync(bulkVSUsername.AsMemory(), bulkVSPassword.AsMemory()); // Assert Assert.NotNull(results); Assert.NotEmpty(results); - var result = await PortTn.GetAsync("1642300", bulkVSUsername, bulkVSPassword); + var result = await PortTn.GetAsync("1642300".AsMemory(), bulkVSUsername.AsMemory(), bulkVSPassword.AsMemory()); Assert.NotNull(result); output.WriteLine(JsonSerializer.Serialize(result));