예제 #1
0
        private async Task DisplayFeatureActionMenuAsync(Feature feature)
        {
            string result = await NavigationService.GetCurrentPage().DisplayActionSheet((string)feature.Properties[Constants.NameProperty], "Dismiss", "Delete", "View");

            switch (result)
            {
            case "Delete":
                shakeService.Start();
                await FeatureStore.DeleteItem(feature);

                RefreshMap();
                break;

            case "View":
                if (feature.Properties.ContainsKey(Constants.LogTimestampsProperty))
                {
                    await NavigationService.NavigateToLoggerPage(feature);
                }
                else
                {
                    await NavigationService.NavigateToEditPage(feature);
                }
                break;

            default:
                break;
            }
        }
예제 #2
0
        public override async Task <string> GetOrNullAsync(FeatureDefinition feature)
        {
            if (!CurrentClient.IsAuthenticated)
            {
                return(null);
            }

            return(await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentClient.Id));
        }
예제 #3
0
        public async override Task <string> GetOrNullAsync(FeatureDefinition feature)
        {
            var editionId = PrincipalAccessor.Principal?.FindEditionId();

            if (editionId == null)
            {
                return(null);
            }

            return(await FeatureStore.GetOrNullAsync(feature.Name, Name, editionId.Value.ToString()));
        }
예제 #4
0
        public async Task ImportRawGeoJSON(string contents)
        {
            try
            {
                int successfulImports = await FeatureStore.ImportRawContents(contents);

                await NavigationService.ShowImportAlert(successfulImports);
            }
            catch (Exception ex)
            {
                await NavigationService.ShowAlert("Import Error", ex.Message, false);
            }
        }
예제 #5
0
        public bool IsActive(string featureKey, FeatureContext featureContext)
        {
            if (featureContext.InternalFeatureContext == null)
            {
                featureContext.InternalFeatureContext = new InternalFeatureContext()
                {
                    Features = this
                }
            }
            ;

            return(FeatureStore.GetFeature(featureKey).IsActive(featureContext));
        }
예제 #6
0
        /// <summary>
        /// Call the Feature Store to delete seleted feature.
        /// </summary>
        /// <param name="feature">Feature to delete.</param>
        /// <returns></returns>
        private async Task DeleteFeature(Feature feature)
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;

            shakeService.Start();
            await FeatureStore.DeleteItem(feature);

            IsBusy = false;
        }
예제 #7
0
        public async void UndoDelete()
        {
            bool result = await NavigationService.GetCurrentPage().DisplayAlert("Undo Delete", "", "Undo", "Cancel");

            if (result)
            {
                string contents = File.ReadAllText(Constants.DELETED_FEATURE_FILE);
                try
                {
                    _ = await FeatureStore.ImportRawContents(contents);
                }
                catch (Exception ex)
                {
                    await NavigationService.ShowAlert("Recovery Error", ex.Message, false);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Shows native share sheet that exports all features.
        /// </summary>
        /// <returns></returns>
        private async Task ShowShareSheet()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;

            ShareFileRequest share = new ShareFileRequest
            {
                Title = "Share Features",
                File  = new ShareFile(await FeatureStore.ExportFeatures(FeatureList), "application/json"),
            };

            share.PresentationSourceBounds = DeviceInfo.Platform == DevicePlatform.iOS && DeviceInfo.Idiom == DeviceIdiom.Tablet
                    ? new System.Drawing.Rectangle((int)(DeviceDisplay.MainDisplayInfo.Width * .474), 80, 0, 0)
                    : System.Drawing.Rectangle.Empty;
            await Share.RequestAsync(share);

            IsBusy = false;
        }
예제 #9
0
        public async Task ImportFeatureList()
        {
            try
            {
                FeatureCollection featureCollection = (FeatureCollection)GeoJSONObject.ImportGeoJSON(Constants.FeaturesFileContents);
                _ = await FeatureStore.ImportItems(featureCollection.Features);
            }
            catch
            {
                bool result = await NavigationService.ShowAlert("Feature List Error", "Groundsman was unable to load your saved features. Would you like to export the corrupted features?", true);

                if (result)
                {
                    await Share.RequestAsync(new ShareFileRequest
                    {
                        Title = "Groundsman Feature List (Corrupted)",
                        File  = new ShareFile(Constants.FEATURES_FILE, "application/json"),
                    });
                }
                await FeatureStore.ResetItems();
            }
        }
예제 #10
0
 public override async Task <string> GetOrNullAsync(FeatureDefinition feature)
 {
     return(await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentTenant.Id?.ToString()).ConfigureAwait(false));
 }
예제 #11
0
        public IEnumerable <IFeatureFlag> GetAllFeatures()
        {
            var a = FeatureStore.GetAllFeatures().ToArray();

            return(a); // a.Select(x => x.Name);
        }
예제 #12
0
 public async override Task <string> GetOrNullAsync(FeatureDefinition feature)
 {
     return(await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentTenant.Id?.ToString()));
 }
예제 #13
0
 public override async Task <string> GetOrNullAsync(FeatureDefinition feature)
 {
     return(await FeatureStore.GetOrNullAsync(feature.Name, Name, _currentUser?.Id?.ToString()));
 }
예제 #14
0
 public static bool IsActive(string featureKey, FeatureContext featureContext)
 {
     return(FeatureStore.GetFeature(featureKey).IsActive(featureContext));
 }