Skip to content

Commit

Permalink
Added time estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
nakov committed Sep 17, 2017
1 parent ecae9ca commit 5062043
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/email-template.html
/.vs
/Smart-Mass-Mailer.csproj.user
/obj
/bin
19 changes: 15 additions & 4 deletions SmartMassMailer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@ static void Main()
if (startRow < 2)
startRow = 2;

using (var package = new ExcelPackage(
new FileInfo(Configuration["recipientsExcelFile"])))
var excelFile = new FileInfo(Configuration["recipientsExcelFile"]);
if (! excelFile.Exists)
throw new FileNotFoundException($"The file '{excelFile.FullName}' does not exist.", excelFile.FullName);

using (var package = new ExcelPackage(excelFile))
{
ExcelWorksheet workSheet = package.Workbook.Worksheets[1];


int mailsLeft = workSheet.Dimension.End.Row - startRow;
TimeSpan timeLeft = TimeSpan.FromMilliseconds(
mailsLeft * (delayBetweenEmails + 100));
Console.WriteLine("Estimated time: {0} hours", timeLeft);

// Read Excel file column titles (the first worhsheet row)
var columnIndexByName = new Dictionary<string, int>();
for (int col = 1; col <= workSheet.Dimension.End.Column; col++)
Expand All @@ -84,6 +92,9 @@ static void Main()
Console.WriteLine("Done.");
Thread.Sleep(delayBetweenEmails);
}
}

Console.WriteLine();
Console.WriteLine("Done.");
}
}
}

0 comments on commit 5062043

Please sign in to comment.