added life cycle

This commit is contained in:
FH 2022-04-01 12:13:56 +02:00
parent 881d8d03ed
commit 9e11d5b33a
18 changed files with 106 additions and 224 deletions

View file

@ -26,45 +26,15 @@
namespace FCS.Lib.Virk.CvrModels namespace FCS.Lib.Virk.CvrModels
{ {
/// <summary>
/// Class CvrCompany.
/// </summary>
public class CvrInfo public class CvrInfo
{ {
/// <summary>
/// Gets or sets the vat number.
/// </summary>
/// <value>The vat number.</value>
public string VatNumber { get; set; } = ""; public string VatNumber { get; set; } = "";
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; } = ""; public string Name { get; set; } = "";
/// <summary>
/// Gets or sets the name of the co.
/// </summary>
/// <value>The name of the co.</value>
public string CoName { get; set; } = ""; public string CoName { get; set; } = "";
/// <summary>
/// Gets or sets the address.
/// </summary>
/// <value>The address.</value>
public string Address { get; set; } = ""; public string Address { get; set; } = "";
/// <summary>
/// Gets or sets the city.
/// </summary>
/// <value>The city.</value>
public string City { get; set; } = ""; public string City { get; set; } = "";
/// <summary>
/// Gets or sets the zip code.
/// </summary>
/// <value>The zip code.</value>
public string ZipCode { get; set; } = ""; public string ZipCode { get; set; } = "";
/// <summary>
/// Gets or sets the status.
/// </summary>
/// <value>The status.</value>
public List<CvrState> States { get; set; } = new(); public List<CvrState> States { get; set; } = new();
public List<LifeCycle> LifeCycles { get; set; } = new();
} }
} }

View file

@ -25,25 +25,10 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk.CvrModels namespace FCS.Lib.Virk.CvrModels
{ {
/// <summary>
/// Class CvrStatus.
/// </summary>
public class CvrState public class CvrState
{ {
/// <summary>
/// Gets or sets the last update.
/// </summary>
/// <value>The last update.</value>
public string LastUpdate { get; set; } = ""; public string LastUpdate { get; set; } = "";
/// <summary> public string State { get; set; } = "";
/// Gets or sets the status.
/// </summary>
/// <value>The status.</value>
public string State { get; set; } = "INAKTIV";
/// <summary>
/// Gets or sets the period.
/// </summary>
/// <value>The period.</value>
public TimeFrame TimeFrame { get; set; } = new(); public TimeFrame TimeFrame { get; set; } = new();
} }
} }

34
CvrModels/LifeCycle.cs Normal file
View file

@ -0,0 +1,34 @@
// ***********************************************************************
// Assembly : FCS.Lib.Virk
// Author : FH
// Created : 03-31-2022
//
// Last Modified By : FH
// Last Modified On : 03-31-2022
// ***********************************************************************
// <copyright file="LifeCycle.cs" company="FCS.Lib.Virk">
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Virk.CvrModels
{
public class LifeCycle
{
public string LastUpdate { get; set; } = "";
public TimeFrame TimeFrame { get; set; } = new ();
}
}

View file

@ -25,20 +25,9 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk.CvrModels namespace FCS.Lib.Virk.CvrModels
{ {
/// <summary>
/// Class CvrPeriod.
/// </summary>
public class TimeFrame public class TimeFrame
{ {
/// <summary>
/// Gets or sets the start date.
/// </summary>
/// <value>The start date.</value>
public string StartDate { get; set; } = ""; public string StartDate { get; set; } = "";
/// <summary>
/// Gets or sets the end date.
/// </summary>
/// <value>The end date.</value>
public string EndDate { get; set; } = ""; public string EndDate { get; set; } = "";
} }
} }

View file

@ -29,16 +29,8 @@ using FCS.Lib.Virk.VrModels;
namespace FCS.Lib.Virk namespace FCS.Lib.Virk
{ {
/// <summary>
/// Class VrCvrMapper.
/// </summary>
public class VrCvrMapper public class VrCvrMapper
{ {
/// <summary>
/// Maps the vr to CVR.
/// </summary>
/// <param name="vrVirk">The vr virk.</param>
/// <returns>CvrInfo.</returns>
public CvrInfo MapVrToCvr(VrVirksomhed vrVirk) public CvrInfo MapVrToCvr(VrVirksomhed vrVirk)
{ {
var c = new CvrInfo var c = new CvrInfo
@ -61,7 +53,7 @@ namespace FCS.Lib.Virk
TimeFrame = new TimeFrame TimeFrame = new TimeFrame
{ {
StartDate = vrStatus.Periode.GyldigFra, StartDate = vrStatus.Periode.GyldigFra,
EndDate = vrStatus.Periode.GyldigTil EndDate = !string.IsNullOrWhiteSpace(vrStatus.Periode.GyldigTil) ? vrStatus.Periode.GyldigTil : ""
} }
})) }))
{ {
@ -73,6 +65,37 @@ namespace FCS.Lib.Virk
c.States.Add(new CvrState()); c.States.Add(new CvrState());
} }
if (vrVirk.Livsforloeb.Any())
{
foreach (var lc in vrVirk.Livsforloeb.Select(
vrCourse => new LifeCycle
{
LastUpdate = vrCourse.SidstOpdateret,
TimeFrame = new TimeFrame
{
StartDate = vrCourse.Periode.GyldigFra,
EndDate = !string.IsNullOrWhiteSpace(vrCourse.Periode.GyldigTil) ? vrCourse.Periode.GyldigTil : ""
}
}
))
{
c.LifeCycles.Add(lc);
}
}
else
{
c.LifeCycles.Add(new LifeCycle());
}
if (!string.IsNullOrWhiteSpace(c.States[c.States.Count - 1].State)) return c;
var sc = c.States.Count - 1;
var lcc = c.LifeCycles.Count - 1;
c.States[sc].LastUpdate = c.LifeCycles[lcc].LastUpdate;
c.States[sc].TimeFrame.StartDate = c.LifeCycles[lcc].TimeFrame.StartDate;
c.States[sc].TimeFrame.EndDate = c.LifeCycles[lcc].TimeFrame.EndDate;
c.States[sc].State = string.IsNullOrWhiteSpace(c.LifeCycles[c.LifeCycles.Count - 1].TimeFrame.EndDate) ? "NORMAL" : "LUKKET";
return c; return c;
} }
} }

View file

@ -29,18 +29,8 @@ using System.Text;
namespace FCS.Lib.Virk namespace FCS.Lib.Virk
{ {
/// <summary>
/// Class VrHttpRequest.
/// </summary>
public class VrHttpRequest public class VrHttpRequest
{ {
/// <summary>
/// Get response as an asynchronous operation.
/// </summary>
/// <param name="endpoint">The endpoint.</param>
/// <param name="jsonData">The json data.</param>
/// <param name="auth">The authentication.</param>
/// <returns>A Task&lt;VrResponseView&gt; representing the asynchronous operation.</returns>
public async Task<VrResponseView> GetResponseAsync(string endpoint, string jsonData, string auth) public async Task<VrResponseView> GetResponseAsync(string endpoint, string jsonData, string auth)
{ {
using var content = new StringContent(jsonData, Encoding.UTF8, "application/json"); using var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

View file

@ -0,0 +1,33 @@
// ***********************************************************************
// Assembly : FCS.Lib.Virk
// Author : FH
// Created : 03-31-2022
//
// Last Modified By : FH
// Last Modified On : 03-31-2022
// ***********************************************************************
// <copyright file="LivsforloebModel.cs" company="FCS.Lib.Virk">
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Virk.VrModels
{
public class LivsforloebModel
{
public string SidstOpdateret { get; set; } = "";
public Periode Periode { get; set; } = new ();
}
}

View file

@ -25,40 +25,13 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk.VrModels namespace FCS.Lib.Virk.VrModels
{ {
/// <summary>
/// Class NyesteBeliggenhedsadresse.
/// </summary>
public class NyesteBeliggenhedsadresse public class NyesteBeliggenhedsadresse
{ {
/// <summary>
/// Gets or sets the husnummer fra.
/// </summary>
/// <value>The husnummer fra.</value>
public int? HusnummerFra { get; set; } public int? HusnummerFra { get; set; }
/// <summary>
/// Gets or sets the husnummer til.
/// </summary>
/// <value>The husnummer til.</value>
public int? HusnummerTil { get; set; } public int? HusnummerTil { get; set; }
/// <summary>
/// Gets or sets the postnummer.
/// </summary>
/// <value>The postnummer.</value>
public int? Postnummer { get; set; } public int? Postnummer { get; set; }
/// <summary>
/// Gets or sets the vejnavn.
/// </summary>
/// <value>The vejnavn.</value>
public string Vejnavn { get; set; } = ""; public string Vejnavn { get; set; } = "";
/// <summary>
/// Gets or sets the co navn.
/// </summary>
/// <value>The co navn.</value>
public string CoNavn { get; set; } = ""; public string CoNavn { get; set; } = "";
/// <summary>
/// Gets or sets the post distrikt.
/// </summary>
/// <value>The post distrikt.</value>
public string PostDistrikt { get; set; } = ""; public string PostDistrikt { get; set; } = "";
} }
} }

View file

@ -26,15 +26,8 @@
namespace FCS.Lib.Virk.VrModels namespace FCS.Lib.Virk.VrModels
{ {
/// <summary>
/// Class NyesteNavn.
/// </summary>
public class NyesteNavn public class NyesteNavn
{ {
/// <summary>
/// Gets or sets the navn.
/// </summary>
/// <value>The navn.</value>
public string Navn { get; set; } = ""; public string Navn { get; set; } = "";
} }
} }

View file

@ -25,20 +25,9 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk.VrModels namespace FCS.Lib.Virk.VrModels
{ {
/// <summary>
/// Class Periode.
/// </summary>
public class Periode public class Periode
{ {
/// <summary>
/// Gets or sets the gyldig fra.
/// </summary>
/// <value>The gyldig fra.</value>
public string GyldigFra { get; set; } = ""; public string GyldigFra { get; set; } = "";
/// <summary>
/// Gets or sets the gyldig til.
/// </summary>
/// <value>The gyldig til.</value>
public string GyldigTil { get; set; } = ""; public string GyldigTil { get; set; } = "";
} }
} }

View file

@ -25,20 +25,9 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk.VrModels namespace FCS.Lib.Virk.VrModels
{ {
/// <summary>
/// Class VirksomhedMetadata.
/// </summary>
public class VirksomhedMetadata public class VirksomhedMetadata
{ {
/// <summary>
/// Gets or sets the nyeste navn.
/// </summary>
/// <value>The nyeste navn.</value>
public NyesteNavn NyesteNavn { get; set; } = new(); public NyesteNavn NyesteNavn { get; set; } = new();
/// <summary>
/// Gets or sets the nyeste beliggenhedsadresse.
/// </summary>
/// <value>The nyeste beliggenhedsadresse.</value>
public NyesteBeliggenhedsadresse NyesteBeliggenhedsadresse { get; set; } = new(); public NyesteBeliggenhedsadresse NyesteBeliggenhedsadresse { get; set; } = new();
} }
} }

View file

@ -25,25 +25,10 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk.VrModels namespace FCS.Lib.Virk.VrModels
{ {
/// <summary>
/// Class VirksomhedsStatus.
/// </summary>
public class VirksomhedsStatus public class VirksomhedsStatus
{ {
/// <summary>
/// Gets or sets the sidst opdateret.
/// </summary>
/// <value>The sidst opdateret.</value>
public string SidstOpdateret { get; set; } = ""; public string SidstOpdateret { get; set; } = "";
/// <summary>
/// Gets or sets the status.
/// </summary>
/// <value>The status.</value>
public string Status { get; set; } = ""; public string Status { get; set; } = "";
/// <summary>
/// Gets or sets the periode.
/// </summary>
/// <value>The periode.</value>
public Periode Periode { get; set; } = new(); public Periode Periode { get; set; } = new();
} }
} }

View file

@ -25,26 +25,11 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk.VrModels namespace FCS.Lib.Virk.VrModels
{ {
/// <summary>
/// Class VrVirksomhed.
/// </summary>
public class VrVirksomhed public class VrVirksomhed
{ {
/// <summary>
/// Gets or sets the CVR nummer.
/// </summary>
/// <value>The CVR nummer.</value>
public string CvrNummer { get; set; } = ""; public string CvrNummer { get; set; } = "";
/// <summary>
/// Gets or sets the virksomheds status.
/// </summary>
/// <value>The virksomheds status.</value>
public List<VirksomhedsStatus> VirksomhedsStatus { get; set; } = new (); public List<VirksomhedsStatus> VirksomhedsStatus { get; set; } = new ();
/// <summary>
/// Gets or sets the virksomhed metadata.
/// </summary>
/// <value>The virksomhed metadata.</value>
public VirksomhedMetadata VirksomhedMetadata { get; set; } = new(); public VirksomhedMetadata VirksomhedMetadata { get; set; } = new();
public List<LivsforloebModel> Livsforloeb { get; set; } = new();
} }
} }

View file

@ -25,30 +25,11 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk namespace FCS.Lib.Virk
{ {
/// <summary>
/// Class VrQuery.
/// </summary>
public class VrQuery public class VrQuery
{ {
/// <summary>
/// Gets or sets the vat number.
/// </summary>
/// <value>The vat number.</value>
public string VatNumber { get; set; } = ""; public string VatNumber { get; set; } = "";
/// <summary>
/// Gets or sets the name of the street.
/// </summary>
/// <value>The name of the street.</value>
public string StreetName { get; set; } = ""; public string StreetName { get; set; } = "";
/// <summary>
/// Gets or sets the house number.
/// </summary>
/// <value>The house number.</value>
public string HouseNumber { get; set; } = ""; public string HouseNumber { get; set; } = "";
/// <summary>
/// Gets or sets the zip code.
/// </summary>
/// <value>The zip code.</value>
public string ZipCode { get; set; } = ""; public string ZipCode { get; set; } = "";
} }
} }

View file

@ -28,16 +28,8 @@ using Newtonsoft.Json.Linq;
namespace FCS.Lib.Virk namespace FCS.Lib.Virk
{ {
/// <summary>
/// Class VrQueryMapper.
/// </summary>
public class VrQueryMapper public class VrQueryMapper
{ {
/// <summary>
/// Vrs the map query.
/// </summary>
/// <param name="query">The query.</param>
/// <returns>JObject.</returns>
public JObject VrMapQuery(VrQuery query) public JObject VrMapQuery(VrQuery query)
{ {
if (string.IsNullOrWhiteSpace(query.VatNumber)) if (string.IsNullOrWhiteSpace(query.VatNumber))
@ -53,7 +45,8 @@ namespace FCS.Lib.Virk
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.husnummerTil", "Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.husnummerTil",
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postnummer", "Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postnummer",
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postdistrikt", "Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postdistrikt",
"Vrvirksomhed.virksomhedsstatus") "Vrvirksomhed.virksomhedsstatus",
"Vrvirksomhed.livsforloeb")
), ),
new JProperty("query", new JProperty("query",
new JObject(new JProperty("bool", new JObject(new JProperty("bool",
@ -89,7 +82,8 @@ namespace FCS.Lib.Virk
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.husnummerTil", "Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.husnummerTil",
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postnummer", "Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postnummer",
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postdistrikt", "Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postdistrikt",
"Vrvirksomhed.virksomhedsstatus") "Vrvirksomhed.virksomhedsstatus",
"Vrvirksomhed.livsforloeb")
), ),
new JProperty("query", new JProperty("query",
new JObject(new JProperty("term", new JObject(new JProperty("term",

View file

@ -25,16 +25,8 @@
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib.Virk namespace FCS.Lib.Virk
{ {
/// <summary>
/// Class VrQueryValidator.
/// </summary>
public static class VrQueryValidator public static class VrQueryValidator
{ {
/// <summary>
/// Validates the vr query.
/// </summary>
/// <param name="query">The query.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public static bool ValidateVrQuery(VrQuery query) public static bool ValidateVrQuery(VrQuery query)
{ {
try try

View file

@ -30,16 +30,8 @@ using Newtonsoft.Json.Linq;
namespace FCS.Lib.Virk namespace FCS.Lib.Virk
{ {
/// <summary>
/// Class VrResponseParser.
/// </summary>
public class VrResponseParser public class VrResponseParser
{ {
/// <summary>
/// Parses the vr response.
/// </summary>
/// <param name="jsonData">The json data.</param>
/// <returns>List&lt;System.Nullable&lt;VrVirksomhed&gt;&gt;.</returns>
public List<VrVirksomhed?> ParseVrResponse(string jsonData) public List<VrVirksomhed?> ParseVrResponse(string jsonData)
{ {
var result = new List<VrVirksomhed?>(); var result = new List<VrVirksomhed?>();

View file

@ -28,25 +28,10 @@ using System.Net;
namespace FCS.Lib.Virk namespace FCS.Lib.Virk
{ {
/// <summary>
/// Class VrResponseView.
/// </summary>
public class VrResponseView public class VrResponseView
{ {
/// <summary>
/// Gets or sets the code.
/// </summary>
/// <value>The code.</value>
public HttpStatusCode Code { get; set; } public HttpStatusCode Code { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is success status code.
/// </summary>
/// <value><c>true</c> if this instance is success status code; otherwise, <c>false</c>.</value>
public bool IsSuccessStatusCode { get; set; } public bool IsSuccessStatusCode { get; set; }
/// <summary>
/// Gets or sets the message.
/// </summary>
/// <value>The message.</value>
public string Message { get; set; } = ""; public string Message { get; set; } = "";
} }
} }