Ejemplo n.º 1
0
 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);
        }
Ejemplo n.º 4
0
        public Form1()
        {
            InitializeComponent();
            // Create the connection manager with its events
            this.cManager = ConnectionManager.Instance;
            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);
            formHelper = new FormHelper(this);

            // Instantiate and add the connection control to the form
            ccsb = new CrmConnectionStatusBar(formHelper);
            this.Controls.Add(ccsb);

            this.ccsb.SetMessage("A message to display...");
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        private void ManageConnectionControl()
        {
            cManager = new ConnectionManager();
            cManager.RequestPassword   += (sender, e) => fHelper.RequestPassword(e.ConnectionDetail);
            cManager.StepChanged       += (sender, e) => ccsb.SetMessage(e.CurrentStep);
            cManager.ConnectionSucceed += (sender, e) =>
            {
                Controls.Remove(infoPanel);
                if (infoPanel != null)
                {
                    infoPanel.Dispose();
                }

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

                if (e.Parameter != null)
                {
                    var control = e.Parameter as UserControl;
                    if (control != null)
                    {
                        var realUserControl = control;
                        DisplayPluginControl(realUserControl);
                    }
                    else if (e.Parameter.ToString() == "ApplyConnectionToTabs" && tabControl1.TabPages.Count > 1)
                    {
                        ApplyConnectionToTabs();
                    }
                    else
                    {
                        var args = e.Parameter 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();
                }
            };
            cManager.ConnectionFailed += (sender, e) =>
            {
                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);
            };
            fHelper = new FormHelper(this, cManager);
            ccsb    = new CrmConnectionStatusBar(cManager, fHelper)
            {
                Dock = DockStyle.Bottom
            };
            Controls.Add(ccsb);
        }
Ejemplo n.º 7
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);
        }