public override void Execute() { var layer = AreaLayerImpl.FraAdministrativtOmrådeNinXml(dataFile); int count = SqlServer.BulkStoreAreaLayer(layer); Log.i("DB", $"Imported {count} items from {dataFile}."); }
public void ParseAdminAreaMapTest_ParseOk() { XDocument areaLayerXml = TestXml.ReadXDocument(@"Data\AreaLayer\AdministrativtOmraadeKartTest.xml"); var areaLayer = AreaLayerImpl.FromXml(areaLayerXml); Assert.NotNull(areaLayer); }
private void OmrådekartFraXml(XDocument gridLayerXml) { var mapElements = NinXmlParser.GetChildElements(gridLayerXml.Root, "kartElementer", TillatAntall.EnEllerFlere); foreach (var mapElement in mapElements) { var gridMapElement = NinXmlParser.GetChildElements(mapElement, "OmraadeKartElement", TillatAntall.AkkuratEn); var gridLayerCell = new GridLayerCellCustom(); var gridLayerItemIds = NinXmlParser.GetChildElements(gridMapElement[0], "id", TillatAntall.AkkuratEn); gridLayerCell.CellId = gridLayerItemIds[0].Value; var gridLayerCellGeometries = NinXmlParser.GetChildElements(gridMapElement[0], "geometri", TillatAntall.AkkuratEn); int epsgCode; var geometry = NinXmlParser.ParseGeometry(gridLayerCellGeometries[0], out epsgCode); gridLayerCell.CustomCell = SqlGeometry.STGeomFromText(new SqlChars(geometry), epsgCode); var gridLayerItemValues = NinXmlParser.GetChildElements(gridMapElement[0], "trinnVerdi", TillatAntall.AkkuratEn); gridLayerCell.Value = gridLayerItemValues[0].Value; if (Cells.Count == 0) { MinValue = gridLayerCell.Value; MaxValue = gridLayerCell.Value; } else { string minValue; string maxValue; AreaLayerImpl.GuessMinAndMaxValues(true, gridLayerCell.Value, MinValue, MaxValue, out minValue, out maxValue); MinValue = minValue; MaxValue = maxValue; } Cells.Add(gridLayerCell); } }
private void RutenettkartFraXml(XDocument gridLayerXml) { bool numberCompare = true; Collection <XElement> gridNets = NinXmlParser.GetChildElements(gridLayerXml.Root, "ruteNett", TillatAntall.AkkuratEn); Type = TilGridType(gridNets[0].Value); var mapElements = NinXmlParser.GetChildElements(gridLayerXml.Root, "kartElementer", TillatAntall.EnEllerFlere); foreach (var mapElement in mapElements) { var gridMapElement = NinXmlParser.GetChildElements(mapElement, "RuteNettKartElement", TillatAntall.AkkuratEn); var layer = new GridLayerCell(); var gridLayerCellIds = NinXmlParser.GetChildElements(gridMapElement[0], "id", TillatAntall.AkkuratEn); layer.CellId = gridLayerCellIds[0].Value; var gridLayerCellValues = NinXmlParser.GetChildElements(gridMapElement[0], "trinnVerdi", TillatAntall.AkkuratEn); layer.Value = gridLayerCellValues[0].Value; if (Cells.Count == 0) { MinValue = layer.Value; MaxValue = layer.Value; } else { string minValue; string maxValue; numberCompare = AreaLayerImpl.GuessMinAndMaxValues(numberCompare, layer.Value, MinValue, MaxValue, out minValue, out maxValue); MinValue = minValue; MaxValue = maxValue; } Cells.Add(layer); } }
public async Task <string> UploadGrid() { Authorize("Dataleverandør"); IFormFile grid2 = Request.Form.Files.GetFile("grid"); HttpFormFile grid = new HttpFormFile(grid2); DataFiles files = HttpFormFile.GetFormFiles(Request.Form.Files); var gridXml = grid.ReadXml(); dataleveranseXmlGreier.ValidateGrid(gridXml); try { var gridFileDocId = Guid.NewGuid(); var gridFile = new File { Id = gridFileDocId.ToString(), FileName = grid.Filename, ContentType = grid.ContentType, Content = grid.OpenReadStream() }; await arkiv.LagreFil(gridFile); Collection <Nin.Types.MsSql.Document> documents; if (gridXml.Root.Name.LocalName.Equals("AdministrativtOmraadeKart")) { AreaLayer areaLayer = AreaLayerImpl.FromXml(gridXml); files.CheckDocuments(areaLayer.Documents); areaLayer.DocGuid = gridFileDocId; documents = areaLayer.Documents; SqlServer.BulkStoreAreaLayer(areaLayer); } else { var gridLayer = GridLayerImpl.FromXml(gridXml); files.CheckDocuments(gridLayer.Documents); gridLayer.DocGuid = gridFileDocId; documents = gridLayer.Documents; SqlServer.BulkStoreGridLayer(gridLayer); } foreach (var file in files.Values) { var fileName = file.Filename; var document = FindDocument(documents, fileName); var docFile = new File { Id = document.Guid.ToString(), FileName = fileName, ContentType = file.ContentType, Content = file.OpenReadStream() }; await arkiv.LagreFil(docFile); } } catch { arkiv.DiscardChanges(); throw; } return("OK"); }