void ApplyChanges(MergeControl mergeControl, DataTable localDataTable, string idColumnNameCountry, string idColumnNameYear, bool local)
        {
            foreach (MergeControl.NodeInfo nodeInfo in local ? mergeControl.GetNodeInfoLocal() : mergeControl.GetNodeInfoRemote())
            {
                if (nodeInfo.changeType != MergeControl.ChangeType.changed ||
                    nodeInfo.changeHandling == (local ? MergeControl.ChangeHandling.accept : MergeControl.ChangeHandling.reject))
                {
                    continue; //not relevant, because neither changed nor locally accepted nor remotely rejected
                }
                string country = nodeInfo.ID.Substring(0, nodeInfo.ID.IndexOf("_"));
                string year    = nodeInfo.ID.Substring(nodeInfo.ID.IndexOf("_") + 1);

                //the existence of the component in local/remote/parent country reflects whether it is added (loc/rem), changed (loc/rem), ...
                string whereClause = idColumnNameCountry + " = '" + country + "' AND " + idColumnNameYear + " = '" + year + "'";


                DataRow dataRow = localDataTable.Select(whereClause).First();

                foreach (MergeControl.CellInfo cellInfo in nodeInfo.cellInfo)
                {
                    if (!cellInfo.isChanged || (local ? cellInfo.acceptChange : !cellInfo.acceptChange))
                    {
                        continue; //not relevant, because neither changed nor locally accepted nor remotely rejected
                    }
                    MergeControl.CellInfo cellInfoRemote = local ? mergeControl.GetTwinCellInfo(cellInfo) : cellInfo;
                    dataRow.SetField <string>(cellInfo.columnID, cellInfoRemote.text);
                }
            }
        }
Ejemplo n.º 2
0
        void AddLabelsWholeCountry(bool local)
        {
            foreach (MergeControl.NodeInfo nodeInfo in local ? _mcCountryLabels.GetNodeInfoLocal() : _mcCountryLabels.GetNodeInfoRemote())
            {
                if (!nodeInfo.ID.StartsWith(MergeAdministrator.IDENTIFIER_ADD_DEL_COUNTRY_LABELS) ||
                    nodeInfo.changeType != (local ? MergeControl.ChangeType.removed : MergeControl.ChangeType.added) ||
                    nodeInfo.changeHandling != (local ? MergeControl.ChangeHandling.reject : MergeControl.ChangeHandling.accept))
                {
                    continue;
                }

                string countryShortName = nodeInfo.ID.Substring(MergeAdministrator.IDENTIFIER_ADD_DEL_COUNTRY_LABELS.Length).ToLower();
                foreach (VarConfig.CountryLabelRow remoteLabel in (from lab in _vcRemote.CountryLabel where lab.Country.ToLower() == countryShortName select lab))
                {
                    VarConfig.VariableRow localParentVariable = _vcFacLocal.GetVariableByID(remoteLabel.VariableID);
                    if (localParentVariable != null)
                    {
                        _vcFacLocal.CopyCountryLabelRow(remoteLabel, localParentVariable);
                    }
                }
            }
        }
        List <string> GetRelevantIDs(MergeControl mergeControl, bool local, bool add)
        {
            List <string> relevantIDs = new List <string>();

            foreach (MergeControl.NodeInfo nodeInfo in local ? mergeControl.GetNodeInfoLocal() : mergeControl.GetNodeInfoRemote())
            {
                if (nodeInfo.changeType != (local ? (add ? MergeControl.ChangeType.removed : MergeControl.ChangeType.added)
                                                  : (add ? MergeControl.ChangeType.added : MergeControl.ChangeType.removed)) ||
                    nodeInfo.changeHandling != (local ? MergeControl.ChangeHandling.reject : MergeControl.ChangeHandling.accept))
                {
                    continue; //not relevant, because not a rejected local-remove nor an accepted remote-add
                }
                relevantIDs.Add(nodeInfo.ID);
            }
            return(relevantIDs);
        }
Ejemplo n.º 4
0
        //void AddSwitchPolicies(bool local)
        //{
        //    foreach (string ID in GetRelevantIDs(_mcSwitchablePolicies, local, true))
        //        SwitchablePolicyConfigFacade.CopySwitchPolicyFromAnotherConfig(_vcLocal, EM_AppContext.Instance.GetSwitchablePolicyConfigFacade().GetSwitchablePolicy(ID));
        //}

        void ApplyChanges(MergeControl mergeControl, DataTable localDataTable, string idColumnName, bool local)
        {
            foreach (MergeControl.NodeInfo nodeInfo in local ? mergeControl.GetNodeInfoLocal() : mergeControl.GetNodeInfoRemote())
            {
                if (nodeInfo.changeType != MergeControl.ChangeType.changed ||
                    nodeInfo.changeHandling == (local ? MergeControl.ChangeHandling.accept : MergeControl.ChangeHandling.reject))
                {
                    continue; //not relevant, because neither changed nor locally accepted nor remotely rejected
                }
                DataRow dataRow = localDataTable.Select(idColumnName + " = '" + nodeInfo.ID + "'").First();

                foreach (MergeControl.CellInfo cellInfo in nodeInfo.cellInfo)
                {
                    if (!cellInfo.isChanged || (local ? cellInfo.acceptChange : !cellInfo.acceptChange))
                    {
                        continue; //not relevant, because neither changed nor locally accepted nor remotely rejected
                    }
                    MergeControl.CellInfo cellInfoRemote = local ? mergeControl.GetTwinCellInfo(cellInfo) : cellInfo;
                    dataRow.SetField <string>(cellInfo.columnID, cellInfoRemote.text);
                }
            }
        }
Ejemplo n.º 5
0
        void ChangeAcros(bool local)
        {
            foreach (MergeControl.NodeInfo nodeInfo in local ? _mcAcronyms.GetNodeInfoLocal() : _mcAcronyms.GetNodeInfoRemote())
            {
                if (nodeInfo.changeType != MergeControl.ChangeType.changed ||
                    nodeInfo.changeHandling == (local ? MergeControl.ChangeHandling.accept : MergeControl.ChangeHandling.reject))
                {
                    continue; //not relevant, because neither changed nor locally accepted nor remotely rejected
                }
                const string          NOT_CHANGED    = "NOT_CHANGED";
                MergeControl.CellInfo cellInfo       = nodeInfo.cellInfo.First();
                MergeControl.CellInfo cellInfoRemote = local ? _mcAcronyms.GetTwinCellInfo(cellInfo) : cellInfo;
                string changedName = (cellInfo.isChanged && (local ? !cellInfo.acceptChange : cellInfo.acceptChange)) //if name is changed and remotely accepted or locally rejected
                                     ? cellInfoRemote.text : NOT_CHANGED;                                             //change to remote name (otherwise mark not changed)
                cellInfo       = nodeInfo.cellInfo.Last();
                cellInfoRemote = local ? _mcAcronyms.GetTwinCellInfo(cellInfo) : cellInfo;
                string changedDesc = (cellInfo.isChanged && (local ? !cellInfo.acceptChange : cellInfo.acceptChange)) //if description is changed and remotely accepted or locally rejected
                                     ? cellInfoRemote.text : NOT_CHANGED;                                             //change to remote description (otherwise mark not changed)
                DataRow dataRow;
                switch (AssessAcroLevel(nodeInfo.ID, true, out dataRow))
                {
                case LEVEL_INVALID: continue;     //should not happen

                case LEVEL_ACROTYPE:
                    VarConfig.AcronymTypeRow acroType = dataRow as VarConfig.AcronymTypeRow;
                    if (changedName != NOT_CHANGED)
                    {
                        acroType.ShortName = changedName;
                    }
                    if (changedDesc != NOT_CHANGED)
                    {
                        acroType.LongName = changedDesc;
                    }
                    break;

                case LEVEL_ACROLEVEL:
                    VarConfig.AcronymLevelRow acroLevel = dataRow as VarConfig.AcronymLevelRow;
                    if (changedName != NOT_CHANGED)
                    {
                        acroLevel.Index = Convert.ToInt32(changedName);                                 //probably not relevant
                    }
                    if (changedDesc != NOT_CHANGED)
                    {
                        acroLevel.Name = changedDesc;
                    }
                    break;

                case LEVEL_ACRO:
                    VarConfig.AcronymRow acro = dataRow as VarConfig.AcronymRow;
                    if (changedName != NOT_CHANGED)
                    {
                        acro.Name = changedName;
                    }
                    if (changedDesc != NOT_CHANGED)
                    {
                        acro.Description = changedDesc;
                    }
                    break;

                case LEVEL_ACROCAT:
                    VarConfig.CategoryRow categ = dataRow as VarConfig.CategoryRow;
                    if (changedName != NOT_CHANGED)
                    {
                        categ.Value = changedName;
                    }
                    if (changedDesc != NOT_CHANGED)
                    {
                        categ.Description = changedDesc;
                    }
                    break;
                }
            }
        }