/// <summary> /// Initialize method of the analysis provider - acquire references to the services provided by the platform. /// </summary> /// <param name="serviceContainer">The service container.</param> public override void InitializeServices(IServiceContainer serviceContainer) { TraceManager.TraceInformation("WSSVC:AP:Initialize"); this.analysisServiceContainer = serviceContainer; supportedContentTypes = new Collection <ContentType>(); supportedContentTypes.Add(WellKnownContentType.VersionControlledFile); supportedContentTypes.Add(WellKnownContentType.VersionControlledFolder); SharePointVCChangeActionHandler handler = new SharePointVCChangeActionHandler(this); supportedChangeActions = new Dictionary <Guid, ChangeActionHandler>(); supportedChangeActions.Add(WellKnownChangeActionId.Add, handler.BasicActionHandler); supportedChangeActions.Add(WellKnownChangeActionId.Delete, handler.BasicActionHandler); supportedChangeActions.Add(WellKnownChangeActionId.Edit, handler.BasicActionHandler); configurationService = (ConfigurationService)analysisServiceContainer.GetService(typeof(ConfigurationService)); highWaterMarkDelta = new HighWaterMark <DateTime>(Constants.HwmDelta); highWaterMarkChangeset = new HighWaterMark <int>("LastChangeSet"); configurationService.RegisterHighWaterMarkWithSession(highWaterMarkDelta); configurationService.RegisterHighWaterMarkWithSession(highWaterMarkChangeset); changeGroupService = (ChangeGroupService)analysisServiceContainer.GetService(typeof(ChangeGroupService)); changeGroupService.RegisterDefaultSourceSerializer(new SharePointVCMigrationItemSerializer()); }
public void InitializeServices(IServiceContainer analysisServiceContainer) { m_analysisServiceContainer = analysisServiceContainer; m_changeGroupService = (ChangeGroupService)m_analysisServiceContainer.GetService(typeof(ChangeGroupService)); m_changeGroupService.RegisterDefaultSourceSerializer(new SubversionMigrationItemSerialzier()); }
public override void InitializeServices(IServiceContainer analysisServiceContainer) { TraceManager.TraceInformation("POC:AP:Initialize"); TraceManager.TraceInformation("Press enter.."); Console.ReadLine(); m_analysisServiceContainer = analysisServiceContainer; m_supportedContentTypes = new Collection <ContentType>(); m_supportedContentTypes.Add(WellKnownContentType.VersionControlledFile); m_supportedContentTypes.Add(WellKnownContentType.VersionControlledFolder); var handler = new BasicChangeActionHandlers(this); m_supportedChangeActions = new Dictionary <Guid, ChangeActionHandler>(); m_supportedChangeActions.Add(WellKnownChangeActionId.Add, handler.BasicActionHandler); m_supportedChangeActions.Add(WellKnownChangeActionId.Delete, handler.BasicActionHandler); m_supportedChangeActions.Add(WellKnownChangeActionId.Edit, handler.BasicActionHandler); m_supportedChangeActions.Add(WellKnownChangeActionId.Rename, handler.BasicActionHandler); ConfigurationService = (ConfigurationService)m_analysisServiceContainer.GetService(typeof(ConfigurationService)); m_hwmDelta = new HighWaterMark <DateTime>(Constants.HwmDelta); m_hwmChangeset = new HighWaterMark <int>("LastChangeSet"); ConfigurationService.RegisterHighWaterMarkWithSession(m_hwmDelta); ConfigurationService.RegisterHighWaterMarkWithSession(m_hwmChangeset); m_changeGroupService = (ChangeGroupService)m_analysisServiceContainer.GetService(typeof(ChangeGroupService)); m_changeGroupService.RegisterDefaultSourceSerializer(new PocVCMigrationItemSerializer()); }
/// <summary> /// Initializes the services. /// </summary> /// <param name="analysisService">The analysis service.</param> /// <exception cref="ArgumentNullException">If the analysisServiceContainer parameter is null</exception> public override void InitializeServices(IServiceContainer analysisService) { TraceManager.TraceInformation("WSSWIT:AP:InitializeServices"); if (analysisService == null) { throw new ArgumentNullException("analysisService"); } this.analysisServiceContainer = analysisService; this.configurationService = (ConfigurationService)analysisService.GetService(typeof(ConfigurationService)); MigrationSource migrationSourceConfiguration = configurationService.MigrationSource; SharePointMigrationDataSource dataSourceConfig = InitializeMigrationDataSource(); string username = string.Empty; string password = string.Empty; foreach (CustomSetting customSetting in configurationService.MigrationSource.CustomSettings.CustomSetting) { switch (customSetting.SettingKey) { case "username": { username = customSetting.SettingValue; break; } case "password": { password = customSetting.SettingValue; break; } } } dataSourceConfig.Credentials = new System.Net.NetworkCredential(username, password); dataSourceConfig.Url = migrationSourceConfiguration.ServerUrl; dataSourceConfig.ListName = migrationSourceConfiguration.SourceIdentifier; this.supportedContentTypes = new Collection <ContentType>(); this.supportedContentTypes.Add(WellKnownContentType.WorkItem); SharePointChangeActionHandlers handler = new SharePointChangeActionHandlers(this); this.supportedChangeActions = new Dictionary <Guid, ChangeActionHandler>(); this.supportedChangeActions.Add(WellKnownChangeActionId.Add, handler.BasicActionHandler); this.supportedChangeActions.Add(WellKnownChangeActionId.Edit, handler.BasicActionHandler); this.supportedChangeActions.Add(WellKnownChangeActionId.Delete, handler.BasicActionHandler); this.highWaterMarkDelta = new HighWaterMark <DateTime>(Constants.HwmDelta); this.highWaterMarkChangeSet = new HighWaterMark <int>("LastChangeSet"); this.configurationService.RegisterHighWaterMarkWithSession(this.highWaterMarkDelta); this.configurationService.RegisterHighWaterMarkWithSession(this.highWaterMarkChangeSet); this.changeGroupService = (ChangeGroupService)analysisServiceContainer.GetService(typeof(ChangeGroupService)); this.changeGroupService.RegisterDefaultSourceSerializer(new SharePointWITMigrationItemSerializer()); }
public override void InitializeServices(IServiceContainer migrationServiceContainer) { TraceManager.TraceInformation("POC:MP:InitializevicesSer"); m_migrationServiceContainer = migrationServiceContainer; m_changeGroupService = (ChangeGroupService)m_migrationServiceContainer.GetService(typeof(ChangeGroupService)); Debug.Assert(m_changeGroupService != null, "Change group service is not initialized"); m_configurationService = (ConfigurationService)m_migrationServiceContainer.GetService(typeof(ConfigurationService)); Debug.Assert(m_configurationService != null, "Configuration service is not initialized"); m_changeGroupService.RegisterDefaultSourceSerializer(new PocVCMigrationItemSerializer()); pocUtil = new PocUtil(); }
/// <summary> /// Initialize TfsVCAdapter /// </summary> public void InitializeServices(IServiceContainer analysisServiceContainer) { m_analysisServiceContainer = analysisServiceContainer; ConfigurationService = (ConfigurationService)m_analysisServiceContainer.GetService(typeof(ConfigurationService)); m_hwmDelta = new HighWaterMark <int>(Constants.HwmDelta); ConfigurationService.RegisterHighWaterMarkWithSession(m_hwmDelta); m_changeGroupService = (ChangeGroupService)m_analysisServiceContainer.GetService(typeof(ChangeGroupService)); m_changeGroupService.RegisterDefaultSourceSerializer(new TfsMigrationItemSerialzier()); }
/// <summary> /// Initialize method of the analysis provider - acquire references to the services provided by the platform. /// </summary> /// <param name="analysisServiceContainer"></param> public void InitializeServices(IServiceContainer analysisServiceContainer) { m_analysisServiceContainer = analysisServiceContainer; m_configurationService = (ConfigurationService)m_analysisServiceContainer.GetService(typeof(ConfigurationService)); m_hwmDelta = new HighWaterMark <DateTime>(Constants.HwmDelta); m_configurationService.RegisterHighWaterMarkWithSession(m_hwmDelta); m_hwmEventId = new HighWaterMark <long>("HWMCCEventId"); m_configurationService.RegisterHighWaterMarkWithSession(m_hwmEventId); m_changeGroupService = (ChangeGroupService)m_analysisServiceContainer.GetService(typeof(ChangeGroupService)); m_changeGroupService.RegisterDefaultSourceSerializer(new ClearCaseV6MigrationItemSerialzier()); }
/// <summary> /// Initialize method. /// </summary> public void InitializeServices(IServiceContainer migrationServiceContainer) { m_migrationServiceContainer = migrationServiceContainer; m_changeGroupService = (ChangeGroupService)m_migrationServiceContainer.GetService(typeof(ChangeGroupService)); m_changeGroupService.RegisterDefaultSourceSerializer(new TfsFileSystemMigrationItemSerializer()); Debug.Assert(m_changeGroupService != null, "Change group service is not initialized"); m_configurationService = (ConfigurationService)m_migrationServiceContainer.GetService(typeof(ConfigurationService)); Debug.Assert(m_configurationService != null, "Configuration service is not initialized"); m_eventService = (EventService)m_migrationServiceContainer.GetService(typeof(EventService)); m_changeGroupHighWaterMark = new HighWaterMark <long>("LastChangeGroupMigratedHighWaterMark"); m_configurationService.RegisterHighWaterMarkWithSession(m_changeGroupHighWaterMark); }
internal ChangeGroup GetChangeGroupForLatestFieldValues(ChangeGroupService changeGroupService) { string author = (string)WorkItem.Fields[CoreField.ChangedBy].Value; if (string.IsNullOrEmpty(author)) { author = (string)WorkItem.Fields[CoreField.AuthorizedAs].Value; } DateTime changedDate = (DateTime)WorkItem.Fields[CoreField.ChangedDate].Value; List <Field> fieldsForSync = new List <Field>(); foreach (Field f in WorkItem.Fields) { // filter out System.History with empty new value if (TFStringComparer.FieldName.Equals(f.ReferenceName, CoreFieldReferenceNames.History)) { if (string.IsNullOrEmpty(f.Value as string)) { continue; } } if (MustTakeField(f.FieldDefinition)) { fieldsForSync.Add(f); } } if (fieldsForSync.Count == 0) { return(null); } XmlDocument migrationActionDetails = CreateFieldRevisionDescriptionDoc( WorkItem.Rev, author, changedDate, fieldsForSync, new List <Field>()); ChangeGroup changeGroup = changeGroupService.CreateChangeGroupForDeltaTable( string.Format("{0}:{1}", WorkItem.Id, WorkItem.Rev)); IMigrationAction action = changeGroup.CreateAction( // Always generate Edit even for rev 1 in force sync case // Action will be changed to Add later if history not found for rev 1 WellKnownChangeActionId.Edit, new TfsWITMigrationItem(WorkItem, WorkItem.Rev), WorkItem.Id.ToString(), "", WorkItem.Rev.ToString(), "", WellKnownContentType.WorkItem.ReferenceName, migrationActionDetails); return(changeGroup); }
internal ChangeGroup CreateChangeGroup( ChangeGroupService changeGroupService, ClearQuestMigrationContext migrationContext, bool isLastRevOfThisSyncCycle) { ChangeGroup changeGroup = changeGroupService.CreateChangeGroupForDeltaTable(ChangeGroupName); OAdEntity record = CQWrapper.GetEntity(CQSession, EntityDefName, EntityDispName); if (IsRecordHistory) { XmlDocument recordHistDesc = CreateRecordHistoryDesc(record, HistoryValue, HistoryFieldName + "::" + Version, isLastRevOfThisSyncCycle); changeGroup.CreateAction(WellKnownChangeActionId.Edit, this, MigrationRecordId, "", Version, "", WellKnownContentType.WorkItem.ReferenceName, recordHistDesc); } else { XmlDocument recordDesc = CreateRecordDesc(record, Version, migrationContext, isLastRevOfThisSyncCycle); if (Version.Equals(NewRecordVersion, StringComparison.InvariantCulture)) { changeGroup.CreateAction(WellKnownChangeActionId.Add, this, MigrationRecordId, "", Version, "", WellKnownContentType.WorkItem.ReferenceName, recordDesc); } else { changeGroup.CreateAction(WellKnownChangeActionId.Edit, this, MigrationRecordId, "", Version, "", WellKnownContentType.WorkItem.ReferenceName, recordDesc); } } return(changeGroup); }
public override void InitializeServices(IServiceContainer analysisServiceContainer) { TraceManager.TraceInformation("WSSWIT:MP:InitializeServices"); if (analysisServiceContainer == null) { throw new ArgumentNullException("analysisServiceContainer"); } this.configurationService = (ConfigurationService)analysisServiceContainer.GetService(typeof(ConfigurationService)); ChangeGroupService changeGroupService = (ChangeGroupService)analysisServiceContainer.GetService(typeof(ChangeGroupService)); changeGroupService.RegisterDefaultSourceSerializer(new SharePointWITMigrationItemSerializer()); }
/// <summary> /// Initialize method of the analysis provider - acquire references to the services provided by the platform. /// </summary> /// <param name="analysisServiceContainer"></param> public void InitializeServices(IServiceContainer analysisServiceContainer) { m_analysisServiceContainer = analysisServiceContainer; m_configurationService = (ConfigurationService)m_analysisServiceContainer.GetService(typeof(ConfigurationService)); m_hwmDelta = new HighWaterMark <DateTime>(Constants.HwmDelta); m_configurationService.RegisterHighWaterMarkWithSession(m_hwmDelta); m_lastTfsChangesetAnalyzed = new HighWaterMark <int>(TFSFileSystemAdapterConstants.HwmLastTfsChangesetAnalyzed); m_configurationService.RegisterHighWaterMarkWithSession(m_lastTfsChangesetAnalyzed); m_lastHighWaterMarkMigratedToPeer = new HighWaterMark <int>(Constants.HwmMigrated); m_configurationService.RegisterHighWaterMarkWithSession(m_lastHighWaterMarkMigratedToPeer, m_configurationService.MigrationPeer); m_changeGroupService = (ChangeGroupService)m_analysisServiceContainer.GetService(typeof(ChangeGroupService)); m_changeGroupService.RegisterDefaultSourceSerializer(new TfsFileSystemMigrationItemSerializer()); m_branchConfiguration = new TfsFileSystemConfiguration(m_configurationService); }
private bool updateConversionHistory(MigrationConflict conflict, ConflictResolutionRule rule, IServiceContainer serviceContainer) { if (!rule.DataFieldDictionary.ContainsKey(TfsCheckinFailureManualResolveAction.MigrationInstructionChangeId) || !rule.DataFieldDictionary.ContainsKey(TfsCheckinFailureManualResolveAction.DeltaTableChangeId)) { return(false); } ChangeGroupService changeGroupService = serviceContainer.GetService(typeof(ChangeGroupService)) as ChangeGroupService; string migrationInstructionName = rule.DataFieldDictionary[TfsCheckinFailureManualResolveAction.MigrationInstructionChangeId]; string deltaTableName = rule.DataFieldDictionary[TfsCheckinFailureManualResolveAction.DeltaTableChangeId]; string comment = rule.RuleDescription; bool result = changeGroupService.UpdateConversionHistoryAndRemovePendingChangeGroups(migrationInstructionName, deltaTableName, comment); TraceManager.TraceInformation(string.Format("Conflict of type '{0}' resolved by updating history with new change versions: Source HighWaterMark: {1}; Target HighWaterMark: {2}", conflict.ConflictType.FriendlyName, deltaTableName, migrationInstructionName)); return(result); }
/// <summary> /// Establish the context based on the context info from the side of the pipeline /// </summary> public virtual void EstablishContext(ChangeGroupService sourceSystemChangeGroupService) { try { if (m_witMetadataSyncPolicy == WitMetadataSyncPolicy.DoNotTakeTheirs) { return; } if (m_witMetadataSyncPolicy == WitMetadataSyncPolicy.Merge) { throw new NotImplementedException("WitMetadataSyncPolicy.Merge has not been implemented"); } int pageNumber = 0; int pageSize = 1000; IEnumerable <ChangeGroup> changeGroups = null; do { changeGroups = sourceSystemChangeGroupService.NextDeltaTablePage(pageNumber++, pageSize, false); foreach (ChangeGroup nextChangeGroup in changeGroups) { if (nextChangeGroup.ContainsBackloggedAction) { continue; } if (TryProcessContextSyncChangeGroup(nextChangeGroup)) { break; } } } while (changeGroups.Count() == pageSize); } catch (Exception exception) { if (!(exception is MigrationUnresolvedConflictException)) { ErrorManager errMgr = m_migrationServiceContainer.GetService(typeof(ErrorManager)) as ErrorManager; errMgr.TryHandleException(exception); } return; } }
/// <summary> /// Initializes the services. /// </summary> /// <param name="migrationService">The migration service.</param> public override void InitializeServices(IServiceContainer migrationService) { TraceManager.TraceInformation("WSSVC:MP:InitializevicesSer"); this.migrationServiceContainer = migrationService; changeGroupService = (ChangeGroupService)this.migrationServiceContainer.GetService(typeof(ChangeGroupService)); Debug.Assert(changeGroupService != null, "Change group service is not initialized"); configurationService = (ConfigurationService)this.migrationServiceContainer.GetService(typeof(ConfigurationService)); Debug.Assert(configurationService != null, "Configuration service is not initialized"); changeGroupService.RegisterDefaultSourceSerializer(new SharePointVCMigrationItemSerializer()); sourceIdentifier = configurationService.MigrationSource.SourceIdentifier; string username = string.Empty; string password = string.Empty; foreach (CustomSetting customSetting in configurationService.MigrationSource.CustomSettings.CustomSetting) { switch (customSetting.SettingKey) { case "username": { username = customSetting.SettingValue; break; } case "password": { password = customSetting.SettingValue; break; } } } NetworkCredential credentials = new NetworkCredential(username, password); sharePointWriteUtilities = new SharePointWriteUtil(configurationService.MigrationSource.ServerUrl, credentials, configurationService.Workspace); }
/// <summary> /// This method allows the implementing class to add file property metadata for any files /// that are added or changed during a migration/sync session. /// </summary> /// <param name="serviceContainer">A service container that provides access to services provided by the /// TFS Integration Platform Toolkit</param> /// <param name="changeGroup">The change group being migrated for file property metadata can be generated /// by adding FileProperty change actions to the ChangeGroup</param> private void AddFilePropertiesToChangeGroup(IServiceContainer serviceContainer, ChangeGroup changeGroup) { ChangeGroupService changeGroupService = (ChangeGroupService)serviceContainer.GetService(typeof(ChangeGroupService)); // This FilePropertiesAnalysisAddin adds two single properties to each item: // The change group identifier from the source from which is was migrated // The owner of the change group FileMetadataProperties fileProperties = new FileMetadataProperties(); fileProperties.Add(FilePropertiesAnalysisAddinResources.SourceChangeGroupIdKey, changeGroup.Name); fileProperties.Add(FilePropertiesAnalysisAddinResources.SourceChangeGroupOwnerKey, changeGroup.Owner); XmlDocument filePropertiesXmlDoc = fileProperties.ToXmlDocument(); IMigrationAction[] currentActions = new IMigrationAction[changeGroup.Actions.Count]; changeGroup.Actions.CopyTo(currentActions, 0); foreach (IMigrationAction action in currentActions) { if (string.Equals(action.ItemTypeReferenceName, WellKnownContentType.VersionControlledFile.ReferenceName, StringComparison.Ordinal) || string.Equals(action.ItemTypeReferenceName, WellKnownContentType.VersionControlledFolder.ReferenceName, StringComparison.Ordinal)) { if (action.Action == WellKnownChangeActionId.Add || action.Action == WellKnownChangeActionId.Edit || action.Action == WellKnownChangeActionId.Rename || action.Action == WellKnownChangeActionId.Undelete) { IMigrationAction addFilePropertiesAction = changeGroup.CreateAction( WellKnownChangeActionId.AddFileProperties, action.SourceItem, action.FromPath, action.Path, action.Version, null, action.ItemTypeReferenceName, filePropertiesXmlDoc); } } } }
/// <summary> /// Initialize method. /// </summary> public void InitializeServices(IServiceContainer migrationServiceContainer) { m_migrationServiceContainer = migrationServiceContainer; m_changeGroupService = (ChangeGroupService)m_migrationServiceContainer.GetService(typeof(ChangeGroupService)); if (m_alternativeSerializer == null) { m_changeGroupService.RegisterDefaultSourceSerializer(new ClearCaseV6MigrationItemSerialzier()); } else { m_changeGroupService.RegisterDefaultSourceSerializer(m_alternativeSerializer); } Debug.Assert(m_changeGroupService != null, "Change group service is not initialized"); m_configurationService = (ConfigurationService)m_migrationServiceContainer.GetService(typeof(ConfigurationService)); Debug.Assert(m_configurationService != null, "Configuration service is not initialized"); m_eventService = (EventService)m_migrationServiceContainer.GetService(typeof(EventService)); m_commentDecorationService = (ICommentDecorationService)m_migrationServiceContainer.GetService(typeof(ICommentDecorationService)); Debug.Assert(m_commentDecorationService != null, "Comment decoration service is not initialized"); m_changeGroupHighWaterMark = new HighWaterMark <long>("LastChangeGroupMigratedHighWaterMark"); m_configurationService.RegisterHighWaterMarkWithSession(m_changeGroupHighWaterMark); if (m_hwmLastSyncedTfsChangeset != null) { m_configurationService.RegisterHighWaterMarkWithSession(m_hwmLastSyncedTfsChangeset); } foreach (BusinessModel.VC.Setting setting in m_configurationService.VcCustomSetting.Settings.Setting) { if (string.Equals( setting.SettingKey, MigrationToolkitResources.VCSetting_DisableTargetAnalysis, StringComparison.OrdinalIgnoreCase)) { if (string.Equals(setting.SettingValue, "True", StringComparison.OrdinalIgnoreCase)) { m_overrideTargetChange = true; break; } } } }
/// <summary> /// Initialize the adapter services /// </summary> /// <param name="analysisServiceContainer"></param> public void InitializeServices(IServiceContainer analysisServiceContainer) { m_analysisServiceContainer = analysisServiceContainer; m_changeGroupService = (ChangeGroupService)m_analysisServiceContainer.GetService(typeof(ChangeGroupService)); Debug.Assert(m_changeGroupService != null, "Change group service is not initialized"); m_changeGroupService.RegisterDefaultSourceSerializer(new ClearQuestRecordItemSerializer()); //m_changeGroupService.RegisterSourceSerializer( // WellKnownChangeActionId.SyncContext, new WorkItemContextSyncMigrationItemSerializer()); m_changeGroupService.RegisterSourceSerializer( WellKnownChangeActionId.AddAttachment, new ClearQuestAttachmentItemSerializer()); m_changeGroupService.RegisterSourceSerializer( WellKnownChangeActionId.DelAttachment, new ClearQuestAttachmentItemSerializer()); m_configurationService = (ConfigurationService)m_analysisServiceContainer.GetService(typeof(ConfigurationService)); Debug.Assert(m_configurationService != null, "Configuration service is not initialized"); m_conflictManagerService = m_analysisServiceContainer.GetService(typeof(ConflictManager)) as ConflictManager; m_hwmDelta = new HighWaterMark <DateTime>(ClearQuestConstants.CqRecordHwm); m_configurationService.RegisterHighWaterMarkWithSession(m_hwmDelta); }
public void InitializeServices(IServiceContainer migrationServiceContainer) { m_migrationServiceContainer = migrationServiceContainer; m_changeGroupService = (ChangeGroupService)m_migrationServiceContainer.GetService(typeof(ChangeGroupService)); Debug.Assert(m_changeGroupService != null, "Change group service is not initialized"); m_changeGroupService.RegisterDefaultSourceSerializer(new ClearQuestRecordItemSerializer()); //m_changeGroupService.RegisterSourceSerializer( // WellKnownChangeActionId.SyncContext, new WorkItemContextSyncMigrationItemSerializer()); m_changeGroupService.RegisterSourceSerializer( WellKnownChangeActionId.AddAttachment, new ClearQuestAttachmentItemSerializer()); m_changeGroupService.RegisterSourceSerializer( WellKnownChangeActionId.DelAttachment, new ClearQuestAttachmentItemSerializer()); m_configurationService = (ConfigurationService)m_migrationServiceContainer.GetService(typeof(ConfigurationService)); Debug.Assert(m_configurationService != null, "Configuration service is not initialized"); m_commentDecorationService = (ICommentDecorationService)m_migrationServiceContainer.GetService(typeof(ICommentDecorationService)); Debug.Assert(m_commentDecorationService != null, "Comment decoration service is not initialized"); m_conflictManagerService = migrationServiceContainer.GetService(typeof(ConflictManager)) as ConflictManager; }
internal ChangeGroup GetChangeGroupForLatestAttachments(ChangeGroupService changeGroupService) { List <TfsMigrationFileAttachment> files = new List <TfsMigrationFileAttachment>(); if (WorkItem.Attachments.Count == 0) { return(null); } else { foreach (Attachment attachment in WorkItem.Attachments) { files.Add(new TfsMigrationFileAttachment(attachment, m_core.TfsTPC.Uri.AbsoluteUri)); } Guid changeActionId = WellKnownChangeActionId.AddAttachment; ChangeGroup changeGroup = changeGroupService.CreateChangeGroupForDeltaTable( string.Format("{0}:{1}", WorkItem.Id, "Attachments")); foreach (TfsMigrationFileAttachment attachmentFile in files) { XmlDocument migrationActionDetails = CreateAttachmentDescriptionDoc(attachmentFile, WorkItem.Rev.ToString()); changeGroup.CreateAction( changeActionId, attachmentFile, WorkItem.Id.ToString(), "", "0", "", WellKnownContentType.WorkItem.ReferenceName, migrationActionDetails); TraceManager.TraceVerbose(String.Format("Generating AddAttachment change action: Work Item: {0}, Attachment File: {1}", WorkItem.Id.ToString(), attachmentFile.Name)); } return(changeGroup); } }
internal void ComputeFieldDelta( ChangeGroupService changeGroupService, DateTime waterMarkChangeStartTime, FieldValueComparer tfsValueComparer, ITranslationService translationService, ConfigurationService configService, List <ChangeGroup> groups, IsWorkItemRevisionProcessed processedRevCallBack) { Guid sourceId = configService.SourceId; List <Revision> revsToBeSynced = FindUnsyncedRevisions(waterMarkChangeStartTime, translationService, sourceId, processedRevCallBack); Dictionary <int, object> fieldValueBaseline = new Dictionary <int, object>(); TryEstablishFieldValueBaseline(fieldValueBaseline, revsToBeSynced); foreach (Revision rev in revsToBeSynced) { // get basic revision info: revision#, author#, and change time int revIndex = (int)rev.Fields[CoreField.Rev].Value; string author = (string)rev.Fields[CoreField.ChangedBy].Value; if (string.IsNullOrEmpty(author)) { author = (string)rev.Fields[CoreField.AuthorizedAs].Value; } DateTime changedDate = (DateTime)rev.Fields[CoreField.ChangedDate].Value; List <Field> fieldForSync = new List <Field>(); List <Field> skippingFields = new List <Field>(); foreach (Field f in rev.Fields) { // filter out System.History with empty new value if (TFStringComparer.FieldName.Equals(f.ReferenceName, CoreFieldReferenceNames.History)) { if (string.IsNullOrEmpty(f.Value as string)) { continue; } } if (MustTakeField(f.FieldDefinition)) { // find out fields that changed in this revision object oldValue; fieldValueBaseline.TryGetValue(f.Id, out oldValue); //***Note: When it is a new work item (unmatched on the other side), // we need to always include fields if ((null != f.Value && (!tfsValueComparer.Equals(oldValue, f.Value) || revIndex == 1)) || (null == f.Value && null != oldValue && revIndex != 1)) { fieldForSync.Add(f); fieldValueBaseline[f.Id] = f.Value; } else if (IsReferencedField(f, configService)) { skippingFields.Add(f); } } else if (IsReferencedField(f, configService)) { skippingFields.Add(f); } } if (fieldForSync.Count == 0) { continue; } XmlDocument migrationActionDetails = CreateFieldRevisionDescriptionDoc( revIndex, author, changedDate, fieldForSync, skippingFields); Guid changeActionId = revIndex == 1 ? WellKnownChangeActionId.Add : WellKnownChangeActionId.Edit; /// TODO: consider batching revs of different workitems in one change group ChangeGroup changeGroup = changeGroupService.CreateChangeGroupForDeltaTable( string.Format("{0}:{1}", WorkItem.Id, revIndex)); IMigrationAction action = changeGroup.CreateAction( changeActionId, new TfsWITMigrationItem(WorkItem, revIndex), WorkItem.Id.ToString(), "", revIndex.ToString(), "", WellKnownContentType.WorkItem.ReferenceName, migrationActionDetails); groups.Add(changeGroup); } }
/// <summary> /// Establish the context based on the context info from the side of the pipeline /// </summary> public void EstablishContext(ChangeGroupService sourceSystemChangeGroupService) { }
internal void ComputeAttachmentDelta( ChangeGroupService changeGroupService, DateTime waterMarkChangeStartTime, ITranslationService translationService, Guid sourceId, List <ChangeGroup> groups) { List <TfsMigrationFileAttachment> files = new List <TfsMigrationFileAttachment>(); if (WorkItem.Attachments.Count > 0) { List <Revision> revsToBeSynced = FindUnsyncedRevisions(waterMarkChangeStartTime, translationService, sourceId, null); bool hasAttachmentChanges = false; foreach (Revision rev in revsToBeSynced) { if (rev.Index == 0 && (int)rev.Fields[CoreField.AttachedFileCount].Value > 0) { hasAttachmentChanges = true; break; } if (rev.Index > 0) { int currAttchCount = (int)rev.Fields[CoreField.AttachedFileCount].Value; Revision prevRev = rev.WorkItem.Revisions[rev.Index - 1]; int prevAttchCount = (int)prevRev.Fields[CoreField.AttachedFileCount].Value; if (currAttchCount != prevAttchCount) { hasAttachmentChanges = true; break; } } } if (!hasAttachmentChanges) { return; } foreach (Attachment attachment in WorkItem.Attachments) { if (attachment.AttachedTimeUtc <= waterMarkChangeStartTime || !attachment.IsSaved) { continue; } files.Add(new TfsMigrationFileAttachment(attachment)); } } Guid changeActionId = WellKnownChangeActionId.AddAttachment; ChangeGroup changeGroup = changeGroupService.CreateChangeGroupForDeltaTable( string.Format("{0}:{1}", WorkItem.Id, "Attachments")); foreach (TfsMigrationFileAttachment attachmentFile in files) { XmlDocument migrationActionDetails = CreateAttachmentDescriptionDoc(attachmentFile, WorkItem.Rev.ToString()); changeGroup.CreateAction( changeActionId, attachmentFile, WorkItem.Id.ToString(), "", "0", "", WellKnownContentType.WorkItem.ReferenceName, migrationActionDetails); } // VERY IMPORTANT: use the RelatedArtifactsStore to detect detailed attachment changes WorkItemAttachmentStore store = new WorkItemAttachmentStore(sourceId); List <FileAttachmentMetadata> additionalAttachmentToDelete; store.UpdatePerItemAttachmentChangesByCheckingRelatedItemRecords( WorkItem.Id.ToString(), changeGroup, out additionalAttachmentToDelete); foreach (FileAttachmentMetadata attch in additionalAttachmentToDelete) { TfsMigrationFileAttachment attachmentFile = new TfsMigrationFileAttachment(attch); XmlDocument migrationActionDetails = CreateAttachmentDescriptionDoc(attachmentFile, WorkItem.Rev.ToString()); changeGroup.CreateAction( WellKnownChangeActionId.DelAttachment, attachmentFile, WorkItem.Id.ToString(), "", "0", "", WellKnownContentType.WorkItem.ReferenceName, migrationActionDetails); } groups.Add(changeGroup); }
private void queryHistory(ChangeGroupService changeGroupService) { m_hwmDelta.Reload(); DateTime since = m_hwmDelta.Value; List <CCHistoryRecord> historyRecordList = m_clearCaseServer.GetHistoryRecords(m_configurationService.Filters, since, true); historyRecordList.Sort(); CCVersion version; CCItem currentItem = null; CCItem previousLnItem = null; string previousLnItemLeafName = null; string previousMkElemItemPath = null; List <CCHistoryRecord> processedRecordList = new List <CCHistoryRecord>(); foreach (CCHistoryRecord historyRecord in historyRecordList) { switch (historyRecord.OperationType) { case OperationType.Checkin: version = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath); currentItem = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath)); if (string.Equals(historyRecord.OperationDescription, OperationDescription.Version)) { if (ClearCasePath.Equals(previousMkElemItemPath, currentItem.AbsoluteVobPath)) { // File version checkin following a mkelem, create an Add historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath; historyRecord.ChangeAction = WellKnownChangeActionId.Add; historyRecord.IsDirectory = version.IsDirectory; processedRecordList.Add(historyRecord); previousMkElemItemPath = null; } else { // File version checkin following a mkelem, create an Edit historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath; historyRecord.ChangeAction = WellKnownChangeActionId.Edit; historyRecord.IsDirectory = version.IsDirectory; processedRecordList.Add(historyRecord); } } else if (string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryVersion) && (ClearCasePath.Equals(previousMkElemItemPath, currentItem.AbsoluteVobPath))) { // Directory version checkin following a mkelem, create an Add historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath; historyRecord.ChangeAction = WellKnownChangeActionId.Add; historyRecord.IsDirectory = version.IsDirectory; processedRecordList.Add(historyRecord); previousMkElemItemPath = null; } break; case OperationType.Mkattr: case OperationType.Mkpool: case OperationType.Mkreplica: case OperationType.Mktype: // ToDo // writeHistoryRecord(historyFields); break; case OperationType.Lnname: version = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath); currentItem = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath)); previousLnItem = currentItem; previousLnItemLeafName = ClearCaseEventSpec.ParseLnNameComment(historyRecord.Comment); break; case OperationType.Mkbranch: // ToDo if (string.Equals(historyRecord.OperationDescription, OperationDescription.Version) || string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryVersion)) { /*version = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath); * currentItem = new CCItem(version, vob); * historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath; * historyRecord.ChangeAction = WellKnownChangeActionId.Add; * historyRecord.IsDirectory = version.IsDirectory; * historyRecordList.Add(historyRecord); * */ } break; case OperationType.Mkelem: if (string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryElement)) { // Todo /*if (currentState == OperationState.Initialized) * { * currentState = OperationState.CreateDirectoryElement; * currentItem = new Item(historyFields[1], ItemType.Element, m_vobName); * } * else * { * logStateTransitionError(currentState, operationType, operationDescription); * }*/ } else if (string.Equals(historyRecord.OperationDescription, OperationDescription.Branch)) { // Todo /* * if ((currentState == OperationState.AddDirectoryToParent) || (currentState == OperationState.CreateDirectoryElement)) ||{ || currentState = OperationState.CreateDirectoryBranch; || currentItem = new Item(historyFields[1], ItemType.Branch, m_vobName); ||} ||else ||{ || logStateTransitionError(currentState, operationType, operationDescription); ||} * */ } else if (string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryVersion) || string.Equals(historyRecord.OperationDescription, OperationDescription.Version)) { version = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath); currentItem = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath)); previousMkElemItemPath = currentItem.AbsoluteVobPath; //if (currentState == OperationState.CreateDirectoryBranch) //{ /*version = m_clearCaseServer.ApplicationClass.get_Version(historyFields[1]); * currentItem = new Item(version, vob); * if (IsPathMapped(currentItem.AbsoluteVobPath) && * IsOurChange(ClearCasePath.removeViewLocationFromVersion(version.ExtendedPath, m_clearCaseServer.ViewRootPath))) * { * createMigrationAction( * version, * null, * currentItem.AbsoluteVobPath, * versionTime, * WellKnownChangeActionId.Add, * version.IsDirectory); * }*/ // Verify the version to be 0 //currentState = OperationState.Initialized; //} //else //{ // logStateTransitionError(currentState, operationType, operationDescription); //} } else { //logStateTransitionError(currentState, operationType, operationDescription); } break; case OperationType.Mkhlink: // ToDo // writeHistoryRecord(historyFields); break; case OperationType.Mklabel: break; case OperationType.Rmname: bool isDirectory; string rmItemName = ClearCaseEventSpec.ParseRmNameComment(historyRecord.Comment, out isDirectory); if (rmItemName == null) { TraceManager.TraceWarning(String.Format("Skipping rmname operation: Unable to determine element type from history record comment: '{0}'", historyRecord.Comment)); continue; } version = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath); currentItem = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath)); if (currentItem.Equals(previousLnItem)) { historyRecord.AbsoluteVobPath = ClearCasePath.Combine(currentItem.AbsoluteVobPath, previousLnItemLeafName); historyRecord.AbsoluteVobPathFrom = ClearCasePath.Combine(currentItem.AbsoluteVobPath, rmItemName); historyRecord.ChangeAction = WellKnownChangeActionId.Rename; historyRecord.IsDirectory = isDirectory; processedRecordList.Add(historyRecord); previousLnItem = null; previousLnItemLeafName = null; // todo, path not mapped exception } else { // delete operation historyRecord.AbsoluteVobPath = ClearCasePath.Combine(currentItem.AbsoluteVobPath, rmItemName); historyRecord.ChangeAction = WellKnownChangeActionId.Delete; historyRecord.IsDirectory = isDirectory; processedRecordList.Add(historyRecord); } break; case OperationType.Undefined: break; case OperationType.Mkvob: // Add of Vob itself. // ToDo // writeHistoryRecord(historyFields); default: break; } } reviseHistoryRecordsForRename(processedRecordList); m_hwmEventId.Reload(); long lastProcessedEventId = m_hwmEventId.Value; foreach (CCHistoryRecord historyRecord in processedRecordList) { if (historyRecord.EventId <= lastProcessedEventId) { // The event has been processed in previous sync. TraceManager.TraceInformation("Skipping history record because the event was processed in a previous sync pass of this session"); continue; } if (Utils.IsOurChange(historyRecord)) { TraceManager.TraceInformation("Skipping history record because it represents a change migrated by the Integration Platform"); continue; } if (Utils.IsPathMapped(historyRecord.AbsoluteVobPath, m_configurationService)) { if (historyRecord.ChangeAction == WellKnownChangeActionId.Rename) { if (Utils.IsPathMapped(historyRecord.AbsoluteVobPathFrom, m_configurationService)) { m_currentChangeGroup = createMigrationAction(historyRecord, historyRecord.ChangeAction); } else { // ToDo Path not mapped conflict m_currentChangeGroup = createMigrationAction(historyRecord, WellKnownChangeActionId.Add); } } else { m_currentChangeGroup = createMigrationAction(historyRecord, historyRecord.ChangeAction); } } else { // ToDo path not mapped conflict if ((historyRecord.ChangeAction == WellKnownChangeActionId.Rename) && (Utils.IsPathMapped(historyRecord.AbsoluteVobPathFrom, m_configurationService))) { m_currentChangeGroup = createMigrationAction(historyRecord, WellKnownChangeActionId.Delete); } else { TraceManager.TraceWarning("Skipping history record because the path '{0}' is not mapped in a filter string", historyRecord.AbsoluteVobPath); } } } if (m_currentChangeGroup != null) { m_currentChangeGroup.Save(); } if (processedRecordList.Count > 0) { m_hwmDelta.Update(processedRecordList.Last().VersionTime); } m_changeGroupService.PromoteDeltaToPending(); }