Esempio n. 1
0
        private async Task <List <AreaMaster> > getRegionByArea(List <Point> points)
        {
            List <List <Area> >       allAreas       = new List <List <Area> >();
            List <List <AreaMaster> > allAreasMaster = new List <List <AreaMaster> >();

            Parallel.ForEach(points, point =>
            {
                Dictionary <string, Condition> keyConditions = new Dictionary <string, Condition>();
                keyConditions.Add("Tile", new Condition()
                {
                    ComparisonOperator = "EQ", AttributeValueList = new List <AttributeValue>()
                    {
                        new AttributeValue(GetTileStr(point.X, point.Y))
                    }
                });

                QueryRequest queryRequest = new QueryRequest()
                {
                    TableName     = areaTableName,
                    IndexName     = "AreaIDIndex",
                    KeyConditions = keyConditions,
                };

                var result = dynamoDBClient.QueryAsync(queryRequest).Result;
                allAreas.Add(Area.ConvertToEntity(result.Items));
            });


            Parallel.ForEach(allAreas.SelectMany(x => x).Select(x => x.AreaID).Distinct(), areaId =>
            {
                Dictionary <string, Condition> keyConditions = new Dictionary <string, Condition>();
                keyConditions.Add("AreaID", new Condition()
                {
                    ComparisonOperator = "EQ", AttributeValueList = new List <AttributeValue>()
                    {
                        new AttributeValue(areaId)
                    }
                });

                QueryRequest queryRequest = new QueryRequest()
                {
                    TableName     = areaMasterTableName,
                    IndexName     = "AreaPolygonIndex",
                    KeyConditions = keyConditions,
                };

                var result = dynamoDBClient.QueryAsync(queryRequest).Result;
                allAreasMaster.Add(AreaMaster.ConvertToEntity(result.Items));
            });

            return(allAreasMaster.SelectMany(x => x).ToList());
        }
Esempio n. 2
0
        public async Task <List <AreaMaster> > GetArea()
        {
            Dictionary <string, Condition> queryCondition = new Dictionary <string, Condition>();
            //queryCondition.Add("IsPredefine", new Condition() { ComparisonOperator = "EQ", AttributeValueList = new List<AttributeValue>() { new AttributeValue() { N = "1" } } });

            var request = new ScanRequest
            {
                TableName  = areaMasterTableName,
                IndexName  = "AreaIDIndex",
                ScanFilter = queryCondition
            };

            var response = await dynamoDBClient.ScanAsync(request);

            List <AreaMaster> listings = AreaMaster.ConvertToEntity(response.Items);

            return(listings);
        }
Esempio n. 3
0
        public async Task <GetAreaListingWrapper> GetArea(string id, string north = null, string east = null, string south = null, string west = null, string beds = null, string bathsFull = null, string bathsHalf = null, string propertyAddressId = null, string averageValue = null, string averageRent = null)
        {
            DateTime                startQueryTime = DateTime.Now;
            List <AreaMaster>       listingArea    = new List <AreaMaster>();
            List <List <Property> > areaProperties = new List <List <Property> >();

            Dictionary <string, Condition> areaKeyConditions = new Dictionary <string, Condition>();
            Dictionary <string, Condition> areaQueryFilter   = new Dictionary <string, Condition>();

            areaKeyConditions.Add("AreaID", new Condition()
            {
                ComparisonOperator = "EQ", AttributeValueList = new List <AttributeValue>()
                {
                    new AttributeValue(id)
                }
            });
            areaQueryFilter.Add("IsPredefine", new Condition()
            {
                ComparisonOperator = "EQ", AttributeValueList = new List <AttributeValue>()
                {
                    new AttributeValue()
                    {
                        N = "1"
                    }
                }
            });

            QueryRequest queryRequest = new QueryRequest()
            {
                TableName = areaMasterTableName,
                ReturnConsumedCapacity = "TOTAL",
                KeyConditions          = areaKeyConditions,
                QueryFilter            = areaQueryFilter
            };

            var result = dynamoDBClient.QueryAsync(queryRequest).Result;

            listingArea = AreaMaster.ConvertToEntity(result.Items);
            DateTime endQueryTime = DateTime.Now;


            if (listingArea.Count() > 0)
            {
                var tempArea = new Area()
                {
                    EncodedPolygon = listingArea.First().EncodedPolygon,
                    Points         = GooglePoints.DecodeBase64(listingArea.First().EncodedPolygon).Select(x => new LocationPoint(x.Latitude, x.Longitude)).ToList()
                };

                GetListingWrapper output = await GetListing(tempArea, north, east, south, west, beds, bathsFull, bathsHalf, propertyAddressId, averageValue, averageRent, listingArea.First().EncodedCompletedTiles, listingArea.First().EncodedPartialTiles);


                foreach (var area in listingArea)
                {
                    area.EncodedPolygon        = ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(area.EncodedPolygon));
                    area.EncodedCompletedTiles = null;
                    area.EncodedPartialTiles   = null;
                }
                return(new GetAreaListingWrapper
                {
                    PropertyCount = output.PropertyCount,
                    ScanCount = output.ScanCount,
                    ConsumedCapacityCount = output.ConsumedCapacityCount,
                    TotalQueryExecutionTime = output.TotalQueryExecutionTime,
                    TotalLambdaExecutionTime = output.TotalLambdaExecutionTime,
                    TotalContainsExecutionTime = output.TotalContainsExecutionTime,
                    TotalAreaQueryTime = (endQueryTime - startQueryTime).TotalMilliseconds,
                    Properties = output.Properties,
                    Area = listingArea,
                });
            }
            else
            {
                return(null);
            }
        }