/// <summary> /// Get forms metadata from altinn /// </summary> /// <param name="altinnResource">The resource</param> /// <returns>The form resource</returns> public static async Task <FormResource> GetFormsMetadata(AltinnResource altinnResource) { string path = FormTaskUrl(altinnResource); FormResource result = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <FormResource>(content); } return(result); }
private static string XsdUrl(AltinnResource altinnResource, AltinnFormMetaData formMetaData) { return(FormTaskUrl(altinnResource) + "/forms/" + formMetaData.DataFormatID + "/" + formMetaData.DataFormatVersion + "/xsd"); }
private static string FormTaskUrl(AltinnResource altinnResource) { return("https://www.altinn.no/api/metadata/formtask/" + altinnResource.ServiceCode + "/" + altinnResource.ServiceEditionCode); }
private static void RememberHighestServiceEditionCode(Dictionary <string, string> serviceCodeToServiceEditionCodeDictionary, AltinnResource resource) { string serviceCode = resource.ServiceCode; string lastHighestServiceEditionCode = serviceCodeToServiceEditionCodeDictionary.GetValueOrDefault(serviceCode); string currentServiceEditionCode = resource.ServiceEditionCode; if (string.IsNullOrEmpty(lastHighestServiceEditionCode)) { serviceCodeToServiceEditionCodeDictionary.Add(serviceCode, resource.ServiceEditionCode); } else { int lastEditionCode = 0; int currentEditionCode = 0; int.TryParse(lastHighestServiceEditionCode, out lastEditionCode); int.TryParse(currentServiceEditionCode, out currentEditionCode); if (currentEditionCode > lastEditionCode) { serviceCodeToServiceEditionCodeDictionary.Remove(serviceCode); serviceCodeToServiceEditionCodeDictionary.Add(serviceCode, resource.ServiceEditionCode); } } }