Ejemplo n.º 1
0
        /// <summary>
        /// Setup the commands
        /// </summary>
        private void SetupCommands()
        {
            RemoveCommand = new RelayCommand(RemoveMap, () => CanRemove);

            // Create the command to run an export for the active map
            RunExportCommand = new RelayCommand <object>
                                   ((exportToRun) =>
            {
                var model = exportToRun as ExportViewModel;

                if (model != null)
                {
                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackExport(model, LiteAnalyticsTracker.Source.Map);

                    model.Save();
                }
            },
                                   (context) =>
            {
                var model = context as ExportViewModel;
                return(model != null && model.CanRun);
            }
                                   );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs the query and publishes it on the Messenger
        /// </summary>
        internal void RunQuery()
        {
            if (CanRun)
            {
                // Determine the recipe
                var recipeCollection = ResultCollection();

                if (recipeCollection != null)
                {
                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackQuery(this, LiteAnalyticsTracker.Source.Queries);

                    // Publish the recipe for the rest of the application to pick up
                    Messenger.Send(new LiteDisplayFeatureCollectionRequestMessage(this, recipeCollection));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Setup the commands
        /// </summary>
        private void SetupCommands()
        {
            RunCommand    = new RelayCommand(RunQuery, () => CanRun);
            RemoveCommand = new RelayCommand(RemoveQuery, () => CanRemove);

            RunReportCommand = new RelayCommand <object>
                                   ((context) =>
            {
                var model = context as ReportViewModel;

                if (model != null && model.CanRun)
                {
                    model.Run(true, true);

                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackReport(model, LiteAnalyticsTracker.Source.Queries);

                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackReport(model, LiteAnalyticsTracker.Source.Details);
                }
            },
                                   (context) =>
            {
                var model = context as ReportViewModel;
                return(model != null && model.CanRun);
            });

            RunExportCommand = new RelayCommand <object>
                                   ((context) =>
            {
                var model = context as ExportViewModel;

                if (model != null && model.CanRun)
                {
                    model.Save();

                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackExport(model, LiteAnalyticsTracker.Source.Queries);
                }
            },
                                   (context) =>
            {
                var model = context as ExportViewModel;
                return(model != null && model.CanRun);
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Setup the viewmodel commands
        /// </summary>
        private void SetupCommands()
        {
            // Create the command to run a report on the active collection
            RunReportCommand = new RelayCommand <object>
                                   ((reportToRun) =>
            {
                var model = reportToRun as ReportViewModel;

                if (model != null && model.CanRun)
                {
                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackReport(model, LiteAnalyticsTracker.Source.ResultList);

                    model.Run(true, true);
                }
            },
                                   (context) =>
            {
                var model = context as ReportViewModel;
                return(model != null);
            }
                                   );

            // Create the command to run an export for the active collection
            RunExportCommand = new RelayCommand <object>
                                   ((exportToRun) =>
            {
                var model = exportToRun as ExportViewModel;

                if (model != null)
                {
                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackExport(model, LiteAnalyticsTracker.Source.ResultList);

                    model.Save();
                }
            },
                                   (context) =>
            {
                var model = context as ExportViewModel;
                return(model != null && model.CanRun);
            }
                                   );
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Setup the viewmodel commands
        /// </summary>
        private void SetupCommands()
        {
            RunReportCommand = new RelayCommand <object>
                                   ((context) =>
            {
                var model = context as ReportViewModel;

                if (model != null)
                {
                    // Do Analytics Tracking
                    LiteAnalyticsTracker.TrackReport(model, LiteAnalyticsTracker.Source.Details);

                    model.Run(true, true);
                }
            },
                                   (context) =>
            {
                var model = context as ReportViewModel;
                return(model != null && !IsRunning);
            }
                                   );
        }
        /// <summary>
        /// The method that handles saving of the constructed query.
        /// </summary>
        private void SaveNewQuery()
        {
            var mode = this.NewQueryViewModel.SelectedMode;

            if (mode != null)
            {
                // Get the name
                var queryName = this.NewQueryViewModel.QueryName;

                // Make sure there is a name
                if (string.IsNullOrEmpty(queryName) || String.Compare(queryName, ApplicationResources.Query, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    queryName = string.Concat(ApplicationResources.Query, " (", mode.TableDescriptor.ExternalName, ")");
                }

                // Make sure it's unique
                queryName = UniqueExternalNameFor(queryName);

                // Get new Query details from the selected mode
                var table       = mode.TableDescriptor;
                var description = UniqueExternalNameFor(queryName);
                var expression  = mode.NewQueryExpression();
                var parameters  = mode.NewQueryParameterDefinitions();

                var newQuery = NewUserQuery(description, table, expression, parameters, true);

                if (newQuery != null)
                {
                    // Track in Analytics
                    LiteAnalyticsTracker.TrackQueryCreate(newQuery);

                    // Request the newly created query to run
                    newQuery.RunQuery();
                }
            }

            NewQueryViewVisibility = Visibility.Collapsed;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// The active document is about to be sent to the printer
        /// </summary>
        protected override void OnSendToPrinter()
        {
            base.OnSendToPrinter();

            LiteAnalyticsTracker.TrackMapPrint();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Called whenever the authentication is about to change. The order in which calls are made are:
        ///
        /// ViewModelLocator - OnAuthenticationChanging
        ///
        /// ViewModels       - OnAuthenticationChanged
        /// ViewModelLocator - OnAuthenticationChanged
        ///
        /// This method gives the possibility to change global settings before individual viewModels are
        /// setting their state when the user has been authenticated. (ie add ServiceProviders depending
        /// on some server setting).
        /// </summary>
        protected override async Task OnAuthenticationChanging(AuthenticationContext context, bool isAuthenticated)
        {
            // Get some base behavior happening and wait for it to complete
            await base.OnAuthenticationChanging(context, isAuthenticated);

            // Clear all referenced service providers - include the local defined ones
            ServiceProviderManager.Instance.RemoveServiceProviders(includeLocalDefined: true, leaveMainProvider: true);

            // Drive the client settings actively, to make sure these are done before any
            // other viewModel kicks in
            await ClientSettingsViewModel.SetupFor(context, isAuthenticated);

            if (isAuthenticated)
            {
                // Make sure we set up the client side GeoLocator (if it is indicated via the client
                // settings that this user uses the client-side one).
                ApplyClientSettingsToViewModels();

                // Tell the LiteAnalyticsTracker our prefered prefix for the Application.
                // Note: Do not make this language dependent, since different clients' identical categories wouldn't match anymore
                //
                // Do not use in case no category prefix is required in Analytics (ie when this is handled using account properties
                // in Google Analytics).
                //
                // AnalyticsAppName   Category                                  Event      Label
                // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                // Set                'GSA Lite (Cambridge): Authentication'   'SignIn'   'test'
                // Not Set            'Authentication'                         'SignIn'   'test'
                //
                // LiteAnalyticsTracker.AnalyticsAppName = string.Format("{0} ({1}): ", AnalyticsName, context.ServiceProviderInfo.Name ?? "");

                // Track the fact that we are signing in
                LiteAnalyticsTracker.TrackSignIn(context.UserName);

                // Get reference providers
                var referenceProviders = await this.ServerInfoViewModel.GetReferenceServiceProvidersAsync();

                foreach (var provider in referenceProviders)
                {
                    ServiceProviderManager.Instance.ServiceProviders.Add(provider);
                }
            }
            else
            {
                // Let's handle the fading out as early as possible
                int fadeOutMs = 1000;

                // When signing in, there is an AuthenticationContext available.
                bool triedLoggingIn = context != null;

                // First of all - fade the application out
                AuthenticationOpacity.FadeOut(fadeOutMs);

                if (triedLoggingIn)
                {
                    // Dependent on the state, track errors to the Analytics Module
                    switch (context.Status)
                    {
                    case AuthenticationStatus.FailedConnectionError:
                        var mainProvider = ServiceProviderManager.Instance.MainServiceProvider as XYServiceProvider;
                        if (mainProvider != null)
                        {
                            // Notify the user/tracker that we have failed to connect
                            var address = mainProvider.ServiceAddress ?? "?";
                            var message = String.Format("{0} {1}", FrameworkResources.AuthenticationFailedConnectionError, address);

                            // Use the analytics tracker
                            LiteAnalyticsTracker.TrackAuthServerError(message);
                        }
                        break;

                    case AuthenticationStatus.FailedInvalidCredentials:
                        // Track in analytics
                        LiteAnalyticsTracker.TrackAuthCredentialsError(context.UserName);
                        break;

                    case AuthenticationStatus.FailedInvalidApplication:
                        // Track in analytics
                        LiteAnalyticsTracker.TrackAuthInvalidApplicationError(context.UserName);
                        break;

                    case AuthenticationStatus.FailedInvalidApplicationUser:
                        // Track in analytics
                        LiteAnalyticsTracker.TrackAuthInvalidApplicationUserError(context.UserName);
                        break;
                    }
                }
                else // so !triedLoggingIn - deliberately signing out
                {
                    // Track the signing out
                    LiteAnalyticsTracker.TrackSignOut();
                }
            }
        }