Skip to content

Commit

Permalink
Adjusted the daily email in support of #390.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Sep 16, 2023
1 parent 526d740 commit 60cc6d3
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 88 deletions.
175 changes: 88 additions & 87 deletions NumberSearch.Ingest/Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,77 +108,44 @@ public static async Task<bool> DailyBriefingEmailAsync(IngestConfiguration appCo
ordersConvertedFromQuotesToday.Add(order);
}
// Orders completed today?
else if (order.Quote is false && order.Completed is true && order.DateCompleted.HasValue is true && order.DateCompleted.Value >= DateTime.Now.AddDays(-2))
else if (order.Quote is false && order.Completed is true && order.DateCompleted.HasValue is true && order.DateCompleted.Value >= DateTime.Now.AddDays(-7))
{
ordersCompletedToday.Add(order);
}
else if (order.Quote is false && order.Completed is false && order.DateSubmitted >= DateTime.Now.AddDays(-2))
else if (order.Quote is false && order.Completed is false && order.DateSubmitted >= DateTime.Now.AddDays(-7))
{
ordersSubmittedToday.Add(order);
}
else if (order.Quote is true && order.DateSubmitted >= DateTime.Now.AddDays(-2))
else if (order.Quote is true && order.DateSubmitted >= DateTime.Now.AddDays(-7))
{
quotesSubmittedToday.Add(order);
}
else if (order.Quote is false && order.InstallDate is not null && order.InstallDate.Value.AddDays(7).Month == DateTime.Now.Month && order.InstallDate.Value.AddDays(7).Day == DateTime.Now.Day)
else if (order.Quote is false && order.InstallDate is not null && DateTime.Now.Ticks > order.InstallDate.Value.AddDays(7).Ticks && DateTime.Now.Ticks < order.InstallDate.Value.AddDays(7).Ticks)
{
oneWeekFollowUp.Add(order);
}
else if (order.Quote is false && order.InstallDate is not null && order.InstallDate.Value.AddMonths(1).Month == DateTime.Now.Month && order.InstallDate.Value.AddMonths(1).Day == DateTime.Now.Day)
else if (order.Quote is false && order.InstallDate is not null && DateTime.Now.Ticks > order.InstallDate.Value.AddMonths(1).Ticks && DateTime.Now.Ticks < order.InstallDate.Value.AddMonths(1).AddDays(7).Ticks)
{
oneMonthFollowUp.Add(order);
}
else if (order.Quote is false && order.InstallDate is not null && order.InstallDate.Value.AddYears(1).DayOfYear == DateTime.Now.DayOfYear)
else if (order.Quote is false && order.InstallDate is not null && DateTime.Now.Ticks > order.InstallDate.Value.AddYears(1).Ticks && DateTime.Now.Ticks < order.InstallDate.Value.AddYears(1).AddDays(7).Ticks)
{
yearlyFollowUp.Add(order);
}
}
var output = new StringBuilder();

output.Append("<p>Hey Dan,</p><p>Here's everything you need to know about the orders in the Accelerate Networks system.</p>");
output.Append("<p>Hey Support,</p><p>Here's everything you need to know about the orders in the Accelerate Networks system.</p>");

output.Append("<p>Orders completed today:</p><ul>");
if (ordersCompletedToday.Count > 0)
{
foreach (var item in ordersCompletedToday)
{
var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "[email protected]" : item.SalesEmail;
var completedDate = item?.DateCompleted is not null ? item?.DateCompleted.GetValueOrDefault().ToShortDateString() : "No completed date set";
output.Append($"<li><a href='https://acceleratenetworks.com/cart/order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> submitted on {item.DateSubmitted.ToShortDateString()} - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://acceleratenetworks.com/cart/order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a> - Completed on {completedDate}</li>");
}
output.Append("</ul>");
}
else
{
output.Append("<li>None</li></ul>");
}

output.Append("<p>Converted from quotes today:</p><ul>");
if (ordersConvertedFromQuotesToday.Count > 0)
output.Append("<p>Orders submitted today:</p><ul>");
if (ordersSubmittedToday.Count > 0)
{
foreach (var item in ordersConvertedFromQuotesToday)
foreach (var item in ordersSubmittedToday)
{
var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
var installDate = item?.InstallDate is not null ? item?.InstallDate.GetValueOrDefault().ToShortDateString() : "No install date set";
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a> - {installDate}</li>");
}
output.Append("</ul>");
}
else
{
output.Append("<li>None</li></ul>");
}

output.Append("<p>Unsubmitted port requests:</p><ul>");
if (ordersWithUnsubmittedPortRequests.Count > 0)
{
foreach (var item in ordersWithUnsubmittedPortRequests)
{
var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a></li>");
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName} - Install Date {installDate}</li>");

Check warning on line 148 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 148 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 148 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.
}
output.Append("</ul>");
}
Expand All @@ -187,14 +154,15 @@ public static async Task<bool> DailyBriefingEmailAsync(IngestConfiguration appCo
output.Append("<li>None</li></ul>");
}

output.Append("<p>Unfinished port requests:</p><ul>");
if (ordersWithUnfinishedPortRequests.Count > 0)
output.Append("<p>Orders completed this week:</p><ul>");
if (ordersCompletedToday.Count > 0)
{
foreach (var item in ordersWithUnfinishedPortRequests)
foreach (var item in ordersCompletedToday)
{
var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a></li>");
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "[email protected]" : item.SalesEmail;
var completedDate = item?.DateCompleted is not null ? item?.DateCompleted.GetValueOrDefault().ToShortDateString() : "No completed date set";
output.Append($"<li><a href='https://acceleratenetworks.com/cart/order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> submitted on {item.DateSubmitted.ToShortDateString()} - Completed on {completedDate}</li>");

Check warning on line 165 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 165 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 165 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.
}
output.Append("</ul>");
}
Expand All @@ -203,15 +171,15 @@ public static async Task<bool> DailyBriefingEmailAsync(IngestConfiguration appCo
output.Append("<li>None</li></ul>");
}

output.Append("<p>Uncompleted orders with completed port requests:</p><ul>");
if (ordersWithCompletedPortRequests.Count > 0)
output.Append("<p>Quotes submitted this week:</p><ul>");
if (quotesSubmittedToday.Count > 0)
{
foreach (var item in ordersWithCompletedPortRequests)
foreach (var item in quotesSubmittedToday)
{
var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
var installDate = item?.InstallDate is not null ? item?.InstallDate.GetValueOrDefault().ToShortDateString() : "No install date set";
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a> - {installDate}</li>");
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a></li>");

Check warning on line 182 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 182 in NumberSearch.Ingest/Orders.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.
}
output.Append("</ul>");
}
Expand All @@ -220,7 +188,73 @@ public static async Task<bool> DailyBriefingEmailAsync(IngestConfiguration appCo
output.Append("<li>None</li></ul>");
}

output.Append("<p>Uncompleted orders where the install date has passed in the last quarter:</p><ul>");
//output.Append("<p>Converted from quotes today:</p><ul>");
//if (ordersConvertedFromQuotesToday.Count > 0)
//{
// foreach (var item in ordersConvertedFromQuotesToday)
// {
// var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
// var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
// var installDate = item?.InstallDate is not null ? item?.InstallDate.GetValueOrDefault().ToShortDateString() : "No install date set";
// output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a> - {installDate}</li>");
// }
// output.Append("</ul>");
//}
//else
//{
// output.Append("<li>None</li></ul>");
//}

//output.Append("<p>Unsubmitted port requests:</p><ul>");
//if (ordersWithUnsubmittedPortRequests.Count > 0)
//{
// foreach (var item in ordersWithUnsubmittedPortRequests)
// {
// var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
// var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
// output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a></li>");
// }
// output.Append("</ul>");
//}
//else
//{
// output.Append("<li>None</li></ul>");
//}

//output.Append("<p>Unfinished port requests:</p><ul>");
//if (ordersWithUnfinishedPortRequests.Count > 0)
//{
// foreach (var item in ordersWithUnfinishedPortRequests)
// {
// var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
// var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
// output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a></li>");
// }
// output.Append("</ul>");
//}
//else
//{
// output.Append("<li>None</li></ul>");
//}

//output.Append("<p>Uncompleted orders with completed port requests:</p><ul>");
//if (ordersWithCompletedPortRequests.Count > 0)
//{
// foreach (var item in ordersWithCompletedPortRequests)
// {
// var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
// var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
// var installDate = item?.InstallDate is not null ? item?.InstallDate.GetValueOrDefault().ToShortDateString() : "No install date set";
// output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a> - {installDate}</li>");
// }
// output.Append("</ul>");
//}
//else
//{
// output.Append("<li>None</li></ul>");
//}

output.Append("<p>Incomplete orders where the install date has passed in the last quarter:</p><ul>");
if (ordersToMarkCompleted.Count > 0)
{
foreach (var item in ordersToMarkCompleted)
Expand All @@ -237,39 +271,6 @@ public static async Task<bool> DailyBriefingEmailAsync(IngestConfiguration appCo
output.Append("<li>None</li></ul>");
}

output.Append("<p>Orders submitted today:</p><ul>");
if (ordersSubmittedToday.Count > 0)
{
foreach (var item in ordersSubmittedToday)
{
var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
var installDate = item?.InstallDate is not null ? item?.InstallDate.GetValueOrDefault().ToShortDateString() : "No install date set";
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a> - {installDate}</li>");
}
output.Append("</ul>");
}
else
{
output.Append("<li>None</li></ul>");
}

output.Append("<p>Quotes submitted today:</p><ul>");
if (oneMonthFollowUp.Count > 0)
{
foreach (var item in oneMonthFollowUp)
{
var orderName = string.IsNullOrWhiteSpace(item.BusinessName) ? $"{item.FirstName} {item.LastName}" : item.BusinessName;
var salesEmail = string.IsNullOrWhiteSpace(item.SalesEmail) ? "No sales rep assigned" : item.SalesEmail;
var installDate = item?.InstallDate is not null ? item?.InstallDate.GetValueOrDefault().ToShortDateString() : "No install date set";
output.Append($"<li><a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a> - <a href=\"mailto:{item.SalesEmail}?subject={orderName}&body=<a href='https://ops.acceleratenetworks.com/Home/Order/{item.OrderId}' target='_blank' rel='noopener noreferrer'>{orderName}</a>\">{salesEmail}</a> - {installDate}</li>");
}
output.Append("</ul>");
}
else
{
output.Append("<li>None</li></ul>");
}

output.Append("<p>Follow up with Installs from last week:</p><ul>");
if (oneWeekFollowUp.Count > 0)
Expand Down
2 changes: 1 addition & 1 deletion NumberSearch.Tests/Ingest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public FunctionalIngest(ITestOutputHelper output)
//[Fact]
//public async Task TestBulkVSPortStatusUpdates()
//{
// await PortRequests.UpdatePortRequestByExternalIdAsync(ingestConfiguration);
// await Orders.EmailDailyAsync(ingestConfiguration);
//}

//[Fact]
Expand Down

0 comments on commit 60cc6d3

Please sign in to comment.