Skip to content

Commit 02eb758

Browse files
committed
Replacing deprecated packages.
Updating package versions. Fixing warnings. Update healthcheck. Add csharpier conifg. Run formatter. Cleanup csproj. Remove unused SPA code.
1 parent 5d2a30c commit 02eb758

40 files changed

+1026
-690
lines changed

Database/Database.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.1.32" />
11-
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client.Dynamics" Version="1.1.32" />
10+
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.7" />
11+
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client.Dynamics" Version="1.2.7" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

Manager/Manager.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="MediatR" Version="12.4.1" />
10+
<PackageReference Include="MediatR" Version="12.5.0" />
1111
<PackageReference Include="MediatR.Contracts" Version="2.0.1" />
1212
</ItemGroup>
1313

Shared.Database/Shared.Database.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="AutoMapper" Version="13.0.1" />
11-
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="7.0.2" />
12-
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.1.27" />
10+
<PackageReference Include="AutoMapper" Version="14.0.0" />
11+
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="8.0.0" />
12+
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.7" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

Tests/Tests.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
</ItemGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="coverlet.collector" Version="6.0.0" />
26-
<PackageReference Include="MediatR" Version="12.4.1" />
27-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
28-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
29-
<PackageReference Include="xunit" Version="2.9.2" />
30-
<PackageReference Include="Xunit.DependencyInjection" Version="9.3.1" />
31-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
25+
<PackageReference Include="coverlet.collector" Version="6.0.4" />
26+
<PackageReference Include="MediatR" Version="12.5.0" />
27+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
28+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
29+
<PackageReference Include="xunit" Version="2.9.3" />
30+
<PackageReference Include="Xunit.DependencyInjection" Version="9.9.1" />
31+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
3232
</ItemGroup>
3333

3434
<ItemGroup>

Utilities/Utilities.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="MediatR" Version="12.4.1" />
10+
<PackageReference Include="MediatR" Version="12.5.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

vsd-app/.csharpierrc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
printWidth: 120
2+
useTabs: false
3+
indentSize: 4
4+
endOfLine: auto

vsd-app/Client/CasHttpClient.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using System.Net.Http;
1+
using System;
2+
using System.Net.Http;
3+
using System.Net.Http.Headers;
24
using System.Text;
3-
using System.Xml.Linq;
5+
using System.Threading.Tasks;
46
using System.Xml;
5-
using System;
6-
using System.Net.Http.Headers;
7+
using System.Xml.Linq;
78
using Microsoft.Extensions.DependencyInjection;
8-
using System.Threading.Tasks;
99
using Newtonsoft.Json;
1010
using Utilities;
1111

@@ -16,7 +16,7 @@ public class CasHttpClient : ICasHttpClient
1616
{
1717
// TODO I remember there are some caveats to HttpClient scope and disposing, which is why the Extension DI register might be better if more HttpClients are added
1818
// Consider researching and implementing the commented out Extension method below, if time permits. I would assume the Extension would affectively get a HttpClient
19-
// from a pool of available HttpClient(s), and dispose of them properly. The downside at first glance seems to be you have multiple client api urls all cluttered
19+
// from a pool of available HttpClient(s), and dispose of them properly. The downside at first glance seems to be you have multiple client api urls all cluttered
2020
// in one pool of HttpClient(s)
2121
// There is also the topic of disposing HttpClient, touched here https://stackoverflow.com/questions/15705092/do-httpclient-and-httpclienthandler-have-to-be-disposed-between-requests
2222
private HttpClient _httpClient = null;
@@ -28,7 +28,7 @@ public void Initialize(string clientId, string clientKey, string url)
2828
httpClient.DefaultRequestHeaders.Add("secret", clientKey);
2929
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
3030
httpClient.BaseAddress = new Uri(url);
31-
httpClient.Timeout = new TimeSpan(1, 0, 0); // 1 hour timeout
31+
httpClient.Timeout = new TimeSpan(1, 0, 0); // 1 hour timeout
3232
_httpClient = httpClient;
3333
}
3434

@@ -49,15 +49,23 @@ public async Task<bool> ApTransaction(CasApTransactionInvoices invoices)
4949
}
5050
var httpResponse = await response.Content.ReadAsStringAsync();
5151

52-
var jsonReader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(httpResponse), new XmlDictionaryReaderQuotas());
52+
var jsonReader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader(
53+
Encoding.UTF8.GetBytes(httpResponse),
54+
new XmlDictionaryReaderQuotas()
55+
);
5356

5457
var root = XElement.Load(jsonReader);
5558
if (root.Element("CAS-Returned-Messages") != null)
5659
{
5760
var casReturnedMessages = root.Element("CAS-Returned-Messages");
5861
if (casReturnedMessages != null)
5962
{
60-
if (!(casReturnedMessages.Value.Equals("SUCCEEDED", StringComparison.InvariantCultureIgnoreCase) | casReturnedMessages.Value.Contains("Duplicate Submission")))
63+
if (
64+
!(
65+
casReturnedMessages.Value.Equals("SUCCEEDED", StringComparison.InvariantCultureIgnoreCase)
66+
| casReturnedMessages.Value.Contains("Duplicate Submission")
67+
)
68+
)
6169
throw new Exception(casReturnedMessages.Value + "\r\n" + jsonRequest);
6270
}
6371
else
@@ -81,7 +89,7 @@ public async Task<bool> ApTransaction(CasApTransactionInvoices invoices)
8189
// httpClient.DefaultRequestHeaders.Add("secret", clientKey);
8290
// httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
8391
// httpClient.BaseAddress = new Uri(url);
84-
// httpClient.Timeout = new TimeSpan(1, 0, 0); // 1 hour timeout
92+
// httpClient.Timeout = new TimeSpan(1, 0, 0); // 1 hour timeout
8593

8694
// services.AddHttpClient<ICasHttpClient, CasHttpClient>(serviceProvider => new CasHttpClient(httpClient));
8795
// return services;

vsd-app/Controllers/AEMController.cs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
using System;
2+
using System.IO;
3+
using System.Text;
4+
using System.Threading.Tasks;
5+
using System.Xml;
6+
using System.Xml.Serialization;
17
using Gov.Cscp.VictimServices.Public.Models;
28
using Gov.Cscp.VictimServices.Public.Services;
39
using Gov.Cscp.VictimServices.Public.ViewModels;
410
using Microsoft.AspNetCore.Mvc;
511
using Serilog;
6-
using System.IO;
7-
using System.Text;
8-
using System.Threading.Tasks;
9-
using System.Xml.Serialization;
10-
using System.Xml;
11-
using System;
1212

1313
namespace Gov.Cscp.VictimServices.Public.Controllers
1414
{
@@ -31,7 +31,9 @@ public async Task<IActionResult> GetVictimApplicationPDF([FromBody] ApplicationF
3131
{
3232
if (!ModelState.IsValid)
3333
{
34-
_logger.Error($"API call to 'GetVictimApplicationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD");
34+
_logger.Error(
35+
$"API call to 'GetVictimApplicationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD"
36+
);
3537
return BadRequest(ModelState);
3638
}
3739

@@ -56,7 +58,9 @@ public async Task<IActionResult> GetIFMApplicationPDF([FromBody] ApplicationForm
5658
{
5759
if (!ModelState.IsValid)
5860
{
59-
_logger.Error($"API call to 'GetIFMApplicationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD");
61+
_logger.Error(
62+
$"API call to 'GetIFMApplicationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD"
63+
);
6064
return BadRequest(ModelState);
6165
}
6266

@@ -81,7 +85,9 @@ public async Task<IActionResult> GetWitnessApplicationPDF([FromBody] Application
8185
{
8286
if (!ModelState.IsValid)
8387
{
84-
_logger.Error($"API call to 'GetWitnessApplicationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD");
88+
_logger.Error(
89+
$"API call to 'GetWitnessApplicationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD"
90+
);
8591
return BadRequest(ModelState);
8692
}
8793

@@ -106,7 +112,9 @@ public async Task<IActionResult> GetAuthorizationPDF([FromBody] ApplicationFormM
106112
{
107113
if (!ModelState.IsValid)
108114
{
109-
_logger.Error($"API call to 'GetAuthorizationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD");
115+
_logger.Error(
116+
$"API call to 'GetAuthorizationPDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD"
117+
);
110118
return BadRequest(ModelState);
111119
}
112120

@@ -131,7 +139,9 @@ public async Task<IActionResult> GetInvoicePDF([FromBody] CounsellorInvoiceFormM
131139
{
132140
if (!ModelState.IsValid)
133141
{
134-
_logger.Error($"API call to 'GetInvoicePDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD");
142+
_logger.Error(
143+
$"API call to 'GetInvoicePDF' made with invalid model state. Error is:\n{ModelState}. Source = VSD"
144+
);
135145
return BadRequest(ModelState);
136146
}
137147

@@ -157,7 +167,7 @@ private static string getApplicationXML(ApplicationFormModel model)
157167
{
158168
Indent = true,
159169
OmitXmlDeclaration = false,
160-
Encoding = encoding
170+
Encoding = encoding,
161171
};
162172

163173
string xml = "";
@@ -186,7 +196,7 @@ private static string getInvoiceXML(CounsellorInvoiceFormModel model)
186196
{
187197
Indent = true,
188198
OmitXmlDeclaration = false,
189-
Encoding = encoding
199+
Encoding = encoding,
190200
};
191201

192202
string xml = "";
@@ -237,11 +247,20 @@ private static string getAEMJSON(string xml, string application_type)
237247
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(xml);
238248
var encoded = System.Convert.ToBase64String(plainTextBytes);
239249

240-
string requestJson = "{\"aem_app\":\"" + aem_app + "\"," +
241-
"\"aem_form\":\"" + aem_form + "\"," +
242-
"\"document_format\":\"" + document_format + "\"," +
243-
"\"aem_xml_data\":\"" + encoded + "\"" +
244-
"}";
250+
string requestJson =
251+
"{\"aem_app\":\""
252+
+ aem_app
253+
+ "\","
254+
+ "\"aem_form\":\""
255+
+ aem_form
256+
+ "\","
257+
+ "\"document_format\":\""
258+
+ document_format
259+
+ "\","
260+
+ "\"aem_xml_data\":\""
261+
+ encoded
262+
+ "\""
263+
+ "}";
245264

246265
return requestJson;
247266
}

vsd-app/Controllers/ConfigurationController.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.Extensions.Configuration;
56
using Microsoft.Extensions.Logging;
6-
using Microsoft.AspNetCore.Authorization;
77

88
namespace Gov.Cscp.VictimServices.Public.Controllers
99
{
@@ -30,13 +30,18 @@ public IActionResult GetConfiguration()
3030
{
3131
OutageMessage = configuration.GetValue<string>("CONFIGURATION_OUTAGEINFORMATION_MESSAGE"),
3232
OutageStartDate = configuration.GetValue<string>("CONFIGURATION_OUTAGEINFORMATION_STARTDATE"),
33-
OutageEndDate = configuration.GetValue<string>("CONFIGURATION_OUTAGEINFORMATION_ENDDATE")
33+
OutageEndDate = configuration.GetValue<string>("CONFIGURATION_OUTAGEINFORMATION_ENDDATE"),
3434
};
3535

36-
if (string.IsNullOrEmpty(config.OutageMessage) || string.IsNullOrEmpty(config.OutageStartDate) || string.IsNullOrEmpty(config.OutageEndDate))
36+
if (
37+
string.IsNullOrEmpty(config.OutageMessage)
38+
|| string.IsNullOrEmpty(config.OutageStartDate)
39+
|| string.IsNullOrEmpty(config.OutageEndDate)
40+
)
3741
{
3842
return Ok();
39-
};
43+
}
44+
;
4045

4146
return Ok(config);
4247
}

vsd-app/Controllers/JusticeController.cs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
using System;
2+
using System.Threading.Tasks;
13
using Gov.Cscp.VictimServices.Public.JsonObjects;
2-
using Gov.Cscp.VictimServices.Public.Models.Extensions;
34
using Gov.Cscp.VictimServices.Public.Models;
5+
using Gov.Cscp.VictimServices.Public.Models.Extensions;
46
using Gov.Cscp.VictimServices.Public.Services;
57
using Gov.Cscp.VictimServices.Public.ViewModels;
68
using Microsoft.AspNetCore.Mvc;
79
using Microsoft.Extensions.Configuration;
810
using Newtonsoft.Json;
911
using Serilog;
10-
using System.Threading.Tasks;
11-
using System;
1212

1313
namespace Gov.Cscp.VictimServices.Public.Controllers
1414
{
@@ -33,7 +33,9 @@ public async Task<IActionResult> SaveApplication([FromBody] ApplicationFormModel
3333
{
3434
if (!ModelState.IsValid)
3535
{
36-
_logger.Error($"API call to 'SaveApplication' made with invalid model state. Error is:\n{ModelState}. Source = VSD");
36+
_logger.Error(
37+
$"API call to 'SaveApplication' made with invalid model state. Error is:\n{ModelState}. Source = VSD"
38+
);
3739
return BadRequest(ModelState);
3840
}
3941

@@ -65,7 +67,9 @@ public async Task<IActionResult> SubmitCounsellorInvoice([FromBody] CounsellorIn
6567
{
6668
if (!ModelState.IsValid)
6769
{
68-
_logger.Error($"API call to 'SubmitCounsellorInvoice' made with invalid model state. Error is:\n{ModelState}. Source = VSD");
70+
_logger.Error(
71+
$"API call to 'SubmitCounsellorInvoice' made with invalid model state. Error is:\n{ModelState}. Source = VSD"
72+
);
6973
return BadRequest(ModelState);
7074
}
7175

@@ -95,7 +99,8 @@ public async Task<IActionResult> ValidateVendor(String VendorNumber, String Vend
9599
{
96100
try
97101
{
98-
string requestJson = "{\"VendorNumber\":\"" + VendorNumber + "\",\"VendorPostalCode\":\"" + VendorPostalCode + "\"}";
102+
string requestJson =
103+
"{\"VendorNumber\":\"" + VendorNumber + "\",\"VendorPostalCode\":\"" + VendorPostalCode + "\"}";
99104
string endpointUrl = "vsd_CheckVendorStatus";
100105

101106
DynamicsResult result = await _dynamicsResultService.Post(endpointUrl, requestJson);
@@ -104,18 +109,39 @@ public async Task<IActionResult> ValidateVendor(String VendorNumber, String Vend
104109
}
105110
catch (Exception e)
106111
{
107-
_logger.Error(e, "Unexpected error while validating vendor. Source = VSD", VendorNumber, VendorPostalCode);
112+
_logger.Error(
113+
e,
114+
"Unexpected error while validating vendor. Source = VSD",
115+
VendorNumber,
116+
VendorPostalCode
117+
);
108118
return BadRequest();
109119
}
110120
finally { }
111121
}
112122

113-
[HttpGet("validate_vendor_and_counsellor/{VendorNumber}/{VendorPostalCode}/{CounsellorNumber}/{CounsellorLastName}")]
114-
public async Task<IActionResult> ValidateVendorAndCounsellor(String VendorNumber, String VendorPostalCode, String CounsellorNumber, String CounsellorLastName)
123+
[HttpGet(
124+
"validate_vendor_and_counsellor/{VendorNumber}/{VendorPostalCode}/{CounsellorNumber}/{CounsellorLastName}"
125+
)]
126+
public async Task<IActionResult> ValidateVendorAndCounsellor(
127+
String VendorNumber,
128+
String VendorPostalCode,
129+
String CounsellorNumber,
130+
String CounsellorLastName
131+
)
115132
{
116133
try
117134
{
118-
string requestJson = "{\"VendorNumber\":\"" + VendorNumber + "\",\"VendorPostalCode\":\"" + VendorPostalCode + "\",\"CounselorNumber\":\"" + CounsellorNumber + "\",\"CounselorLastName\":\"" + CounsellorLastName + "\"}";
135+
string requestJson =
136+
"{\"VendorNumber\":\""
137+
+ VendorNumber
138+
+ "\",\"VendorPostalCode\":\""
139+
+ VendorPostalCode
140+
+ "\",\"CounselorNumber\":\""
141+
+ CounsellorNumber
142+
+ "\",\"CounselorLastName\":\""
143+
+ CounsellorLastName
144+
+ "\"}";
119145
string endpointUrl = "vsd_CheckVendorStatus";
120146

121147
DynamicsResult result = await _dynamicsResultService.Post(endpointUrl, requestJson);

0 commit comments

Comments
 (0)