Esempio n. 1
0
        public override IMigrationAction LoadSingleAction(long actionInternalId)
        {
            IMigrationAction retAction = null;

            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                Guid sessionUniqueId = new Guid(Session.SessionUniqueId);
                var  actions         =
                    (from ca in context.RTChangeActionSet
                     where ca.ChangeActionId == actionInternalId
                     select ca);

                if (actions.Count() > 0)
                {
                    RTChangeAction rtChangeAction = actions.First();
                    rtChangeAction.ChangeGroupReference.Load();
                    RTChangeGroup parentRTGroup = rtChangeAction.ChangeGroup;

                    SqlChangeGroup parentChangeGroup = new SqlChangeGroup(this);
                    retAction = parentChangeGroup.RealizeFromEDMWithSingleAction(parentRTGroup, rtChangeAction);
                }
            }

            return(retAction);
        }
Esempio n. 2
0
        public override ReadOnlyCollection <KeyValuePair <MigrationAction, MigrationAction> > DetectContentConflict()
        {
            List <KeyValuePair <MigrationAction, MigrationAction> > conflictActions = new List <KeyValuePair <MigrationAction, MigrationAction> >();
            Dictionary <long, SqlChangeGroup> loadedChangeGroups = new Dictionary <long, SqlChangeGroup>();

            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                foreach (VCContentConflictResult contentConflictResults in context.QueryContentConflict(SourceId, new Guid(Session.SessionUniqueId)))
                {
                    RTChangeAction migrationInstructionAction =
                        context.RTChangeActionSet.Where(a => a.ChangeActionId == contentConflictResults.MigrationInstructionChangeActionId).First();

                    RTChangeAction deltaAction =
                        context.RTChangeActionSet.Where(a => a.ChangeActionId == contentConflictResults.DeltaChangeActionId).First();

                    SqlMigrationAction conflictActionSource = SqlMigrationAction.RealizeFromDB(migrationInstructionAction);
                    if (loadedChangeGroups.ContainsKey(migrationInstructionAction.ChangeGroupId))
                    {
                        conflictActionSource.ChangeGroup = loadedChangeGroups[migrationInstructionAction.ChangeGroupId];
                    }
                    else
                    {
                        RTChangeGroup  migrationInstructionChangeGroup = context.RTChangeGroupSet.Where(c => c.Id == migrationInstructionAction.ChangeGroupId).First();
                        SqlChangeGroup conflictChangeGroupSource       = new SqlChangeGroup(this);
                        conflictChangeGroupSource.RealizeFromEDMWithSingleAction(migrationInstructionChangeGroup, migrationInstructionAction);
                        loadedChangeGroups.Add(migrationInstructionAction.ChangeGroupId, conflictChangeGroupSource);
                        conflictActionSource.ChangeGroup = conflictChangeGroupSource;
                    }

                    SqlMigrationAction conflictActionTarget = SqlMigrationAction.RealizeFromDB(deltaAction);

                    if (loadedChangeGroups.ContainsKey(deltaAction.ChangeGroupId))
                    {
                        conflictActionTarget.ChangeGroup = loadedChangeGroups[deltaAction.ChangeGroupId];
                    }
                    else
                    {
                        RTChangeGroup  deltaChangeGroup          = context.RTChangeGroupSet.Where(c => c.Id == deltaAction.ChangeGroupId).First();
                        SqlChangeGroup conflictChangeGroupTarget = new SqlChangeGroup(this);
                        conflictChangeGroupTarget.RealizeFromEDMWithSingleAction(deltaChangeGroup, deltaAction);
                        loadedChangeGroups.Add(deltaAction.ChangeGroupId, conflictChangeGroupTarget);
                        conflictActionTarget.ChangeGroup = conflictChangeGroupTarget;
                    }

                    conflictActions.Add(new KeyValuePair <MigrationAction, MigrationAction>(conflictActionSource, conflictActionTarget));
                }
            }
            return(conflictActions.AsReadOnly());
        }