-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Worked on improving the performance of the FirstPointCom ingest and r…
…educing memory consumption.
- Loading branch information
1 parent
cafcffc
commit fbd295a
Showing
21 changed files
with
604 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,72 @@ | ||
using NumberSearch.DataAccess; | ||
using NumberSearch.DataAccess.Models; | ||
|
||
using Serilog; | ||
|
||
using ServiceReference1; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
|
||
namespace FirstCom | ||
{ | ||
public sealed class NpaNxxFirstPointCom | ||
{ | ||
public static async Task<IEnumerable<PhoneNumber>> GetAsync(string npa, string nxx, string did, string username, string password) | ||
public static async Task<PhoneNumber[]> GetAsync(ReadOnlyMemory<char> npa, ReadOnlyMemory<char> nxx, ReadOnlyMemory<char> did, ReadOnlyMemory<char> username, ReadOnlyMemory<char> password) | ||
{ | ||
var Auth = new Credentials | ||
{ | ||
Username = username, | ||
Password = password | ||
Username = username.ToString(), | ||
Password = password.ToString() | ||
}; | ||
var DIDSearch = new DIDOrderQuery | ||
{ | ||
DID = did, | ||
NPA = npa, | ||
NXX = nxx, | ||
DID = did.ToString(), | ||
NPA = npa.ToString(), | ||
NXX = nxx.ToString(), | ||
RateCenter = string.Empty | ||
}; | ||
// Limited to 100 results at the moment. | ||
var ReturnAmount = 100; | ||
// Limited to 100 results at the moment. There's no way to offset the results to get the complete list of numbers, so we won't bother. | ||
int ReturnAmount = 100; | ||
|
||
using var client = new DIDManagementSoapClient(DIDManagementSoapClient.EndpointConfiguration.DIDManagementSoap); | ||
|
||
var list = new List<PhoneNumber>(); | ||
bool moreToQuery = true; | ||
|
||
while (moreToQuery) | ||
{ | ||
var result = await client.DIDInventorySearchAsync(Auth, DIDSearch, ReturnAmount).ConfigureAwait(false); | ||
var result = await client.DIDInventorySearchAsync(Auth, DIDSearch, ReturnAmount).ConfigureAwait(false); | ||
|
||
foreach (var item in result.DIDOrder) | ||
foreach (var item in result.DIDOrder) | ||
{ | ||
if (item.DID.StartsWith('1')) | ||
{ | ||
if (item.DID.StartsWith('1')) | ||
{ | ||
var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(item.DID[1..], out var phoneNumber); | ||
var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(item.DID[1..].AsSpan(), out var phoneNumber); | ||
|
||
if (checkParse) | ||
{ | ||
list.Add(new PhoneNumber | ||
{ | ||
NPA = phoneNumber.NPA, | ||
NXX = phoneNumber.NXX, | ||
XXXX = phoneNumber.XXXX, | ||
DialedNumber = phoneNumber.DialedNumber, | ||
City = "Unknown City", | ||
State = "Unknown State", | ||
DateIngested = DateTime.Now, | ||
IngestedFrom = "FirstPointCom" | ||
}); | ||
} | ||
else | ||
if (checkParse) | ||
{ | ||
list.Add(new PhoneNumber | ||
{ | ||
Log.Error($"[FirstCom] This number failed to parse {item.DID}"); | ||
} | ||
NPA = phoneNumber.NPA, | ||
NXX = phoneNumber.NXX, | ||
XXXX = phoneNumber.XXXX, | ||
DialedNumber = phoneNumber.DialedNumber, | ||
City = "Unknown City", | ||
State = "Unknown State", | ||
DateIngested = DateTime.Now, | ||
IngestedFrom = "FirstPointCom" | ||
}); | ||
} | ||
else | ||
{ | ||
Log.Error($"[FirstCom] This number did not start with a 1: {item.DID}"); | ||
Log.Error($"[FirstCom] This number failed to parse {item.DID}"); | ||
} | ||
} | ||
|
||
// Break the loop. | ||
if (result.DIDOrder.Length is not 100) | ||
else | ||
{ | ||
moreToQuery = false; | ||
Log.Error($"[FirstCom] This number did not start with a 1: {item.DID}"); | ||
} | ||
} | ||
|
||
return list; | ||
return [..list]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
using Newtonsoft.Json; | ||
|
||
using NumberSearch.DataAccess.Models; | ||
|
||
using Serilog; | ||
|
||
using System; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
using Newtonsoft.Json; | ||
|
||
using NumberSearch.DataAccess.Models; | ||
|
||
using Serilog; | ||
|
||
using System; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.