コード例 #1
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;

            // 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");

            // 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 (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();
                }
            }
        }
コード例 #2
0
        private void DoLogin()
        {
            // 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 += mgr_ServerConnectionStatusUpdate;
            _mgr.ConnectionCheckComplete      += mgr_ConnectionCheckComplete;
            // Start the connection process.
            _mgr.ConnectToServerCheck();

            // Show the message grid.
            CrmLoginCtrl.ShowMessageGrid();
        }
コード例 #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 
            if (!mgr.RequireUserLogin())
            {
                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();
                }
            }
        }
コード例 #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)
        {
            // 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();
                }
            }
        }