From 57638a9022490a0a659de4c68a3ad5e0e32cba98 Mon Sep 17 00:00:00 2001 From: bcgov-fw <88113811+bcgov-fw@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:10:55 -0800 Subject: [PATCH] S10 set funding record status when application is approved (#47) * etFundingRecordStatus (initial version) * Update statusReasonValue for Approved (6) --- .../Application/SetFundingRecordStatus.cs | 97 ++++ OFM.Infrastructure.PCF/Web.config | 2 +- .../OFM.Infrastructure.WebAPI.xml | 419 +----------------- OFM.sln | 4 +- 4 files changed, 116 insertions(+), 406 deletions(-) create mode 100644 OFM.Infrastructure.CustomWorkflowActivities/Application/SetFundingRecordStatus.cs diff --git a/OFM.Infrastructure.CustomWorkflowActivities/Application/SetFundingRecordStatus.cs b/OFM.Infrastructure.CustomWorkflowActivities/Application/SetFundingRecordStatus.cs new file mode 100644 index 00000000..e4ff2d65 --- /dev/null +++ b/OFM.Infrastructure.CustomWorkflowActivities/Application/SetFundingRecordStatus.cs @@ -0,0 +1,97 @@ +using ECC.Core.DataContext; +using Microsoft.Xrm.Sdk; +using Microsoft.Xrm.Sdk.Messages; +using Microsoft.Xrm.Sdk.Query; +using Microsoft.Xrm.Sdk.Workflow; +using System; +using System.Activities; +using System.Linq; +using System.Runtime.InteropServices.ComTypes; +using System.Threading; + +namespace OFM.Infrastructure.CustomWorkflowActivities.Application +{ + public sealed class SetFundingRecordStatus : CodeActivity + { + [ReferenceTarget("ofm_application")] + [RequiredArgument] + [Input("Application")] + public InArgument application { get; set; } + + protected override void Execute(CodeActivityContext executionContext) + { + ITracingService tracingService = executionContext.GetExtension(); + IWorkflowContext context = executionContext.GetExtension(); + IOrganizationServiceFactory serviceFactory = executionContext.GetExtension(); + IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId); + + //var recordId = context.PrimaryEntityId; + var recordId = application.Get(executionContext).Id; + + tracingService.Trace("{0}{1}", "Start Custom Workflow Activity: Application - SetFundingRecordStatus", DateTime.Now.ToLongTimeString()); + try + { + Entity applicationRcord = service.Retrieve("ofm_application", recordId, new ColumnSet("statuscode")); + int statusReason = applicationRcord.GetAttributeValue("statuscode").Value; + + tracingService.Trace("Checking Application record StatusReason value:{0} ", statusReason); + if (applicationRcord != null && applicationRcord.Attributes.Count > 0 && statusReason == 6) // 6 - approved (application) + { + tracingService.Trace("\nThe Application Record - logical name: {0}, id:{1}", applicationRcord.LogicalName, applicationRcord.Id); + var fetchData = new + { + ofm_application = recordId.ToString(), + statecode = "0", // 0 - Active (funding) + statuscode = "3" // 3 - Draft (funding) + }; + var fetchXml = $@" + + + + + + + + + + + + + + "; + + EntityCollection fundingRecords = service.RetrieveMultiple(new FetchExpression(fetchXml)); + + //Change Active Funding record status: Draft (3) --> FA Review (4) + if (fundingRecords.Entities.Count > 0 && fundingRecords[0] != null) + { + var id = fundingRecords[0].Id; + tracingService.Trace("\nActive funding record to be updated with FA Review status: " + id); + + Entity fundingRecordTable = new Entity("ofm_funding"); + fundingRecordTable.Id = id; + fundingRecordTable["statuscode"] = new OptionSetValue(4); // 4 - FA Review (funding) + service.Update(fundingRecordTable); + + tracingService.Trace("\nChange sucessfully active funding detail record status from Draft to FA review."); + } + else + { + tracingService.Trace("\nNo active funding record found."); + } + } + else + { + tracingService.Trace("\nNo application record found."); + } + + tracingService.Trace("Workflow activity end."); + + } + catch (Exception ex) + { + throw new InvalidWorkflowException("Exeception in Custom Workflow -" + ex.Message + ex.InnerException); + } + } + } +} diff --git a/OFM.Infrastructure.PCF/Web.config b/OFM.Infrastructure.PCF/Web.config index 076a0fc0..f3d20e64 100644 --- a/OFM.Infrastructure.PCF/Web.config +++ b/OFM.Infrastructure.PCF/Web.config @@ -9,7 +9,7 @@ --> - + \ No newline at end of file diff --git a/OFM.Infrastructure.WebAPI/OFM.Infrastructure.WebAPI.xml b/OFM.Infrastructure.WebAPI/OFM.Infrastructure.WebAPI.xml index 72cfbb76..22940516 100644 --- a/OFM.Infrastructure.WebAPI/OFM.Infrastructure.WebAPI.xml +++ b/OFM.Infrastructure.WebAPI/OFM.Infrastructure.WebAPI.xml @@ -478,11 +478,6 @@ Gets a binding to the set of all entities. - - - Gets a binding to the set of all entities. - - Gets a binding to the set of all entities. @@ -493,11 +488,6 @@ Gets a binding to the set of all entities. - - - Gets a binding to the set of all entities. - - Gets a binding to the set of all entities. @@ -1620,21 +1610,11 @@ 1:N ofm_funding_facility_account - - - 1:N ofm_integrationlog_provider - - 1:N ofm_organization_application - - - 1:N ofm_payment_facility_account - - N:1 account_master_account @@ -2866,11 +2846,6 @@ 1:N ofm_facility_business_bceid - - - 1:N ofm_payment_expense_authority_contact - - 1:N ofm_request_contact @@ -3147,6 +3122,11 @@ Information regarding whether the email activity was billed as part of resolving a case. + + + Indicates if the sender of the email is unresolved in case of multiple match + + For internal use only. Shows whether this email is followed. This is evaluated state which overrides user selection of follow email. @@ -4124,16 +4104,6 @@ 1:N ofm_document_application - - - 1:N ofm_integrationlog_application - - - - - 1:N ofm_payment_application_ofm_application - - 1:N ofm_request_application @@ -5348,6 +5318,11 @@ Boolean Attribute + + + Calculated On + + Funding End Date @@ -5764,16 +5739,6 @@ 1:N ofm_funding_tracker - - - 1:N ofm_integrationlog_funding - - - - - 1:N ofm_payment_funding_ofm_funding - - N:1 ofm_application_funding @@ -5976,172 +5941,6 @@ LINQ anonymous type. - - - Integration Log - - - - - Available fields, a the time of codegen, for the ofm_integration_log entity - - - - - Default Constructor. - - - - - Unique identifier of the user who created the record. - - - - - Date and time when the record was created. - - - - - Unique identifier of the delegate user who created the record. - - - - - Sequence number of the import that created this record. - - - - - Unique identifier of the user who modified the record. - - - - - Date and time when the record was modified. - - - - - Unique identifier of the delegate user who modified the record. - - - - - ID - - - - - Category - - - - - Unique identifier for entity instances - - - - - Message - - - - - Regarding - - - - - External Service - - - - - Subject - - - - - Date and time that the record was migrated. - - - - - Owner Id - - - - - Unique identifier for the business unit that owns the record - - - - - Unique identifier for the team that owns the record. - - - - - Unique identifier for the user that owns the record. - - - - - Status of the Integration Log - - - - - Reason for the status of the Integration Log - - - - - For internal use only. - - - - - Time zone code that was in use when the record was created. - - - - - Version Number - - - - - N:1 ofm_integrationlog_application - - - - - N:1 ofm_integrationlog_funding - - - - - N:1 ofm_integrationlog_payment - - - - - N:1 ofm_integrationlog_provider - - - - - N:1 team_ofm_integration_log - - - - - Constructor for populating via LINQ queries given a LINQ anonymous type - LINQ anonymous type. - - Facility Licence @@ -6343,6 +6142,11 @@ Unique identifier of the delegate user who modified the record. + + + Boolean Attribute + + Care Type @@ -6479,167 +6283,6 @@ LINQ anonymous type. - - - Represents payment records that must be submitted to CAS to trigger payments to contractors. - - - - - Available fields, a the time of codegen, for the ofm_payment entity - - - - - Default Constructor. - - - - - Unique identifier of the user who created the record. - - - - - Date and time when the record was created. - - - - - Unique identifier of the delegate user who created the record. - - - - - Exchange rate for the currency associated with the entity with respect to the base currency. - - - - - Sequence number of the import that created this record. - - - - - Unique identifier of the user who modified the record. - - - - - Date and time when the record was modified. - - - - - Unique identifier of the delegate user who modified the record. - - - - - Value of the Funding Amount in base currency. - - - - - Allows users to adjust payment records by either marking it as complete or resubmitting the request to CAS. - - - - - Unique identifier for entity instances - - - - - Date and time that the record was migrated. - - - - - Owner Id - - - - - Unique identifier for the business unit that owns the record - - - - - Unique identifier for the team that owns the record. - - - - - Unique identifier for the user that owns the record. - - - - - Status of the Payment - - - - - Reason for the status of the Payment - - - - - For internal use only. - - - - - Unique identifier of the currency associated with the entity. - - - - - Time zone code that was in use when the record was created. - - - - - Version Number - - - - - 1:N ofm_integrationlog_payment - - - - - N:1 ofm_payment_application_ofm_application - - - - - N:1 ofm_payment_expense_authority_contact - - - - - N:1 ofm_payment_facility_account - - - - - N:1 ofm_payment_funding_ofm_funding - - - - - N:1 team_ofm_payment - - - - - Constructor for populating via LINQ queries given a LINQ anonymous type - LINQ anonymous type. - - Progress Tracker Record @@ -6717,7 +6360,7 @@ - OFM Progress Tracker Record + OFM Progress Tracker ID @@ -7792,11 +7435,6 @@ 1:N team_ofm_funding_rate - - - 1:N team_ofm_integration_log - - 1:N team_ofm_licence @@ -7807,11 +7445,6 @@ 1:N team_ofm_licence_detail - - - 1:N team_ofm_payment - - 1:N team_ofm_progress_tracker @@ -11120,16 +10753,6 @@ Reason for the status of the Funding - - - Status of the Integration Log - - - - - Reason for the status of the Integration Log - - Status of the Licence Details @@ -11150,16 +10773,6 @@ Reason for the status of the Licence - - - Status of the Payment - - - - - Reason for the status of the Payment - - Status of the Progress Tracker diff --git a/OFM.sln b/OFM.sln index cc773ad8..b30e6247 100644 --- a/OFM.sln +++ b/OFM.sln @@ -13,7 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02 Core", "02 Core", "{0BA2 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "04 Application", "04 Application", "{1CA8FF5C-99C4-4CC8-B4B2-4D0EC65F8CD1}" EndProject -Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "OFM.Application.WebResources(1)", "OFM.Application.WebResources\", "{6869D6B7-1D39-4C6E-AA46-427430F6A3D5}" +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "OFM.Application.WebResources", "OFM.Application.WebResources\", "{6869D6B7-1D39-4C6E-AA46-427430F6A3D5}" ProjectSection(WebsiteProperties) = preProject TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.8" Debug.AspNetCompiler.VirtualPath = "/localhost_58948" @@ -44,7 +44,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OFM.Infrastructure.Plugins" EndProject Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "OFM.Infrastructure.PCF", "OFM.Infrastructure.PCF\", "{BCFED66B-8958-4F43-B089-18D97D6AF058}" ProjectSection(WebsiteProperties) = preProject - TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0" + TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.8.1" Debug.AspNetCompiler.VirtualPath = "/localhost_4420" Debug.AspNetCompiler.PhysicalPath = "OFM.Infrastructure.PCF\" Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_4420\"