Esempio n. 1
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));
                }
            }
        }
Esempio n. 2
0
        private void SaveLinkChangeGroupTranslationResult(LinkChangeGroup linkChangeGroup, RuntimeEntityModel context)
        {
            Debug.Assert(linkChangeGroup.InternalId != LinkChangeGroup.INVALID_INTERNAL_ID);

            var linkChangeGroupQuery = from g in context.RTLinkChangeGroupSet
                                       where g.Id == linkChangeGroup.InternalId
                                       select g;

            Debug.Assert(linkChangeGroupQuery.Count() == 1);
            RTLinkChangeGroup rtLinkChangeGroup = linkChangeGroupQuery.First();

            // update the source side link change group status
            rtLinkChangeGroup.Status = (int)linkChangeGroup.Status;
            if (linkChangeGroup.Status == LinkChangeGroup.LinkChangeGroupStatus.InAnalysisDeferred)
            {
                // if the link change group cannot be translated in the current run
                // we check the number of translation attemps that have been made at the group's current age
                // if it has reached the max number of retries allowed for this age, we increment its age and reset the retry count
                rtLinkChangeGroup.RetriesAtCurrAge = rtLinkChangeGroup.RetriesAtCurrAge ?? 0;
                rtLinkChangeGroup.Age = rtLinkChangeGroup.Age ?? 0;
                if (++rtLinkChangeGroup.RetriesAtCurrAge >= LinkEngine.AgeInterveralSecAndRetries[rtLinkChangeGroup.Age.Value, 1])
                {
                    rtLinkChangeGroup.Age++;
                    rtLinkChangeGroup.RetriesAtCurrAge = 0;
                }
            }

            // identify translated actions in the group
            List <LinkChangeAction> translatedActions = new List <LinkChangeAction>();

            foreach (LinkChangeAction action in linkChangeGroup.Actions)
            {
                if (action.Status == LinkChangeAction.LinkChangeActionStatus.Translated)
                {
                    translatedActions.Add(action);
                    UpdateLinkChangeActionStatus(action.InternalId, LinkChangeAction.LinkChangeActionStatus.DeltaCompleted, context);
                }
                else
                {
                    UpdateLinkChangeActionStatus(action.InternalId, action.Status, context);
                }
            }

            if (AllActionsTranslated(linkChangeGroup))
            {
                // mark group completed when all its actions are successfully translated
                rtLinkChangeGroup.Status = (int)LinkChangeGroup.LinkChangeGroupStatus.Completed;
            }
            else
            {
                rtLinkChangeGroup.ContainsConflictedAction = linkChangeGroup.IsConflicted;
            }

            // move the translated actions to the target side (current side) and create a new group to store them
            LinkChangeGroup translatedGroup = new LinkChangeGroup(
                linkChangeGroup.GroupName, LinkChangeGroup.LinkChangeGroupStatus.InAnalysisTranslated, false);

            foreach (LinkChangeAction action in translatedActions)
            {
                action.InternalId = LinkChangeAction.INVALID_INTERNAL_ID;
                translatedGroup.AddChangeAction(action);
            }

            RTLinkChangeGroup rtLinkChangeGroupTranslated = AddLinkChangeGroup(translatedGroup);

            if (rtLinkChangeGroupTranslated != null)
            {
                context.Attach(rtLinkChangeGroupTranslated);
            }
        }