Skip to content

Commit

Permalink
Fixed logic issue for P200 and P205
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyiwang-cgi committed Nov 20, 2023
1 parent de6fa81 commit 1a11fc5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion OFM.Infrastructure.WebAPI/Models/DataverseModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public bool IsCompleted
{
get
{
if (statecode == 0)
if (statecode == 1)
return true;

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ public async Task<JsonObject> RunProcessAsync(ID365AppUserService appUserService
// Emails are created with "Completed - Pending Send" status. Step 2 will be needed if the sender is not configured for Exchange Online Mailbox.
// Query all Draft emails created in the last 24 hours and by the OFM system user or Notification Service in the future. Must use the correct conditions to find only the Draft emails created in Step 1

var sendEmailBody = new JsonObject {
{ "IssueSend", false}
};
//var sendEmailBody = new JsonObject {
// { "IssueSend", false}
//};

var sendEmailRequests = new List<HttpRequestMessage>() {
new SendEmailRequest(new Guid("00000000-0000-0000-0000-000000000000"), sendEmailBody),
new SendEmailRequest(new Guid("00000000-0000-0000-0000-000000000000"), sendEmailBody)
};
//var sendEmailRequests = new List<HttpRequestMessage>() {
// new SendEmailRequest(new Guid("00000000-0000-0000-0000-000000000000"), sendEmailBody),
// new SendEmailRequest(new Guid("00000000-0000-0000-0000-000000000000"), sendEmailBody)
// };

//var step2BatchResult = await d365WebApiService.SendBatchMessageAsync(appUserService.AZSystemAppUser, sendEmailRequests, null);

Expand All @@ -208,16 +208,16 @@ public async Task<JsonObject> RunProcessAsync(ID365AppUserService appUserService

#region Step3: Other email updates (TODO)

var emailToUpdate = new JsonObject {
{ "scheduledstart",DateTime.Now.ToShortDateString()},
{ "scheduledend",DateTime.Now.AddDays(30).ToShortDateString()},
{ "ofm_is_read",true },
{ "[email protected]", "ofm_communication_types(00000000-0000-0000-0000-000000000000)"}
};
//var emailToUpdate = new JsonObject {
// { "scheduledstart",DateTime.Now.ToShortDateString()},
// { "scheduledend",DateTime.Now.AddDays(30).ToShortDateString()},
// { "ofm_is_read",true },
// { "[email protected]", "ofm_communication_types(00000000-0000-0000-0000-000000000000)"}
// };

var updateEmailRequests = new List<HttpRequestMessage>() {
new UpdateRequest(new EntityReference("emails",new Guid("00000000-0000-0000-0000-000000000000")), emailToUpdate)
};
//var updateEmailRequests = new List<HttpRequestMessage>() {
// new UpdateRequest(new EntityReference("emails",new Guid("00000000-0000-0000-0000-000000000000")), emailToUpdate)
// };

//var step3BatchResult = await d365WebApiService.SendBatchMessageAsync(appUserService.AZSystemAppUser, updateEmailRequests, null);
//if (step3BatchResult.Errors.Any())
Expand Down Expand Up @@ -249,8 +249,8 @@ private bool IsUnreadReminderRequired(D365Email email)
if (email.lastopenedtime is null)
{
var firstReminderInDays = _notificationSettings.UnreadEmailOptions.FirstReminderInDays;
var secondReminderInDays = _notificationSettings.UnreadEmailOptions.FirstReminderInDays;
var thirdReminderInDays = _notificationSettings.UnreadEmailOptions.FirstReminderInDays;
var secondReminderInDays = _notificationSettings.UnreadEmailOptions.SecondReminderInDays;
var thirdReminderInDays = _notificationSettings.UnreadEmailOptions.ThirdReminderInDays;

if (email.scheduledstart.Value.Date.AddDays(firstReminderInDays).Equals(DateTime.Now.Date) ||
email.scheduledstart.Value.Date.AddDays(secondReminderInDays).Equals(DateTime.Now.Date) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public async Task<JsonObject> RunProcessAsync(ID365AppUserService appUserService

serializedData?.ForEach(contact =>
{
recipientsList.Add($"contacts({contact.emailaddress1})");
recipientsList.Add($"contacts({contact.contactid})");
});

if (_processParams.TemplateId is not null)
Expand All @@ -147,7 +147,7 @@ public async Task<JsonObject> RunProcessAsync(ID365AppUserService appUserService
if (!bulkEmailsResponse.IsSuccessStatusCode)
{
var responseBody = await bulkEmailsResponse.Content.ReadAsStringAsync();
_logger.LogError(CustomLogEvent.Process, "Failed to create email reminder records with error: {error}", responseBody);
_logger.LogError(CustomLogEvent.Process, "Failed to create email notification records with error: {error}", responseBody);

return ProcessResult.Failure(ProcessId, new String[] { responseBody }, 0, localData.Data.AsArray().Count).SimpleProcessResult;
}
Expand Down

0 comments on commit 1a11fc5

Please sign in to comment.