Exemplo n.º 1
0
        public override void onReceive(Context arg0, Intent arg1)
        {
            TestTip.Inst.ShowText("GeoFenceBroadcast success");
            GeofenceData geofenceData = GeofenceData.getDataFromIntent(arg1);
            string       s            = "receive\n";

            if (geofenceData != null)
            {
                int      errorCode  = geofenceData.getErrorCode();
                int      conversion = geofenceData.getConversion();
                List     list       = geofenceData.getConvertingGeofenceList();
                Location mLocation  = geofenceData.getConvertingLocation();
                bool     status     = geofenceData.isSuccess();
                s += "errorcode: " + errorCode.ToString() + "\n";
                s += "conversion: " + conversion.ToString() + "\n";
                for (int i = 0; i < list.toArray().Length; i++)
                {
                    Geofence g = HmsUtil.GetHmsBase <Geofence>(list.toArray()[i]);
                    s += ("geoFence id :" + g.getUniqueId() + "\n");
                }
                s += ("location is :" + mLocation.getLongitude() + " " + mLocation.getLatitude() + "\n");
                s += ("is successful :" + status);
            }
            TestTip.Inst.ShowText(s);
        }
Exemplo n.º 2
0
        public void MapGeofenceDataToGeofence()
        {
            var geofenceData = new GeofenceData
            {
                GeofenceUID   = Guid.NewGuid(),
                GeofenceName  = "whatever",
                GeofenceType  = GeofenceType.CutZone.ToString(),
                GeometryWKT   = "blah",
                CustomerUID   = Guid.NewGuid(),
                UserUID       = Guid.NewGuid(),
                IsTransparent = true,
                Description   = null,
                AreaSqMeters  = 1.234,
                FillColor     = 0,
            };
            var result = AutoMapperUtility.Automapper.Map <Geofence>(geofenceData);

            Assert.Equal(geofenceData.GeofenceUID.ToString(), result.GeofenceUID);
            Assert.Equal(geofenceData.GeofenceName, result.Name);
            Assert.Equal(geofenceData.GeofenceType, result.GeofenceType.ToString());
            Assert.Equal(geofenceData.GeometryWKT, result.GeometryWKT);
            Assert.Equal(geofenceData.CustomerUID.ToString(), result.CustomerUID);
            Assert.Equal(geofenceData.UserUID.ToString(), result.UserUID);
            Assert.Equal(geofenceData.IsTransparent, result.IsTransparent);
            Assert.Equal(geofenceData.Description, result.Description);
            Assert.Equal(geofenceData.AreaSqMeters, result.AreaSqMeters);
            Assert.Equal(geofenceData.FillColor, result.FillColor);
        }
Exemplo n.º 3
0
        public async Task HydrateJsonWithBoundary_InvalidBoundary(FilterType filterType)
        {
            var log          = serviceProvider.GetRequiredService <ILoggerFactory>().CreateLogger <ValidationTests>();
            var geofenceRepo = new Mock <IGeofenceRepository>();
            var geofence     = new Geofence {
                GeometryWKT = "This is not a valid polygon WKT", GeofenceType = GeofenceType.Filter
            };

            geofenceRepo.Setup(g => g.GetGeofence(It.IsAny <string>())).ReturnsAsync(geofence);
            //var geofenceProxy = new Mock<IGeofenceProxy>();
            var geofenceData = new GeofenceData {
                GeometryWKT = geofence.GeometryWKT, GeofenceType = GeofenceType.Generic.ToString()
            };
            //geofenceProxy.Setup(g => g.GetGeofenceForCustomer(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<HeaderDictionary>())).ReturnsAsync(geofenceData);

            var request = FilterRequestFull.Create(null, custUid, false, userUid, new ProjectData {
                ProjectUID = projectUid
            },
                                                   new FilterRequest
            {
                FilterUid  = filterUid,
                Name       = "a filter",
                FilterType = filterType,
                FilterJson = "{\"designUID\": \"id\", \"vibeStateOn\": true, \"polygonUID\": \"" + boundaryUid + "\"}"
            });

            var ex = await Assert.ThrowsAsync <ServiceException>(async() => await ValidationUtil
                                                                 .HydrateJsonWithBoundary(/*geofenceProxy.Object,*/ geofenceRepo.Object, log, serviceExceptionHandler, request).ConfigureAwait(false));

            Assert.Contains("2045", ex.GetContent);
            Assert.Contains("Invalid spatial filter boundary. One or more polygon components are missing.", ex.GetContent);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get the generated tile for the request. Used for geofence thumbnails.
        /// </summary>
        protected async Task <FileResult> GetGeneratedTile(GeofenceData geofence,
                                                           TileOverlayType[] overlays, int width, int height, string bbox, MapType?mapType,
                                                           string language, bool adjustBoundingBox)
        {
            var byteResult = await tileCache.GetOrCreateAsync <byte[]>(geofence.GeofenceUID, async entry =>
            {
                entry.SlidingExpiration = tileCacheExpiration;

                var overlayTypes = overlays.ToList();

                language = string.IsNullOrEmpty(language) ? (await GetShortCachedUserPreferences()).Language : language;

                var geofences = new List <GeofenceData> {
                    geofence
                };
                var mapParameters = tileGenerator.GetMapParameters(bbox, width, height, overlayTypes.Contains(TileOverlayType.GeofenceBoundary), adjustBoundingBox);

                var request = TileGenerationRequest.CreateTileGenerationRequest(null, null, null, null, null,
                                                                                geofences, null, null, null, null, null, null, overlayTypes, width, height, mapType, null,
                                                                                language, null, mapParameters, CustomHeaders, null);

                request.Validate();

                Log.LogDebug("The tile doesn't exist in cache - generating it");
                return(await WithServiceExceptionTryExecuteAsync(() =>
                                                                 tileGenerator.GetMapData(request)));
            });

            return(new FileStreamResult(new MemoryStream(byteResult), ContentTypeConstants.ImagePng));
        }
Exemplo n.º 5
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (intent != null)
     {
         var action = intent.Action;
         if (action == ActionGeofence)
         {
             GeofenceData geofenceData = GeofenceData.GetDataFromIntent(intent);
             if (geofenceData != null)
             {
                 Toast.MakeText(context, "Geofence triggered: " + geofenceData.ConvertingLocation.Latitude + "\n" + geofenceData.ConvertingLocation.Longitude + "\n" + geofenceData.Conversion.ToConversionName(), ToastLength.Long).Show();
             }
         }
     }
 }
 public override void OnReceive(Context context, Intent intent)
 {
     if (intent != null)
     {
         string        action = intent.Action;
         StringBuilder sb     = new StringBuilder();
         string        next   = Environment.NewLine;
         if (ActionProcessLocation.Equals(action))
         {
             GeofenceData geofenceData = GeofenceData.GetDataFromIntent(intent);
             if (geofenceData != null)
             {
                 int errorCode               = geofenceData.ErrorCode;
                 int conversion              = geofenceData.Conversion;
                 List <IGeofence> list       = geofenceData.ConvertingGeofenceList.ToList();
                 Location         myLocation = geofenceData.ConvertingLocation;
                 bool             status     = geofenceData.IsSuccess;
                 sb.Append($"ErrorCode: {errorCode}{next}");
                 sb.Append($"Conversion: {conversion}{next}");
                 if (list != null)
                 {
                     foreach (IGeofence geofence in list)
                     {
                         sb.Append($"GeoFence id: {geofence.UniqueId}{next}");
                     }
                 }
                 if (myLocation != null)
                 {
                     sb.Append($"location is : {myLocation.Longitude} {myLocation.Latitude}{next}");
                 }
                 sb.Append("is successful :" + status);
                 Logger.GeofenceInstance.Info("GeoFenceBroadcastReceiver", sb.ToString());
             }
         }
     }
 }
Exemplo n.º 7
0
 public GeofenceDataSingleResult(GeofenceData geofenceData)
 {
     GeofenceData = geofenceData;
 }