/// <summary> /// Initialize configuration services and add it to service container /// </summary> private void CreateServices() { Debug.Assert(m_serviceContainers.Count == 2); ChangeGroupManager changeGroupManager = null; foreach (KeyValuePair <Guid, ServiceContainer> container in m_serviceContainers) { ConfigurationService configurationService = new ConfigurationService(m_globalConfiguration, Configuration, container.Key); container.Value.AddService(typeof(ConfigurationService), configurationService); var sqlChangeGroupManager = new SqlChangeGroupManager(m_session, container.Key); ChangeGroupService changeGroupService = new ChangeGroupService(sqlChangeGroupManager); sqlChangeGroupManager.ChangeGroupService = changeGroupService; container.Value.AddService(typeof(ChangeGroupService), changeGroupService); if (null == changeGroupManager) { changeGroupManager = sqlChangeGroupManager; } else { changeGroupManager.OtherSideChangeGroupManager = sqlChangeGroupManager; sqlChangeGroupManager.OtherSideChangeGroupManager = changeGroupManager; } } }
public override void UpdateConversionHistory(ConversionResult result) { SqlChangeGroupManager manager = this.Manager as SqlChangeGroupManager; Debug.Assert(null != manager, "Manager is not a SqlChangeGroupManager for SqlChangeGroup"); result.Save(manager.RuntimeSessionRun.Id, manager.RunTimeMigrationSource.UniqueId, SessionId, ReflectedChangeGroupId); }
public override void UpdateConversionHistory(ConversionResult result) { SqlChangeGroupManager manager = this.Manager as SqlChangeGroupManager; Debug.Assert(null != manager, "Manager is not a SqlChangeGroupManager for SqlChangeGroup"); result.Save(manager.RuntimeSessionRun.Id, manager.RunTimeMigrationSource.UniqueId, SessionId, ReflectedChangeGroupId); if (Manager.Session.SessionType == SessionTypeEnum.VersionControl) { updateVCSyncPoint(result); } }
private void SavePartialChangeGroup() { if (null != m_runTimeChangeGroup) { return; } SqlChangeGroupManager manager = this.Manager as SqlChangeGroupManager; Debug.Assert(null != manager, "Manager is not a SqlChangeGroupManager for SqlChangeGroup"); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { try { context.Attach(manager.RunTimeMigrationSource); context.Attach(manager.RuntimeSessionRun); // save group attributes m_runTimeChangeGroup = RTChangeGroup.CreateRTChangeGroup(-1, ExecutionOrder, SessionId, SourceId, (int)ChangeStatus.ChangeCreationInProgress, false); m_runTimeChangeGroup.Owner = Owner; m_runTimeChangeGroup.Comment = Comment; // Store the ChangeTimeUtc value in the RevsionTime column unless the ChangeTimeUtc is not set (MinValue) // If it's not set, store DateTime.MaxValue to indicate that because DateTime.MinValue is outside the range allowed by SQL m_runTimeChangeGroup.RevisionTime = ChangeTimeUtc.Equals(DateTime.MinValue) ? DateTime.MaxValue : ChangeTimeUtc; m_runTimeChangeGroup.StartTime = DateTime.UtcNow; m_runTimeChangeGroup.Name = Name; m_runTimeChangeGroup.ReflectedChangeGroupId = ReflectedChangeGroupId; m_runTimeChangeGroup.UsePagedActions = m_usePagedActions; m_runTimeChangeGroup.IsForcedSync = IsForcedSync; // establish SessionRun association m_runTimeChangeGroup.SessionRun = manager.RuntimeSessionRun; // estabilish MigrationSource association m_runTimeChangeGroup.SourceSideMigrationSource = manager.RunTimeMigrationSource; // save the group context.AddToRTChangeGroupSet(m_runTimeChangeGroup); context.TrySaveChanges(); // record internal Id this.ChangeGroupId = m_runTimeChangeGroup.Id; } finally { context.Detach(m_runTimeChangeGroup); context.Detach(manager.RunTimeMigrationSource); context.Detach(manager.RuntimeSessionRun); } } }
public SqlChangeGroupProvider( RTChangeGroup runtimeChangeGroup, SqlChangeGroupManager parentSqlChangeGroupManager) { if (null == runtimeChangeGroup) { throw new ArgumentNullException("runtimeChangeGroup"); } m_runtimeChangeGroup = runtimeChangeGroup; m_sqlChangeGroupManager = parentSqlChangeGroupManager; }
private void SavePartialChangeGroup() { if (null != m_runTimeChangeGroup) { return; } SqlChangeGroupManager manager = this.Manager as SqlChangeGroupManager; Debug.Assert(null != manager, "Manager is not a SqlChangeGroupManager for SqlChangeGroup"); using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { try { context.Attach(manager.RunTimeMigrationSource); context.Attach(manager.RuntimeSessionRun); // save group attributes m_runTimeChangeGroup = RTChangeGroup.CreateRTChangeGroup(-1, ExecutionOrder, SessionId, SourceId, (int)ChangeStatus.ChangeCreationInProgress, false); m_runTimeChangeGroup.Owner = Owner; m_runTimeChangeGroup.Comment = Comment; m_runTimeChangeGroup.RevisionTime = RevisionTime; m_runTimeChangeGroup.StartTime = DateTime.UtcNow; m_runTimeChangeGroup.Name = Name; m_runTimeChangeGroup.ReflectedChangeGroupId = ReflectedChangeGroupId; m_runTimeChangeGroup.UsePagedActions = m_usePagedActions; // establish SessionRun association m_runTimeChangeGroup.SessionRun = manager.RuntimeSessionRun; // estabilish MigrationSource association m_runTimeChangeGroup.SourceSideMigrationSource = manager.RunTimeMigrationSource; // save the group context.AddToRTChangeGroupSet(m_runTimeChangeGroup); context.TrySaveChanges(); // record internal Id this.ChangeGroupId = m_runTimeChangeGroup.Id; } finally { context.Detach(m_runTimeChangeGroup); context.Detach(manager.RunTimeMigrationSource); context.Detach(manager.RuntimeSessionRun); } } }
protected override void Create() { // ToDo ChangeStatus targetStatus = Status; SqlChangeGroupManager manager = this.Manager as SqlChangeGroupManager; Debug.Assert(null != manager, "Manager is not a SqlChangeGroupManager for SqlChangeGroup"); // save the group (without child actions) SavePartialChangeGroup(); // bulk save sliced child change actions const int bulkChangeActionInsertionSize = 1000; int changeActionCount = 0; while (Actions.Count > 0) { using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { try { context.Attach(m_runTimeChangeGroup); while (Actions.Count > 0 && changeActionCount < bulkChangeActionInsertionSize) { SqlMigrationAction action = Actions[0] as SqlMigrationAction; Debug.Assert(null != action); action.ChangeGroup = this; IMigrationItemSerializer serializer = ManagerWithMigrationItemSerializers[action.Action]; action.CreateNew(serializer); action.RTChangeAction.ChangeGroup = m_runTimeChangeGroup; // Remove processed child change actions. // When this ObjectModel context is disposed, // the RTChangeAction will be disposed as well. Actions.RemoveAt(0); ++changeActionCount; } context.TrySaveChanges(); } finally { context.Detach(m_runTimeChangeGroup); } } changeActionCount = 0; } // update group status in DB using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance()) { try { context.Attach(m_runTimeChangeGroup); m_runTimeChangeGroup.Status = (int)targetStatus; m_runTimeChangeGroup.UsePagedActions = m_usePagedActions; context.TrySaveChanges(); } finally { context.Detach(m_runTimeChangeGroup); } } }