private static void TreeListNodeColor(TreeListNode treeListNode, Color color) { //treeListNode.ForeColor = color; foreach (TreeListNode childTreeListNode in treeListNode.Nodes) { //Thread.Sleep(1); if (ArchAngel.Providers.Database.BLL.Helper.GetBaseType(childTreeListNode.Tag) == typeof(ScriptBase)) { ScriptBase scriptBase = (ScriptBase)childTreeListNode.Tag; if (!scriptBase.Enabled) { continue; } if (scriptBase.GetType() == typeof(MapColumn)) { color = Color.Green; } else { if (scriptBase.IsUserDefined) { color = Color.Blue; } } } TreeListNodeColor(childTreeListNode, color); } }
EventHandler GetScriptMenuItemClickHandler(ScriptBase script) { var handler = new EventHandler((sender, e) => { var newInstance = scriptMgr.CreateScriptFromType(script.GetType()); scriptMgr.RunScript(newInstance); }); return(handler); }
private string[] GetTreeListNodeText(ScriptBase scriptBase) { if (scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.Table) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.View) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.StoredProcedure) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.Column) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.Filter) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.Index) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.Key)) { return new string[] { scriptBase.Alias, scriptBase.Name != scriptBase.Alias ? scriptBase.Name : null, null }; } if (scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.MapColumn)) { MapColumn mapColumn = (MapColumn)scriptBase; return new string[] { scriptBase.Alias, scriptBase.Name != scriptBase.Alias ? scriptBase.Name : null, mapColumn.ForeignColumn.Parent.Alias + "." + mapColumn.ForeignColumn.Alias }; } if (scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.OneToOneRelationship) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.OneToManyRelationship) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.ManyToOneRelationship) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.ManyToManyRelationship)) { Relationship relationship = (Relationship)scriptBase; return new string[] { scriptBase.Alias, scriptBase.Name != scriptBase.Alias ? scriptBase.Name : null, relationship.Path }; } throw new Exception("ScriptBase Type " + scriptBase.GetType().Name + " not found"); }
/// <summary> /// Adds per-object options to ScriptObject node. /// </summary> /// <param name="scriptObjectNode"></param> /// <param name="scriptObject"></param> private void AddOptionNodes(TreeListNode scriptObjectNode, ScriptBase scriptObject) { string typeName = scriptObject.GetType().ToString(); switch (typeName) { case "ArchAngel.Providers.Database.Model.MapColumn": case "ArchAngel.Providers.Database.Model.Column": AddIndividualOptions(scriptObjectNode, _optionsForColumns, scriptObject); break; case "ArchAngel.Providers.Database.Model.Filter": AddIndividualOptions(scriptObjectNode, _optionsForFilters, scriptObject); break; case "ArchAngel.Providers.Database.Model.Index": AddIndividualOptions(scriptObjectNode, _optionsForIndexes, scriptObject); break; case "ArchAngel.Providers.Database.Model.Key": AddIndividualOptions(scriptObjectNode, _optionsForKeys, scriptObject); break; case "ArchAngel.Providers.Database.Model.ManyToManyRelationship": AddIndividualOptions(scriptObjectNode, _optionsForManyToManyRelationship, scriptObject); break; case "ArchAngel.Providers.Database.Model.ManyToOneRelationship": AddIndividualOptions(scriptObjectNode, _optionsForManyToOneRelationship, scriptObject); break; case "ArchAngel.Providers.Database.Model.OneToManyRelationship": AddIndividualOptions(scriptObjectNode, _optionsForOneToManyRelationship, scriptObject); break; case "ArchAngel.Providers.Database.Model.OneToOneRelationship": AddIndividualOptions(scriptObjectNode, _optionsForOneToOneRelationships, scriptObject); break; case "ArchAngel.Providers.Database.Model.ScriptObject": AddIndividualOptions(scriptObjectNode, _optionsForScriptObjects, scriptObject); break; case "ArchAngel.Providers.Database.Model.StoredProcedure": AddIndividualOptions(scriptObjectNode, _optionsForStoredProcedures, scriptObject); break; case "ArchAngel.Providers.Database.Model.Table": AddIndividualOptions(scriptObjectNode, _optionsForTable, scriptObject); break; case "ArchAngel.Providers.Database.Model.View": AddIndividualOptions(scriptObjectNode, _optionsForViews, scriptObject); break; default: throw new NotImplementedException("Not coded yet:" + typeName); } }
public static void TreeListNodeError(DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs e) { return; TreeListNode treeListNode = e.Node; if (treeListNode.StateImageIndex == 0) { return; } if (ArchAngel.Providers.Database.BLL.Helper.GetBaseType(treeListNode.Tag) == typeof(ScriptBase)) { ScriptBase scriptBase = (ScriptBase)treeListNode.Tag; if (scriptBase.Enabled) { bool errorNode = false; if (scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.Table) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.View) || scriptBase.GetType() == typeof(ArchAngel.Providers.Database.Model.StoredProcedure)) { if (CountAlias(Controller.Instance.BllDatabase.EnabledScriptObjects, scriptBase.Alias) > 1) { errorNode = true; //treeListNode.TreeList.SetColumnError(treeListNode.TreeList.Columns[0], "Duplicate alias: More than one item has the same alias. Right-click one of the duplicate nodes to change its name to be unique."); } } if (scriptBase.GetType() == typeof(Column) || scriptBase.GetType() == typeof(MapColumn)) { ScriptObject scriptObject = ((Column)scriptBase).Parent; if (CountAlias(ScriptBLL.GetEnabledColumns(scriptObject.Columns), scriptBase.Alias) > 1) { errorNode = true; //treeListNode.TreeList.SetColumnError(treeListNode.TreeList.Columns[0], "Duplicate alias: More than one column has the same alias. Right-click one of the duplicate columns to change its name to be unique."); } } if (scriptBase.GetType() == typeof(Key)) { ArchAngel.Providers.Database.Model.Table table = (ArchAngel.Providers.Database.Model.Table)((Key)scriptBase).Parent; if (CountAlias(ScriptBLL.GetEnabledKeys(table.Keys), scriptBase.Alias) > 1) { errorNode = true; //treeListNode.TreeList.SetColumnError(treeListNode.TreeList.Columns[0], "Duplicate alias: More than one key has the same alias. Right-click one of the duplicate keys to change its name to be unique."); } } if (scriptBase.GetType() == typeof(Filter)) { ScriptObject scriptObject = (ScriptObject)((Filter)scriptBase).Parent; if (CountAlias(ScriptBLL.GetEnabledFilters(scriptObject.Filters), scriptBase.Alias) > 1) { errorNode = true; //treeListNode.TreeList.SetColumnError(treeListNode.TreeList.Columns[0], "Duplicate alias: More than one filter has the same alias. Right-click one of the duplicate filters to change its name to be unique."); } } if (scriptBase.GetType() == typeof(OneToOneRelationship) || scriptBase.GetType() == typeof(OneToManyRelationship) || scriptBase.GetType() == typeof(ManyToOneRelationship) || scriptBase.GetType() == typeof(ManyToManyRelationship)) { ScriptObject scriptObject = (ScriptObject)((Relationship)scriptBase).Parent; if (CountAlias(ScriptBLL.GetEnabledRelationships(scriptObject.Relationships), scriptBase.Alias) > 1) { errorNode = true; //treeListNode.TreeList.SetColumnError(treeListNode.TreeList.Columns[0], "Duplicate alias: More than one relationship has the same alias. Right-click one of the duplicate relationships to change its name to be unique."); } } if (errorNode) { e.Appearance.ForeColor = Color.Red; // Parents are shown as red also /*TreeListNode parentTreeListNode = treeListNode.ParentNode; * while (parentTreeListNode != null) * { * //parentTreeListNode.ForeColor = Color.Red; * parentTreeListNode = parentTreeListNode.ParentNode; * }*/ } else { //treeListNode.TreeList.ToolTipController.SetToolTip(treeListNode, ""); } } } /*foreach (TreeListNode childTreeListNode in treeListNode.Nodes) * { * if (ArchAngel.Providers.Database.BLL.Helper.GetBaseType(childTreeListNode.Tag) == typeof(ScriptBase)) * { * ScriptBase scriptBase = (ScriptBase)childTreeListNode.Tag; * if (!scriptBase.Enabled) * { * continue; * } * } * * TreeListNodeError(childTreeListNode); * }*/ }
private static Column GetNewScriptBase(ScriptObject[] newScriptObjects, ScriptBase oldImmediateParent, Column oldColumn) { // Look for script object still existing ScriptObject newScriptObject = GetNewScriptBase(newScriptObjects, oldColumn.Parent); // Look for column still existing Column newColumn = Search.GetColumn(newScriptObject.Columns, oldColumn.Name, false); // Stored procedure create columns in place of parameters in order to create filters if (newColumn == null && newScriptObject.GetType() == typeof(Model.StoredProcedure)) { Model.StoredProcedure newStoredProcedure = (Model.StoredProcedure)newScriptObject; Model.StoredProcedure.Parameter parameter = Search.GetParameter(newStoredProcedure.Parameters, oldColumn.Name); if (parameter == null) { string errorMessage = oldImmediateParent.GetType().Name + " " + oldImmediateParent.Alias + " references deleted parameter " + oldColumn.Alias + " of script object " + oldColumn.Parent.Alias + ".\n" + oldColumn.GetType().Name + " " + oldColumn.Alias + " does not exist anymore." + "\nPlease delete " + oldColumn.GetType().Name + " " + oldColumn.Alias + " from this " + oldImmediateParent.GetType().Name; throw new Exception(errorMessage); } // Create columns for parameter as it is used as a filter column newColumn = new Column(parameter.Name, false, newScriptObject, parameter.OrdinalPosition, false, parameter.DataType, parameter.Size, false, false, "", true, false, parameter.Precision, parameter.Scale); } if (newColumn == null) { string errorMessage = oldImmediateParent.GetType().Name + " " + oldImmediateParent.Alias + " references deleted column " + oldColumn.Alias + " of script object " + oldColumn.Parent.Alias + ".\n" + oldColumn.GetType().Name + " " + oldColumn.Alias + " does not exist anymore." + "\nPlease delete " + oldColumn.GetType().Name + " " + oldColumn.Alias + " from this " + oldImmediateParent.GetType().Name; throw new Exception(errorMessage); } return newColumn; }
private void AddOptionNodes(Node scriptObjectNode, ScriptBase scriptObject) { string scriptObjectTypeName = scriptObject.GetType().FullName; if (scriptObjectTypeName == ModelTypes.MapColumn.FullName || scriptObjectTypeName == ModelTypes.Column.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForColumns, scriptObject); } else if (scriptObjectTypeName == ModelTypes.Filter.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForFilters, scriptObject); } else if (scriptObjectTypeName == ModelTypes.Index.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForIndexes, scriptObject); } else if (scriptObjectTypeName == ModelTypes.Key.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForKeys, scriptObject); } else if (scriptObjectTypeName == ModelTypes.ManyToManyRelationship.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForManyToManyRelationship, scriptObject); } else if (scriptObjectTypeName == ModelTypes.ManyToOneRelationship.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForManyToOneRelationship, scriptObject); } else if (scriptObjectTypeName == ModelTypes.OneToManyRelationship.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForOneToManyRelationship, scriptObject); } else if (scriptObjectTypeName == ModelTypes.OneToOneRelationship.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForOneToOneRelationships, scriptObject); } else if (scriptObjectTypeName == ModelTypes.ScriptObject.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForScriptObjects, scriptObject); } else if (scriptObjectTypeName == ModelTypes.StoredProcedure.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForStoredProcedures, scriptObject); } else if (scriptObjectTypeName == ModelTypes.Table.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForTable, scriptObject); } else if (scriptObjectTypeName == ModelTypes.View.FullName) { AddIndividualOptions(scriptObjectNode, _optionsForViews, scriptObject); } else { throw new NotImplementedException("Not coded yet:" + scriptObject.GetType().FullName + ". Apparently '" + scriptObjectTypeName + "' != '" + ModelTypes.Table.FullName + "'."); } }
private static void GetTreeListNodeText(ScriptBase scriptBase, Node node) { if (scriptBase.GetType() == typeof (Table) || scriptBase.GetType() == typeof (View) || scriptBase.GetType() == typeof (StoredProcedure) || scriptBase.GetType() == typeof (Column) || scriptBase.GetType() == typeof (Filter) || scriptBase.GetType() == typeof (Index) || scriptBase.GetType() == typeof (Key) || scriptBase.GetType() == typeof (Association)) { node.Text = scriptBase.Alias; if (scriptBase.Name != scriptBase.Alias) { node.Cells[1].Text = scriptBase.Name; } else { node.Cells[1].Text = ""; } return; } if (scriptBase.GetType() == typeof (MapColumn)) { MapColumn mapColumn = (MapColumn) scriptBase; node.Text = scriptBase.Alias; node.Cells[1].Text = scriptBase.Name != scriptBase.Alias ? scriptBase.Name : ""; node.Cells[2].Text = mapColumn.ForeignColumn == null ? "" : mapColumn.ForeignColumn.Parent.Alias + "." + mapColumn.ForeignColumn.Alias; return; } if (scriptBase.GetType() == typeof (OneToOneRelationship) || scriptBase.GetType() == typeof (OneToManyRelationship) || scriptBase.GetType() == typeof (ManyToOneRelationship) || scriptBase.GetType() == typeof (ManyToManyRelationship)) { Relationship relationship = (Relationship) scriptBase; node.Text = scriptBase.Alias; node.Cells[1].Text = scriptBase.Name != scriptBase.Alias ? scriptBase.Name : ""; node.Cells[2].Text = relationship.Path; return; } throw new Exception("ScriptBase Type " + scriptBase.GetType().Name + " not found"); }