diff --git a/.gitignore b/.gitignore index bc5d5ba..44e4e57 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ # Azure Functions localsettings file local.settings.json +/.idea + # User-specific files *.rsuser *.suo diff --git a/src/Dan.Plugin.Tilda/Utils/Helpers.cs b/src/Dan.Plugin.Tilda/Utils/Helpers.cs index 2c7700c..80da1ec 100644 --- a/src/Dan.Plugin.Tilda/Utils/Helpers.cs +++ b/src/Dan.Plugin.Tilda/Utils/Helpers.cs @@ -250,9 +250,14 @@ public static async Task GetAnnualTurnoverFromBR(string org new Context(cacheKey)); dynamic tmp = JsonConvert.DeserializeObject(rawResult); + if (tmp is null) + { + return result; + } + result.ToDate = tmp[0]["regnskapsperiode"]["tilDato"]; - result.FromDate = tmp[0]["regnskapsperiode"]["fraDato"]; - result.AnnualTurnover = tmp[0]["resultatregnskapResultat"]["driftsresultat"]["driftsinntekter"]["sumDriftsinntekter"]; + result.FromDate = tmp[0]["regnskapsperiode"]["fraDato"]; + result.AnnualTurnover = tmp[0]["resultatregnskapResultat"]["driftsresultat"]["driftsinntekter"]["sumDriftsinntekter"]; } catch { @@ -378,7 +383,7 @@ public static IAuditList Filter(IAuditList resultList, List // *** TEMPORARY TILDA FILTERING *** // We need to temporarily remove _all_ data from the result list if orgForm is ENK // For all other orgforms - // - remove meldingTilAnnenMyndighet + // - remove meldingTilAnnenMyndighet // - remove tilsynsnotater // - remove kontaktperson name if (orgs == null || orgs.Count == 0) @@ -388,7 +393,7 @@ public static IAuditList Filter(IAuditList resultList, List var firstOrg = orgs.First(); // If first organization is a specific test organization, disable filtering - if (firstOrg.OrganizationNumber == "111111111") + if (firstOrg.OrganizationNumber == "111111111") { return resultList; } @@ -398,16 +403,21 @@ bool IsEnk(string orgNo) return orgs.Any(x => x.OrganizationNumber == orgNo && x.OrganisationForm == "ENK"); } - switch (resultList) + switch (resultList) { case AuditReportList filteredResultList: filteredResultList.AuditReports?.ForEach(x => { + if (x is null) + { + return; + } + x.AuditNotes = null; if (IsEnk(x.ControlObject)) { - x.NotesAndRemarks.Clear(); + x.NotesAndRemarks?.Clear(); x.ControlAttributes = null; } }); @@ -416,6 +426,11 @@ bool IsEnk(string orgNo) case AuditCoordinationList filteredResultList: filteredResultList.AuditCoordinations?.ForEach(x => { + if (x is null) + { + return; + } + if (IsEnk(x.ControlObject)) { x.Alerts?.Clear(); @@ -426,11 +441,16 @@ bool IsEnk(string orgNo) case NPDIDAuditReportList filteredResultList: filteredResultList.AuditReports?.ForEach(x => { + if (x is null) + { + return; + } + x.AuditNotes = null; if (IsEnk(x.ControlObject)) { - x.NotesAndRemarks.Clear(); + x.NotesAndRemarks?.Clear(); x.ControlAttributes = null; } }); @@ -460,7 +480,7 @@ public static async Task GetFileContents(string folder, string fileNam { var binDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var rootDirectory = Path.GetFullPath(Path.Combine(binDirectory, "..")); - return await File.ReadAllLinesAsync(rootDirectory + $@"\{folder}\{fileName}"); + return await File.ReadAllLinesAsync(rootDirectory + $@"\{folder}\{fileName}"); } public static async Task> GetParagraph(string paragraph)