示例#1
0
 /// <summary>
 /// TODO: I don't think this should be exposed to the user???
 /// </summary>
 /// <param name="scriptObject"></param>
 public void RemoveScriptObject(ScriptObject scriptObject)
 {
     if (ModelTypes.Table.IsInstanceOfType(scriptObject))
     {
         _tables.Remove((Table)scriptObject);
     }
     if (scriptObject.GetType() == typeof(View))
     {
         _views.Remove((View)scriptObject);
     }
     if (scriptObject.GetType() == typeof(StoredProcedure))
     {
         _storedProcedures.Remove((StoredProcedure)scriptObject);
     }
 }
示例#2
0
 /// <summary>
 /// TODO: I don't think this should be exposed to the user???
 /// </summary>
 /// <param name="scriptObject"></param>
 public void AddScriptObject(ScriptObject scriptObject)
 {
     if (ModelTypes.Table.IsInstanceOfType(scriptObject))
     {
         _tables.Add((Table)scriptObject);
     }
     if (scriptObject.GetType() == typeof(View))
     {
         _views.Add((View)scriptObject);
     }
     if (scriptObject.GetType() == typeof(StoredProcedure))
     {
         _storedProcedures.Add((StoredProcedure)scriptObject);
     }
     scriptObject.Database = this;
 }
示例#3
0
        private void UpdateScriptObjectNode(TreeListNode scriptObjectNode, ScriptObject scriptObject)
        {
            scriptObjectNode.SetValue(0, scriptObject.Alias);
            scriptObjectNode.SetValue(1, scriptObject.Name != scriptObject.Alias ? scriptObject.Name : null);
            scriptObjectNode.Tag = scriptObject;
            AddOptionNodes(scriptObjectNode, scriptObject);

            TreeListNode columnNodes = treeList.AppendNode(new object[] { "Columns", null, null }, scriptObjectNode);
            columnNodes.Tag = scriptObject.Columns;
            columnNodes.ImageIndex = columnNodes.SelectImageIndex = (int)Images.Column;

            foreach (Column column in scriptObject.Columns)
            {
                TreeListNode columnNode = treeList.AppendNode(GetTreeListNodeText(column), columnNodes);
                columnNode.Tag = column;
                columnNode.ImageIndex = columnNode.SelectImageIndex = (int)Images.GreenBullet;
                AddOptionNodes(columnNode, (ScriptBase)column);
            }

            TreeListNode relationshipNodes = treeList.AppendNode(new object[] { "Relationships" }, scriptObjectNode);
            relationshipNodes.Tag = scriptObject.Relationships;
            relationshipNodes.ImageIndex = relationshipNodes.SelectImageIndex = (int)Images.Relationship;

            TreeListNode oneToOneRelationshipNodes = treeList.AppendNode(new object[] { "One to One" }, relationshipNodes);
            oneToOneRelationshipNodes.Tag = scriptObject.OneToOneRelationships;
            oneToOneRelationshipNodes.ImageIndex = oneToOneRelationshipNodes.SelectImageIndex = (int)Images.Relationship;

            foreach (OneToOneRelationship oneToOneRelationship in scriptObject.OneToOneRelationships)
            {
                TreeListNode oneToOneRelationshipNode = treeList.AppendNode(GetTreeListNodeText(oneToOneRelationship), oneToOneRelationshipNodes);
                oneToOneRelationshipNode.Tag = oneToOneRelationship;
                oneToOneRelationshipNode.ImageIndex = oneToOneRelationshipNode.SelectImageIndex = (int)Images.GreenBullet;
                AddOptionNodes(oneToOneRelationshipNode, (ScriptBase)oneToOneRelationship);
            }

            TreeListNode oneToManyRelationshipNodes = treeList.AppendNode(new object[] { "One to Many" }, relationshipNodes);
            oneToManyRelationshipNodes.Tag = scriptObject.OneToManyRelationships;
            oneToManyRelationshipNodes.ImageIndex = oneToManyRelationshipNodes.SelectImageIndex = (int)Images.Relationship;

            foreach (OneToManyRelationship oneToManyRelationship in scriptObject.OneToManyRelationships)
            {
                TreeListNode oneToManyRelationshipNode = treeList.AppendNode(GetTreeListNodeText(oneToManyRelationship), oneToManyRelationshipNodes);
                oneToManyRelationshipNode.Tag = oneToManyRelationship;
                oneToManyRelationshipNode.ImageIndex = oneToManyRelationshipNode.SelectImageIndex = (int)Images.GreenBullet;
                AddOptionNodes(oneToManyRelationshipNode, (ScriptBase)oneToManyRelationship);
            }

            TreeListNode manyToOneRelationshipNodes = treeList.AppendNode(new object[] { "Many to One" }, relationshipNodes);
            manyToOneRelationshipNodes.Tag = scriptObject.ManyToOneRelationships;
            manyToOneRelationshipNodes.ImageIndex = manyToOneRelationshipNodes.SelectImageIndex = (int)Images.Relationship;

            foreach (ManyToOneRelationship manyToOneRelationship in scriptObject.ManyToOneRelationships)
            {
                TreeListNode manyToOneRelationshipNode = treeList.AppendNode(GetTreeListNodeText(manyToOneRelationship), manyToOneRelationshipNodes);
                manyToOneRelationshipNode.Tag = manyToOneRelationship;
                manyToOneRelationshipNode.ImageIndex = manyToOneRelationshipNode.SelectImageIndex = (int)Images.GreenBullet;
                AddOptionNodes(manyToOneRelationshipNode, (ScriptBase)manyToOneRelationship);
            }

            TreeListNode manyToManyRelationshipNodes = treeList.AppendNode(new object[] { "Many to Many" }, relationshipNodes);
            manyToManyRelationshipNodes.Tag = scriptObject.ManyToManyRelationships;
            manyToManyRelationshipNodes.ImageIndex = manyToManyRelationshipNodes.SelectImageIndex = (int)Images.Relationship;

            foreach (ManyToManyRelationship manyToManyRelationship in scriptObject.ManyToManyRelationships)
            {
                TreeListNode manyToManyRelationshipNode = treeList.AppendNode(GetTreeListNodeText(manyToManyRelationship), manyToManyRelationshipNodes);
                manyToManyRelationshipNode.Tag = manyToManyRelationship;
                manyToManyRelationshipNode.ImageIndex = manyToManyRelationshipNode.SelectImageIndex = (int)Images.GreenBullet;
                AddOptionNodes(manyToManyRelationshipNode, (ScriptBase)manyToManyRelationship);
            }

            TreeListNode filterNodes = treeList.AppendNode(new object[] { "Filters" }, scriptObjectNode);
            filterNodes.Tag = scriptObject.Filters;
            filterNodes.ImageIndex = filterNodes.SelectImageIndex = (int)Images.Filter;

            foreach (Filter filter in scriptObject.Filters)
            {
                TreeListNode filterNode = treeList.AppendNode(GetTreeListNodeText(filter), filterNodes);
                filterNode.Tag = filter;
                filterNode.ImageIndex = filterNode.SelectImageIndex = (int)Images.GreenBullet;
                AddOptionNodes(filterNode, (ScriptBase)filter);
            }

            if (scriptObject.GetType() == typeof(ArchAngel.Providers.Database.Model.Table))
            {
                ArchAngel.Providers.Database.Model.Table table = (ArchAngel.Providers.Database.Model.Table)scriptObject;
                TreeListNode indexNodes = treeList.AppendNode(new object[] { "Indexes" }, scriptObjectNode);
                indexNodes.Tag = table.Indexes;
                indexNodes.ImageIndex = indexNodes.SelectImageIndex = (int)Images.Index;

                foreach (Index index in table.Indexes)
                {
                    TreeListNode indexNode = treeList.AppendNode(GetTreeListNodeText(index), indexNodes);
                    indexNode.Tag = index;
                    indexNode.ImageIndex = indexNode.SelectImageIndex = (int)Images.GreenBullet;
                }

                TreeListNode keyNodes = treeList.AppendNode(new object[] { "Keys" }, scriptObjectNode);
                keyNodes.Tag = table.Keys;
                keyNodes.ImageIndex = keyNodes.SelectImageIndex = (int)Images.Key;

                foreach (Key key in table.Keys)
                {
                    TreeListNode keyNode = treeList.AppendNode(GetTreeListNodeText(key), keyNodes);
                    keyNode.Tag = key;
                    keyNode.ImageIndex = keyNode.SelectImageIndex = (int)Images.GreenBullet;
                }
            }

            if (scriptObject.GetType() == typeof(ArchAngel.Providers.Database.Model.StoredProcedure))
            {
                ArchAngel.Providers.Database.Model.StoredProcedure storedProcedure = (ArchAngel.Providers.Database.Model.StoredProcedure)scriptObject;
                TreeListNode parameterNodes = treeList.AppendNode(new object[] { "Parameters" }, scriptObjectNode);
                parameterNodes.Tag = storedProcedure.Parameters;
                parameterNodes.ImageIndex = parameterNodes.SelectImageIndex = (int)Images.StoredProcedure;

                foreach (ArchAngel.Providers.Database.Model.StoredProcedure.Parameter parameter in storedProcedure.Parameters)
                {
                    TreeListNode parameterNode = treeList.AppendNode(new object[] { parameter.Name, null, null }, parameterNodes);
                    parameterNode.Tag = parameter;
                    parameterNode.ImageIndex = parameterNode.SelectImageIndex = (int)Images.GreenBullet;
                }
            }
        }
示例#4
0
        private void SetupNewTreeListNode(TreeListNode treeListNode, ScriptObject scriptObject)
        {
            TreeListNode columnNodes = treeList.AppendNode(new object[] { "Columns", null, null }, treeListNode);
            columnNodes.Tag = scriptObject.Columns;

            TreeListNode relationshipNodes = treeList.AppendNode(new object[] { "Relationships", null, null }, treeListNode);
            relationshipNodes.Tag = scriptObject.Relationships;

            TreeListNode oneToOneRelationshipNodes = treeList.AppendNode(new object[] { "One to One", null, null }, relationshipNodes);
            oneToOneRelationshipNodes.Tag = scriptObject.OneToOneRelationships;

            TreeListNode oneToManyRelationshipNodes = treeList.AppendNode(new object[] { "One to Many", null, null }, relationshipNodes);
            oneToManyRelationshipNodes.Tag = scriptObject.OneToManyRelationships;

            TreeListNode manyToOneRelationshipNodes = treeList.AppendNode(new object[] { "Many to One", null, null }, relationshipNodes);
            manyToOneRelationshipNodes.Tag = scriptObject.ManyToOneRelationships;

            TreeListNode manyToManyRelationshipNodes = treeList.AppendNode(new object[] { "Many to Many", null, null }, relationshipNodes);
            manyToManyRelationshipNodes.Tag = scriptObject.ManyToManyRelationships;

            TreeListNode filterNodes = treeList.AppendNode(new object[] { "Filters", null, null }, treeListNode);
            filterNodes.Tag = scriptObject.Filters;

            if (scriptObject.GetType() == typeof(ArchAngel.Providers.Database.Model.Table))
            {
                ArchAngel.Providers.Database.Model.Table table = (ArchAngel.Providers.Database.Model.Table)scriptObject;

                TreeListNode indexNodes = treeList.AppendNode(new object[] { "Indexes", null, null }, treeListNode);
                indexNodes.Tag = table.Indexes;

                TreeListNode keyNodes = treeList.AppendNode(new object[] { "Keys", null, null }, treeListNode);
                keyNodes.Tag = table.Keys;
            }
        }
示例#5
0
            private static ScriptObject GetNewScriptBase(ScriptObject[] newScriptObjects, ScriptObject oldScriptObject)
            {
            // Look for script object still existing
            ScriptObject newScriptObject = Search.GetScriptObject(newScriptObjects, oldScriptObject, oldScriptObject.GetType(), false);
            //if (newScriptObject == null)
            //{
            //    string errorMessage = oldImmediateParent.GetType().Name + " " + oldImmediateParent.Alias + " references deleted script object " + oldScriptObject.Alias +
            //        ".\n" + oldScriptObject.GetType().Name + " " + oldScriptObject.Alias + " does not exist anymore." +
            //        "\nPlease delete " + oldScriptObject.GetType().Name + " " + oldScriptObject.Alias + " from this " + oldImmediateParent.GetType().Name;
            //    throw new Exception(errorMessage);
            //}

            return newScriptObject;
            }
示例#6
0
        private void UpdateScriptObjectNode(Node scriptObjectNode, ScriptObject scriptObject, Images image)
        {
            scriptObjectNode.Cells[0].Text = scriptObject.Alias;
            scriptObjectNode.Cells[1].Text = scriptObject.Name != scriptObject.Alias ? scriptObject.Name : "";
            scriptObjectNode.Tag = scriptObject;
            SetNodeImage(scriptObjectNode, image);
            scriptObjectNode.CheckBoxVisible = true;
            scriptObjectNode.Checked = scriptObject.Enabled;
            AddOptionNodes(scriptObjectNode, scriptObject);

            #region Columns

            Node columnNodes = AddNode(scriptObjectNode, "Columns", scriptObject.Columns, Images.Column,
                                                             false, true);

            if (scriptObject.Columns.Length > 0)
            {
                AddNode(columnNodes, "", "LAZY", Images.Unchecked, true, false);
            }

            #endregion

            #region Relationships

            Node relationshipNodes = AddNode(scriptObjectNode, "Relationships", scriptObject.Relationships, Images.Relationship,
                                             false, true);

            #region One-to-one relationships

            Node oneToOneRelationshipNodes = AddNode(relationshipNodes, "One to One", scriptObject.OneToOneRelationships,
                                                     Images.Relationship, false, true);

            if (scriptObject.OneToOneRelationships.Length > 0)
            {
                AddNode(oneToOneRelationshipNodes, "", "LAZY", Images.Unchecked, true, false);
            }

            #endregion

            #region One-to-many relationships

            Node oneToManyRelationshipNodes = AddNode(relationshipNodes, "One to Many",
                                                                            scriptObject.OneToManyRelationships,
                                                                            Images.Relationship, false, true);

            if (scriptObject.OneToManyRelationships.Length > 0)
            {
                AddNode(oneToManyRelationshipNodes, "", "LAZY", Images.Unchecked, true, false);
            }

            #endregion

            #region Many-to-one relationships

            Node manyToOneRelationshipNodes = AddNode(relationshipNodes, "Many to One",
                                                                            scriptObject.ManyToOneRelationships,
                                                                            Images.Relationship, false, true);

            if (scriptObject.ManyToOneRelationships.Length > 0)
            {
                AddNode(manyToOneRelationshipNodes, "", "LAZY", Images.Unchecked, true, false);
            }

            #endregion

            #region Many-to-many relationships

            Node manyToManyRelationshipNodes = AddNode(relationshipNodes, "Many to Many", scriptObject.ManyToManyRelationships,
                                                       Images.Relationship, false, true);

            if (scriptObject.ManyToManyRelationships.Length > 0)
            {
                AddNode(manyToManyRelationshipNodes, "", "LAZY", Images.Unchecked, true, false);
            }

            #endregion

            #endregion

            #region Filters

            Node filterNodes = AddNode(scriptObjectNode, "Filters", scriptObject.Filters, Images.Filter,
                                                             false, true);

            if (scriptObject.Filters.Length > 0)
            {
                AddNode(filterNodes, "", "LAZY", Images.Unchecked, true, false);
            }

            #endregion

            #region Associations

            Node associationNodes = AddNode(scriptObjectNode, "Associations", scriptObject.Associations,
                                                                  Images.Association, false, true);

            if (scriptObject.Associations.Count > 0)
            {
                AddNode(associationNodes, "", "LAZY", Images.Unchecked, true, false);
            }

            #endregion

            #region Table-only nodes

            if (scriptObject.GetType() == typeof (Table))
            {
                Table table = (Table) scriptObject;
                Node indexNodes = AddNode(scriptObjectNode, "Indexes", table.Indexes, Images.Index, false,
                                                                true);

                if (table.Indexes.Length > 0)
                {
                    AddNode(indexNodes, "", "LAZY", Images.Unchecked, true, false);
                }
                Node keyNodes = AddNode(scriptObjectNode, "Keys", table.Keys, Images.Key, false, true);

                if (table.Keys.Length > 0)
                {
                    AddNode(keyNodes, "", "LAZY", Images.Unchecked, true, false);
                }
            }

            #endregion

            #region Stored-procedure-only nodes

            if (scriptObject.GetType() == typeof (StoredProcedure))
            {
                StoredProcedure storedProcedure = (StoredProcedure) scriptObject;
                Node parameterNodes = AddNode(scriptObjectNode, "Parameters", storedProcedure.Parameters,
                                                                    Images.StoredProcedure, false, true);

                if (storedProcedure.Parameters.Length > 0)
                {
                    AddNode(parameterNodes, "", "LAZY", Images.Unchecked, true, false);
                }
            }

            #endregion
        }
示例#7
0
        private void SetupNewTreeListNode(Node treeListNode, ScriptObject scriptObject)
        {
            Node associationNodes = AddNode(treeListNode, "Associations", scriptObject.Associations, Images.Association, false,
                                            true);
            Node columnNodes = AddNode(treeListNode, "Columns", scriptObject.Columns, Images.Column, false, true);
            Node relationshipNodes = AddNode(treeListNode, "Relationships", scriptObject.Relationships, Images.Relationship,
                                             false, true);
            Node oneToOneRelationshipNodes = AddNode(relationshipNodes, "One to One", scriptObject.OneToOneRelationships,
                                                     Images.Relationship, false, true);
            Node oneToManyRelationshipNodes = AddNode(relationshipNodes, "One to Many", scriptObject.OneToManyRelationships,
                                                      Images.Relationship, false, true);
            Node manyToOneRelationshipNodes = AddNode(relationshipNodes, "Many to One", scriptObject.ManyToOneRelationships,
                                                      Images.Relationship, false, true);
            Node manyToManyRelationshipNodes = AddNode(relationshipNodes, "Many to Many", scriptObject.ManyToManyRelationships,
                                                       Images.Relationship, false, true);
            Node filterNodes = AddNode(treeListNode, "Filters", scriptObject.Filters, Images.Filter, false, true);

            if (scriptObject.GetType() == typeof (Table))
            {
                Table table = (Table) scriptObject;
                Node indexNodes = AddNode(treeListNode, "Indexes", table.Indexes, Images.Index, false, true);
                Node keyNodes = AddNode(treeListNode, "Keys", table.Keys, Images.Key, false, true);
            }
        }