Exemplo n.º 1
0
        private void SyncUserAccount(XmlDocument xmlDocument, WitMetadataSyncPolicy witMetadataSyncPolicy)
        {
            if (witMetadataSyncPolicy != WitMetadataSyncPolicy.TakeTheirs)
            {
                throw new NotImplementedException();
            }

            byte[] newDocHash  = new byte[0];
            bool   hashMatched = m_md5Utility.CompareDocHash(xmlDocument, m_userAccountsDocMD5, ref newDocHash);

            if (!hashMatched)
            {
                XmlNodeList globGroupNodes = xmlDocument.SelectNodes("/UserGroups/GlobalGroups/Identity");
                XmlNodeList projGroupNodes = xmlDocument.SelectNodes("/UserGroups/ProjectGroups/Identity");

                Identity[] globalGroupsOther  = GetIdentities(globGroupNodes);
                Identity[] projectGroupsOther = GetIdentities(projGroupNodes);

                Project    p = m_migrationSource.WorkItemStore.WorkItemStore.Projects[m_migrationSource.WorkItemStore.Core.Config.Project];
                Identity[] globalGroupsThis  = m_migrationSource.WorkItemStore.GetGlobalGroups(p);
                Identity[] projectGroupsThis = m_migrationSource.WorkItemStore.GetProjectGroups(p);

                SymDiff <Identity> globs = new SymDiff <Identity>(globalGroupsOther, globalGroupsThis, this);
                SymDiff <Identity> projs = new SymDiff <Identity>(projectGroupsOther, projectGroupsThis, this);

                m_migrationSource.WorkItemStore.SyncAccounts(globs.LeftOnly, projs.LeftOnly);

                m_md5Utility.UpdateDocHash(ref m_userAccountsDocMD5, newDocHash);
            }
        }
Exemplo n.º 2
0
        private IGeoProcessorResult SymDiffOverlay(Geoprocessor gp)
        {
            SymDiff symDiff = new SymDiff();

            symDiff.in_features       = GetFeatureLayer(cbInputLayer.Text);
            symDiff.update_features   = GetFeatureLayer(cbOverLayLayer.Text);
            symDiff.out_feature_class = outputFullPath;

            IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(symDiff, null);

            return(results);
        }
        private IGeoProcessorResult SymDiffOverlay(Geoprocessor gp)
        {
            SymDiff symDiff = new SymDiff();

            symDiff.in_features     = GetFeatureLayer(strInputLayer);
            symDiff.update_features = GetFeatureLayer(strOverLayer);
            string outputFullPath = System.IO.Path.Combine
                                        (strOutputPath, strInputLayer + "_" + strOverLayer + "_" + "SymDiff.shp");

            symDiff.out_feature_class = outputFullPath;
            symDiff.join_attributes   = strJoinAttributeType;
            symDiff.cluster_tolerance = tolerance;
            IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(symDiff, null);

            return(results);
        }
        private IGeoProcessorResult SymDiffOverlay(Geoprocessor gp)
        {
            //SymDiff_analysis (in_features, update_features, out_feature_class, join_attributes, cluster_tolerance)

            SymDiff symDiff = new SymDiff();

            symDiff.in_features     = m_InputLayer;
            symDiff.update_features = m_OverlayLayer;
            string outputFullPath = System.IO.Path.Combine(m_OutPutPath, m_InputLayer + "_" + m_OverlayLayer + "_" + "SymDiff");

            symDiff.out_feature_class = outputFullPath;
            symDiff.join_attributes   = m_OutputAttributeType;
            symDiff.cluster_tolerance = m_Tolerance;

            IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(symDiff, null);

            return(results);
        }
Exemplo n.º 5
0
        public void Analyze()
        {
            m_conflictedWorkItems.Clear();
            m_conflictedWorkItems[SourceSystemId] = new List <string>();
            m_conflictedWorkItems[TargetSystemId] = new List <string>();

            if (null == Configuration || null == TargetChangeGroupService || Guid.Empty == TargetSystemId)
            {
                return;
            }

            if (!TargetDeltaContainsMappedItem())
            {
                return;
            }

            try
            {
                FlattenDeltaTable(m_mappedWorkItemsInSourceDeltaTable, m_mappedWorkItemAttachmentUpdatesInSource, true);
                FlattenDeltaTable(m_mappedWorkItemsInTargetDeltaTable, m_mappedWorkItemAttachmentUpdatesInTarget, false);

                // work item basic edit/edit conflict detection
                using (SymDiff <string> mappedWorkItemDiff = new SymDiff <string>(
                           m_mappedWorkItemsInSourceDeltaTable.ToArray(),
                           m_mappedWorkItemsInTargetDeltaTable.ToArray(),
                           StringComparer.InvariantCultureIgnoreCase))
                {
                    if (mappedWorkItemDiff.LeftOnly.Count != m_mappedWorkItemsInSourceDeltaTable.Count ||
                        mappedWorkItemDiff.RightOnly.Count != m_mappedWorkItemsInTargetDeltaTable.Count)
                    {
                        TraceManager.TraceInformation("Edit/Edit conflicted work items are detected from source system ({0}): ",
                                                      Configuration.MigrationSources[SourceSystemId].ServerUrl);

                        IEnumerable <string> conflictedWorkItems = m_mappedWorkItemsInSourceDeltaTable.Except <string>(mappedWorkItemDiff.LeftOnly);
                        foreach (string targetWiId in conflictedWorkItems)
                        {
                            TryResolvePerWorkItemConflicts(targetWiId);
                        }
                    }
                }

                // try cleaning up the collections used for WIT revision analysis ASAP
                m_mappedWorkItemsInSourceDeltaTable.Clear();
                m_mappedWorkItemsInTargetDeltaTable.Clear();
                m_perMappedItemEdits.Clear();
                m_perMappedItemEditsTargetDelta.Clear();

                // attachment diff and take default policy (TakeTheirs)
                foreach (var attUpdateSource in m_mappedWorkItemAttachmentUpdatesInSource)
                {
                    if (m_mappedWorkItemAttachmentUpdatesInTarget.ContainsKey(attUpdateSource.Key))
                    {
                        IMigrationFileAttachment[] sourceSideAttachments      = GetAttachmentList(attUpdateSource.Value);
                        List <MigrationAction>     targetSideAttUpdateActions = m_mappedWorkItemAttachmentUpdatesInTarget[attUpdateSource.Key];
                        IMigrationFileAttachment[] targetSideAttachments      = GetAttachmentList(targetSideAttUpdateActions);

                        SymDiff <IMigrationFileAttachment> attSymDiff = new SymDiff <IMigrationFileAttachment>(
                            sourceSideAttachments,
                            targetSideAttachments,
                            m_migrAttachComparer);

                        IEnumerable <IMigrationFileAttachment> sourceOnlyAttachments = sourceSideAttachments.Intersect(attSymDiff.LeftOnly);

                        foreach (MigrationAction action in attUpdateSource.Value)
                        {
                            if (!sourceOnlyAttachments.Contains(action.SourceItem as IMigrationFileAttachment))
                            {
                                action.State = ActionState.Skipped;
                                action.ChangeGroup.Save(action);
                            }
                        }
                    }
                }
            }
            finally
            {
                // in case we throw in stage 1 (edit/edit conflict) analysis, we want to make sure to
                // clean up the collections used for WIT revision analysis
                m_mappedWorkItemsInSourceDeltaTable.Clear();
                m_mappedWorkItemsInTargetDeltaTable.Clear();
                m_perMappedItemEdits.Clear();
                m_perMappedItemEditsTargetDelta.Clear();

                // clean up the collections used for attachment analysis
                m_mappedWorkItemAttachmentUpdatesInSource.Clear();
                m_mappedWorkItemAttachmentUpdatesInTarget.Clear();
                m_sourceToTargetWorkItemIdMapping.Clear();
                m_targetToSourceWorkItemIdMapping.Clear();
            }
        }