コード例 #1
0
        public ComparisonObject GetComparisonObject(GameObject comparisonIndicator)
        {
            var script = comparisonIndicator.GetComponent <ComparisonTypeIndicatorScript>();
            ComparisonObject comparisonObject = new ComparisonObject();

            comparisonObject.comparedType = script.SelectedComparisonType;
            return(comparisonObject);
        }
コード例 #2
0
        private void RefreshComparisonObjFromGrid(TreeGridNode node)
        {
            ComparisonObjectType nodeCubeOjbectType = (ComparisonObjectType)Enum.Parse(typeof(ComparisonObjectType), node.Cells[9].Value.ToString());

            ComparisonObject comparisonObject = _comparison.FindComparisonObjectByObjectInternalNames(
                node.Cells[1].Value.ToString(),
                node.Cells[2].Value.ToString(),
                node.Cells[5].Value.ToString(),
                node.Cells[6].Value.ToString(),
                nodeCubeOjbectType);

            if (comparisonObject != null)
            {
                comparisonObject.MergeAction = (MergeAction)Enum.Parse(typeof(MergeAction), node.Cells[8].Value.ToString());
            }

            //this version of the TreeGridView does not support binding from an object collection (or any built in data binding for that matter), so we have to refresh the CubeDiff with changes done by the user in the UI (they can modify the MergeActions).
            foreach (TreeGridNode childNode in node.Nodes)
            {
                RefreshComparisonObjFromGrid(childNode);
            }
        }
コード例 #3
0
        /// <summary>
        /// Helper method to transform comparison object to structure understood by Angular control
        /// </summary>
        /// <param name="comparisonObject">Individual node in the tree</param>
        /// <param name="level">Level in the heirarchy to which the object belongs</param>
        /// <param name="parentNode">Reference to the parent node of the current object</param>
        private void PopulateComparisonData(ComparisonObject comparisonObject, int level, ComparisonNode parentNode)
        {
            if (comparisonObject != null)
            {
                string nodeType = "";
                switch (comparisonObject.ComparisonObjectType)
                {
                case ComparisonObjectType.DataSource:
                    nodeType = "Data Source";
                    break;

                case ComparisonObjectType.CalculationItem:
                    nodeType = "Calculation Item";
                    break;

                case ComparisonObjectType.Table:

                    //Check if source table has any calc item children. If yes, it's a calc group.
                    bool isCalcGroup = false;
                    foreach (ComparisonObject childComparisonObject in comparisonObject.ChildComparisonObjects)
                    {
                        if (childComparisonObject.ComparisonObjectType == ComparisonObjectType.CalculationItem && childComparisonObject.Status != ComparisonObjectStatus.MissingInSource)
                        {
                            isCalcGroup = true;
                            break;
                        }
                    }
                    nodeType = isCalcGroup ? "Calculation Group" : "Table";
                    break;

                default:
                    nodeType = comparisonObject.ComparisonObjectType.ToString();
                    break;
                }

                ComparisonNode currentNode = new ComparisonNode
                {
                    NodeType               = nodeType,
                    SourceName             = comparisonObject.SourceObjectName,
                    TargetName             = comparisonObject.TargetObjectName,
                    SourceInternalName     = comparisonObject.SourceObjectInternalName,
                    TargetInternalName     = comparisonObject.TargetObjectInternalName,
                    SourceObjectDefinition = comparisonObject.SourceObjectDefinition,
                    TargetObjectDefinition = comparisonObject.TargetObjectDefinition,
                    ShowNode               = true,
                    Level            = level,
                    MergeAction      = comparisonObject.MergeAction.ToString(),
                    DisableMessage   = "",
                    DropdownDisabled = false
                };

                if (parentNode != null)
                {
                    currentNode.ParentId = parentNode.Id;
                    parentNode.ChildNodes.Add(currentNode.Id);
                }

                switch (comparisonObject.Status)
                {
                case ComparisonObjectStatus.MissingInTarget:
                    currentNode.Status = "Missing in Target";
                    break;

                case ComparisonObjectStatus.MissingInSource:
                    currentNode.Status = "Missing in Source";
                    break;

                case ComparisonObjectStatus.SameDefinition:
                    currentNode.Status = "Same Definition";
                    break;

                case ComparisonObjectStatus.DifferentDefinitions:
                    currentNode.Status = "Different Definitions";
                    break;

                default:
                    break;
                }

                comparisonList.Add(currentNode);

                // Populate helper objects
                AngularComposite angularComposite = new AngularComposite(currentNode, comparisonObject);
                _directAccessList.Add(currentNode.Id, angularComposite);


                // set drop-down to have limited members based on what is available
                switch (comparisonObject.MergeAction)
                {
                case MergeAction.Create:
                    currentNode.AvailableActions = new List <string> {
                        "Create", "Skip"
                    };

                    if (parentNode != null && string.Equals(parentNode.Status, "Missing in Target") && string.Equals(parentNode.MergeAction, "Skip"))
                    {
                        comparisonObject.MergeAction = MergeAction.Skip;
                        currentNode.MergeAction      = MergeAction.Skip.ToString();
                        currentNode.DropdownDisabled = true;
                        SetNodeTooltip(angularComposite, true);
                    }
                    break;

                case MergeAction.Update:
                    currentNode.AvailableActions = new List <string> {
                        "Update", "Skip"
                    };
                    break;

                case MergeAction.Delete:
                    currentNode.AvailableActions = new List <string> {
                        "Delete", "Skip"
                    };

                    //check if parent is also set to delete, in which case make this cell readonly
                    if (parentNode != null && string.Equals(parentNode.MergeAction, "Delete"))
                    {
                        currentNode.DropdownDisabled = true;
                        SetNodeTooltip(angularComposite, true);
                    }
                    break;

                case MergeAction.Skip:

                    switch (comparisonObject.Status)
                    {
                    case ComparisonObjectStatus.MissingInTarget:
                        currentNode.AvailableActions = new List <string> {
                            "Create", "Skip"
                        };

                        //check if parent is also MissingInTarget and Skip, make this cell readonly
                        if (parentNode != null && string.Equals(parentNode.Status, "Missing in Target") && string.Equals(parentNode.MergeAction, "Skip"))
                        {
                            currentNode.DropdownDisabled = true;
                            SetNodeTooltip(angularComposite, true);
                        }

                        break;

                    case ComparisonObjectStatus.MissingInSource:
                        currentNode.AvailableActions = new List <string> {
                            "Delete", "Skip"
                        };
                        break;

                    case ComparisonObjectStatus.DifferentDefinitions:
                        currentNode.AvailableActions = new List <string> {
                            "Update", "Skip"
                        };
                        break;

                    default:
                        //default covers ComparisonObjectStatus.SameDefinition: which is most common case (above cases are for saved skip selections from file)
                        currentNode.AvailableActions = new List <string> {
                            "Skip"
                        };
                        currentNode.DropdownDisabled = true;
                        SetNodeTooltip(angularComposite, true);
                        break;
                    }

                    break;

                default:
                    break;
                }
                ;

                // Add child objects if it exists
                if (comparisonObject.ChildComparisonObjects != null && comparisonObject.ChildComparisonObjects.Count > 0)
                {
                    foreach (ComparisonObject childComparisonObject in comparisonObject.ChildComparisonObjects)
                    {
                        PopulateComparisonData(childComparisonObject, level + 1, currentNode);
                    }
                }
            }
        }
コード例 #4
0
        private void PopulateNode(TreeGridNode node, ComparisonObject comparisonObject)
        {
            switch (comparisonObject.Status)
            {
            case ComparisonObjectStatus.MissingInTarget:
                node.Cells[3].Value           = ">";
                node.Cells[4].Value           = "Missing in Target";
                node.Cells[5].Style.BackColor = Color.LightGray;
                node.Cells[6].Style.BackColor = Color.LightGray;
                break;

            case ComparisonObjectStatus.MissingInSource:
                node.Cells[1].Style.BackColor = Color.LightGray;
                node.Cells[2].Style.BackColor = Color.LightGray;
                node.Cells[3].Value           = "<";
                node.Cells[4].Value           = "Missing in Source";
                break;

            case ComparisonObjectStatus.SameDefinition:
                node.Cells[3].Value = "=";
                node.Cells[4].Value = "Same Definition";
                break;

            case ComparisonObjectStatus.DifferentDefinitions:
                node.Cells[3].Value = "≠";
                node.Cells[4].Value = "Different Definitions";
                break;

            default:
                break;
            }
            node.Cells[1].Value = comparisonObject.SourceObjectName;
            node.Cells[2].Value = comparisonObject.SourceObjectInternalName;
            //node.Cells[8].Value = comparisonObject.MergeAction.ToString();  //set below instead
            node.Cells[5].Value  = comparisonObject.TargetObjectName;
            node.Cells[6].Value  = comparisonObject.TargetObjectInternalName;
            node.Cells[9].Value  = comparisonObject.ComparisonObjectType.ToString();
            node.Cells[10].Value = comparisonObject.SourceObjectDefinition;
            node.Cells[11].Value = comparisonObject.TargetObjectDefinition;

            string treeIndentLevel1 = new String(' ', 13);
            string treeIndentLevel2 = new String(' ', 20);

            switch (comparisonObject.ComparisonObjectType)
            {
            // Tabular objecs
            case ComparisonObjectType.Model:
                node.ImageIndex     = 25;
                node.Cells[0].Value = treeIndentLevel1 + "Model";
                break;

            case ComparisonObjectType.DataSource:
                node.ImageIndex     = 0;
                node.Cells[0].Value = treeIndentLevel1 + "Data Source";
                break;

            case ComparisonObjectType.Table:
                node.ImageIndex     = 1;
                node.Cells[0].Value = treeIndentLevel1 + "Table";
                break;

            case ComparisonObjectType.Relationship:
                node.ImageIndex     = 2;
                node.Cells[0].Value = treeIndentLevel2 + "Relationship";
                break;

            case ComparisonObjectType.Measure:
                node.ImageIndex     = 3;
                node.Cells[0].Value = treeIndentLevel2 + "Measure";
                break;

            case ComparisonObjectType.Kpi:
                node.ImageIndex     = 4;
                node.Cells[0].Value = treeIndentLevel2 + "KPI";
                break;

            case ComparisonObjectType.CalculationItem:
                node.ImageIndex     = 24;
                node.Cells[0].Value = treeIndentLevel2 + "Calculation Item";
                break;

            case ComparisonObjectType.Expression:
                node.ImageIndex     = 22;
                node.Cells[0].Value = treeIndentLevel1 + "Expression";
                break;

            case ComparisonObjectType.Perspective:
                node.ImageIndex     = 15;
                node.Cells[0].Value = treeIndentLevel1 + "Perspective";
                break;

            case ComparisonObjectType.Culture:
                node.ImageIndex     = 21;
                node.Cells[0].Value = treeIndentLevel1 + "Culture";
                break;

            case ComparisonObjectType.Role:
                node.ImageIndex     = 14;
                node.Cells[0].Value = treeIndentLevel1 + "Role";
                break;

            case ComparisonObjectType.Action:
                node.ImageIndex     = 16;
                node.Cells[0].Value = treeIndentLevel1 + "Action";
                break;
            //case ComparisonObjectType.RefreshPolicy:
            //    node.ImageIndex = 26;
            //    node.Cells[0].Value = treeIndentLevel1 + "Refresh Policy";
            //    break;

            default:
                break;
            }
            ;

            DataGridViewComboBoxCell comboCell             = (DataGridViewComboBoxCell)node.Cells[8];
            DataGridViewCell         parentMergeActionCell = node.Parent.Cells[8];
            DataGridViewCell         parentStatusCell      = node.Parent.Cells[4];

            // set drop-down to have limited members based on what is available
            switch (comparisonObject.MergeAction)
            {
            case MergeAction.Create:
                node.Cells[7].Value  = this.ImageList.Images[7];        //7: Create
                node.Cells[8].Value  = comparisonObject.MergeAction.ToString();
                comboCell.DataSource = new string[] { "Create", "Skip" };

                if (parentStatusCell.Value != null && parentMergeActionCell.Value != null &&
                    parentStatusCell.Value.ToString() == "Missing in Target" && parentMergeActionCell.Value.ToString() == "Skip")
                {
                    // Can only happen if loading from file
                    node.Cells[7].Value           = this.ImageList.Images[19]; //19: Skip Gray
                    node.Cells[8].Value           = MergeAction.Skip.ToString();
                    node.Cells[8].Style.ForeColor = Color.DimGray;
                    node.Cells[8].ReadOnly        = true;
                    SetNodeTooltip(node, true);
                }
                break;

            case MergeAction.Update:
                node.Cells[7].Value  = this.ImageList.Images[6];        //6: Update
                node.Cells[8].Value  = comparisonObject.MergeAction.ToString();
                comboCell.DataSource = new string[] { "Update", "Skip" };
                break;

            case MergeAction.Delete:
                node.Cells[7].Value  = this.ImageList.Images[5];        //5: Delete
                node.Cells[8].Value  = comparisonObject.MergeAction.ToString();
                comboCell.DataSource = new string[] { "Delete", "Skip" };

                //check if parent is also set to delete, in which case make this cell readonly
                if (parentMergeActionCell.Value != null && parentMergeActionCell.Value.ToString() == "Delete")
                {
                    node.Cells[7].Value           = this.ImageList.Images[18]; //18: Delete Gray
                    node.Cells[8].Style.ForeColor = Color.DimGray;
                    node.Cells[8].ReadOnly        = true;
                    SetNodeTooltip(node, true);
                }
                break;

            case MergeAction.Skip:
                node.Cells[7].Value = this.ImageList.Images[8];         //8: Skip
                node.Cells[8].Value = comparisonObject.MergeAction.ToString();
                switch (comparisonObject.Status)
                {
                case ComparisonObjectStatus.MissingInTarget:
                    comboCell.DataSource = new string[] { "Create", "Skip" };

                    //check if parent is also MissingInTarget and Skip, make this cell readonly
                    if (parentStatusCell.Value != null && parentMergeActionCell.Value != null &&
                        parentStatusCell.Value.ToString() == "Missing in Target" && parentMergeActionCell.Value.ToString() == "Skip")
                    {
                        node.Cells[7].Value           = this.ImageList.Images[19];   //19: Skip Gray
                        node.Cells[8].Style.ForeColor = Color.DimGray;
                        node.Cells[8].ReadOnly        = true;
                        SetNodeTooltip(node, true);
                    }

                    break;

                case ComparisonObjectStatus.MissingInSource:
                    comboCell.DataSource = new string[] { "Delete", "Skip" };
                    break;

                case ComparisonObjectStatus.DifferentDefinitions:
                    comboCell.DataSource = new string[] { "Update", "Skip" };
                    break;

                default:
                    //default covers ComparisonObjectStatus.SameDefinition: which is most common case (above cases are for saved skip selections from file)
                    node.Cells[7].Value           = this.ImageList.Images[19];   //19: Skip Gray
                    comboCell.DataSource          = new string[] { "Skip" };
                    node.Cells[8].Style.ForeColor = Color.DimGray;
                    node.Cells[8].ReadOnly        = true;
                    break;
                }

                break;

            default:
                break;
            }
            ;

            if (comparisonObject.ChildComparisonObjects != null && comparisonObject.ChildComparisonObjects.Count > 0)
            {
                foreach (ComparisonObject childComparisonObject in comparisonObject.ChildComparisonObjects)
                {
                    TreeGridNode childNode = node.Nodes.Add();
                    PopulateNode(childNode, childComparisonObject);
                    //node.Expand();  //for inexplicable reason, keeps erroring on this line as though the node doesn't belong to the grid, but it does because its parent does.  So instead will iterate all nodes once fully populate to expand.
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Constructor for composite node with Angular and .Net
 /// </summary>
 /// <param name="node">Set value for angular node</param>
 /// <param name="comparisonObject">set value for .Net node</param>
 public AngularComposite(ComparisonNode node, ComparisonObject comparisonObject)
 {
     ngComparison     = node;
     dotNetComparison = comparisonObject;
 }