Notes
Notes - notes.io |
{
try
{
while (!stoppingToken.IsCancellationRequested)
{
executionCount++;
_logger.LogInformation(
"Scoped Processing Service is working. Count: {Count}",
executionCount);
Console.WriteLine($"Execution Started - {DateTime.Now}");
// Load lookup data once
var legacyRolodexDetailList = await _appDbContext.LegacyRoledexDirty.ToListAsync();
var updateRolodexDetailList = await _appDbContext.RolodexUpdateStatus.ToListAsync();
#region HR_VOE Email Cleanup
int hrCount = 0;
var invalidHREmailRecords = await _appDbContext.Roledex
.Where(x =>
!string.IsNullOrEmpty(x.HR_VOEEmail) &&
EF.Functions.Like(x.HR_VOEEmail, "%protected%"))
.ToListAsync();
foreach (var item in invalidHREmailRecords)
{
hrCount++;
item.HR_VOEEmail = string.Empty;
var legacyRolodexDetails = legacyRolodexDetailList
.FirstOrDefault(x => x.RoledexID == item.RoledexID);
if (legacyRolodexDetails != null)
{
legacyRolodexDetails.IsScrapingDone = false;
}
var updateRolodexDetails = updateRolodexDetailList
.FirstOrDefault(x => x.RoledexID == item.RoledexID);
if (updateRolodexDetails != null)
{
updateRolodexDetails.HR_VOEEmail = 0;
}
Console.WriteLine($"{hrCount}. HR Email Cleaned : {item.Company}");
}
#endregion
#region Payroll Email Cleanup
int prCount = 0;
var invalidPREmailRecords = await _appDbContext.Roledex
.Where(x =>
!string.IsNullOrEmpty(x.PREmail) &&
EF.Functions.Like(x.PREmail, "%protected%"))
.ToListAsync();
foreach (var item in invalidPREmailRecords)
{
prCount++;
item.PREmail = string.Empty;
var legacyRolodexDetails = legacyRolodexDetailList
.FirstOrDefault(x => x.RoledexID == item.RoledexID);
if (legacyRolodexDetails != null)
{
legacyRolodexDetails.IsScrapingDone = false;
}
var updateRolodexDetails = updateRolodexDetailList
.FirstOrDefault(x => x.RoledexID == item.RoledexID);
if (updateRolodexDetails != null)
{
updateRolodexDetails.PREmail = 0;
}
Console.WriteLine($"{prCount}. Payroll Email Cleaned : {item.Company}");
}
#endregion
// Save all Rolodex changes together
await _appDbContext.SaveChangesAsync(stoppingToken);
#region Delete Invalid Company Emails
int deletedEmailCount = 0;
var invalidEmailRecordList = await _waveDbContext.CompanyEmail
.Where(x =>
!string.IsNullOrEmpty(x.EmailAddress) &&
EF.Functions.Like(x.EmailAddress, "%protected%"))
.ToListAsync();
deletedEmailCount = invalidEmailRecordList.Count;
foreach (var item in invalidEmailRecordList)
{
Console.WriteLine(
$"Deleting Invalid Email : CompanyID={item.CompanyID}, Email={item.EmailAddress}");
}
if (invalidEmailRecordList.Any())
{
_waveDbContext.CompanyEmail.RemoveRange(invalidEmailRecordList);
await _waveDbContext.SaveChangesAsync(stoppingToken);
}
#endregion
Console.WriteLine(
$"Execution Completed Successfully. " +
$"HR Cleaned={hrCount}, " +
$"PR Cleaned={prCount}, " +
$"Deleted Emails={deletedEmailCount}");
await _emailService.SendAsync(
subject: $"Cleaner Scheduler - {DateTime.Now:yyyy-MM-dd HH:mm:ss}",
body: $@"
Hi Team,
<br/><br/>
<strong>Execution Completed Successfully</strong>
<br/><br/>
HR Emails Cleaned: {hrCount}
<br/>
Payroll Emails Cleaned: {prCount}
<br/>
Invalid Company Emails Deleted: {deletedEmailCount}
<br/><br/>
Run Time: {DateTime.Now:yyyy-MM-dd HH:mm:ss}"
);
await Task.Delay(getJobRunDelay(), stoppingToken);
}
}
catch (OperationCanceledException)
{
_logger.LogInformation("Cleaner Scheduler cancelled.");
}
catch (Exception ex)
{
_logExceptionService.WriteToFile(
$"Exception Error in DoWork at {DateTime.Now}",
ex.ToString());
Console.WriteLine(
$"Exception Error in DoWork and Stop Scraping due to {ex.Message}");
throw;
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
