Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A2 migrations: Changed method name to confirm to callback expectations #588

Merged
merged 4 commits into from
Dec 19, 2024
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
3 changes: 2 additions & 1 deletion src/Storage/Controllers/ContentOnDemandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@
/// <param name="language">language</param>
/// <returns>The formatted content</returns>
[HttpGet("formdatapdf")]
public async Task<Stream> GetFormdataAsPdf([FromRoute] string org, [FromRoute] string app, [FromRoute] Guid instanceGuid, [FromRoute] Guid dataGuid, [FromRoute] string language)

Check warning on line 127 in src/Storage/Controllers/ContentOnDemandController.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
(Instance instance, _) = await _instanceRepository.GetOne(instanceGuid, true);
DataElement htmlElement = instance.Data.First(d => d.Id == dataGuid.ToString());
string htmlFormId = htmlElement.Metadata.First(m => m.Key == "formid").Value;

Check warning on line 131 in src/Storage/Controllers/ContentOnDemandController.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

Define a constant instead of using this literal 'formid' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
DataElement xmlElement = instance.Data.First(d => d.Metadata.First(m => m.Key == "formid").Value == htmlFormId && d.Id != htmlElement.Id);
string visiblePagesString = xmlElement.Metadata.FirstOrDefault(m => m.Key == "A2VisiblePages")?.Value;
List<int> visiblePages = !string.IsNullOrEmpty(visiblePagesString) ? visiblePagesString.Split(';').Select(int.Parse).ToList() : null;
Expand Down Expand Up @@ -237,7 +237,8 @@

xsls[^1].LastPage = true;

string watermark = ((DateTime)xmlElement.Created).ToString("dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture)
instance.DataValues.TryGetValue("A2ArchRefTs", out string watermark);
watermark = (watermark ?? ((DateTime)instance.Created).ToLocalTime().ToString("dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture))
+ $" AR{instance.DataValues["A2ArchRef"]}";
return _a2OndemandFormattingService.GetFormdataHtml(
xsls,
Expand Down
6 changes: 3 additions & 3 deletions src/Storage/Helpers/A2FormServerXslFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@
/// <returns>
/// Formatted string
/// </returns>
public string FormatString(string str, string type, string format)
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "Must match infopath callback name")]
public string formatString(string str, string type, string format)
{
try
{
Expand Down Expand Up @@ -690,7 +691,7 @@
dateStr = DateTimeFormatInfo.CurrentInfo.MonthNames[date.Month - 1] + " " + date.Year;
break;
case "none":
if (formatParams.ContainsKey("noSeconds") && formatParams["noSeconds"].Equals("1"))

Check warning on line 694 in src/Storage/Helpers/A2FormServerXslFunction.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

Define a constant instead of using this literal 'noSeconds' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
{
timeStr = date.ToShortTimeString();
}
Expand All @@ -701,8 +702,7 @@

break;
default:
int locale = int.Parse(formatParams["locale"].ToString());
dateStr = date.ToString(formatString, new CultureInfo(locale));
dateStr = date.ToString(formatString, CultureInfo.InvariantCulture);
break;
}

Expand Down Expand Up @@ -1089,7 +1089,7 @@
/// FilterMatchType
/// </summary>
[DataContract(Name = "FilterMatchType", Namespace = "http://schemas.altinn.no/serviceengine/formsengine/2009/10")]
public enum FilterMatchType : int

Check warning on line 1092 in src/Storage/Helpers/A2FormServerXslFunction.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

'int' should not be explicitly used as the underlying type. (https://rules.sonarsource.com/csharp/RSPEC-1939)
{
/// <summary>
/// The default with no filter
Expand Down
Loading