Example #1
0
 private bool CheckRefType(__DSREFTYPE type)
 {
     if (_consumer != null)
     {
         try
         {
             return((_consumer.GetType(RootNode) & type) == type);
         }
         catch { }
     }
     return(false);
 }
Example #2
0
            /// <summary>
            /// Convert the node structure to a string. Note that these properties are
            /// not intended to be used by a normal application and are not necessarily
            /// stable. They are only provided to aid in debugging.
            /// </summary>
            /// <param name="type">DSRef node type</param>
            /// <returns>Description of the structure</returns>
            private string GetNodeStructure(__DSREFTYPE type)
            {
                // Convert the flag enumeration to a set of legible strings
                List <string> structure = new List <string>();

                if ((type & __DSREFTYPE.DSREFTYPE_NODE) ==
                    __DSREFTYPE.DSREFTYPE_NODE)
                {
                    structure.Add("Node");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_HASNAME) ==
                    __DSREFTYPE.DSREFTYPE_HASNAME)
                {
                    structure.Add("Name");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_HASMONIKER) ==
                    __DSREFTYPE.DSREFTYPE_HASMONIKER)
                {
                    structure.Add("Moniker");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_HASOWNER) ==
                    __DSREFTYPE.DSREFTYPE_HASOWNER)
                {
                    structure.Add("Owner");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_HASPROP) ==
                    __DSREFTYPE.DSREFTYPE_HASPROP)
                {
                    structure.Add("Additional Properties");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_HASFIRSTCHILD) ==
                    __DSREFTYPE.DSREFTYPE_HASFIRSTCHILD)
                {
                    structure.Add("Children");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_HASNEXTSIBLING) ==
                    __DSREFTYPE.DSREFTYPE_HASNEXTSIBLING)
                {
                    structure.Add("Sibling");
                }
                return(string.Join(", ", structure.ToArray()));
            }
Example #3
0
            /// <summary>
            /// Build a tree of the DSRef Consumer's selection starting with the provided
            /// node in the DSRef Consumer and node in the TreeView
            /// </summary>
            /// <param name="consumer">DSRef Consumer containing the selection</param>
            /// <param name="node">Current node in the DSRef Consumer</param>
            /// <param name="treeNode">Node in the tree</param>
            private void BuildTree(IDSRefConsumer consumer, IntPtr node,
                                   System.Windows.Forms.TreeNode treeNode)
            {
                // Copy the properties for the current node given its type
                treeNode.Text = "";
                __DSREFTYPE type = consumer.GetType(node);

                if ((type & __DSREFTYPE.DSREFTYPE_HASNAME) ==
                    __DSREFTYPE.DSREFTYPE_HASNAME)
                {
                    treeNode.Text = string.Format("{0} ", consumer.GetName(node));
                }
                treeNode.Text += string.Format("(Type: {0}", GetNodeTypes(type));
                string structure = GetNodeStructure(type);

                if (!string.IsNullOrEmpty(structure))
                {
                    treeNode.Text += string.Format(" || Structure: {0}", structure);
                }
                if ((type & __DSREFTYPE.DSREFTYPE_HASOWNER) ==
                    __DSREFTYPE.DSREFTYPE_HASOWNER)
                {
                    treeNode.Text += string.Format(" || Owner: {0}", consumer.GetOwner(node));
                }
                treeNode.Text += ")";

                // Iterate over the children
                IntPtr child = consumer.GetFirstChildNode(node);

                while (child != IntPtr.Zero)
                {
                    // Create a tree node for the child and set its properties
                    TreeNode next = new TreeNode();
                    treeNode.Nodes.Add(next);
                    BuildTree(consumer, child, next);

                    // Move to the next child
                    child = consumer.GetNextSiblingNode(child);
                }
            }
Example #4
0
        /// <summary>
        /// Enumerate the names of the tables in the selection represented by
        /// the DSRef Consumer
        /// </summary>
        public IEnumerable <DSLFactory.Candle.SystemModel.Utilities.SchemaDiscover.DbTable> GetTables(System.IServiceProvider serviceProvider)
        {
            foreach (IntPtr child in ChildNodes)
            {
                __DSREFTYPE type = _consumer.GetType(child);
                string      name = String.Empty;
                if ((type & __DSREFTYPE.DSREFTYPE_HASNAME) == __DSREFTYPE.DSREFTYPE_HASNAME)
                {
                    name = _consumer.GetName(child);
                }

                if ((type & __DSREFTYPE.DSREFTYPE_TABLE) == __DSREFTYPE.DSREFTYPE_TABLE)
                {
                    DSLFactory.Candle.SystemModel.Utilities.SchemaDiscover.DbTable table = new DSLFactory.Candle.SystemModel.Utilities.SchemaDiscover.DbTable();
                    table.Name  = name;
                    table.Owner = string.Empty;
                    if ((type & __DSREFTYPE.DSREFTYPE_HASOWNER) == __DSREFTYPE.DSREFTYPE_HASOWNER)
                    {
                        table.Owner = _consumer.GetOwner(child);
                    }

                    yield return(table);
                }
                else if ((type & __DSREFTYPE.DSREFTYPE_DATASOURCEROOT) == __DSREFTYPE.DSREFTYPE_DATASOURCEROOT)
                {
                    Guid   guid1 = new Guid("B30985D6-6BBB-45f2-9AB8-371664F03270");
                    string text1 = _consumer.GetProperty(child, ref guid1) as string;
                    Guid   guid2 = Guid.Empty;
                    if (!String.IsNullOrEmpty(text1))
                    {
                        guid2 = new Guid(text1);
                    }
                    DataConnection connection = ((DataConnectionManager)serviceProvider.GetService(typeof(DataConnectionManager))).GetDataConnection(guid2, name, false);
                    if (connection != null)
                    {
                        dataConnection = connection.ConnectionSupport.ProviderObject as IDbConnection;
                    }
                }
            }
        }
Example #5
0
            /// <summary>
            /// Convert the type of a node to a string
            /// </summary>
            /// <param name="type">Type of a DSRef node</param>
            /// <returns>String representation of the node type</returns>
            private string GetNodeTypes(__DSREFTYPE type)
            {
                // Convert the flag enumeration to a set of legible strings
                List <string> names = new List <string>();

                if ((type & __DSREFTYPE.DSREFTYPE_COLLECTION) ==
                    __DSREFTYPE.DSREFTYPE_COLLECTION)
                {
                    names.Add("Collection");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_MULTIPLE) ==
                    __DSREFTYPE.DSREFTYPE_MULTIPLE)
                {
                    names.Add("Multiple Selection");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_MIXED) ==
                    __DSREFTYPE.DSREFTYPE_MIXED)
                {
                    names.Add("Collecion of Multiple Selections");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_DATABASE) ==
                    __DSREFTYPE.DSREFTYPE_DATABASE)
                {
                    names.Add("Database");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_DATASOURCEROOT) ==
                    __DSREFTYPE.DSREFTYPE_DATASOURCEROOT)
                {
                    names.Add("Data Source Root");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_EXTENDED) ==
                    __DSREFTYPE.DSREFTYPE_EXTENDED)
                {
                    names.Add("[Extended]");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_FIELD) ==
                    __DSREFTYPE.DSREFTYPE_FIELD)
                {
                    names.Add("Field");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_FUNCTION) ==
                    __DSREFTYPE.DSREFTYPE_FUNCTION)
                {
                    names.Add("Function");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_INDEX) ==
                    __DSREFTYPE.DSREFTYPE_INDEX)
                {
                    names.Add("Index");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_PACKAGE) ==
                    __DSREFTYPE.DSREFTYPE_PACKAGE)
                {
                    names.Add("Package");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_PACKAGEBODY) ==
                    __DSREFTYPE.DSREFTYPE_PACKAGEBODY)
                {
                    names.Add("Package Body");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_QUERY) ==
                    __DSREFTYPE.DSREFTYPE_QUERY)
                {
                    names.Add("Query");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_RELATIONSHIP) ==
                    __DSREFTYPE.DSREFTYPE_RELATIONSHIP)
                {
                    names.Add("Relationship");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_SCHEMADIAGRAM) ==
                    __DSREFTYPE.DSREFTYPE_SCHEMADIAGRAM)
                {
                    names.Add("Schema Diagram");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_STOREDPROCEDURE) ==
                    __DSREFTYPE.DSREFTYPE_STOREDPROCEDURE)
                {
                    names.Add("Stored Procedure");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_SYNONYM) ==
                    __DSREFTYPE.DSREFTYPE_SYNONYM)
                {
                    names.Add("Synonym");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_TABLE) ==
                    __DSREFTYPE.DSREFTYPE_TABLE)
                {
                    names.Add("Table");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_TRIGGER) ==
                    __DSREFTYPE.DSREFTYPE_TRIGGER)
                {
                    names.Add("Trigger");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_USERDEFINEDTYPE) ==
                    __DSREFTYPE.DSREFTYPE_USERDEFINEDTYPE)
                {
                    names.Add("User Defined Type");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_VIEW) ==
                    __DSREFTYPE.DSREFTYPE_VIEW)
                {
                    names.Add("View");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_VIEWINDEX) ==
                    __DSREFTYPE.DSREFTYPE_VIEWINDEX)
                {
                    names.Add("View Index");
                }
                if ((type & __DSREFTYPE.DSREFTYPE_VIEWTRIGGER) ==
                    __DSREFTYPE.DSREFTYPE_VIEWTRIGGER)
                {
                    names.Add("View Trigger");
                }
                return(string.Join(", ", names.ToArray()));
            }