示例#1
0
        public void AddConnection(ConnectionDetail con)
        {
            var conNode = treeView.Nodes.Add(con.ConnectionName);

            conNode.Tag = con;
            conNode.ContextMenuStrip = serverContextMenuStrip;
            SetIcon(conNode, "Environment");
            var entitiesNode = conNode.Nodes.Add("Entities");

            SetIcon(entitiesNode, "Folder");
            AddVirtualChildNodes(entitiesNode, LoadEntities);
            treeView.SelectedNode = conNode;

            if (new Uri(con.OrganizationServiceUrl).Host.EndsWith(".dynamics.com") &&
                new Version(con.OrganizationVersion) >= new Version("9.1.0.17437"))
            {
                var tsqlNode = conNode.Nodes.Add("T-SQL Endpoint");

                if (TSqlEndpoint.IsEnabled(con.ServiceClient))
                {
                    if (!String.IsNullOrEmpty(con.ServiceClient.CurrentAccessToken))
                    {
                        tsqlNode.ImageIndex         = 21;
                        tsqlNode.SelectedImageIndex = 21;
                    }
                    else
                    {
                        tsqlNode.Text              += " (Unavailable - OAuth authentication required)";
                        tsqlNode.ImageIndex         = 22;
                        tsqlNode.SelectedImageIndex = 22;
                    }
                }
                else
                {
                    tsqlNode.Text              += " (Disabled)";
                    tsqlNode.ImageIndex         = 20;
                    tsqlNode.SelectedImageIndex = 20;
                }

                tsqlNode.ContextMenuStrip = tsqlContextMenuStrip;
            }

            conNode.Expand();
        }
示例#2
0
        private void AddConnectionChildNodes(ConnectionDetail con, CrmServiceClient svc, TreeNode conNode)
        {
            var entitiesNode = conNode.Nodes.Add("Entities");

            SetIcon(entitiesNode, "Folder");
            AddVirtualChildNodes(entitiesNode, LoadEntities);
            var metadataNode = conNode.Nodes.Add("Metadata");

            SetIcon(metadataNode, "Folder");
            AddVirtualChildNodes(metadataNode, LoadMetadata);
            treeView.SelectedNode = conNode;

            if (new Uri(con.OrganizationServiceUrl).Host.EndsWith(".dynamics.com") &&
                new Version(con.OrganizationVersion) >= new Version("9.1.0.17437"))
            {
                var tsqlNode = conNode.Nodes.Add("TDS Endpoint");

                if (TSqlEndpoint.IsEnabled(svc))
                {
                    if (!String.IsNullOrEmpty(svc.CurrentAccessToken))
                    {
                        tsqlNode.ImageIndex         = 21;
                        tsqlNode.SelectedImageIndex = 21;
                    }
                    else
                    {
                        tsqlNode.Text              += " (Unavailable - OAuth authentication required)";
                        tsqlNode.ImageIndex         = 22;
                        tsqlNode.SelectedImageIndex = 22;
                    }
                }
                else
                {
                    tsqlNode.Text              += " (Disabled)";
                    tsqlNode.ImageIndex         = 20;
                    tsqlNode.SelectedImageIndex = 20;
                }

                tsqlNode.ContextMenuStrip = tsqlContextMenuStrip;
            }

            conNode.Expand();
        }