Skip to content

Commit

Permalink
Merge branch 'dev' into dev-rook-NK-FOIMOD-3563
Browse files Browse the repository at this point in the history
# Conflicts:
#	web/src/components/FOI/Home/Redlining.js
  • Loading branch information
nkan-aot2 committed Nov 6, 2024
2 parents 61092ff + 79cb423 commit 667febd
Show file tree
Hide file tree
Showing 62 changed files with 2,250 additions and 427 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ bld/
MCS.FOI.S3FileConversion/MCS.FOI.S3FileConversion/QtBinariesWindows/
computingservices/ZippingServices/env/*
openshift/templates/zippingservice/zipper.env
*.locenv

MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDFUnitTests/SourceFiles/result_*.pdf
MCS.FOI.S3FileConversion/MCS.FOI.CalendarToPDFUnitTests/SourceFiles/result_*.pdf
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,22 @@ public CalendarFileProcessor(Stream sourceStream)

string organizer = string.Empty;
//Organizer Name and Email
if (e.Organizer != null)
if (e.Organizer?.Value != null)
{
organizer = e.Organizer.CommonName + "(" + e.Organizer.Value.AbsoluteUri + ")";
try
{
organizer = e.Organizer?.CommonName + "(" + e.Organizer?.Value.AbsoluteUri + ")";
}
catch
{

organizer = @"Unknown Organizer";
}

}
else
{
organizer = @"Unknown Organizer(mailto:unknownorganizer@calendar.google.com)";
organizer = @"Unknown Organizer(mailto:unknownorganizer@calendar.bcgov.ca)";
}
htmlString.Append(@"<tr>
<td><b>From: </b></td>
Expand All @@ -174,7 +182,7 @@ public CalendarFileProcessor(Stream sourceStream)
//Meeting created timestamp
htmlString.Append(@"<tr>
<td><b>Sent: </b></td>
<td>" + e.DtStamp.Date + "</td></tr>");
<td>" + e.DtStamp.Value + "</td></tr>");

//Priority
htmlString.Append(@"<tr>
Expand All @@ -184,12 +192,12 @@ public CalendarFileProcessor(Stream sourceStream)
//Meeting Start Timestamp
htmlString.Append(@"<tr>
<td><b>Start Time: </b></td>
<td>" + e.DtStart.Date + "</td></tr>");
<td>" + e.DtStart.Value + "</td></tr>");

//Meeting End Timestamp
htmlString.Append(@"<tr>
<td><b>End Time: </b></td>
<td>" + e.DtEnd.Date + "</td></tr>");
<td>" + e.DtEnd.Value + "</td></tr>");
//Meeting Message
string message = @"" + e.Description?.Replace("\n", "<br>");
message = message.Replace("&lt;br&gt;", "<br>").Replace("&lt;br/&gt;", "<br/>");
Expand Down Expand Up @@ -243,6 +251,22 @@ public CalendarFileProcessor(Stream sourceStream)

}


private DateTime GetPSTTime(DateTime _timetoconvert)
{
DateTime converteddate = _timetoconvert;
if (TimeZone.CurrentTimeZone.StandardName != "Pacific Standard Time" || _timetoconvert.Kind == DateTimeKind.Utc )
{

converteddate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(converteddate, "Pacific Standard Time");

}

return converteddate;
}



/// <summary>
/// Converts HTML string to PDF using syncfution library and blink engine
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ public void ProcessSimpleCalendarFilesTest()
Dictionary<MemoryStream, Dictionary<string,string>> attachments = new Dictionary<MemoryStream, Dictionary<string, string>>();
string rootFolder = getSourceFolder();
Stream output = new MemoryStream();
Stream testFile = new FileStream(Path.Combine(getSourceFolder(), "test-cal.ics"), FileMode.Open, FileAccess.Read);
Stream testFile = new FileStream(Path.Combine(getSourceFolder(), "Backlog refinement.ics"), FileMode.Open, FileAccess.Read);

CalendarFileProcessor calendarFileProcessor = new CalendarFileProcessor(testFile);
calendarFileProcessor.WaitTimeinMilliSeconds = 5000;
calendarFileProcessor.FailureAttemptCount = 10;
string outputPath = Path.Combine(getSourceFolder(), "output");
(isProcessed, message, output, attachments) = calendarFileProcessor.ProcessCalendarFiles();
Assert.IsTrue(isProcessed == true, $"Calendar to PDF Conversion failed");

SaveStreamAsFile(getSourceFolder(), output, "result_Backlog refinement.pdf");
}

[TestMethod]
Expand All @@ -60,7 +62,7 @@ public void ProcessCalendarFileWithAttachmentsTest()
Dictionary<MemoryStream, Dictionary<string, string>> attachments = new Dictionary<MemoryStream, Dictionary<string, string>>();
string rootFolder = getSourceFolder();
Stream output = new MemoryStream();
Stream testFile = new FileStream(Path.Combine(getSourceFolder(), "test-with-attachments.ics"), FileMode.Open, FileAccess.Read);
Stream testFile = new FileStream(Path.Combine(getSourceFolder(), "Backlog refinement.ics"), FileMode.Open, FileAccess.Read);

CalendarFileProcessor calendarFileProcessor = new CalendarFileProcessor(testFile);
calendarFileProcessor.WaitTimeinMilliSeconds = 5000;
Expand All @@ -71,6 +73,8 @@ public void ProcessCalendarFileWithAttachmentsTest()

bool isAttachmentsExists = attachments.Count == 2;
Assert.IsTrue(isAttachmentsExists, $"Attachments not found");

SaveStreamAsFile(getSourceFolder(), output, "result_Backlog refinement.pdf");
}

[TestMethod]
Expand All @@ -81,18 +85,34 @@ public void ProcessComplexCalendarFilesTest()
Dictionary<MemoryStream, Dictionary<string, string>> attachments = new Dictionary<MemoryStream, Dictionary<string, string>>();
string rootFolder = getSourceFolder();
Stream output = new MemoryStream();
Stream testFile = new FileStream(Path.Combine(getSourceFolder(), "test-problematic-calendar.ics"), FileMode.Open, FileAccess.Read);
Stream testFile = new FileStream(Path.Combine(getSourceFolder(), "test-with-attachments.ics"), FileMode.Open, FileAccess.Read);

CalendarFileProcessor calendarFileProcessor = new CalendarFileProcessor(testFile);
calendarFileProcessor.WaitTimeinMilliSeconds = 5000;
calendarFileProcessor.FailureAttemptCount = 10;
(isProcessed, message, output, attachments) = calendarFileProcessor.ProcessCalendarFiles();
Assert.IsTrue(isProcessed == true, $"Calendar to PDF Conversion failed");

SaveStreamAsFile(getSourceFolder(), output, "result_test-with-attachmentsr.pdf");
}

private string getSourceFolder()
{
return "C:\\Projects\\foi-docreviewer\\MCS.FOI.S3FileConversion\\MCS.FOI.CalendarToPDFUnitTests\\SourceFiles";
return "C:\\AOT\\FOI\\Source\\foi-docreviewer\\foi-docreviewer\\MCS.FOI.S3FileConversion\\MCS.FOI.CalendarToPDFUnitTests\\SourceFiles";
}

public static void SaveStreamAsFile(string filePath, Stream stream, string fileName)
{
stream.Position = 0;
var path = Path.Combine(filePath, fileName);
var bytesInStream = new byte[stream.Length];

stream.Read(bytesInStream, 0, (int)bytesInStream.Length);

using (var outputFileStream = new FileStream(path, FileMode.Create))
{
outputFileStream.Write(bytesInStream, 0, bytesInStream.Length);
}
}
}
}
Expand Down
Loading

0 comments on commit 667febd

Please sign in to comment.