Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 private static string XsdUrl(AltinnResource altinnResource, AltinnFormMetaData formMetaData)
 {
     return(FormTaskUrl(altinnResource) + "/forms/" + formMetaData.DataFormatID + "/" + formMetaData.DataFormatVersion + "/xsd");
 }
Exemplo n.º 3
0
 private static string FormTaskUrl(AltinnResource altinnResource)
 {
     return("https://www.altinn.no/api/metadata/formtask/" + altinnResource.ServiceCode + "/" + altinnResource.ServiceEditionCode);
 }
Exemplo n.º 4
0
        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);
                }
            }
        }