private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     bIsConnectedComplete = false;
     mgr = new CrmConnectionManager();
     mgr.ParentControl = CrmLoginCtrl;
     mgr.UseUserLocalDirectoryForConfigStore = true;
     mgr.ClientId    = "51f81489-12ee-4a9e-aaae-a2591f45987d";
     mgr.RedirectUri = new Uri("app://58145B91-0C36-4500-8554-080854F2AC97");
     CrmLoginCtrl.SetGlobalStoreAccess(mgr);
     CrmLoginCtrl.SetControlMode(ServerLoginConfigCtrlMode.FullLoginPanel);
     CrmLoginCtrl.ConnectionCheckBegining += new EventHandler(CrmLoginCtrl_ConnectionCheckBegining);
     CrmLoginCtrl.ConnectErrorEvent       += new EventHandler <ConnectErrorEventArgs>(CrmLoginCtrl_ConnectErrorEvent);
     CrmLoginCtrl.ConnectionStatusEvent   += new EventHandler <ConnectStatusEventArgs>(CrmLoginCtrl_ConnectionStatusEvent);
     CrmLoginCtrl.UserCancelClicked       += new EventHandler(CrmLoginCtrl_UserCancelClicked);
     if (!mgr.RequireUserLogin())
     {
         if (MessageBox.Show("Credentials already saved in configuration\nChoose Yes to Auto Login or No to Reset Credentials", "DynamicsCrm.DevKit - Auto Login", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             CrmLoginCtrl.IsEnabled            = false;
             mgr.ServerConnectionStatusUpdate += new EventHandler <ServerConnectStatusEventArgs>(mgr_ServerConnectionStatusUpdate);
             mgr.ConnectionCheckComplete      += new EventHandler <ServerConnectStatusEventArgs>(mgr_ConnectionCheckComplete);
             mgr.ConnectToServerCheck();
             CrmLoginCtrl.ShowMessageGrid();
         }
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            /*
             *                  This is the setup process for the login control,
             *                  The login control uses a class called CrmConnectionManager to manage the interaction with CRM, this class and also be queried as later points for information about the current connection.
             *                  In this case, the login control is referred to as CrmLoginCtrl
             */

            // Set off flag.
            _bIsConnectedComplete = false;

            // Init the CRM Connection manager..
            _mgr = new CrmConnectionManager();
            // Pass a reference to the current UI or container control,  this is used to synchronize UI threads In the login control
            _mgr.ParentControl = CrmLoginCtrl;
            // if you are using an unmanaged client, excel for example, and need to store the config in the users local directory
            // set this option to true.
            _mgr.UseUserLocalDirectoryForConfigStore = true;

            if (_profileName != null)
            {
                _mgr.ProfileName = _profileName;
            }

            _mgr.ClientId    = "2ad88395-b77d-4561-9441-d0e40824f9bc";
            _mgr.RedirectUri = new Uri("app://5d3e90d6-aa8e-48a8-8f2c-58b45cc67315");
            // if you are using an unmanaged client,  you need to provide the name of an exe to use to create app config key's for.
            //mgr.HostApplicatioNameOveride = "MyExecName.exe";
            // CrmLoginCtrl is the Login control,  this sets the CrmConnection Manager into it.
            CrmLoginCtrl.SetGlobalStoreAccess(_mgr);
            // There are several modes to the login control UI
            CrmLoginCtrl.SetControlMode(ServerLoginConfigCtrlMode.FullLoginPanel);
            // this wires an event that is raised when the login button is pressed.
            CrmLoginCtrl.ConnectionCheckBegining += CrmLoginCtrl_ConnectionCheckBegining;
            // this wires an event that is raised when an error in the connect process occurs.
            CrmLoginCtrl.ConnectErrorEvent += CrmLoginCtrl_ConnectErrorEvent;
            // this wires an event that is raised when a status event is returned.
            CrmLoginCtrl.ConnectionStatusEvent += CrmLoginCtrl_ConnectionStatusEvent;
            // this wires an event that is raised when the user clicks the cancel button.
            CrmLoginCtrl.UserCancelClicked += CrmLoginCtrl_UserCancelClicked;
            // Check to see if its possible to do an Auto Login
            if (_mgr.RequireUserLogin())
            {
                return;
            }

            MessageBoxResult result = MessageBoxResult.No;

            if (!_autoLogin)
            {
                result = MessageBox.Show(
                    "Credentials already saved in configuration\nChoose Yes to Auto Login or No to Reset Credentials",
                    "Auto Login", MessageBoxButton.YesNo, MessageBoxImage.Question);
            }

            if (_autoLogin || result == MessageBoxResult.Yes)
            {
                DoLogin();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Raised when the window loads for the first time.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            /*
             *                  This is the setup process for the login control,
             *                  The login control uses a class called CrmConnectionManager to manage the interaction with CRM, this class and also be queried as later points for information about the current connection.
             *                  In this case, the login control is referred to as CrmLoginCtrl
             */

            // Set off flag.
            bIsConnectedComplete = false;

            // Init the CRM Connection manager..
            mgr = new CrmConnectionManager();
            // Pass a reference to the current UI or container control,  this is used to synchronize UI threads In the login control
            mgr.ParentControl = CrmLoginCtrl;
            // if you are using an unmanaged client, excel for example, and need to store the config in the users local directory
            // set this option to true.
            mgr.UseUserLocalDirectoryForConfigStore = true;
            // if you are using an unmanaged client,  you need to provide the name of an exe to use to create app config key's for.
            //mgr.HostApplicatioNameOveride = "MyExecName.exe";
            // CrmLoginCtrl is the Login control,  this sets the CrmConnection Manager into it.
            CrmLoginCtrl.SetGlobalStoreAccess(mgr);
            // There are several modes to the login control UI
            CrmLoginCtrl.SetControlMode(ServerLoginConfigCtrlMode.FullLoginPanel);
            // this wires an event that is raised when the login button is pressed.
            CrmLoginCtrl.ConnectionCheckBegining += new EventHandler(CrmLoginCtrl_ConnectionCheckBegining);
            // this wires an event that is raised when an error in the connect process occurs.
            CrmLoginCtrl.ConnectErrorEvent += new EventHandler <ConnectErrorEventArgs>(CrmLoginCtrl_ConnectErrorEvent);
            // this wires an event that is raised when a status event is returned.
            CrmLoginCtrl.ConnectionStatusEvent += new EventHandler <ConnectStatusEventArgs>(CrmLoginCtrl_ConnectionStatusEvent);
            // this wires an event that is raised when the user clicks the cancel button.
            CrmLoginCtrl.UserCancelClicked += new EventHandler(CrmLoginCtrl_UserCancelClicked);
            // Check to see if its possible to do an Auto Login
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Raised when the window loads for the first time.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Headingtext.Text = "Connecting to " + ConnectionLabel;

            /*
             *                  This is the setup process for the login control,
             *                  The login control uses a class called CrmConnectionManager to manage the interaction with CRM, this class and also be queried as later points for information about the current connection.
             *                  In this case, the login control is referred to as CrmLoginCtrl
             */

            // Set off flag.
            bIsConnectedComplete = false;

            // Init the CRM Connection manager..
            mgr = new CrmConnectionManager();
            // Pass a reference to the current UI or container control,  this is used to synchronize UI threads In the login control
            mgr.ParentControl = CrmLoginCtrl;
            // if you are using an unmanaged client, excel for example, and need to store the config in the users local directory
            // set this option to true.
            mgr.UseUserLocalDirectoryForConfigStore = true;

            // Client ID to use for oAuth.  ID: 51f81489-12ee-4a9e-aaae-a2591f45987d is a sample ID that should be replaced by a ID created for your use.
            mgr.ClientId = "51f81489-12ee-4a9e-aaae-a2591f45987d";
            // Redirect URI required for oAuth.
            mgr.RedirectUri = new Uri("app://58145B91-0C36-4500-8554-080854F2AC97");

            mgr.ProfileName = ConnectionId;

            // if you are using an unmanaged client,  you need to provide the name of an exe to use to create app config key's for.
            //mgr.HostApplicatioNameOveride = "MyExecName.exe";
            // CrmLoginCtrl is the Login control,  this sets the CrmConnection Manager into it.
            CrmLoginCtrl.SetGlobalStoreAccess(mgr);
            // There are several modes to the login control UI
            CrmLoginCtrl.SetControlMode(ServerLoginConfigCtrlMode.FullLoginPanel);
            // this wires an event that is raised when the login button is pressed.
            CrmLoginCtrl.ConnectionCheckBegining += new EventHandler(CrmLoginCtrl_ConnectionCheckBegining);
            // this wires an event that is raised when an error in the connect process occurs.
            CrmLoginCtrl.ConnectErrorEvent += new EventHandler <ConnectErrorEventArgs>(CrmLoginCtrl_ConnectErrorEvent);
            // this wires an event that is raised when a status event is returned.
            CrmLoginCtrl.ConnectionStatusEvent += new EventHandler <ConnectStatusEventArgs>(CrmLoginCtrl_ConnectionStatusEvent);
            // this wires an event that is raised when the user clicks the cancel button.
            CrmLoginCtrl.UserCancelClicked += new EventHandler(CrmLoginCtrl_UserCancelClicked);
            // Check to see if its possible to do an Auto Login
            if (!mgr.RequireUserLogin())
            {
                // If RequireUserLogin is false, it means that there has been a successful login here before and the credentials are cached.
                CrmLoginCtrl.IsEnabled = false;
                // When running an auto login,  you need to wire and listen to the events from the connection manager.
                // Run Auto User Login process, Wire events.
                mgr.ServerConnectionStatusUpdate += new EventHandler <ServerConnectStatusEventArgs>(mgr_ServerConnectionStatusUpdate);
                mgr.ConnectionCheckComplete      += new EventHandler <ServerConnectStatusEventArgs>(mgr_ConnectionCheckComplete);
                // Start the connection process.
                mgr.ConnectToServerCheck();

                // Show the message grid.
                CrmLoginCtrl.ShowMessageGrid();
            }
        }
        /// <summary>
        /// Raised when the window loads for the first time.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            /*
             *                  This is the setup process for the login control,
             *                  The login control uses a class called CrmConnectionManager to manage the interaction with CRM, this class and also be queried as later points for information about the current connection.
             *                  In this case, the login control is referred to as CrmLoginCtrl
             */

            // Set off flag.
            bIsConnectedComplete = false;

            // Init the CRM Connection manager..
            mgr = new CrmConnectionManager();

            mgr.UseUserLocalDirectoryForConfigStore = true;
            mgr.ProfileName = connectionDetailId.ToString("B");
            mgr.ClientId    = AppId;
            mgr.RedirectUri = RedirectUri;

            // Pass a reference to the current UI or container control,  this is used to synchronize UI threads In the login control
            mgr.ParentControl = CrmLoginCtrl;
            // if you are using an unmanaged client, excel for example, and need to store the config in the users local directory
            // set this option to true.
            mgr.UseUserLocalDirectoryForConfigStore = true;
            // if you are using an unmanaged client,  you need to provide the name of an exe to use to create app config key's for.
            //mgr.HostApplicatioNameOveride = "MyExecName.exe";
            // CrmLoginCtrl is the Login control,  this sets the CrmConnection Manager into it.
            CrmLoginCtrl.SetGlobalStoreAccess(mgr);
            // There are several modes to the login control UI
            CrmLoginCtrl.SetControlMode(ServerLoginConfigCtrlMode.FullLoginPanel);
            // this wires an event that is raised when the login button is pressed.
            CrmLoginCtrl.ConnectionCheckBegining += new EventHandler(CrmLoginCtrl_ConnectionCheckBegining);
            // this wires an event that is raised when an error in the connect process occurs.
            CrmLoginCtrl.ConnectErrorEvent += new EventHandler <ConnectErrorEventArgs>(CrmLoginCtrl_ConnectErrorEvent);
            // this wires an event that is raised when a status event is returned.
            CrmLoginCtrl.ConnectionStatusEvent += new EventHandler <ConnectStatusEventArgs>(CrmLoginCtrl_ConnectionStatusEvent);
            // this wires an event that is raised when the user clicks the cancel button.
            CrmLoginCtrl.UserCancelClicked += new EventHandler(CrmLoginCtrl_UserCancelClicked);
            // Check to see if its possible to do an Auto Login
            if (!mgr.RequireUserLogin() && !isUpdate)
            {
                //if (MessageBox.Show("Credentials already saved in configuration\nChoose Yes to Auto Login or No to Reset Credentials", "Auto Login", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                //{
                // If RequireUserLogin is false, it means that there has been a successful login here before and the credentials are cached.
                CrmLoginCtrl.IsEnabled = false;
                // When running an auto login,  you need to wire and listen to the events from the connection manager.
                // Run Auto User Login process, Wire events.
                mgr.ServerConnectionStatusUpdate += new EventHandler <ServerConnectStatusEventArgs>(mgr_ServerConnectionStatusUpdate);
                mgr.ConnectionCheckComplete      += new EventHandler <ServerConnectStatusEventArgs>(mgr_ConnectionCheckComplete);
                // Start the connection process.
                mgr.ConnectToServerCheck();

                // Show the message grid.
                CrmLoginCtrl.ShowMessageGrid();
                //}
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Raised when the window loads for the first time.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // This is the setup process for the login control.
            // The login control uses a class called CrmConnectionManager to manage
            // the interaction with CRM. This class can also be queried at later points
            // for information about the current connection.
            // In this case, the login control is referred to as CrmLoginCtrl.

            // Set off flag.
            bIsConnectedComplete = false;

            // Initialize the CRM Connection manager.
            mgr = new CrmConnectionManager();

            // Pass a reference to the current UI or container control. This is used to
            // synchronize UI threads In the login control.
            mgr.ParentControl = CrmLoginCtrl;

            // If you are using an unmanaged client, say Microsoft Excel, and need to
            // store the config in the users local directory, you must set this option to true.
            mgr.UseUserLocalDirectoryForConfigStore = true;

            // If you are using an unmanaged client, you need to provide the name of
            // an executable (.exe) to use to create app config key.
            //mgr.HostApplicatioNameOveride = "MyExecName.exe";

            // This sets the CRM Connection manager for CrmLoginCtrl.
            CrmLoginCtrl.SetGlobalStoreAccess(mgr);

            // There are several modes to the login control UI.
            CrmLoginCtrl.SetControlMode(ServerLoginConfigCtrlMode.FullLoginPanel);

            // This wires an event that is raised when the login button is pressed.
            CrmLoginCtrl.ConnectionCheckBegining += new EventHandler(CrmLoginCtrl_ConnectionCheckBegining);

            // This wires an event that is raised when an error in the connect process occurs.
            CrmLoginCtrl.ConnectErrorEvent += new EventHandler <ConnectErrorEventArgs>(CrmLoginCtrl_ConnectErrorEvent);

            // This wires an event that is raised when a status event is returned.
            CrmLoginCtrl.ConnectionStatusEvent += new EventHandler <ConnectStatusEventArgs>(CrmLoginCtrl_ConnectionStatusEvent);

            // This wires an event that is raised when the user clicks the cancel button.
            CrmLoginCtrl.UserCancelClicked += new EventHandler(CrmLoginCtrl_UserCancelClicked);

            // This prompts the user to automatically sign in using the cached credentials
            // when signing for the second time or later.
            if (!mgr.RequireUserLogin())
            {
                if (MessageBox.Show("Credentials already saved in configuration.\nClick Yes to sign in using saved credentials.\nClick No to reset credentials to sign in.", "Auto Sign-In", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    // If RequireUserLogin is false, it means that there has been a successful login here before and the credentials are cached.
                    CrmLoginCtrl.IsEnabled = false;
                    // When running an auto login,  you need to wire and listen to the events from the connection manager.
                    // Run Auto User Login process, Wire events.
                    mgr.ServerConnectionStatusUpdate += new EventHandler <ServerConnectStatusEventArgs>(mgr_ServerConnectionStatusUpdate);
                    mgr.ConnectionCheckComplete      += new EventHandler <ServerConnectStatusEventArgs>(mgr_ConnectionCheckComplete);
                    // Start the connection process.
                    mgr.ConnectToServerCheck();

                    // Show the message grid.
                    CrmLoginCtrl.ShowMessageGrid();
                }
            }
        }