public GoogleMapsEngineToolsExtensionForArcGIS()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("The extension is initializing.");

            // set the extension object to this
            log.Debug("Setting the extension object to this.");
            s_extension = this;

            // The Google Maps Engine Tools Extension for ArcMap is initializing
            // This occures when the extension is loaded or referenced for the first time
            // The extension is set for delayed loading, so this may happen at Map Load or later, for instance
            // when the user goes to the Tools > Extension menu

            // initialize the OAuth2 token object
            log.Debug("Initializing the OAuth2 token object.");
            token = null;

            // Step 1: Check to see if the extension is enabled
            log.Debug("Checking to see if the extension is enabled.");
            if (this.State == ESRI.ArcGIS.Desktop.AddIns.ExtensionState.Enabled)
            {
                log.Debug("The extension is enabled.");

                // raise an extension changed event
                OnRaiseExtensionStateChangeEvent(new Extension.StateChangeEventArgs(true));

                // check to see if there is a valid token stored for this user
                log.Debug("Checking to see if the token object exists in the user's profile.");
                if (Extension.Auth.OAuth2Utilities.doesTokenExist(ref log))
                {
                    log.Debug("Token exists.");

                    // retrieve token from the user's profile for use
                    log.Debug("Getting token object from user's proflie.");
                    token = Extension.Auth.OAuth2Utilities.getToken(ref log);
                }

                // check to see if there is an update to the Extension
                //TODO: Spin off a seperate thread to do this
                // create an update check object
                log.Debug("Creating an update check object.");
                Extension.Update.ExtensionUpdateCheck updateCheck = new Extension.Update.ExtensionUpdateCheck();

                // check to see if there is an update available
                log.Debug("Checking to see if there is an update available.");
                if (updateCheck.isUpdateAvailable())
                {
                    log.Debug("isUpdateAvailable = true");

                    // create a dialog to inform the user of an update
                    log.Debug("Showing the user an OK/Cancel dialog to notify them of an update.");
                    if (System.Windows.Forms.MessageBox.Show("An update to the Google Maps Engine Tools for ArcGIS is avaiable.  Would you like to update the Add-in now?"
                        , "Update Available (" + updateCheck.getLocalVersion().ToString() + " < " + updateCheck.getServerVersion().ToString() + ")"
                        , System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                    {
                        // launch browser at the URL provided in the update check
                        log.Debug("Launching the browser to the update URL, as the user selected OK.");
                        System.Diagnostics.Process.Start(updateCheck.getUpdateURI());
                    }
                }
            }
            else
            {
                // the extension is not enabled or is unavailable
                log.Debug("The extension is disabled or unavailable (" + this.State + ").");
            }
        }
Ejemplo n.º 2
0
        public GoogleMapsEngineToolsExtensionForArcGIS()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("The extension is initializing.");

            // set the extension object to this
            log.Debug("Setting the extension object to this.");
            s_extension = this;

            // The Google Maps Engine Tools Extension for ArcMap is initializing
            // This occures when the extension is loaded or referenced for the first time
            // The extension is set for delayed loading, so this may happen at Map Load or later, for instance
            // when the user goes to the Tools > Extension menu

            // initialize the OAuth2 token object
            log.Debug("Initializing the OAuth2 token object.");
            token = null;

            // Step 1: Check to see if the extension is enabled
            log.Debug("Checking to see if the extension is enabled.");
            if (this.State == ESRI.ArcGIS.Desktop.AddIns.ExtensionState.Enabled)
            {
                log.Debug("The extension is enabled.");

                // raise an extension changed event
                OnRaiseExtensionStateChangeEvent(new Extension.StateChangeEventArgs(true));

                // check to see if there is a valid token stored for this user
                log.Debug("Checking to see if the token object exists in the user's profile.");
                if (Extension.Auth.OAuth2Utilities.doesTokenExist(ref log))
                {
                    log.Debug("Token exists.");

                    // retrieve token from the user's profile for use
                    log.Debug("Getting token object from user's proflie.");
                    token = Extension.Auth.OAuth2Utilities.getToken(ref log);
                }

                // check to see if there is an update to the Extension
                //TODO: Spin off a seperate thread to do this
                // create an update check object
                log.Debug("Creating an update check object.");
                Extension.Update.ExtensionUpdateCheck updateCheck = new Extension.Update.ExtensionUpdateCheck();

                // check to see if there is an update available
                log.Debug("Checking to see if there is an update available.");
                if (updateCheck.isUpdateAvailable())
                {
                    log.Debug("isUpdateAvailable = true");

                    // create a dialog to inform the user of an update
                    log.Debug("Showing the user an OK/Cancel dialog to notify them of an update.");
                    if (System.Windows.Forms.MessageBox.Show("An update to the Google Maps Engine Tools for ArcGIS is avaiable.  Would you like to update the Add-in now?"
                                                             , "Update Available (" + updateCheck.getLocalVersion().ToString() + " < " + updateCheck.getServerVersion().ToString() + ")"
                                                             , System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                    {
                        // launch browser at the URL provided in the update check
                        log.Debug("Launching the browser to the update URL, as the user selected OK.");
                        System.Diagnostics.Process.Start(updateCheck.getUpdateURI());
                    }
                }
            }
            else
            {
                // the extension is not enabled or is unavailable
                log.Debug("The extension is disabled or unavailable (" + this.State + ").");
            }
        }