Пример #1
0
        public void PromoteInAnalysisChangesToReadyForMigration()
        {
            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                //todo: convert to sproc
                int inAnalysisVal   = (int)LinkChangeGroup.LinkChangeGroupStatus.InAnalysisTranslated;
                int translatedVal   = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.Translated);
                int readyForMigrVal = (int)LinkChangeGroup.LinkChangeGroupStatus.ReadyForMigration;
                var linkActionQuery = from a in context.RTLinkChangeActionSet
                                      where a.LinkChangeGroup.SessionGroupUniqueId.Equals(SessionGroupId) &&
                                      a.LinkChangeGroup.SessionUniqueId.Equals(SessionId) &&
                                      a.LinkChangeGroup.SourceId.Equals(SourceId) &&
                                      a.LinkChangeGroup.Status == inAnalysisVal &&
                                      !a.LinkChangeGroup.ContainsConflictedAction &&
                                      a.Status == translatedVal &&
                                      a.Conflicted == false
                                      select a;

                foreach (RTLinkChangeAction linkChangeAction in linkActionQuery)
                {
                    linkChangeAction.Status = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.ReadyForMigration);
                }
                context.TrySaveChanges();

                context.BatchUpdateLinkChangeGroupStatus(SessionGroupId, SessionId, SourceId, false,
                                                         inAnalysisVal, readyForMigrVal);
            }
        }
Пример #2
0
        private bool LinkChangeActionMatchesExistingServerLinkChangeId(LinkChangeAction linkChangeAction, RuntimeEntityModel context)
        {
            if (string.IsNullOrEmpty(linkChangeAction.ServerLinkChangeId))
            {
                TraceManager.TraceVerbose("LinkChangeActionMatchesExistingServerLinkChangeId returning false because ServerLinkChangeId is null or empty");
                return(false);
            }
            else
            {
                // Look for existing row in LINK_LINK_CHANGEACTION with linkChangeAction.ServerLinkChangeId;
                int completedStatus         = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.Completed);
                var serverLinkChangeIdQuery =
                    from a in context.RTLinkChangeActionSet
                    where a.ActionId.Equals(linkChangeAction.ChangeActionId) &&
                    a.SessionGroupUniqueId.Equals(SessionGroupId) &&
                    a.SessionUniqueId.Equals(SessionId) &&
                    a.SourceId.Equals(SourceId) &&
                    a.ServerLinkChangeId.Equals(linkChangeAction.ServerLinkChangeId) &&
                    a.Status == completedStatus
                    select a.Id;

                // Return true only if row found
                return(serverLinkChangeIdQuery.Count() > 0);
            }
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
0
        private void GetLinkChangeActions(LinkChangeGroup linkChangeGroup, RuntimeEntityModel context)
        {
            int skippedWILinkValue = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.SkipScopedOutWILinks);
            int skippedVCLinkValue = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.SkipScopedOutVCLinks);
            var changeActionQuery  = from a in context.RTLinkChangeActionSet
                                     where a.LinkChangeGroup.Id == linkChangeGroup.InternalId &&
                                     a.Status != skippedVCLinkValue &&
                                     a.Status != skippedWILinkValue
                                     select a;

            foreach (RTLinkChangeAction rtLinkChangeAction in changeActionQuery)
            {
                if (rtLinkChangeAction.SourceId.Equals(SourceId))
                {
                    linkChangeGroup.AddChangeAction(RealizeLinkChangeActionFromEDM(linkChangeGroup, rtLinkChangeAction));
                }
            }
        }
Пример #6
0
        internal void TryDeprecateActiveAddActionMigrationInstruction(LinkChangeAction queryAction)
        {
            ILink link                    = queryAction.Link;
            int   translatedStatus        = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.Translated);
            int   readyForMigrationStatus = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.ReadyForMigration);

            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                string extendedLinkProperties = GetExtendedPropertyString(link);
                var    query =
                    (from lcAction in context.RTLinkChangeActionSet
                     where lcAction.ActionId.Equals(WellKnownChangeActionId.Add) &&
                     lcAction.SessionGroupUniqueId.Equals(SessionGroupId) &&
                     lcAction.SessionUniqueId.Equals(SessionId) &&
                     lcAction.SourceId.Equals(SourceId) &&
                     (lcAction.Status == translatedStatus || lcAction.Status == readyForMigrationStatus) &&
                     lcAction.ArtifactLink.SourceArtifactId.Equals(link.SourceArtifactId) &&
                     lcAction.ArtifactLink.SourceArtifactUri.Equals(link.SourceArtifact.Uri) &&
                     lcAction.ArtifactLink.TargetArtifactUri.Equals(link.TargetArtifact.Uri) &&
                     lcAction.ArtifactLink.Comment.Equals(link.Comment) &&
                     lcAction.ArtifactLink.LinkType.ReferenceName.Equals(link.LinkType.ReferenceName) &&
                     lcAction.ArtifactLink.LinkType.ExtendedProperty.Equals(extendedLinkProperties) &&
                     lcAction.ArtifactLink.LinkType.SourceArtifactType.ReferenceName.Equals(link.LinkType.SourceArtifactType.ReferenceName) &&
                     lcAction.ArtifactLink.LinkType.SourceArtifactType.ArtifactContentType.Equals(link.LinkType.SourceArtifactType.ContentTypeReferenceName) &&
                     lcAction.ArtifactLink.LinkType.TargetArtifactType.ReferenceName.Equals(link.LinkType.TargetArtifactType.ReferenceName) &&
                     lcAction.ArtifactLink.LinkType.TargetArtifactType.ArtifactContentType.Equals(link.LinkType.TargetArtifactType.ContentTypeReferenceName)
                     orderby lcAction.Id descending
                     select lcAction).Take(1);


                foreach (var action in query)
                {
                    action.Status = LinkChangeAction.GetStatusStorageValue(LinkChangeAction.LinkChangeActionStatus.Skipped);
                }

                context.TrySaveChanges();
            }
        }