Пример #1
0
        private void WhoAmI()
        {
            int i = 0;

            do
            {
                //WhoAmIRequest request = new WhoAmIRequest();
                //WhoAmIResponse response = (WhoAmIResponse)this.service.Execute(request);

                var user = this.service.RetrieveMultiple(new QueryExpression("systemuser")
                {
                    ColumnSet = new ColumnSet("fullname"),

                    Criteria = new FilterExpression
                    {
                        Conditions =
                        {
                            new ConditionExpression("systemuserid", ConditionOperator.EqualUserId)
                        }
                    }
                }).Entities.First();

                i++;

                ccsb.SetMessage("Doing...");
                ccsb.SetProgress(i * 10);

                lbLogs.Items.Add($"Hello {user.GetAttributeValue<string>("fullname")},Your ID is: {user.Id:B}");
            } while (i < 1);

            ccsb.SetMessage("Done");
            ccsb.SetProgress(null);
        }
Пример #2
0
        private void WhoAmI()
        {
            int i = 0;

            do
            {
                WhoAmIRequest  request  = new WhoAmIRequest();
                WhoAmIResponse response = (WhoAmIResponse)this.service.Execute(request);

                i++;

                ccsb.SetMessage("Doing...");
                ccsb.SetProgress(i * 10);

                MessageBox.Show(this, "Your ID is: " + response.UserId.ToString("B"));
            } while (i < 1);

            ccsb.SetMessage("Done");
            ccsb.SetProgress(null);
        }
Пример #3
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);
        }
Пример #4
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);
        }