Ejemplo n.º 1
0
        private RTLinkChangeAction AddChangeAction(LinkChangeAction action, RuntimeEntityModel context)
        {
            if (action.InternalId == LinkChangeAction.INVALID_INTERNAL_ID)
            {
                RTArtifactLink rtArtifactLink = FindCreateLink(action.Link, context);
                Debug.Assert(null != rtArtifactLink, "rtArtifactLink is null.");

                int status = LinkChangeAction.GetStatusStorageValue(action.Status);
                var duplicateActionInDeferralQuery =
                    from a in context.RTLinkChangeActionSet
                    where a.ActionId.Equals(action.ChangeActionId) &&
                    a.SessionGroupUniqueId.Equals(SessionGroupId) &&
                    a.SessionUniqueId.Equals(SessionId) &&
                    a.SourceId.Equals(SourceId) &&
                    a.ArtifactLink.Id == rtArtifactLink.Id &&
                    a.Status == status
                    select a.Id;

                if (duplicateActionInDeferralQuery.Count() > 0)
                {
                    // duplicate link change action in deferral status
                    return(null);
                }

                var rtLinkChangeAction = RTLinkChangeAction.CreateRTLinkChangeAction(
                    0, SessionGroupId, SessionId, action.ChangeActionId,
                    status,
                    false, SourceId);
                rtLinkChangeAction.ArtifactLink = rtArtifactLink;

                return(rtLinkChangeAction);
            }

            throw new MigrationException(MigrationToolkitResources.ErrorSaveDuplicateLinkAction, action.InternalId);
        }
Ejemplo n.º 2
0
        private RTLinkChangeAction AddChangeAction(LinkChangeAction action, RuntimeEntityModel context)
        {
            if (LinkChangeActionMatchesExistingServerLinkChangeId(action, context))
            {
                TraceManager.TraceInformation(String.Format("LinkChangeGroupManager: Skipping generated link change ({0} link to work item {1}) because it was made by the sync process",
                                                            action.ChangeActionId == WellKnownChangeActionId.Add ? "Add" : "Delete", action.Link.SourceArtifactId));
                return(null);
            }

            if (action.InternalId == LinkChangeAction.INVALID_INTERNAL_ID)
            {
                RTArtifactLink rtArtifactLink = FindCreateLink(action.Link, context);
                Debug.Assert(null != rtArtifactLink, "rtArtifactLink is null.");

                int status = LinkChangeAction.GetStatusStorageValue(action.Status);
                var duplicateActionInDeferralQuery =
                    from a in context.RTLinkChangeActionSet
                    where a.ActionId.Equals(action.ChangeActionId) &&
                    a.SessionGroupUniqueId.Equals(SessionGroupId) &&
                    a.SessionUniqueId.Equals(SessionId) &&
                    a.SourceId.Equals(SourceId) &&
                    a.ArtifactLink.Id == rtArtifactLink.Id &&
                    a.Status == status
                    select a.Id;

                if (duplicateActionInDeferralQuery.Count() > 0)
                {
                    // duplicate link change action in deferral status
                    return(null);
                }

                var rtLinkChangeAction = RTLinkChangeAction.CreateRTLinkChangeAction(
                    0, SessionGroupId, SessionId, action.ChangeActionId,
                    status,
                    false, SourceId);
                rtLinkChangeAction.ArtifactLink = rtArtifactLink;
                if (!string.IsNullOrEmpty(action.ServerLinkChangeId))
                {
                    rtLinkChangeAction.ServerLinkChangeId = action.ServerLinkChangeId;
                }

                return(rtLinkChangeAction);
            }

            throw new MigrationException(MigrationToolkitResources.ErrorSaveDuplicateLinkAction, action.InternalId);
        }