示例#1
0
        public override void Execute()
        {
            Types.RavenDb.Dataleveranse dataleveranse;
            using (var streamReader = File.OpenText(dataFile))
            {
                var fileContent = streamReader.ReadToEnd();

                XDocument dataDeliveryXml = XDocument.Parse(fileContent);
                dataleveranse = DataleveranseXmlGreier.ParseDataDelivery(dataDeliveryXml);
            }
            //DataleveranseXmlGreier.ValidateDataDeliveryContent(dataDelivery);

            var dataDeliveryMsSql = new Dataleveranse(dataleveranse);

            MapProjection.ConvertGeometry(dataDeliveryMsSql);
            foreach (var natureArea in dataDeliveryMsSql.Metadata.NatureAreas)
            {
                natureArea.Institution = "Institution";
            }

            dataDeliveryMsSql.Id      = "1";
            dataDeliveryMsSql.Created = DateTime.Now;
            SqlServer.DeleteDataDelivery(dataDeliveryMsSql.Metadata.UniqueId.LocalId);
            SqlServer.LagreDataleveranse(dataDeliveryMsSql);
        }
示例#2
0
        private static void LastOppDataleveranse(string xmlPath)
        {
            var    arkiv = new NinRavenDb();
            string fileContent;

            using (var streamReader = new StreamReader(xmlPath, Encoding.GetEncoding("iso-8859-1")))
                fileContent = streamReader.ReadToEnd();
            XDocument dataDeliveryXml = XDocument.Parse(fileContent);
            var       dataleveranse   = DataleveranseXmlGreier.ParseDataDelivery(dataDeliveryXml);
//            arkiv.LastOppDataleveranse(new DataleveranseXmlGreier(), metadata, files, username);
        }
示例#3
0
        public async Task LastOppDataleveranse(DataleveranseXmlGreier dataDeliveryCore, IDataFile metadata, DataFiles files,
                                               string username)
        {
            if (metadata == null)
            {
                throw new Exception("Kan ikke lagre en tom leveranse.");
            }

            var dataDeliveryXml = metadata.ReadXml();

            dataDeliveryCore.ValidateDataDelivery(dataDeliveryXml);
            var dataleveranse = DataleveranseXmlGreier.ParseDataDelivery(dataDeliveryXml);

            files.CheckDocuments(dataleveranse);
            DataleveranseXmlGreier.ValidateDataDeliveryContent(dataleveranse);

            OvertaForForrigeVersjon(dataleveranse);
            ImporterDataleveranse(dataleveranse, username);

            var metadataFile = new File
            {
                Id          = dataleveranse.Id.Replace("DataDeliveries/", ""),
                FileName    = metadata.Filename,
                ContentType = metadata.ContentType,
                Content     = metadata.OpenReadStream()
            };

            await LagreFil(metadataFile);

            foreach (var file in files.Values)
            {
                var fileName = file.Filename;
                var document = dataleveranse.Metadata.FindDocument(fileName);
                if (document == null)
                {
                    throw new DataDeliveryParseException("Finner ingen referanse i datafilen til vedlegg '" + fileName +
                                                         "'.");
                }

                var docFile = new File
                {
                    Id          = document.Guid.ToString(),
                    FileName    = fileName,
                    ContentType = file.ContentType,
                    Content     = file.OpenReadStream()
                };
                await LagreFil(docFile);
            }

            SaveChanges();
        }