Ejemplo n.º 1
0
        private async Task <(DataFrame?, Graphic[]?)> loadDataAsync()
        {
            DataFrame?data = await QueryDbAsync(OilGasQueries.WellsData);

            Graphic[]? dataJson = null;

            if (data != null)
            {
                List <Graphic> rows = new List <Graphic>((int)data.Rows.Count);

                AttributeProperties attributeProperties;

                for (int i = 0; i < data.Rows.Count; ++i)
                {
                    attributeProperties = new AttributeProperties();
                    attributeProperties.AddProperty("ObjectId", i + 1);
                    attributeProperties.AddProperty("Api", data.Rows[i][0].StringValue());
                    attributeProperties.AddProperty("ReservoirName", data.Rows[i][1].StringValue());
                    attributeProperties.AddProperty("ReservoirDepth", data.Rows[i][2].DoubleValue() ?? 0.0);
                    attributeProperties.AddProperty("GasSpecificGravity", data.Rows[i][3].DoubleValue() ?? 0.0);
                    attributeProperties.AddProperty("OilApiGravity", data.Rows[i][4].DoubleValue() ?? 0.0);
                    attributeProperties.AddProperty("SurfaceEasting", data.Rows[i][5].DoubleValue() ?? 0.0);
                    attributeProperties.AddProperty("SurfaceNorthing", data.Rows[i][6].DoubleValue() ?? 0.0);
                    attributeProperties.AddProperty("BottomEasting", data.Rows[i][7].DoubleValue() ?? 0.0);
                    attributeProperties.AddProperty("BottomNorthing", data.Rows[i][8].DoubleValue() ?? 0.0);

                    rows.Add(new Graphic
                    {
                        Geometry = new Geometry
                        {
                            Type = "point",
                            X    = data.Rows[i][5].DoubleValue() ?? 0.0,
                            Y    = data.Rows[i][6].DoubleValue() ?? 0.0
                        },
                        Attributes = attributeProperties
                    });
                }

                dataJson = rows.ToArray();

                //locationsJson = "[" + string.Join(", ", rows) + "]";

                //ArcGisService.StoreDataAsync("WellLocations", source);
            }

            //Sequence.LinearSpacing

            //DataFrame? data = await ArcGisService.QueryDbAsync(locationQuery);

            //if (locationsJson != null)
            //{
            //    jsInteropService.StoreSessionDataAsync("WellLocations", locationsJson).GetAwaiter().GetResult();

            //    Action? addFeaturesFromStorage = jsInteropService.BuildJsAction("window.addFeaturesFromStorage");

            //    addFeaturesFromStorage?.Invoke();
            //}

            return(data, dataJson);
        }
Ejemplo n.º 2
0
        private async Task <(DataFrame?, Graphic[]?)> loadLocationsAsync()
        {
            //DataFrame? locations = QueryDb(OilGasQueries.WellsKarnesLocations);
            DataFrame?locations = await QueryDbAsync(OilGasQueries.AllWellsLocations);

            Graphic[]? locationsJson = null;

            if (locations != null)
            {
                List <Graphic> rows = new List <Graphic>((int)locations.Rows.Count);

                AttributeProperties attributeProperties;

                for (int i = 0; i < locations.Rows.Count; ++i)
                {
                    attributeProperties = new AttributeProperties();

                    attributeProperties.AddProperty("ObjectId", i + 1);

                    attributeProperties.AddProperty("Api", locations.Rows[i][0].StringValue());

                    rows.Add(new Graphic
                    {
                        Geometry = new Geometry
                        {
                            Type  = "polyline",
                            Paths = new List <List <double> >
                            {
                                new List <double>
                                {
                                    locations.Rows[i][1].DoubleValue() ?? 0.0, locations.Rows[i][2].DoubleValue() ?? 0.0
                                },
                                new List <double>
                                {
                                    locations.Rows[i][3].DoubleValue() ?? 0.0, locations.Rows[i][4].DoubleValue() ?? 0.0
                                }
                            }
                        },
                        Attributes = attributeProperties
                    });
                }

                locationsJson = rows.ToArray();

                //locationsJson = "[" + string.Join(", ", rows) + "]";

                //ArcGisService.StoreDataAsync("WellLocations", source);
            }

            //Sequence.LinearSpacing

            //DataFrame? locations = await ArcGisService.QueryDbAsync(locationQuery);

            //if (locationsJson != null)
            //{
            //    jsInteropService.StoreSessionDataAsync("WellLocations", locationsJson).GetAwaiter().GetResult();

            //    Action? addFeaturesFromStorage = jsInteropService.BuildJsAction("window.addFeaturesFromStorage");

            //    addFeaturesFromStorage?.Invoke();
            //}

            return(locations, locationsJson);
        }