public ExportManager()
 {
     InitializeComponent();
     this.cManager = new ConnectionManager(this);
     this.cManager.ConnectionFailed += new ConnectionManager.ConnectionFailedEventHandler(cManager_ConnectionFailed);
     this.cManager.ConnectionSucceed += new ConnectionManager.ConnectionSucceedEventHandler(cManager_ConnectionSucceed);
     this.cManager.StepChanged += new ConnectionManager.StepChangedEventHandler(cManager_StepChanged);
     // Instantiate and add the connection control to the form
     ccsb = new CrmConnectionStatusBar(this.cManager);
     this.Controls.Add(ccsb);
 }
        /// <summary>
        /// Stores the organization service proxy.
        /// </summary>
        public Generator()
        {
            InitializeComponent();

            this.cManager = new McTools.Xrm.Connection.ConnectionManager(this);
            this.cManager.ConnectionFailed  += CManager_ConnectionFailed;
            this.cManager.ConnectionSucceed += CManager_ConnectionSucceed;
            this.cManager.StepChanged       += CManager_StepChanged;
            // Instantiate and add the connection control to the form
            ccsb = new CrmConnectionStatusBar(this.cManager);
            this.Controls.Add(ccsb);
        }
        /// <summary>
        /// Stores the organization service proxy.
        /// </summary>
        public Generator()
        {
            InitializeComponent();

            this.cManager = new McTools.Xrm.Connection.ConnectionManager(this);
            this.cManager.ConnectionFailed += CManager_ConnectionFailed;
            this.cManager.ConnectionSucceed += CManager_ConnectionSucceed;
            this.cManager.StepChanged += CManager_StepChanged;
            // Instantiate and add the connection control to the form
            ccsb = new CrmConnectionStatusBar(this.cManager);
            this.Controls.Add(ccsb);
        }
Example #4
0
        public Form1()
        {
            InitializeComponent();

            // Create the connection manager with its events
            this.cManager = new ConnectionManager();
            this.cManager.ConnectionSucceed += new ConnectionManager.ConnectionSucceedEventHandler(cManager_ConnectionSucceed);
            this.cManager.ConnectionFailed += new ConnectionManager.ConnectionFailedEventHandler(cManager_ConnectionFailed);
            this.cManager.StepChanged += new ConnectionManager.StepChangedEventHandler(cManager_StepChanged);
            this.cManager.RequestPassword += new ConnectionManager.RequestPasswordEventHandler(cManager_RequestPassword);
            this.cManager.UseProxy += new ConnectionManager.UseProxyEventHandler(cManager_UseProxy);
            formHelper = new FormHelper(this, cManager);

            // Instantiate and add the connection control to the form
            ccsb = new CrmConnectionStatusBar(this.cManager, formHelper);
            this.Controls.Add(ccsb);
        }
Example #5
0
        private void ManageConnectionControl()
        {
            cManager = ConnectionManager.Instance;
            cManager.RequestPassword += (sender, e) => fHelper.RequestPassword(e.ConnectionDetail);
            cManager.StepChanged += (sender, e) => ccsb.SetMessage(e.CurrentStep);
            cManager.ConnectionSucceed += (sender, e) =>
            {
                var parameter = e.Parameter as ConnectionParameterInfo;
                if (parameter != null)
                {
                    Controls.Remove(parameter.InfoPanel);
                    parameter.InfoPanel.Dispose();
                }

                currentConnectionDetail = e.ConnectionDetail;
                service = e.OrganizationService;
                ccsb.SetConnectionStatus(true, e.ConnectionDetail);
                ccsb.SetMessage(string.Empty);

                if (parameter != null)
                {
                    var control = parameter.ConnectionParmater as UserControl;
                    if (control != null)
                    {
                        var pluginModel = control.Tag as Lazy<IXrmToolBoxPlugin, IPluginMetadata>;
                        if (pluginModel == null)
                        {
                            // Actual Plugin was passed, Just update the plugin's Tab.
                            UpdateTabConnection((TabPage)control.Parent);
                        }
                        else
                        {
                            this.DisplayPluginControl(pluginModel);
                        }
                    }
                    else if (parameter.ConnectionParmater.ToString() == "ApplyConnectionToTabs" && tabControl1.TabPages.Count > 1)
                    {
                        ApplyConnectionToTabs();
                    }
                    else
                    {
                        var args = parameter.ConnectionParmater as RequestConnectionEventArgs;
                        if (args != null)
                        {
                            var userControl = (UserControl)args.Control;

                            args.Control.UpdateConnection(e.OrganizationService, currentConnectionDetail, args.ActionName, args.Parameter);

                            userControl.Parent.Text = string.Format("{0} ({1})",
                                userControl.Parent.Text.Split(' ')[0],
                                e.ConnectionDetail.ConnectionName);
                        }
                    }
                }
                else if (tabControl1.TabPages.Count > 1)
                {
                    ApplyConnectionToTabs();
                }

                this.StartPluginWithConnection();
            };
            cManager.ConnectionFailed += (sender, e) =>
            {
                this.Invoke(new Action(() =>
                {
                    var infoPanel = ((ConnectionParameterInfo)e.Parameter).InfoPanel;
                    Controls.Remove(infoPanel);
                    if (infoPanel != null) infoPanel.Dispose();

                    MessageBox.Show(this, e.FailureReason, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    currentConnectionDetail = null;
                    service = null;
                    ccsb.SetConnectionStatus(false, null);
                    ccsb.SetMessage(e.FailureReason);

                    this.StartPluginWithConnection();
                }));
            };

            fHelper = new FormHelper(this);
            ccsb = new CrmConnectionStatusBar(fHelper) { Dock = DockStyle.Bottom };
            Controls.Add(ccsb);
        }