added life cycle
This commit is contained in:
parent
881d8d03ed
commit
9e11d5b33a
18 changed files with 106 additions and 224 deletions
|
@ -26,45 +26,15 @@
|
|||
|
||||
namespace FCS.Lib.Virk.CvrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class CvrCompany.
|
||||
/// </summary>
|
||||
public class CvrInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the vat number.
|
||||
/// </summary>
|
||||
/// <value>The vat number.</value>
|
||||
public string VatNumber { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
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; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the address.
|
||||
/// </summary>
|
||||
/// <value>The address.</value>
|
||||
public string Address { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the city.
|
||||
/// </summary>
|
||||
/// <value>The city.</value>
|
||||
public string City { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the zip code.
|
||||
/// </summary>
|
||||
/// <value>The zip code.</value>
|
||||
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<LifeCycle> LifeCycles { get; set; } = new();
|
||||
}
|
||||
}
|
|
@ -25,25 +25,10 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk.CvrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class CvrStatus.
|
||||
/// </summary>
|
||||
public class CvrState
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the last update.
|
||||
/// </summary>
|
||||
/// <value>The last update.</value>
|
||||
public string LastUpdate { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 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 string State { get; set; } = "";
|
||||
public TimeFrame TimeFrame { get; set; } = new();
|
||||
}
|
||||
}
|
34
CvrModels/LifeCycle.cs
Normal file
34
CvrModels/LifeCycle.cs
Normal 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 ();
|
||||
|
||||
}
|
||||
}
|
|
@ -25,20 +25,9 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk.CvrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class CvrPeriod.
|
||||
/// </summary>
|
||||
public class TimeFrame
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the start date.
|
||||
/// </summary>
|
||||
/// <value>The start date.</value>
|
||||
public string StartDate { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the end date.
|
||||
/// </summary>
|
||||
/// <value>The end date.</value>
|
||||
public string EndDate { get; set; } = "";
|
||||
}
|
||||
}
|
|
@ -29,16 +29,8 @@ using FCS.Lib.Virk.VrModels;
|
|||
|
||||
namespace FCS.Lib.Virk
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrCvrMapper.
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
var c = new CvrInfo
|
||||
|
@ -61,7 +53,7 @@ namespace FCS.Lib.Virk
|
|||
TimeFrame = new TimeFrame
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,8 @@ using System.Text;
|
|||
|
||||
namespace FCS.Lib.Virk
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrHttpRequest.
|
||||
/// </summary>
|
||||
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<VrResponseView> representing the asynchronous operation.</returns>
|
||||
public async Task<VrResponseView> GetResponseAsync(string endpoint, string jsonData, string auth)
|
||||
{
|
||||
using var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
|
||||
|
|
33
VrModels/LivsforloebModel.cs
Normal file
33
VrModels/LivsforloebModel.cs
Normal 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 ();
|
||||
}
|
||||
}
|
|
@ -25,40 +25,13 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk.VrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class NyesteBeliggenhedsadresse.
|
||||
/// </summary>
|
||||
public class NyesteBeliggenhedsadresse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the husnummer fra.
|
||||
/// </summary>
|
||||
/// <value>The husnummer fra.</value>
|
||||
public int? HusnummerFra { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the husnummer til.
|
||||
/// </summary>
|
||||
/// <value>The husnummer til.</value>
|
||||
public int? HusnummerTil { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the postnummer.
|
||||
/// </summary>
|
||||
/// <value>The postnummer.</value>
|
||||
public int? Postnummer { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the vejnavn.
|
||||
/// </summary>
|
||||
/// <value>The vejnavn.</value>
|
||||
public string Vejnavn { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the co navn.
|
||||
/// </summary>
|
||||
/// <value>The co navn.</value>
|
||||
public string CoNavn { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the post distrikt.
|
||||
/// </summary>
|
||||
/// <value>The post distrikt.</value>
|
||||
public string PostDistrikt { get; set; } = "";
|
||||
}
|
||||
}
|
|
@ -26,15 +26,8 @@
|
|||
|
||||
namespace FCS.Lib.Virk.VrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class NyesteNavn.
|
||||
/// </summary>
|
||||
public class NyesteNavn
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the navn.
|
||||
/// </summary>
|
||||
/// <value>The navn.</value>
|
||||
public string Navn { get; set; } = "";
|
||||
}
|
||||
}
|
|
@ -25,20 +25,9 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk.VrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class Periode.
|
||||
/// </summary>
|
||||
public class Periode
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the gyldig fra.
|
||||
/// </summary>
|
||||
/// <value>The gyldig fra.</value>
|
||||
public string GyldigFra { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the gyldig til.
|
||||
/// </summary>
|
||||
/// <value>The gyldig til.</value>
|
||||
public string GyldigTil { get; set; } = "";
|
||||
}
|
||||
}
|
|
@ -25,20 +25,9 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk.VrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VirksomhedMetadata.
|
||||
/// </summary>
|
||||
public class VirksomhedMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the nyeste navn.
|
||||
/// </summary>
|
||||
/// <value>The nyeste navn.</value>
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -25,25 +25,10 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk.VrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VirksomhedsStatus.
|
||||
/// </summary>
|
||||
public class VirksomhedsStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the sidst opdateret.
|
||||
/// </summary>
|
||||
/// <value>The sidst opdateret.</value>
|
||||
public string SidstOpdateret { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the status.
|
||||
/// </summary>
|
||||
/// <value>The status.</value>
|
||||
public string Status { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the periode.
|
||||
/// </summary>
|
||||
/// <value>The periode.</value>
|
||||
public Periode Periode { get; set; } = new();
|
||||
}
|
||||
}
|
|
@ -25,26 +25,11 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk.VrModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrVirksomhed.
|
||||
/// </summary>
|
||||
public class VrVirksomhed
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the CVR nummer.
|
||||
/// </summary>
|
||||
/// <value>The CVR nummer.</value>
|
||||
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 ();
|
||||
/// <summary>
|
||||
/// Gets or sets the virksomhed metadata.
|
||||
/// </summary>
|
||||
/// <value>The virksomhed metadata.</value>
|
||||
public VirksomhedMetadata VirksomhedMetadata { get; set; } = new();
|
||||
|
||||
public List<LivsforloebModel> Livsforloeb { get; set; } = new();
|
||||
}
|
||||
}
|
19
VrQuery.cs
19
VrQuery.cs
|
@ -25,30 +25,11 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrQuery.
|
||||
/// </summary>
|
||||
public class VrQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the vat number.
|
||||
/// </summary>
|
||||
/// <value>The vat number.</value>
|
||||
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; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the house number.
|
||||
/// </summary>
|
||||
/// <value>The house number.</value>
|
||||
public string HouseNumber { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the zip code.
|
||||
/// </summary>
|
||||
/// <value>The zip code.</value>
|
||||
public string ZipCode { get; set; } = "";
|
||||
}
|
||||
}
|
|
@ -28,16 +28,8 @@ using Newtonsoft.Json.Linq;
|
|||
|
||||
namespace FCS.Lib.Virk
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrQueryMapper.
|
||||
/// </summary>
|
||||
public class VrQueryMapper
|
||||
{
|
||||
/// <summary>
|
||||
/// Vrs the map query.
|
||||
/// </summary>
|
||||
/// <param name="query">The query.</param>
|
||||
/// <returns>JObject.</returns>
|
||||
public JObject VrMapQuery(VrQuery query)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(query.VatNumber))
|
||||
|
@ -53,7 +45,8 @@ namespace FCS.Lib.Virk
|
|||
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.husnummerTil",
|
||||
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postnummer",
|
||||
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postdistrikt",
|
||||
"Vrvirksomhed.virksomhedsstatus")
|
||||
"Vrvirksomhed.virksomhedsstatus",
|
||||
"Vrvirksomhed.livsforloeb")
|
||||
),
|
||||
new JProperty("query",
|
||||
new JObject(new JProperty("bool",
|
||||
|
@ -89,7 +82,8 @@ namespace FCS.Lib.Virk
|
|||
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.husnummerTil",
|
||||
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postnummer",
|
||||
"Vrvirksomhed.virksomhedMetadata.nyesteBeliggenhedsadresse.postdistrikt",
|
||||
"Vrvirksomhed.virksomhedsstatus")
|
||||
"Vrvirksomhed.virksomhedsstatus",
|
||||
"Vrvirksomhed.livsforloeb")
|
||||
),
|
||||
new JProperty("query",
|
||||
new JObject(new JProperty("term",
|
||||
|
|
|
@ -25,16 +25,8 @@
|
|||
// ***********************************************************************
|
||||
namespace FCS.Lib.Virk
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrQueryValidator.
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -30,16 +30,8 @@ using Newtonsoft.Json.Linq;
|
|||
|
||||
namespace FCS.Lib.Virk
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrResponseParser.
|
||||
/// </summary>
|
||||
public class VrResponseParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Parses the vr response.
|
||||
/// </summary>
|
||||
/// <param name="jsonData">The json data.</param>
|
||||
/// <returns>List<System.Nullable<VrVirksomhed>>.</returns>
|
||||
public List<VrVirksomhed?> ParseVrResponse(string jsonData)
|
||||
{
|
||||
var result = new List<VrVirksomhed?>();
|
||||
|
|
|
@ -28,25 +28,10 @@ using System.Net;
|
|||
|
||||
namespace FCS.Lib.Virk
|
||||
{
|
||||
/// <summary>
|
||||
/// Class VrResponseView.
|
||||
/// </summary>
|
||||
public class VrResponseView
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the code.
|
||||
/// </summary>
|
||||
/// <value>The code.</value>
|
||||
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; }
|
||||
/// <summary>
|
||||
/// Gets or sets the message.
|
||||
/// </summary>
|
||||
/// <value>The message.</value>
|
||||
public string Message { get; set; } = "";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue