Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,33 @@ trim_trailing_whitespace = true
# Generated code
[*{_AssemblyInfo.cs,.notsupported.cs,AsmOffsets.cs}]
generated_code = true
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_exactly_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_readonly_field = true:suggestion

# JSON files
[*.json]
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

# C# files
[*.cs]
Expand All @@ -31,12 +58,12 @@ csharp_new_line_between_query_expression_clauses = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion

# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:suggestion
Expand All @@ -45,24 +72,24 @@ dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Types: use keywords instead of BCL types, and permit var only when the type is clear
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = false:none
csharp_style_var_elsewhere = false:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
Expand All @@ -72,7 +99,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case
# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
Expand All @@ -88,10 +115,21 @@ csharp_prefer_static_local_function = true:suggestion
csharp_prefer_simple_using_statement = false:none
csharp_style_prefer_switch_expression = true:suggestion
dotnet_style_readonly_field = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_collection_expression = when_types_exactly_match
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class FileShareServiceConfiguration
public string FssDataDirectoryPath { get; set; }
public string FssInfoResponseFileName { get; set; }
public string FssSingleReadMeResponseFileName { get; set; }
public string FssMultipleReadMeResponseFileName { get; set; }
public string FssMultipleReadMeResponseFileName { get; set; }
public int WeeksToIncrement { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace UKHO.FmEssFssMock.API.Services
public class FileShareService
{
private readonly IOptions<FileShareServiceConfiguration> fssConfiguration;
private readonly string aioInfoFilesBatchId = "649C902D-5282-4CCF-924A-2B548EF42179";
private readonly string aioInfoFilesBatchId = "649C902D-5282-4CCF-924A-2B548EF42179";
private readonly Dictionary<string, string> mimeTypes = new()
{
{ ".zip", "application/zip" },
Expand Down Expand Up @@ -62,26 +62,39 @@ public BatchResponse CreateBatch(IEnumerable<KeyValuePair<string, string>> attri
return new BatchResponse() { BatchId = Guid.Parse(batchId) };
}

private (string CurrentWeek, string CurrentYear) GetWeekNumber(bool isAioBatchType)
{
var now = isAioBatchType ? DateTime.UtcNow.AddDays(fssConfiguration.Value.WeeksToIncrement * 7) : DateTime.UtcNow;
var currentWeek = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(now, CalendarWeekRule.FirstFullWeek, DayOfWeek.Thursday);
var currentYear = now.Year;

if (currentWeek > 5 && now.Month < 2)
{
currentYear--;
}

return (currentWeek.ToString("00"), currentYear.ToString("0000"));
}

public BatchDetail GetBatchDetails(string batchId, string homeDirectoryPath)
{
batchId = batchId.ToLower();
CultureInfo cultureInfo = CultureInfo.InvariantCulture;
string currentWeek = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(DateTime.UtcNow, CalendarWeekRule.FirstFullWeek, DayOfWeek.Thursday).ToString().PadLeft(2, '0');
string currentYear = DateTime.UtcNow.Year.ToString();
string path = Path.Combine(homeDirectoryPath, batchId);
string businessUnit = "AVCSData";
List<BatchFile> files = new();

foreach (string? filePath in Directory.GetFiles(path))
var isAioBatchType = aioBatchTypes.Contains(EnumHelper.GetValueFromDescription<Batch>(batchId));
(var currentWeek, var currentYear) = GetWeekNumber(isAioBatchType);
var path = Path.Combine(homeDirectoryPath, batchId);
var businessUnit = "AVCSData";
List<BatchFile> files = [];

foreach (var filePath in Directory.GetFiles(path))
{
FileInfo fileInfo = new(filePath);
var fileInfo = new FileInfo(filePath);

files.Add(new BatchFile()
files.Add(new BatchFile
{
Attributes = new List<Models.Response.Attribute>
{
new Models.Response.Attribute { Key = "Product Type", Value = aioBatchTypes.Contains(EnumHelper.GetValueFromDescription<Batch>(batchId)) ? "AIO" : "AVCS" },
new Models.Response.Attribute { Key = "File Name", Value = fileInfo.Name }
new() { Key = "Product Type", Value = isAioBatchType ? "AIO" : "AVCS" },
new() { Key = "File Name", Value = fileInfo.Name }
},
MimeType = mimeTypes.ContainsKey(fileInfo.Extension.ToLower()) ? mimeTypes[fileInfo.Extension.ToLower()] : DEFAULTMIMETYPE,
FileSize = fileInfo.Length,
Expand Down Expand Up @@ -139,7 +152,7 @@ public BatchDetail GetBatchDetails(string batchId, string homeDirectoryPath)

List<KeyValuePair<string, string>> attributes = new()
{
new("Product Type", aioBatchTypes.Contains(EnumHelper.GetValueFromDescription<Batch>(batchId)) ? "AIO" : "AVCS"),
new("Product Type", isAioBatchType ? "AIO" : "AVCS"),
new("Week Number", currentWeek),
new("Year", currentYear),
new("Year / Week", currentYear + " / " + currentWeek), };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<None Update="Data\10D40DD5-DDFB-497A-BB67-D99FB1658320\distributors.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\15B38135-AA92-4D1A-9B6B-846462A18362\AIO_S63_WK34_22_Only.zip">
<None Update="Data\15B38135-AA92-4D1A-9B6B-846462A18362\AIO_Update_WK34_22_Only.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\27067A02-DF4B-49A1-8699-442B265A75D2\V01X01.zip">
Expand Down Expand Up @@ -156,13 +156,13 @@
<None Update="Data\D2B46C4F-415A-4CA3-B844-6577254F39E5\CommitInProgress.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\EB74B68E-95A7-4D3B-A162-1444EFE43257\AIO_S631-1_CD_WK34_22.iso">
<None Update="Data\EB74B68E-95A7-4D3B-A162-1444EFE43257\AIO_CD_WK34_22.iso">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\EB74B68E-95A7-4D3B-A162-1444EFE43257\AIO_S631-1_CD_WK34_22.iso.sha1">
<None Update="Data\EB74B68E-95A7-4D3B-A162-1444EFE43257\AIO_CD_WK34_22.iso.sha1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\EB74B68E-95A7-4D3B-A162-1444EFE43257\AIO_S631-1_CD_WK34_22.zip">
<None Update="Data\EB74B68E-95A7-4D3B-A162-1444EFE43257\AIO_CD_WK34_22.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\F8FD2FB4-3DD6-425D-B34F-3059E262FEED\V01X01.zip">
Expand Down
73 changes: 37 additions & 36 deletions UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"FleetManagerB2BApiConfiguration": {
"UserName": "",
"Password": "",
"SubscriptionKey": "",
"GetCatalogueResponseFilePath": "FM\\avcs_catalogue_ft.xml"
},
"ExchangeSetServiceConfiguration": {
"EssDataDirectoryPath": "Data\\ESS\\",
"PostProductIdentifiersResponseFileName": "ESSResponse.json"
},
"FileShareServiceConfiguration": {
"FssDataDirectoryPath": "Data\\FSS\\",
"FssInfoResponseFileName": "FssInfoResponse.json",
"FssSingleReadMeResponseFileName": "FssSingleReadMeResponse.json",
"FssMultipleReadMeResponseFileName": "FssMultipleFilesReadMeResponse.json"
},
"IsFTRunning": true,
"POSFolderName": "POS",
"BessStorageConfiguration": {
"ConnectionString": "",
"ContainerName": "bess-configs-ft"
},
"SharedKeyConfiguration": {
"Key": ""
},
"SalesCatalogue": {
"FileDirectoryPath": "Data\\SalesCatalogueService\\",
"ScsResponseFile": "SCSResponse.json",
"ScsCatalogueResponseFile": "SCSCatalogueResponse.json"
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"FleetManagerB2BApiConfiguration": {
"UserName": "",
"Password": "",
"SubscriptionKey": "",
"GetCatalogueResponseFilePath": "FM\\avcs_catalogue_ft.xml"
},
"ExchangeSetServiceConfiguration": {
"EssDataDirectoryPath": "Data\\ESS\\",
"PostProductIdentifiersResponseFileName": "ESSResponse.json"
},
"FileShareServiceConfiguration": {
"FssDataDirectoryPath": "Data\\FSS\\",
"FssInfoResponseFileName": "FssInfoResponse.json",
"FssSingleReadMeResponseFileName": "FssSingleReadMeResponse.json",
"FssMultipleReadMeResponseFileName": "FssMultipleFilesReadMeResponse.json",
"WeeksToIncrement": 1
},
"IsFTRunning": true,
"POSFolderName": "POS",
"BessStorageConfiguration": {
"ConnectionString": "",
"ContainerName": "bess-configs-ft"
},
"SharedKeyConfiguration": {
"Key": ""
},
"SalesCatalogue": {
"FileDirectoryPath": "Data\\SalesCatalogueService\\",
"ScsResponseFile": "SCSResponse.json",
"ScsCatalogueResponseFile": "SCSCatalogueResponse.json"
}
}
Loading