tech·nic·al·ly agile

Creating a WIT Adapter for the TFS Integration Platform for a source with no history

Learn how to create a WIT adapter for the TFS Integration Platform, enabling seamless integration with Test Track Pro, even without historical data.

Published on
40 minute read
Image
https://nkdagility.com/resources/bSv-E4Y5zk0

Creating a WIT Adapter for the TFS Integration Platform for a source with no history   I have recently been working on a TFS Integration Platform Adapter for integrating with Test Track Pro. The problem with TTP is that it does not contain any history.


Although I have had my Test Track Pro Tip Adapter working for quite some time, the customer came back and asked if they could have a rolling migration. i.e. Shipping changes on a regular basis, but only the TIP each time.

  1<?xml version="1.0" encoding="utf-16"?>
  2<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  4               UniqueId="ADD2D39C-C44A-4046-93AC-03A4970B2312"
  5               FriendlyName="(3)Northwest Cadence Test Track Pro to TFS">
  6  <Providers>
  7    <Provider ReferenceName="c0e63c2b-e06c-48bb-8698-243a82bb950e" FriendlyName="TestTrackPro TIP Adapter" />
  8    <Provider ReferenceName="04201d39-6e47-416f-98b2-07f0013f8455" FriendlyName="TFS 2010 Migration WIT Provider" />
  9  </Providers>
 10  <Addins>
 11    <Addin ReferenceName="cdde6b6b-72fc-43b6-bbd1-b8a89a788c6f"
 12          FriendlyName="TFS Active Directory User Id Lookup Service Addin" />
 13  </Addins>
 14  <SessionGroup CreationTime="2011-04-14T14:59:58.72-07:00"
 15                FriendlyName="(3)Northwest Cadence Test Track Pro to TFS"
 16                SessionGroupGUID="FECE4D93-8498-4ED4-87D2-22599336A07D"
 17                Creator="martinhinshelwood"
 18                SyncIntervalInSeconds="0"
 19                SyncDurationInMinutes="0">
 20    <MigrationSources>
 21      <MigrationSource InternalUniqueId="C513F930-2602-400D-A0BF-A2A3AB434DF5"
 22                       FriendlyName="TestTrackPro source"
 23                       ServerIdentifier="ttpDatabase@http://ttpserver.domain.com:80"
 24                       ServerUrl="http://10.191.164.95:80"
 25                       SourceIdentifier="ttpDatabase"
 26                       ProviderReferenceName="c0e63c2b-e06c-48bb-8698-243a82bb950e">
 27        <Settings>
 28          <Addins />
 29          <UserIdentityLookup>
 30
 31            <LookupAddin Precedence="1" ReferenceName="cdde6b6b-72fc-43b6-bbd1-b8a89a788c6f" />
 32
 33          </UserIdentityLookup>
 34
 35          <DefaultUserIdProperty UserIdPropertyName="DisplayName" />
 36        </Settings>
 37        <CustomSettings>
 38          <CustomSetting SettingKey="Username" SettingValue="mhinshelwood" />
 39          <CustomSetting SettingKey="Password" SettingValue="password" />
 40          <!--<CustomSetting SettingKey="OverrideHWM" SettingValue="2011-05-5T14:59:58.72-07:00" />-->
 41        </CustomSettings>
 42        <StoredCredential />
 43      </MigrationSource>
 44      <MigrationSource InternalUniqueId="6E3BDF70-F1AE-4CD5-8EE4-133C8AEE0857"
 45                       FriendlyName="tfs01.nwcadence.com (WIT)"
 46                       ServerIdentifier="346dd524-18b0-4eda-ba05-0f4d6b14e076"
 47                       ServerUrl="http://tfs01.nwcadence.com:8080/tfs/defaultcollection"
 48                       SourceIdentifier="ttpImportTest"
 49                       ProviderReferenceName="04201d39-6e47-416f-98b2-07f0013f8455">
 50        <Settings>
 51          <Addins />
 52          <UserIdentityLookup>
 53
 54            <LookupAddin Precedence="1" ReferenceName="cdde6b6b-72fc-43b6-bbd1-b8a89a788c6f" />
 55
 56          </UserIdentityLookup>
 57
 58          <DefaultUserIdProperty UserIdPropertyName="DisplayName" />
 59        </Settings>
 60        <CustomSettings>
 61          <CustomSetting SettingKey="EnableBypassRuleDataSubmission" SettingValue="True" />
 62          <CustomSetting SettingKey="DisableAreaPathAutoCreation" SettingValue="False" />
 63          <CustomSetting SettingKey="DisableIterationPathAutoCreation" SettingValue="False" />
 64        </CustomSettings>
 65        <StoredCredential />
 66      </MigrationSource>
 67    </MigrationSources>
 68    <Sessions>
 69      <Session CreationTime="2011-04-14T14:59:58.703-07:00"
 70               SessionUniqueId="adea805d-51df-489a-b2fd-9717b4af3703"
 71               FriendlyName="Work Item Tracking Session"
 72               LeftMigrationSourceUniqueId="C513F930-2602-400D-A0BF-A2A3AB434DF5"
 73               RightMigrationSourceUniqueId="6E3BDF70-F1AE-4CD5-8EE4-133C8AEE0857"
 74               SessionType="WorkItemTracking">
 75        <EventSinks />
 76        <CustomSettings>
 77          <SettingXml>
 78            <WITSessionCustomSetting>
 79              <WorkItemTypes>
 80                <WorkItemType LeftWorkItemTypeName="Defect" RightWorkItemTypeName="Bug" fieldMap="Defect2BugFieldMap" />
 81              </WorkItemTypes>
 82              <FieldMaps>
 83                <FieldMap name="Defect2BugFieldMap">
 84                  <MappedFields>
 85                    <MappedField LeftName="Summary" RightName="System.Title" MapFromSide="Left" valueMap="" />
 86                    <MappedField LeftName="Description" RightName="System.Description" MapFromSide="Left" valueMap="" />
 87                    <MappedField LeftName="Severity" RightName="Microsoft.VSTS.Common.Severity" MapFromSide="Left" valueMap="SeverityMapTTP2TFS" />
 88                    <MappedField LeftName="Status" RightName="System.State" MapFromSide="Left" valueMap="StatusMapTTP2TFS" />
 89                    <MappedField LeftName="Reason" RightName="System.Reason" MapFromSide="Left" valueMap="ReasonMapTTP2TFS" />
 90                    <MappedField LeftName="Priority" RightName="Microsoft.VSTS.Common.Priority" MapFromSide="Left" valueMap="PriorityMapTTP2TFS" />
 91                    <MappedField LeftName="Steps to Reproduce" RightName="Microsoft.VSTS.TCM.ReproSteps" MapFromSide="Left" />
 92                    <MappedField LeftName="History" RightName="System.History" MapFromSide="Left" />
 93                    <MappedField LeftName="Assigned To User" RightName="System.AssignedTo" MapFromSide="Left" valueMap="UserMapTTP2TFS" />
 94                    <MappedField LeftName="Date Created" RightName="Microsoft.VSTS.Common.CreatedDate" MapFromSide="Left"  />
 95                    <MappedField LeftName="Found by" RightName="Microsoft.VSTS.Common.HowFoundCategory" MapFromSide="Left"  valueMap="HowFoundCategoryTFS" />
 96                    <!-- WORKAROUND using unused field: Manual Testing -->
 97                    <!--
 98                    <MappedField LeftName="@@MISSINGFIELD@@" RightName="Microsoft.VSTS.Common.Triage" MapFromSide="Left" valueMap="TfsTriageMapping" />
 99                    <MappedField LeftName="@@MISSINGFIELD@@" RightName="Microsoft.VSTS.Common.Regression" MapFromSide="Left" valueMap="TfsRegressionMapping" />
100                    <MappedField LeftName="@@MISSINGFIELD@@" RightName="Microsoft.VSTS.Build.Changelist" MapFromSide="Left" valueMap="TfsChangelistMapping" />
101                    -->
102                    <MappedField LeftName="Date Modified" RightName="System.ChangedDate" MapFromSide="Left" />
103                    <!--<MappedField LeftName="Modified By" RightName="System.ChangedBy" MapFromSide="Left" valueMap="StatusMapTTP2TFS" /-->
104                    <MappedField LeftName="Verify Version" RightName="Microsoft.VSTS.Build.FoundIn" MapFromSide="Left" valueMap="VerifyVersionMapTTP2TFS" />
105                  </MappedFields>
106                  <AggregatedFields>
107                    <FieldsAggregationGroup   MapFromSide="Left" TargetFieldName="System.AreaPath" Format="TestTrackProImport{0}{1}">
108                      <SourceField Index="0" SourceFieldName="Component" valueMap="ComponentMapTTP2TFS" />
109                      <SourceField Index="1" SourceFieldName="Functional Area" valueMap="FunctionalAreaMapTTP2TFS" />
110                    </FieldsAggregationGroup>
111                    <FieldsAggregationGroup   MapFromSide="Left" TargetFieldName="System.IterationPath" Format="TestTrackProImport{0}">
112                      <SourceField Index="0" SourceFieldName="Version Found" valueMap="VerifyVersionMapTTP2TFS"/>
113                    </FieldsAggregationGroup>
114                  </AggregatedFields>
115                  <UserIdentityFields>
116                    <LeftUserIdentityFields />
117                    <RightUserIdentityFields>
118                      <UserIdField FieldReferenceName="System.AssignedTo" UserIdPropertyName="DisplayName" />
119                    </RightUserIdentityFields>
120                  </UserIdentityFields>
121                </FieldMap>
122              </FieldMaps>
123              <ValueMaps>
124                <ValueMap name="HowFoundCategoryTFS">
125                  <Value LeftValue="*" RightValue="Manual Testing">
126                  </Value>
127                </ValueMap>
128                <ValueMap name="SeverityMapTTP2TFS">
129                  <Value LeftValue="" RightValue="2" />
130                  <Value LeftValue="3-Usability" RightValue="3" />
131                  <Value LeftValue="4-Cosmetic" RightValue="4" />
132                  <Value LeftValue="2-Feature not functioning" RightValue="2" />
133                  <Value LeftValue="1-Critical, Crash" RightValue="1" />
134                  <Value LeftValue="5-Security" RightValue="4" />
135                </ValueMap>
136                 <ValueMap name="TfsChangelistMapping">
137                  <Value LeftValue="" RightValue="Unknown" />
138                  <Value LeftValue="*" RightValue="*" />
139                </ValueMap>
140                <ValueMap name="TfsTriageMapping">
141                  <!-- Approved Rejected Submitted -->
142                  <Value LeftValue="" RightValue="Approved">
143                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Submitted" />
144                  </Value>
145                  <Value LeftValue="" RightValue="Rejected">
146                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Verify Failed" />
147                  </Value>
148                </ValueMap>
149                <ValueMap name="TfsRegressionMapping">
150                  <!-- No Yes -->
151                  <Value LeftValue="" RightValue="Yes">
152                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="New (Re-Opened)" />
153                  </Value>
154                  <Value LeftValue="" RightValue="Yes">
155                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Verify Failed" />
156                  </Value>
157                </ValueMap>
158                <ValueMap name="StatusMapTTP2TFS">
159                  <!-- STRIP ALL AFTER THE "," -->
160                  <Value LeftValue="" RightValue="Proposed" />
161                  <Value LeftValue="*" RightValue="Proposed" />
162                  <Value LeftValue="Verified" RightValue="Validated" />
163                  <Value LeftValue="Closed" RightValue="Closed" />
164                  <Value LeftValue="Fixed" RightValue="Resolved" />
165                  <Value LeftValue="Release to Testing" RightValue="Resolved" />
166                  <Value LeftValue="Verify Failed" RightValue="Resolved" />
167                  <Value LeftValue="New (Re-Opened)" RightValue="Proposed" />
168                  <Value LeftValue="Deferred" RightValue="Resolved" />
169                </ValueMap>
170                <ValueMap name="ReasonMapTTP2TFS">
171                  <Value LeftValue="" RightValue="New">
172                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="New (Re-Opened)" />
173                  </Value>
174                  <Value LeftValue="" RightValue="Resolved">
175                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Release to Testing" />
176                  </Value>
177                  <Value LeftValue="" RightValue="Verification Rejected">
178                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Verify Failed" />
179                  </Value>
180                  <Value LeftValue="" RightValue="Resolved">
181                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Fixed" />
182                  </Value>
183                  <Value LeftValue="" RightValue="Verified">
184                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Validated" />
185                  </Value>
186                  <Value LeftValue="" RightValue="Cut">
187                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="Deferred" />
188                  </Value>
189                  <Value LeftValue="Duplicate" RightValue="Duplicate" />
190                  <Value LeftValue="Not a bug" RightValue="Not a bug" />
191                  <Value LeftValue="Not reproducible" RightValue="Not reproducible" />
192                  <Value LeftValue="Deprecated Functionality" RightValue="Deprecated Functionality" />
193                  <Value LeftValue="Functions as Designed" RightValue="Functions as Designed" />
194                </ValueMap>
195                <ValueMap name="ComponentMapTTP2TFS">
196                  <Value LeftValue="*" RightValue="*" />
197                  <Value LeftValue="" RightValue="None" />
198
199                </ValueMap>
200                <ValueMap name="FunctionalAreaMapTTP2TFS">
201                  <Value LeftValue="*" RightValue="*" />
202                  <Value LeftValue="" RightValue="None" />
203
204                </ValueMap>
205                <ValueMap name="VerifyVersionMapTTP2TFS">
206                  <Value LeftValue="*" RightValue="*" />
207                  <Value LeftValue="" RightValue="None" />
208
209                </ValueMap>
210                <ValueMap name="PriorityMapTTP2TFS">
211                  <Value LeftValue="*" RightValue="2" />
212                  <Value LeftValue="4-Low" RightValue="3" />
213                  <Value LeftValue="3-Medium" RightValue="3" />
214                  <Value LeftValue="2-High" RightValue="2" />
215                  <Value LeftValue="1-Must Be Fixed" RightValue="1" />
216                  <Value LeftValue="Highest (QA)" RightValue="0" />
217                </ValueMap>
218                <ValueMap name="UserMapTTP2TFS">
219                  <Value LeftValue="*" RightValue="*" />
220                  <Value LeftValue="" RightValue="Triage">
221                    <When ConditionalSrcFieldName="Status" ConditionalSrcFieldValue="New" />
222                  </Value>
223
224                </ValueMap>
225
226                <ValueMap name="TypeofCRMapTTP2TFS">
227                  <Value LeftValue="*" RightValue="*" />
228                </ValueMap>
229
230              </ValueMaps>
231            </WITSessionCustomSetting>
232          </SettingXml>
233          <SettingXmlSchema />
234        </CustomSettings>
235        <Filters>
236          <FilterPair Neglect="false">
237            <FilterItem MigrationSourceUniqueId="C513F930-2602-400D-A0BF-A2A3AB434DF5" FilterString="NWC_Test" />
238            <FilterItem MigrationSourceUniqueId="6E3BDF70-F1AE-4CD5-8EE4-133C8AEE0857" FilterString="[System.Id] = 0" />
239          </FilterPair>
240        </Filters>
241      </Session>
242    </Sessions>
243    <Linking>
244      <CustomSettings />
245      <LinkTypeMappings />
246    </Linking>
247    <WorkFlowType Frequency="ContinuousManual" DirectionOfFlow="Unidirectional" SyncContext="Disabled" />
248    <CustomSettings />
249    <UserIdentityMappings EnableValidation="false">
250      <UserIdentityLookupAddins />
251    </UserIdentityMappings>
252    <ErrorManagement>
253      <ErrorRouters />
254      <ReportingSettings />
255    </ErrorManagement>
256  </SessionGroup>
257</Configuration>

The problem I ran into was that as all of the example Adapters are TIP adapters they do not take into account history at all. Here is the code for my first run through that was heavily based on Robert MacLean’s  code from How to create an adapter for the TFS Integration Platform  :

  1Imports Microsoft.TeamFoundation.Migration.Toolkit
  2Imports System.ComponentModel.Design
  3Imports System.Collections.ObjectModel
  4Imports Microsoft.TeamFoundation.Migration.Toolkit.Services
  5Imports Microsoft.TeamFoundation.Migration.BusinessModel
  6Imports Microsoft.TeamFoundation.Migration.Toolkit.ErrorManagement
  7Imports System.Globalization
  8Imports System.Xml
  9Imports Microsoft.TeamFoundation.Migration.Toolkit.SyncOrchestrator
 10Imports System.Net
 11Imports System.IO
 12Imports System.ServiceModel
 13Imports System.ServiceModel.Security
 14Imports NorthwestCadence.TtpTipAdapter.TtpSoapSdk
 15Imports NorthwestCadence.TtpTipAdapter.TtpSoapSdk.api
 16
 17Public Class TtpAnalysisProvider
 18    Inherits AnalysisProviderBase
 19
 20    ' Fields
 21    Private _analysisServiceContainer As IServiceContainer
 22    Private _changeGroupService As ChangeGroupService
 23    Private _configurationService As ConfigurationService
 24    Private _conflictManagerService As ConflictManager
 25    Private _highWaterMarkDelta As HighWaterMark(Of DateTime)
 26    Private _highWaterMarkChangeSet As HighWaterMark(Of Integer)
 27    Private _supportedChangeActions As Dictionary(Of Guid, ChangeActionHandler)
 28    Private _supportedContentTypes As Collection(Of ContentType)
 29    Private _dataSourceConfig As TtpMigrationDataSource
 30
 31    ' Properties
 32    Public Overrides ReadOnly Property SupportedChangeActions As Dictionary(Of Guid, ChangeActionHandler)
 33        Get
 34            Return Me._supportedChangeActions
 35        End Get
 36    End Property
 37
 38    Public Overrides ReadOnly Property SupportedContentTypes As Collection(Of ContentType)
 39        Get
 40            Return Me._supportedContentTypes
 41        End Get
 42    End Property
 43
 44    ' Methods
 45    Private Function CreateChangeGroup(ByVal changeset As Integer, ByVal executionOrder As Long) As ChangeGroup
 46        Dim group As ChangeGroup = Me._changeGroupService.CreateChangeGroupForDeltaTable(changeset.ToString(CultureInfo.CurrentCulture))
 47        group.Owner = Nothing
 48        group.Comment = String.Format(CultureInfo.CurrentCulture, "Changeset {0}", New Object() {changeset})
 49        group.ChangeTimeUtc = DateTime.UtcNow
 50        group.Status = ChangeStatus.Delta
 51        group.ExecutionOrder = executionOrder
 52        Return group
 53    End Function
 54
 55    Private Shared Function CreateFieldRevisionDescriptionDoc(row As TtpDefectMigrationItem) As XmlDocument
 56        Dim columns As New XElement("Columns", New Object() {New XElement("Column", New Object() {New XAttribute("DisplayName", "Author"), New XAttribute("ReferenceName", "Author"), New XAttribute("Type", "String"), New XElement("Value", row.AuthorId)}), New XElement("Column", New Object() {New XAttribute("DisplayName", "DisplayName"), New XAttribute("ReferenceName", "DisplayName"), New XAttribute("Type", "String"), New XElement("Value", row.DisplayName)}), New XElement("Column", New Object() {New XAttribute("DisplayName", "Id"), New XAttribute("ReferenceName", "Id"), New XAttribute("Type", "String"), New XElement("Value", row.Id.ToString)})})
 57        Dim column As KeyValuePair(Of String, Object)
 58        For Each column In row.Columns
 59            If Not String.IsNullOrEmpty(column.Value) Then
 60                columns.Add(New XElement("Column", New Object() {New XAttribute("DisplayName", column.Key), New XAttribute("ReferenceName", column.Key), New XAttribute("Type", "String"), New XElement("Value", column.Value)}))
 61            End If
 62        Next
 63        Dim descriptionDoc As New XElement("WorkItemChanges", New Object() {New XAttribute("Revision", "0"), New XAttribute("WorkItemType", row.WorItemType), New XAttribute("Author", IIf(String.IsNullOrEmpty(row.AuthorId), "", row.AuthorId)), New XAttribute("ChangeDate", row.ModifiedOn.ToString(CultureInfo.CurrentCulture)), New XAttribute("WorkItemID", row.Id.ToString), columns})
 64        Dim doc As New XmlDocument
 65        doc.LoadXml(descriptionDoc.ToString)
 66        Return doc
 67    End Function
 68
 69    Public Overrides Sub GenerateDeltaTable()
 70        Dim viewName As String = Me._configurationService.Filters.Item(0).Path
 71        TraceManager.TraceInformation("TtpWIT:AP:GenerateDeltaTable:View - {0}", New Object() {viewName})
 72        Me._highWaterMarkDelta.Reload()
 73        Me.GetTtpUpdates(viewName)
 74        Me._highWaterMarkDelta.Update(DateTime.Now)
 75        Me._changeGroupService.PromoteDeltaToPending()
 76    End Sub
 77
 78    Public Overrides Sub InitializeClient()
 79        TraceManager.TraceInformation("TtpWIT:AP:InitializeClient")
 80    End Sub
 81
 82    Private Shared Function InitializeMigrationDataSource() As TtpMigrationDataSource
 83        Return New TtpMigrationDataSource
 84    End Function
 85
 86    Public Overrides Sub InitializeServices(ByVal analysisService As IServiceContainer)
 87        TraceManager.TraceInformation("TtpWIT:AP:InitializeServices")
 88        If (analysisService Is Nothing) Then
 89            Throw New ArgumentNullException("analysisService")
 90        End If
 91        Me._analysisServiceContainer = analysisService
 92        Me._configurationService = DirectCast(analysisService.GetService(GetType(ConfigurationService)), ConfigurationService)
 93        Dim migrationSourceConfiguration As MigrationSource = Me._configurationService.MigrationSource
 94        _dataSourceConfig = TtpAnalysisProvider.InitializeMigrationDataSource
 95        Dim customSetting As CustomSetting
 96        Dim username As String = ""
 97        Dim password As String = ""
 98        For Each customSetting In Me._configurationService.MigrationSource.CustomSettings.CustomSetting
 99            If customSetting.SettingKey.Equals("Username", StringComparison.OrdinalIgnoreCase) Then
100                username = customSetting.SettingValue
101            End If
102            If customSetting.SettingKey.Equals("Password", StringComparison.OrdinalIgnoreCase) Then
103                password = customSetting.SettingValue
104            End If
105        Next
106
107        _dataSourceConfig.Credentials = New NetworkCredential(username, password)
108        _dataSourceConfig.DatabaseName = migrationSourceConfiguration.SourceIdentifier
109        _dataSourceConfig.FilterName = IIf(migrationSourceConfiguration.ServerIdentifier = "[enterFiltername]", "", migrationSourceConfiguration.ServerIdentifier)
110        _dataSourceConfig.Url = migrationSourceConfiguration.ServerUrl
111
112        Me._supportedContentTypes = New Collection(Of ContentType)
113        Me.SupportedContentTypes.Add(WellKnownContentType.WorkItem)
114
115        Dim handler As New TtpChangeActionHandlers(Me)
116
117        Me._supportedChangeActions = New Dictionary(Of Guid, ChangeActionHandler)
118        Me.SupportedChangeActions.Add(WellKnownChangeActionId.Add, New ChangeActionHandler(AddressOf handler.BasicActionHandler))
119        Me.SupportedChangeActions.Add(WellKnownChangeActionId.Edit, New ChangeActionHandler(AddressOf handler.BasicActionHandler))
120        Me.SupportedChangeActions.Add(WellKnownChangeActionId.Delete, New ChangeActionHandler(AddressOf handler.BasicActionHandler))
121        Me._highWaterMarkDelta = New HighWaterMark(Of DateTime)("HWMDelta")
122        Me._highWaterMarkChangeSet = New HighWaterMark(Of Integer)("LastChangeSet")
123
124        Me._configurationService.RegisterHighWaterMarkWithSession(Me._highWaterMarkDelta)
125        Me._configurationService.RegisterHighWaterMarkWithSession(Me._highWaterMarkChangeSet)
126
127        Me._changeGroupService = DirectCast(Me._analysisServiceContainer.GetService(GetType(ChangeGroupService)), ChangeGroupService)
128
129        Me._changeGroupService.RegisterDefaultSourceSerializer(New TtpDefectMigrationItemSerializer)
130    End Sub
131
132    Public Overrides Sub RegisterConflictTypes(ByVal conflictManager As ConflictManager)
133        TraceManager.TraceInformation("TtpWIT:AP:RegisterConflictTypes")
134        Me._conflictManagerService = DirectCast(Me._analysisServiceContainer.GetService(GetType(ConflictManager)), ConflictManager)
135        Me._conflictManagerService.RegisterConflictType(New GenericConflictType)
136        Me._conflictManagerService.RegisterConflictType(New TtpGeneralConflictType, ConflictsSyncOrchOptions.Continue)
137    End Sub
138
139    Public Overrides Sub RegisterSupportedChangeActions(ByVal changeActionRegistrationService As ChangeActionRegistrationService)
140        TraceManager.TraceInformation("TtpWIT:AP:RegisterSupportedChangeActions")
141        changeActionRegistrationService = DirectCast(Me._analysisServiceContainer.GetService(GetType(ChangeActionRegistrationService)), ChangeActionRegistrationService)
142        Dim supportedChangeAction As KeyValuePair(Of Guid, ChangeActionHandler)
143        For Each supportedChangeAction In Me.SupportedChangeActions
144            Dim contentType As ContentType
145            For Each contentType In Me.SupportedContentTypes
146                changeActionRegistrationService.RegisterChangeAction(supportedChangeAction.Key, contentType.ReferenceName, supportedChangeAction.Value)
147            Next
148        Next
149    End Sub
150
151    Public Overrides Sub RegisterSupportedContentTypes(contentTypeRegistrationService As Microsoft.TeamFoundation.Migration.Toolkit.Services.ContentTypeRegistrationService)
152
153    End Sub
154
155    Private Sub GetTtpUpdates(ByVal viewName As String)
156        TraceManager.TraceInformation("TtpWIT:AP:GetTtpDefectUpdates")
157        Dim TtpServer As Uri = New Uri(String.Format("{0}/scripts/ttsoapcgi.exe", _dataSourceConfig.Url))
158
159        TraceManager.TraceInformation(ChrW(9) & "TtpWIT:AP:Loading Ttp  {0}", New Object() {TtpServer})
160        Try
161
162            Dim _ttpsoapclient = New TtpSoapSdkApi(TtpServer)
163            Dim _sourceProject As CProject = Nothing
164            TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:GetProjectList")
165            Dim projects() As CProject = _ttpsoapclient.getProjectList(_dataSourceConfig.Credentials.UserName, _dataSourceConfig.Credentials.Password)
166            TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:FindSourceProject")
167            For Each project In projects
168                If project.database.name.ToLower = _dataSourceConfig.DatabaseName.ToLower Then
169                    _sourceProject = project
170                    TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:SourceProjectFound")
171                    Exit For
172                End If
173            Next
174
175            If _sourceProject Is Nothing Then
176                TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:Project Not Found")
177                Exit Sub
178            End If
179
180            TraceManager.TraceInformation("TTP:AP:InitializeClient:GetSessionId")
181            Dim _lSession = _ttpsoapclient.ProjectLogon(_sourceProject, _dataSourceConfig.Credentials.UserName, _dataSourceConfig.Credentials.Password)
182            TraceManager.TraceInformation("TTP:AP:InitializeClient:Logged onto {0}", _sourceProject.database.name)
183            Dim _deltaTableStartTime As DateTime = DateTime.Now
184
185            ' Dim atc() As CTableColumn = {New CTableColumn With {.name = "Number"}, New CTableColumn With {.name = "Date Modified"}}
186            Dim atc() As CTableColumn = _ttpsoapclient.getColumnsForTable(_lSession, "Defect")
187            Dim tstart As DateTime = Now
188            TraceManager.TraceInformation("TTP:AP:InitializeClient:Atempting get on all data")
189            Dim rows As CRecordListSoap = _ttpsoapclient.getRecordListForTable(_lSession, "Defect", viewName, atc)
190            TraceManager.TraceInformation("TTP:AP:InitializeClient:Found {0} records in {1} seconds", rows.records.Count, Now.Subtract(tstart).TotalSeconds)
191            Dim currentRecord As Integer = 1
192            Dim countRecords = rows.records.Count
193            For Each record In rows.records
194                ' item has been modified since HWM & before deltra table start time
195                Try
196                    Dim DefectMI As TtpDefectMigrationItem = TtpDefectMigrationItem.ConvertCDefectToTtpDefectMigrationItem(atc, record)
197                    ' Dim Modified As DateTime = DateTime.Parse(record.row(1).value)
198
199                    If DefectMI.ModifiedOn.CompareTo(_highWaterMarkDelta.Value) > 0 And DefectMI.ModifiedOn.CompareTo(_deltaTableStartTime) Then
200                        ' Atempt to import additional data from objects
201                        DefectMI.ImportDefectData(_ttpsoapclient, _lSession)
202
203                        ' Create and add acction group
204                        Dim actionGuid As Guid = WellKnownChangeActionId.Add
205                        If ((Not _highWaterMarkDelta.Value = DateTime.MinValue) AndAlso (DefectMI.ModifiedOn.CompareTo(_highWaterMarkDelta.Value) > 0)) Then
206                            actionGuid = WellKnownChangeActionId.Edit
207                        Else
208                            actionGuid = WellKnownChangeActionId.Add
209                        End If
210                        Dim changeGroup As ChangeGroup = Me.CreateChangeGroup(_highWaterMarkChangeSet.Value, 0)
211                        changeGroup.CreateAction(actionGuid, DefectMI, String.Empty, _dataSourceConfig.DatabaseName, String.Empty, String.Empty, WellKnownContentType.WorkItem.ReferenceName, TtpAnalysisProvider.CreateFieldRevisionDescriptionDoc(delta))
212                        changeGroup.Save()
213                        _highWaterMarkChangeSet.Update((_highWaterMarkChangeSet.Value + 1))
214                        ' DONE
215                        TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' has {4} processing in {5} seconds", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, "passed", Now.Subtract(tstart).TotalSeconds)
216                    Else
217                        TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' has {4} processing in {5} seconds", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, "skipped", Now.Subtract(tstart).TotalSeconds)
218                    End If
219
220                Catch ex As Exception
221                    TraceManager.TraceError("  {0} of {1} - '{2}' Number '{3}' has {4} processing in {5} seconds", currentRecord, countRecords, "unknown", "unknown", "failed", Now.Subtract(tstart).TotalSeconds)
222                    TraceManager.TraceException(ex)
223                End Try
224                currentRecord = currentRecord + 1
225
226            Next
227
228        Catch ex As Exception
229            TraceManager.TraceException(ex)
230        End Try
231
232    End Sub
233
234End Class

Figure: Full source for the Analysis Provider v1

1Dim changeGroup As ChangeGroup = Me.CreateChangeGroup(_highWaterMarkChangeSet.Value, 0)
2changeGroup.CreateAction(actionGuid, DefectMI, String.Empty, _dataSourceConfig.DatabaseName, String.Empty, String.Empty, WellKnownContentType.WorkItem.ReferenceName, TtpAnalysisProvider.CreateFieldRevisionDescriptionDoc(delta))
3changeGroup.Save()

Figure: Snipit of the Analysis Provider v1

The problem that I have encountered is that although it adds new Work Items that come into scope, it does not do any updates to those work item. Now, I can understand this if there had been any updates on the TFS side, but I can guarantee that there has not. So I sought help:

-Willy-Peter Schaub, VSALM Ranger Mother

So I changed my code so that when the create action occurred it passed in a version (work item revision) number. As my source system does not have revisions, and does not even keep track of edits I just have to make up the number as long as it is greater than the one before. I went for Option 1 provided by Willy.

  1Imports Microsoft.TeamFoundation.Migration.Toolkit
  2Imports System.ComponentModel.Design
  3Imports System.Collections.ObjectModel
  4Imports Microsoft.TeamFoundation.Migration.Toolkit.Services
  5Imports Microsoft.TeamFoundation.Migration.BusinessModel
  6Imports Microsoft.TeamFoundation.Migration.Toolkit.ErrorManagement
  7Imports System.Globalization
  8Imports System.Xml
  9Imports Microsoft.TeamFoundation.Migration.Toolkit.SyncOrchestrator
 10Imports System.Net
 11Imports System.IO
 12Imports System.ServiceModel
 13Imports System.ServiceModel.Security
 14Imports NorthwestCadence.TtpTipAdapter.TtpSoapSdk
 15Imports NorthwestCadence.TtpTipAdapter.TtpSoapSdk.api
 16
 17Public Class TtpAnalysisProvider
 18    Inherits AnalysisProviderBase
 19
 20    ' Fields
 21    Private _analysisServiceContainer As IServiceContainer
 22    Private _changeGroupService As ChangeGroupService
 23    Private _configurationService As ConfigurationService
 24    Private _conflictManagerService As ConflictManager
 25    Private _highWaterMarkDelta As HighWaterMark(Of DateTime)
 26    Private _highWaterMarkChangeSet As HighWaterMark(Of Integer)
 27    Private _highWaterMarkRevision As HighWaterMark(Of Integer)
 28    Private _supportedChangeActions As Dictionary(Of Guid, ChangeActionHandler)
 29    Private _supportedContentTypes As Collection(Of ContentType)
 30    Private _dataSourceConfig As TtpMigrationDataSource
 31
 32    ' Properties
 33    Public Overrides ReadOnly Property SupportedChangeActions As Dictionary(Of Guid, ChangeActionHandler)
 34        Get
 35            Return Me._supportedChangeActions
 36        End Get
 37    End Property
 38
 39    Public Overrides ReadOnly Property SupportedContentTypes As Collection(Of ContentType)
 40        Get
 41            Return Me._supportedContentTypes
 42        End Get
 43    End Property
 44
 45    Private Shared Function CreateFieldRevisionDescriptionDoc(row As TtpDefectMigrationItem) As XmlDocument
 46        Dim columns As New XElement("Columns", New Object() {New XElement("Column", New Object() {New XAttribute("DisplayName", "Author"), New XAttribute("ReferenceName", "Author"), New XAttribute("Type", "String"), New XElement("Value", row.AuthorId)}), New XElement("Column", New Object() {New XAttribute("DisplayName", "DisplayName"), New XAttribute("ReferenceName", "DisplayName"), New XAttribute("Type", "String"), New XElement("Value", row.DisplayName)}), New XElement("Column", New Object() {New XAttribute("DisplayName", "Id"), New XAttribute("ReferenceName", "Id"), New XAttribute("Type", "String"), New XElement("Value", row.Id.ToString)})})
 47        Dim column As KeyValuePair(Of String, Object)
 48        For Each column In row.Columns
 49            If Not String.IsNullOrEmpty(column.Value) Then
 50                columns.Add(New XElement("Column", New Object() {New XAttribute("DisplayName", column.Key), New XAttribute("ReferenceName", column.Key), New XAttribute("Type", "String"), New XElement("Value", column.Value)}))
 51            End If
 52        Next
 53        Dim descriptionDoc As New XElement("WorkItemChanges", New Object() {New XAttribute("Revision", row.Revision), New XAttribute("WorkItemType", row.WorItemType), New XAttribute("Author", IIf(String.IsNullOrEmpty(row.AuthorId), "", row.AuthorId)), New XAttribute("ChangeDate", row.ModifiedOn.ToString(CultureInfo.CurrentCulture)), New XAttribute("WorkItemID", row.Id.ToString), columns})
 54        Dim doc As New XmlDocument
 55        doc.LoadXml(descriptionDoc.ToString)
 56        Return doc
 57    End Function
 58
 59    Public Overrides Sub GenerateDeltaTable()
 60        Dim viewName As String = Me._configurationService.Filters.Item(0).Path
 61        TraceManager.TraceInformation("TtpWIT:AP:GenerateDeltaTable:View - {0}", New Object() {viewName})
 62        Me._highWaterMarkDelta.Reload()
 63        Me.GetTtpUpdates(viewName)
 64        Me._highWaterMarkDelta.Update(DateTime.Now)
 65        Me._changeGroupService.PromoteDeltaToPending()
 66    End Sub
 67
 68    Public Overrides Sub InitializeClient()
 69        TraceManager.TraceInformation("TtpWIT:AP:InitializeClient")
 70    End Sub
 71
 72    Private Shared Function InitializeMigrationDataSource() As TtpMigrationDataSource
 73        Return New TtpMigrationDataSource
 74    End Function
 75
 76    Public Overrides Sub InitializeServices(ByVal analysisService As IServiceContainer)
 77        TraceManager.TraceInformation("TtpWIT:AP:InitializeServices")
 78        If (analysisService Is Nothing) Then
 79            Throw New ArgumentNullException("analysisService")
 80        End If
 81        Me._analysisServiceContainer = analysisService
 82        Me._configurationService = DirectCast(analysisService.GetService(GetType(ConfigurationService)), ConfigurationService)
 83        Dim migrationSourceConfiguration As MigrationSource = Me._configurationService.MigrationSource
 84        _dataSourceConfig = TtpAnalysisProvider.InitializeMigrationDataSource
 85        Dim customSetting As CustomSetting
 86        Dim username As String = ""
 87        Dim password As String = ""
 88        Dim hwmDateOveride As DateTime = DateTime.MinValue
 89        For Each customSetting In Me._configurationService.MigrationSource.CustomSettings.CustomSetting
 90            If customSetting.SettingKey.Equals("Username", StringComparison.OrdinalIgnoreCase) Then
 91                username = customSetting.SettingValue
 92            End If
 93            If customSetting.SettingKey.Equals("Password", StringComparison.OrdinalIgnoreCase) Then
 94                password = customSetting.SettingValue
 95            End If
 96            If customSetting.SettingKey.Equals("OverrideHWM", StringComparison.OrdinalIgnoreCase) Then
 97                If Not DateTime.TryParse(customSetting.SettingValue, hwmDateOveride) Then
 98                    Throw New InvalidCastException("Date is not in the correct format: OverrideHWM")
 99                End If
100            End If
101        Next
102
103        _dataSourceConfig.Credentials = New NetworkCredential(username, password)
104        _dataSourceConfig.DatabaseName = migrationSourceConfiguration.SourceIdentifier
105        _dataSourceConfig.FilterName = IIf(migrationSourceConfiguration.ServerIdentifier = "[enterFiltername]", "", migrationSourceConfiguration.ServerIdentifier)
106        _dataSourceConfig.Url = migrationSourceConfiguration.ServerUrl
107
108        Me._supportedContentTypes = New Collection(Of ContentType)
109        Me.SupportedContentTypes.Add(WellKnownContentType.WorkItem)
110
111        Dim handler As New TtpChangeActionHandlers(Me)
112
113        Me._supportedChangeActions = New Dictionary(Of Guid, ChangeActionHandler)
114        Me.SupportedChangeActions.Add(WellKnownChangeActionId.Add, New ChangeActionHandler(AddressOf handler.BasicActionHandler))
115        Me.SupportedChangeActions.Add(WellKnownChangeActionId.Edit, New ChangeActionHandler(AddressOf handler.BasicActionHandler))
116        Me.SupportedChangeActions.Add(WellKnownChangeActionId.Delete, New ChangeActionHandler(AddressOf handler.BasicActionHandler))
117        Me._highWaterMarkDelta = New HighWaterMark(Of DateTime)("HWMDelta")
118        Me._highWaterMarkChangeSet = New HighWaterMark(Of Integer)("LastChangeSet")
119        _highWaterMarkRevision = New HighWaterMark(Of Integer)("Revision")
120
121        Me._configurationService.RegisterHighWaterMarkWithSession(Me._highWaterMarkDelta)
122        Me._configurationService.RegisterHighWaterMarkWithSession(Me._highWaterMarkChangeSet)
123        Me._configurationService.RegisterHighWaterMarkWithSession(Me._highWaterMarkRevision)
124
125        If hwmDateOveride > DateTime.MinValue Then
126            _highWaterMarkDelta.Update(hwmDateOveride)
127        End If
128
129        Me._changeGroupService = DirectCast(Me._analysisServiceContainer.GetService(GetType(ChangeGroupService)), ChangeGroupService)
130
131        Me._changeGroupService.RegisterDefaultSourceSerializer(New TtpDefectMigrationItemSerializer)
132    End Sub
133
134    Public Overrides Sub RegisterConflictTypes(ByVal conflictManager As ConflictManager)
135        TraceManager.TraceInformation("TtpWIT:AP:RegisterConflictTypes")
136        Me._conflictManagerService = DirectCast(Me._analysisServiceContainer.GetService(GetType(ConflictManager)), ConflictManager)
137        Me._conflictManagerService.RegisterConflictType(New GenericConflictType)
138        Me._conflictManagerService.RegisterConflictType(New TtpGeneralConflictType, ConflictsSyncOrchOptions.Continue)
139    End Sub
140
141    Public Overrides Sub RegisterSupportedChangeActions(ByVal changeActionRegistrationService As ChangeActionRegistrationService)
142        TraceManager.TraceInformation("TtpWIT:AP:RegisterSupportedChangeActions")
143        changeActionRegistrationService = DirectCast(Me._analysisServiceContainer.GetService(GetType(ChangeActionRegistrationService)), ChangeActionRegistrationService)
144        Dim supportedChangeAction As KeyValuePair(Of Guid, ChangeActionHandler)
145        For Each supportedChangeAction In Me.SupportedChangeActions
146            Dim contentType As ContentType
147            For Each contentType In Me.SupportedContentTypes
148                changeActionRegistrationService.RegisterChangeAction(supportedChangeAction.Key, contentType.ReferenceName, supportedChangeAction.Value)
149            Next
150        Next
151    End Sub
152
153    Public Overrides Sub RegisterSupportedContentTypes(contentTypeRegistrationService As Microsoft.TeamFoundation.Migration.Toolkit.Services.ContentTypeRegistrationService)
154
155    End Sub
156
157    Private Sub GetTtpUpdates(ByVal viewName As String)
158        TraceManager.TraceInformation("TtpWIT:AP:GetTtpDefectUpdates")
159        Dim TtpServer As Uri = New Uri(String.Format("{0}/scripts/ttsoapcgi.exe", _dataSourceConfig.Url))
160
161        TraceManager.TraceInformation(ChrW(9) & "TtpWIT:AP:Loading Ttp  {0}", New Object() {TtpServer})
162        Try
163
164            Dim _ttpsoapclient = New TtpSoapSdkApi(TtpServer)
165            Dim _sourceProject As CProject = Nothing
166            TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:GetProjectList")
167            Dim projects() As CProject = _ttpsoapclient.getProjectList(_dataSourceConfig.Credentials.UserName, _dataSourceConfig.Credentials.Password)
168            TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:FindSourceProject")
169            For Each project In projects
170                If project.database.name.ToLower = _dataSourceConfig.DatabaseName.ToLower Then
171                    _sourceProject = project
172                    TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:SourceProjectFound")
173                    Exit For
174                End If
175            Next
176
177            If _sourceProject Is Nothing Then
178                TraceManager.TraceInformation("TTP:AP:GetTtpDefectsAsDeltaFromSource:Project Not Found")
179                Exit Sub
180            End If
181
182            TraceManager.TraceInformation("TTP:AP:InitializeClient:GetSessionId")
183            Dim _lSession = _ttpsoapclient.ProjectLogon(_sourceProject, _dataSourceConfig.Credentials.UserName, _dataSourceConfig.Credentials.Password)
184            TraceManager.TraceInformation("TTP:AP:InitializeClient:Logged onto {0}", _sourceProject.database.name)
185            Dim _deltaTableStartTime As DateTime = DateTime.Now
186
187            ' Dim atc() As CTableColumn = {New CTableColumn With {.name = "Number"}, New CTableColumn With {.name = "Date Modified"}}
188            Dim atc() As CTableColumn = _ttpsoapclient.getColumnsForTable(_lSession, "Defect")
189            Dim tstart As DateTime = Now
190            TraceManager.TraceInformation("TTP:AP:InitializeClient:Atempting get on all data")
191            Dim rows As CRecordListSoap = _ttpsoapclient.getRecordListForTable(_lSession, "Defect", viewName, atc)
192            TraceManager.TraceInformation("TTP:AP:InitializeClient:Found {0} records in {1} seconds", rows.records.Count, Now.Subtract(tstart).TotalSeconds)
193
194            _highWaterMarkRevision.Reload()
195            _highWaterMarkRevision.Update(_highWaterMarkRevision.Value + 1)
196
197            Dim currentRecord As Integer = 1
198            Dim countRecords = rows.records.Count
199            For Each record In rows.records
200                ' item has been modified since HWM & before deltra table start time
201                Try
202                    Dim DefectMI As TtpDefectMigrationItem = TtpDefectMigrationItem.ConvertCDefectToTtpDefectMigrationItem(atc, record)
203                    ' Dim Modified As DateTime = DateTime.Parse(record.row(1).value)
204
205                    If DefectMI.ModifiedOn.CompareTo(_highWaterMarkDelta.Value) > 0 And DefectMI.ModifiedOn.CompareTo(_deltaTableStartTime) Then
206                        ' Atempt to import additional data from objects
207                        DefectMI.ImportDefectData(_ttpsoapclient, _lSession)
208
209                        ' Create and add acction group
210                        Dim actionGuid As Guid = WellKnownChangeActionId.Add
211                        If ((Not _highWaterMarkDelta.Value = DateTime.MinValue) AndAlso (DefectMI.CreatedOn.CompareTo(_highWaterMarkDelta.Value) > 0)) Then
212                            actionGuid = WellKnownChangeActionId.Add
213                            TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' has {4} processing revision {5} as add in {6} seconds", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, "passed", _highWaterMarkRevision.Value, Now.Subtract(tstart).TotalSeconds)
214                        ElseIf ((Not _highWaterMarkDelta.Value = DateTime.MinValue) AndAlso (DefectMI.ModifiedOn.CompareTo(_highWaterMarkDelta.Value) > 0)) Then
215                            actionGuid = WellKnownChangeActionId.Edit
216                            TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' has {4} processing revision {5} as edit in {6} seconds", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, "passed", _highWaterMarkRevision.Value, Now.Subtract(tstart).TotalSeconds)
217                        Else
218                            TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' has {4} processing revision {5} as edit in {6} seconds", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, "skipped", _highWaterMarkRevision.Value, Now.Subtract(tstart).TotalSeconds)
219                        End If
220
221                        ' Add revision to obejct
222                        DefectMI.Revision = _highWaterMarkRevision.Value
223
224                        Dim changeGroup As ChangeGroup = Me._changeGroupService.CreateChangeGroupForDeltaTable(String.Format("{0}:{1}", DefectMI.Id, DefectMI.Revision))
225                        changeGroup.CreateAction(actionGuid, DefectMI, DefectMI.Id, "", _highWaterMarkRevision.Value, "", WellKnownContentType.WorkItem.ReferenceName, TtpAnalysisProvider.CreateFieldRevisionDescriptionDoc(DefectMI))
226                        TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' CreateAction: action={4};sourceItem={5};fromPath={5};version={6};mergeVersionTo=;itemTypeRefName={7};actionDetails=[xml]", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, actionGuid, DefectMI.Id, _highWaterMarkRevision.Value, WellKnownContentType.WorkItem.ReferenceName)
227                        changeGroup.Save()
228
229                        _highWaterMarkChangeSet.Update((_highWaterMarkChangeSet.Value + 1))
230                        ' DONE
231
232                    Else
233                        TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' has {4} processing in {5} seconds", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, "skipped", Now.Subtract(tstart).TotalSeconds)
234                    End If
235
236                Catch ex As Exception
237                    TraceManager.TraceError("  {0} of {1} - '{2}' Number '{3}' has {4} processing in {5} seconds", currentRecord, countRecords, "unknown", "unknown", "failed", Now.Subtract(tstart).TotalSeconds)
238                    TraceManager.TraceException(ex)
239                End Try
240                currentRecord = currentRecord + 1
241
242            Next
243
244        Catch ex As Exception
245            TraceManager.TraceException(ex)
246        End Try
247
248    End Sub
249
250End Class

Figure: Full source code for new Analysis Provider v2

1Dim changeGroup As ChangeGroup = Me._changeGroupService.CreateChangeGroupForDeltaTable(String.Format("{0}:{1}", DefectMI.Id, DefectMI.Revision))
2changeGroup.CreateAction(actionGuid, DefectMI, DefectMI.Id, "", _highWaterMarkRevision.Value, "", WellKnownContentType.WorkItem.ReferenceName, TtpAnalysisProvider.CreateFieldRevisionDescriptionDoc(DefectMI))
3TraceManager.TraceInformation("  {0} of {1} - '{2}' Number '{3}' CreateAction: action={4};sourceItem={5};fromPath={5};version={6};mergeVersionTo=;itemTypeRefName={7};actionDetails=[xml]", currentRecord, countRecords, DefectMI.WorItemType, DefectMI.Id, actionGuid, DefectMI.Id, _highWaterMarkRevision.Value, WellKnownContentType.WorkItem.ReferenceName)
4changeGroup.Save()

Figure: Snipit of the Analysis Provider v2

You can see in the full source for v2 of the Analysis Provider that I have added a new high watermark for the revision that should stay in sync with the number of runs of the migration there have been. This way, all of the edit’s  that happen on the third run will have a revision number of 3.

Creating a WIT Adapter for the TFS Integration Platform for a source with no history  

Figure: None of the originally imported data has a revision.

The problem now is that no matter how many times I run the import in my test environment I can’t get it to perform an edit. I am hoping that someone will be able to spot a silly mistake on my code that will solve this problem. it is one of those “stare at it for hours hoping it will just work” problems.

And it gets worse, now when I try to run the code I get an “Index was out of range” exception for the TFS server that I just can’t track down. I have even backed all my code back to a known working version and I still get the error. I have even gone so far as to restart the Target TFS server and try another one. Here is the log I keep getting:

  1[02/06/2011 18:14:15] MigrationConsole started...
  2[02/06/2011 18:14:29] MigrationConsole.exe Information: 0 : ConfigurationChangeTracker did not detect any non-transient changes. No cached data will be deleted for session group '00000000-0000-0000-0000-000000000000'
  3[02/06/2011 18:14:29] MigrationConsole.exe Information: 0 : : StartSessionGroup: Enter with sessionGroupUniqueId: a69d4175-24ad-4f12-8fb5-4edd33f40ada
  4[02/06/2011 18:14:29] MigrationConsole.exe Information: 0 : : StartSessionGroup: Creating new SyncOrchestrator
  5[02/06/2011 18:14:30] MigrationConsole.exe Information: 0 : : Provider ChangeGroup Label AnalysisAddin Provider a4f53905-25b6-4311-ac0c-637da6688f2b is available
  6[02/06/2011 18:14:30] MigrationConsole.exe Information: 0 : : Provider ClearQuest Adapter d9637401-7385-4643-9c64-31585d77ed16 is available
  7[02/06/2011 18:14:30] MigrationConsole.exe Information: 0 : : Provider Northwest Cadence CSV Adapter 06a2457f-ebba-4979-bc5f-0f5006b8b4e6 is available
  8[02/06/2011 18:14:30] MigrationConsole.exe Information: 0 : : Provider TFS 2008 User Identity Lookup Add-In Provider eecc0227-8006-45f0-888d-10ab03019ad5 is available
  9[02/06/2011 18:14:30] MigrationConsole.exe Information: 0 : : Provider Semaphore File Analysis Addin Provider e8cec3c5-5848-4b83-904f-4324094c3f78 is available
 10[02/06/2011 18:14:30] MigrationConsole.exe Information: 0 : : Provider TFS 2010 Migration VC Provider febc091f-82a2-449e-aed8-133e5896c47a is available
 11[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : Provider TFS 2010 Migration WIT Provider 04201d39-6e47-416f-98b2-07f0013f8455 is available
 12[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : Provider TestTrackPro TIP Adapter c0e63c2b-e06c-48bb-8698-243a82bb950e is available
 13[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : CsvAdapter:GetService - Microsoft.TeamFoundation.Migration.Toolkit.IAddin
 14[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : Provider TFS 2010 Migration WIT Provider 04201d39-6e47-416f-98b2-07f0013f8455 is loaded
 15[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Microsoft.TeamFoundation.Migration.Toolkit.IAddin
 16[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Cant find--
 17[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : Provider TestTrackPro TIP Adapter c0e63c2b-e06c-48bb-8698-243a82bb950e is loaded
 18[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : 2 Adapter instance(s) loaded
 19[02/06/2011 18:14:31] MigrationConsole.exe Information: 0 : : 5 Add-Ins loaded
 20[02/06/2011 18:14:35] MigrationConsole.exe Information: 0 : : Active Directory lookup will be used for this end point.
 21[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Microsoft.TeamFoundation.Migration.Toolkit.IAnalysisProvider
 22[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService Creating - TtpAnalysisProvider
 23[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService Returning - NorthwestCadence.TtpTipAdapter.TtpAnalysisProvider
 24[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpWIT:AP:InitializeServices
 25[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpWIT:AP:RegisterSupportedChangeActions
 26[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpWIT:AP:RegisterConflictTypes
 27[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Microsoft.TeamFoundation.Migration.Toolkit.Services.IServerPathTranslationService
 28[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Cant find--
 29[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Microsoft.TeamFoundation.Migration.Toolkit.IMigrationProvider
 30[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService Creating - TtpMigrationProvider
 31[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService Returning - NorthwestCadence.TtpTipAdapter.TtpAnalysisProvider
 32[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpWIT:AP:RegisterConflictTypes
 33[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Microsoft.TeamFoundation.Migration.Toolkit.ILinkProvider
 34[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : TtpAdapter:GetService - Cant find--
 35[02/06/2011 18:14:39] MigrationConsole.exe Information: 0 : : Connecting to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 36[02/06/2011 18:14:41] MigrationConsole.exe Information: 0 : : Connected to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 37[02/06/2011 18:14:42] MigrationConsole.exe Information: 0 : : Connecting to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 38[02/06/2011 18:14:42] MigrationConsole.exe Information: 0 : : Connected to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 39[02/06/2011 18:14:42] MigrationConsole.exe Information: 0 : : TtpWIT:AP:InitializeClient
 40[02/06/2011 18:14:42] MigrationConsole.exe Information: 0 : : Connecting to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 41[02/06/2011 18:14:42] MigrationConsole.exe Information: 0 : : Connected to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 42[02/06/2011 18:14:43] MigrationConsole.exe Information: 0 : : Connecting to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 43[02/06/2011 18:14:43] MigrationConsole.exe Information: 0 : : Connected to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 44[02/06/2011 18:14:44] MigrationConsole.exe Information: 0 : : StartSessionGroup: Starting SyncOrchestrator; now 0 running sessions
 45[02/06/2011 18:14:44] MigrationConsole.exe Information: 0 : WorkItemTracking: Session worker thread [WorkItemTracking] started
 46[02/06/2011 18:14:44] MigrationConsole.exe Information: 0 : WorkItemTracking: Pipeline flow from bcf2ef19-dbaf-48a3-bbd1-82424ef9d7f2 to 90acdef5-e512-4df5-a680-cb2f386b08fd
 47[02/06/2011 18:14:44] MigrationConsole.exe Information: 0 : WorkItemTracking: Generating delta tables for the migration source bcf2ef19-dbaf-48a3-bbd1-82424ef9d7f2
 48[02/06/2011 18:14:44] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpWIT:AP:GenerateDeltaTable:View - NWC_Test
 49[02/06/2011 18:14:44] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpWIT:AP:GetTtpDefectUpdates
 50[02/06/2011 18:14:44] MigrationConsole.exe Information: 0 : WorkItemTracking:     TtpWIT:AP:Loading Ttp  http://ttp01.nwcadence.com/scripts/ttsoapcgi.exe
 51[02/06/2011 18:14:45] MigrationConsole.exe Information: 0 : WorkItemTracking: TTP:AP:GetTtpDefectsAsDeltaFromSource:GetProjectList
 52[02/06/2011 18:14:47] MigrationConsole.exe Information: 0 : WorkItemTracking: TTP:AP:GetTtpDefectsAsDeltaFromSource:FindSourceProject
 53[02/06/2011 18:14:47] MigrationConsole.exe Information: 0 : WorkItemTracking: TTP:AP:GetTtpDefectsAsDeltaFromSource:SourceProjectFound
 54[02/06/2011 18:14:47] MigrationConsole.exe Information: 0 : WorkItemTracking: TTP:AP:InitializeClient:GetSessionId
 55[02/06/2011 18:14:48] MigrationConsole.exe Information: 0 : WorkItemTracking: TTP:AP:InitializeClient:Logged onto expreSSO_Vergence
 56[02/06/2011 18:14:49] MigrationConsole.exe Information: 0 : WorkItemTracking: TTP:AP:InitializeClient:Atempting get on all data
 57[02/06/2011 18:14:51] MigrationConsole.exe Information: 0 : WorkItemTracking: TTP:AP:InitializeClient:Found 3 records in 1.9663932 seconds
 58[02/06/2011 18:14:52] MigrationConsole.exe Information: 0 : WorkItemTracking:   1 of 3 - 'Defect' Number '3284' has skipped processing revision 1 as edit in 3.2796558 seconds
 59[02/06/2011 18:14:52] MigrationConsole.exe Information: 0 : WorkItemTracking:   1 of 3 - 'Defect' Number '3284' CreateAction: action=cb71d043-bede-4092-aa87-cf0f14586625;sourceItem=3284;fromPath=3284;version=0;mergeVersionTo=;itemTypeRefName=Microsoft.TeamFoundation.Migration.Toolkit.WorkItem;actionDetails=[xml]
 60[02/06/2011 18:14:54] MigrationConsole.exe Information: 0 : WorkItemTracking:   2 of 3 - 'Defect' Number '3285' has skipped processing revision 1 as edit in 4.8739746 seconds
 61[02/06/2011 18:14:54] MigrationConsole.exe Information: 0 : WorkItemTracking:   2 of 3 - 'Defect' Number '3285' CreateAction: action=cb71d043-bede-4092-aa87-cf0f14586625;sourceItem=3285;fromPath=3285;version=0;mergeVersionTo=;itemTypeRefName=Microsoft.TeamFoundation.Migration.Toolkit.WorkItem;actionDetails=[xml]
 62[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking:   3 of 3 - 'Defect' Number '3243' has skipped processing revision 1 as edit in 6.1952388 seconds
 63[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking:   3 of 3 - 'Defect' Number '3243' CreateAction: action=cb71d043-bede-4092-aa87-cf0f14586625;sourceItem=3243;fromPath=3243;version=0;mergeVersionTo=;itemTypeRefName=Microsoft.TeamFoundation.Migration.Toolkit.WorkItem;actionDetails=[xml]
 64[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking: Generating linking delta for the migration source bcf2ef19-dbaf-48a3-bbd1-82424ef9d7f2
 65[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking: Generating delta tables for the migration source 90acdef5-e512-4df5-a680-cb2f386b08fd
 66[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking: Getting modified items from '90acdef5-e512-4df5-a680-cb2f386b08fd!http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)'
 67[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking: Connecting to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 68[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking: Connected to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 69[02/06/2011 18:14:55] MigrationConsole.exe Information: 0 : WorkItemTracking: TFS Query: SELECT [System.Id], [System.Rev] FROM WorkItems WHERE ([System.TeamProject]=@project AND ([System.Id] = 0)) ORDER BY [System.Id]
 70[02/06/2011 18:14:56] MigrationConsole.exe Information: 0 : WorkItemTracking: TFS Query: returned 0 item(s)
 71[02/06/2011 18:14:56] MigrationConsole.exe Information: 0 : WorkItemTracking: Received modified items from '90acdef5-e512-4df5-a680-cb2f386b08fd!http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)'
 72[02/06/2011 18:14:56] MigrationConsole.exe Information: 0 : WorkItemTracking: Persisted WIT HWM: HWMDeltaWit
 73[02/06/2011 18:14:56] MigrationConsole.exe Information: 0 : WorkItemTracking: Updated high watermark to '06/02/2011 22:14:55'
 74[02/06/2011 18:14:56] MigrationConsole.exe Information: 0 : WorkItemTracking: Generating migration instructions for the migration source 90acdef5-e512-4df5-a680-cb2f386b08fd
 75[02/06/2011 18:14:56] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 76[02/06/2011 18:14:57] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 77[02/06/2011 18:14:57] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 78[02/06/2011 18:14:57] MigrationConsole.exe Information: 0 : WorkItemTracking: Generating migration instruction for ChangeGroup 4382
 79[02/06/2011 18:14:57] MigrationConsole.exe Information: 0 : WorkItemTracking: Generating migration instruction for ChangeGroup 4383
 80[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Generating migration instruction for ChangeGroup 4384
 81[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Starting basic conflict detection
 82[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Finishing basic conflict detection
 83[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Loading 50 ChangeGroup(s)
 84[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 85[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 86[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 87[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Target AnalysisProvider detecting conflicts in ChangeGroup #4385
 88[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Target AnalysisProvider detecting conflicts in ChangeGroup #4386
 89[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Target AnalysisProvider detecting conflicts in ChangeGroup #4387
 90[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Post-processing delta table entries from the migration source 90acdef5-e512-4df5-a680-cb2f386b08fd
 91[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Marking as 'DeltaComplete' the target-side delta table for uni-directional session
 92[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Migrating to the migration source 90acdef5-e512-4df5-a680-cb2f386b08fd
 93[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Loading 50 ChangeGroup(s)
 94[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 95[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 96[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: TtpDefectMigrationItemSerializer:LoadItem
 97[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Processing ChangeGroup #4385, change 3284:0
 98[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Connecting to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
 99[02/06/2011 18:14:58] MigrationConsole.exe Information: 0 : WorkItemTracking: Connected to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
100[02/06/2011 18:14:59] MigrationConsole.exe Information: 0 : WorkItemTracking: Area 'TestTrackProTestTrackProImportAdministrators DesktopInstallation' does not exist in the TFS work item store 'http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)' or access is denied.
101[02/06/2011 18:15:00] MigrationConsole.exe Information: 0 : WorkItemTracking: Wake up from 100 millisec sleep for polling CSS node Id
102[02/06/2011 18:15:01] MigrationConsole.exe Information: 0 : WorkItemTracking: Wake up from 500 millisec sleep for polling CSS node Id
103[02/06/2011 18:15:01] MigrationConsole.exe Information: 0 : WorkItemTracking: Created path 'TestTrackProTestTrackProImportAdministrators DesktopInstallation'(Id: 605) in the TFS Work Item store 'http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)'
104[02/06/2011 18:15:01] MigrationConsole.exe Information: 0 : WorkItemTracking: Iteration 'TestTrackProTestTrackProImportexpreSSO 2.5 SP3 CD5' does not exist in the TFS work item store 'http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)' or access is denied.
105[02/06/2011 18:15:02] MigrationConsole.exe Information: 0 : WorkItemTracking: Wake up from 100 millisec sleep for polling CSS node Id
106[02/06/2011 18:15:03] MigrationConsole.exe Information: 0 : WorkItemTracking: Wake up from 500 millisec sleep for polling CSS node Id
107[02/06/2011 18:15:03] MigrationConsole.exe Information: 0 : WorkItemTracking: Wake up from 500 millisec sleep for polling CSS node Id
108[02/06/2011 18:15:04] MigrationConsole.exe Information: 0 : WorkItemTracking: Created path 'TestTrackProTestTrackProImportexpreSSO 2.5 SP3 CD5'(Id: 607) in the TFS Work Item store 'http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)'
109[02/06/2011 18:15:04] MigrationConsole.exe Information: 0 : WorkItemTracking: WorkItem type 'Bug' does not contain field 'TfsMigrationTool.ReflectedWorkItemId'. Writing source item Id will be skipped.
110[02/06/2011 18:15:04] MigrationConsole.exe Information: 0 : WorkItemTracking: Connecting to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
111[02/06/2011 18:15:04] MigrationConsole.exe Information: 0 : WorkItemTracking: Connected to 'http://tfs01.nwcadence.com:8080/tfs/sandbox'
112[02/06/2011 18:15:04] MigrationConsole.exe Error: 0 : WorkItemTracking: System.Web.Services.Protocols.SoapException: Index was out of range. Must be non-negative and less than the size of the collection.
113[02/06/2011 18:15:04] Parameter name: index ---> Index was out of range. Must be non-negative and less than the size of the collection.
114[02/06/2011 18:15:04] Parameter name: index
115[02/06/2011 18:15:04]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.RetryHandler.HandleSoapException(SoapException se)
116[02/06/2011 18:15:04]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
117[02/06/2011 18:15:04]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.Tfs2010WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
118[02/06/2011 18:15:04]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsBatchUpdateHelper.Submit(Int32 firstItem, Int32 lastItem)
119[02/06/2011 18:15:05] MigrationConsole.exe Information: 0 : WorkItemTracking: Unresolved conflict:
120[02/06/2011 18:15:05]   Session: 1c1faa2a-0d43-4381-b877-2df1d232694c
121[02/06/2011 18:15:05]   Source: 90acdef5-e512-4df5-a680-cb2f386b08fd
122[02/06/2011 18:15:05]   Message: Cannot find applicable resolution rule.
123[02/06/2011 18:15:05]   Conflict Type: TFS WIT invalid submission conflict type
124[02/06/2011 18:15:05]   Conflict Type Reference Name: c9d80b52-bb8a-4f7b-a40c-f8f63d6fd374
125[02/06/2011 18:15:05]   Conflict Details: <?xml version="1.0"?>
126[02/06/2011 18:15:05] <InvalidSubmissionConflictDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
127[02/06/2011 18:15:05]   <ExceptionType>System.Web.Services.Protocols.SoapException</ExceptionType>
128[02/06/2011 18:15:05]   <ExceptionMessage>Index was out of range. Must be non-negative and less than the size of the collection.
129[02/06/2011 18:15:05] Parameter name: index ---&gt; Index was out of range. Must be non-negative and less than the size of the collection.
130[02/06/2011 18:15:05] Parameter name: index</ExceptionMessage>
131[02/06/2011 18:15:05]   <InnerExceptionType />
132[02/06/2011 18:15:05]   <InnerExceptionMessage />
133[02/06/2011 18:15:05]   <ActionData />
134[02/06/2011 18:15:05]   <SourceItemId>3284</SourceItemId>
135[02/06/2011 18:15:05]   <SourceItemRevision>0</SourceItemRevision>
136[02/06/2011 18:15:05] </InvalidSubmissionConflictDetails>
137[02/06/2011 18:15:05]
138[02/06/2011 18:15:05]
139[02/06/2011 18:15:05] MigrationConsole.exe Information: 0 : WorkItemTracking: Processing ChangeGroup #4386, change 3285:0
140[02/06/2011 18:15:05] MigrationConsole.exe Information: 0 : WorkItemTracking: Area 'TestTrackProTestTrackProImportAdministrators DesktopBridges' does not exist in the TFS work item store 'http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)' or access is denied.
141[02/06/2011 18:15:06] MigrationConsole.exe Information: 0 : WorkItemTracking: Wake up from 100 millisec sleep for polling CSS node Id
142[02/06/2011 18:15:06] MigrationConsole.exe Information: 0 : WorkItemTracking: Wake up from 500 millisec sleep for polling CSS node Id
143[02/06/2011 18:15:07] MigrationConsole.exe Information: 0 : WorkItemTracking: Created path 'TestTrackProTestTrackProImportAdministrators DesktopBridges'(Id: 608) in the TFS Work Item store 'http://tfs01.nwcadence.com:8080/tfs/sandbox (TestTrackPro)'
144[02/06/2011 18:15:07] MigrationConsole.exe Information: 0 : WorkItemTracking: WorkItem type 'Bug' does not contain field 'TfsMigrationTool.ReflectedWorkItemId'. Writing source item Id will be skipped.
145[02/06/2011 18:15:07] MigrationConsole.exe Error: 0 : WorkItemTracking: System.Web.Services.Protocols.SoapException: Index was out of range. Must be non-negative and less than the size of the collection.
146[02/06/2011 18:15:07] Parameter name: index ---> Index was out of range. Must be non-negative and less than the size of the collection.
147[02/06/2011 18:15:07] Parameter name: index
148[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.RetryHandler.HandleSoapException(SoapException se)
149[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
150[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.Tfs2010WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
151[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsBatchUpdateHelper.Submit(Int32 firstItem, Int32 lastItem)
152[02/06/2011 18:15:07] MigrationConsole.exe Information: 0 : WorkItemTracking: Unresolved conflict:
153[02/06/2011 18:15:07]   Session: 1c1faa2a-0d43-4381-b877-2df1d232694c
154[02/06/2011 18:15:07]   Source: 90acdef5-e512-4df5-a680-cb2f386b08fd
155[02/06/2011 18:15:07]   Message: Cannot find applicable resolution rule.
156[02/06/2011 18:15:07]   Conflict Type: TFS WIT invalid submission conflict type
157[02/06/2011 18:15:07]   Conflict Type Reference Name: c9d80b52-bb8a-4f7b-a40c-f8f63d6fd374
158[02/06/2011 18:15:07]   Conflict Details: <?xml version="1.0"?>
159[02/06/2011 18:15:07] <InvalidSubmissionConflictDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
160[02/06/2011 18:15:07]   <ExceptionType>System.Web.Services.Protocols.SoapException</ExceptionType>
161[02/06/2011 18:15:07]   <ExceptionMessage>Index was out of range. Must be non-negative and less than the size of the collection.
162[02/06/2011 18:15:07] Parameter name: index ---&gt; Index was out of range. Must be non-negative and less than the size of the collection.
163[02/06/2011 18:15:07] Parameter name: index</ExceptionMessage>
164[02/06/2011 18:15:07]   <InnerExceptionType />
165[02/06/2011 18:15:07]   <InnerExceptionMessage />
166[02/06/2011 18:15:07]   <ActionData />
167[02/06/2011 18:15:07]   <SourceItemId>3285</SourceItemId>
168[02/06/2011 18:15:07]   <SourceItemRevision>0</SourceItemRevision>
169[02/06/2011 18:15:07] </InvalidSubmissionConflictDetails>
170[02/06/2011 18:15:07]
171[02/06/2011 18:15:07]
172[02/06/2011 18:15:07] MigrationConsole.exe Information: 0 : WorkItemTracking: Processing ChangeGroup #4387, change 3243:0
173[02/06/2011 18:15:07] MigrationConsole.exe Error: 0 : WorkItemTracking: System.FormatException: String was not recognized as a valid DateTime.
174[02/06/2011 18:15:07]    at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
175[02/06/2011 18:15:07]    at System.DateTime.Parse(String s, IFormatProvider provider)
176[02/06/2011 18:15:07]    at System.Convert.ToDateTime(String value)
177[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsUpdateDocument.AddColumn(XmlElement cs, String workItemType, String fieldName, String fieldReferenceName, String stringVal)
178[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsUpdateDocument.AddFields(IMigrationAction action, String workItemType, String author, String changedTime, Boolean insertWorkItem)
179[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsMigrationWorkItemStore.CreateNewWorkItemOperation(IMigrationAction action, ConflictManager conflictMgrService)
180[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsMigrationWorkItemStore.CreateUpdateOperationDoc(IMigrationAction action)
181[02/06/2011 18:15:07]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsMigrationWorkItemStore.SubmitChangesWithUpdateDoc(ChangeGroup changeGroup, ConversionResult changeResult, Guid sourceSideSourceId)
182[02/06/2011 18:15:08] MigrationConsole.exe Information: 0 : WorkItemTracking: Unresolved conflict:
183[02/06/2011 18:15:08]   Session: 1c1faa2a-0d43-4381-b877-2df1d232694c
184[02/06/2011 18:15:08]   Source: 90acdef5-e512-4df5-a680-cb2f386b08fd
185[02/06/2011 18:15:08]   Message: Cannot find applicable resolution rule.
186[02/06/2011 18:15:08]   Conflict Type: TFS WIT invalid submission conflict type
187[02/06/2011 18:15:08]   Conflict Type Reference Name: c9d80b52-bb8a-4f7b-a40c-f8f63d6fd374
188[02/06/2011 18:15:08]   Conflict Details: <?xml version="1.0"?>
189[02/06/2011 18:15:08] <InvalidSubmissionConflictDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
190[02/06/2011 18:15:08]   <ExceptionType>System.FormatException</ExceptionType>
191[02/06/2011 18:15:08]   <ExceptionMessage>String was not recognized as a valid DateTime.</ExceptionMessage>
192[02/06/2011 18:15:08]   <InnerExceptionType />
193[02/06/2011 18:15:08]   <InnerExceptionMessage />
194[02/06/2011 18:15:08]   <ActionData />
195[02/06/2011 18:15:08]   <SourceItemId>3243</SourceItemId>
196[02/06/2011 18:15:08]   <SourceItemRevision>0</SourceItemRevision>
197[02/06/2011 18:15:08] </InvalidSubmissionConflictDetails>
198[02/06/2011 18:15:08]
199[02/06/2011 18:15:08]
200[02/06/2011 18:15:08] MigrationConsole.exe Information: 0 : WorkItemTracking: Processing linking delta
201[02/06/2011 18:15:08] MigrationConsole.exe Information: 0 : WorkItemTracking: Migrating links to the migration source 90acdef5-e512-4df5-a680-cb2f386b08fd
202[02/06/2011 18:15:08] MigrationConsole.exe Warning: 0 : WorkItemTracking: Unable to record sync point for migration source bcf2ef19-dbaf-48a3-bbd1-82424ef9d7f2 of session 1c1faa2a-0d43-4381-b877-2df1d232694c because lastMigratedTargetItem.ItemId is null or empty
203[02/06/2011 18:15:08] MigrationConsole.exe Information: 0 : WorkItemTracking:
204[02/06/2011 18:15:08] MigrationConsole.exe Information: 0 : WorkItemTracking: WorkItemTracking: Migration is done!
205[02/06/2011 18:15:08] MigrationConsole.exe Information: 0 : WorkItemTracking: Session worker thread [WorkItemTracking] completed

Figure: Index was out of range. Must be non-negative and less than the size of the collection

My last and only hope is that in all the development and debugging the I broke the TFS Integration Platform install, so I am going to:

  1. Uninstall TFS Integration Platform

  2. Clean “C:Program Files (x86)Microsoft Team Foundation Server Integration Tools” of all files

  3. Check all locations where files are stored after the craziness that is getting the source for the TFS Integration Platform to build

Creating a WIT Adapter for the TFS Integration Platform for a source with no history  

Figure: Reinstalling the TFS Integration Platform is thankfully quick

So, that did not help and I am now getting two error messages for the data that I am parsing. Both of which are coming from TFS and are realy confusing me. The first is a “Index was out of range” error, which is just beyond me as I am not even passing any arrays.

 1[02/06/2011 21:47:22] MigrationConsole.exe Information: 0 : WorkItemTracking: Processing ChangeGroup #511, change 3270:1
 2[02/06/2011 21:47:22] MigrationConsole.exe Information: 0 : WorkItemTracking: WorkItem type 'Bug' does not contain field 'TfsMigrationTool.ReflectedWorkItemId'. Writing source item Id will be skipped.
 3[02/06/2011 21:47:22] MigrationConsole.exe Error: 0 : WorkItemTracking: System.Web.Services.Protocols.SoapException: Index was out of range. Must be non-negative and less than the size of the collection.
 4[02/06/2011 21:47:22] Parameter name: index ---> Index was out of range. Must be non-negative and less than the size of the collection.
 5[02/06/2011 21:47:22] Parameter name: index
 6[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.RetryHandler.HandleSoapException(SoapException se)
 7[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
 8[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.Tfs2010WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
 9[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsBatchUpdateHelper.Submit(Int32 firstItem, Int32 lastItem)
10[02/06/2011 21:47:23] MigrationConsole.exe Information: 0 : WorkItemTracking: Unresolved conflict:
11[02/06/2011 21:47:23]   Session: 583c945a-b2b8-4de3-8090-4a3126506984
12[02/06/2011 21:47:23]   Source: 3e1cfab9-910a-4a92-8c7a-25ff05ac5f48
13[02/06/2011 21:47:23]   Message: Cannot find applicable resolution rule.
14[02/06/2011 21:47:23]   Conflict Type: TFS WIT invalid submission conflict type
15[02/06/2011 21:47:23]   Conflict Type Reference Name: c9d80b52-bb8a-4f7b-a40c-f8f63d6fd374
16[02/06/2011 21:47:23]   Conflict Details: <?xml version="1.0"?>
17[02/06/2011 21:47:23] <InvalidSubmissionConflictDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
18[02/06/2011 21:47:23]   <ExceptionType>System.Web.Services.Protocols.SoapException</ExceptionType>
19[02/06/2011 21:47:23]   <ExceptionMessage>Index was out of range. Must be non-negative and less than the size of the collection.
20[02/06/2011 21:47:23] Parameter name: index ---&gt; Index was out of range. Must be non-negative and less than the size of the collection.
21[02/06/2011 21:47:23] Parameter name: index</ExceptionMessage>
22[02/06/2011 21:47:23]   <InnerExceptionType />
23[02/06/2011 21:47:23]   <InnerExceptionMessage />
24[02/06/2011 21:47:23]   <ActionData />
25[02/06/2011 21:47:23]   <SourceItemId>3270</SourceItemId>
26[02/06/2011 21:47:23]   <SourceItemRevision>1</SourceItemRevision>
27[02/06/2011 21:47:23] </InvalidSubmissionConflictDetails>

Figure: Index was out of range. Must be non-negative and less than the size of the collection

The second is a date format exception that I would have thought should be taken care of by the Integration Platform and not wait until it gets to TFS.

 1[02/06/2011 21:47:23] MigrationConsole.exe Information: 0 : WorkItemTracking: Processing ChangeGroup #512, change 3173:1
 2[02/06/2011 21:47:23] MigrationConsole.exe Error: 0 : WorkItemTracking: System.FormatException: String was not recognized as a valid DateTime.
 3[02/06/2011 21:47:23]    at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
 4[02/06/2011 21:47:23]    at System.DateTime.Parse(String s, IFormatProvider provider)
 5[02/06/2011 21:47:23]    at System.Convert.ToDateTime(String value)
 6[02/06/2011 21:47:23]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsUpdateDocument.AddColumn(XmlElement cs, String workItemType, String fieldName, String fieldReferenceName, String stringVal)
 7[02/06/2011 21:47:23]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsUpdateDocument.AddFields(IMigrationAction action, String workItemType, String author, String changedTime, Boolean insertWorkItem)
 8[02/06/2011 21:47:23]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsMigrationWorkItemStore.CreateNewWorkItemOperation(IMigrationAction action, ConflictManager conflictMgrService)
 9[02/06/2011 21:47:23]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsMigrationWorkItemStore.CreateUpdateOperationDoc(IMigrationAction action)
10[02/06/2011 21:47:23]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsMigrationWorkItemStore.SubmitChangesWithUpdateDoc(ChangeGroup changeGroup, ConversionResult changeResult, Guid sourceSideSourceId)
11[02/06/2011 21:47:23] MigrationConsole.exe Information: 0 : WorkItemTracking: Unresolved conflict:
12[02/06/2011 21:47:23]   Session: 583c945a-b2b8-4de3-8090-4a3126506984
13[02/06/2011 21:47:23]   Source: 3e1cfab9-910a-4a92-8c7a-25ff05ac5f48
14[02/06/2011 21:47:23]   Message: Cannot find applicable resolution rule.
15[02/06/2011 21:47:23]   Conflict Type: TFS WIT invalid submission conflict type
16[02/06/2011 21:47:23]   Conflict Type Reference Name: c9d80b52-bb8a-4f7b-a40c-f8f63d6fd374
17[02/06/2011 21:47:23]   Conflict Details: <?xml version="1.0"?>
18[02/06/2011 21:47:23] <InvalidSubmissionConflictDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
19[02/06/2011 21:47:23]   <ExceptionType>System.FormatException</ExceptionType>
20[02/06/2011 21:47:23]   <ExceptionMessage>String was not recognized as a valid DateTime.</ExceptionMessage>
21[02/06/2011 21:47:23]   <InnerExceptionType />
22[02/06/2011 21:47:23]   <InnerExceptionMessage />
23[02/06/2011 21:47:23]   <ActionData />
24[02/06/2011 21:47:23]   <SourceItemId>3173</SourceItemId>
25[02/06/2011 21:47:23]   <SourceItemRevision>1</SourceItemRevision>
26[02/06/2011 21:47:23] </InvalidSubmissionConflictDetails>

Figure: String was not recognized as a valid DateTime

I have even checked the output that is sent to the TFS web service and I can’t see anything that jumps out as a problem…

 1<?xml version="1.0" encoding="utf-8"?>
 2<InsertWorkItem ObjectType="WorkItem" BypassRules="1">
 3  <Columns>
 4    <Column Column="System.Title">
 5      <Value>There is a typing mistake in Product Diagnostic logging status messge</Value>
 6    </Column>
 7    <Column Column="Microsoft.VSTS.Common.Priority" Type="Number">
 8      <Value>3</Value>
 9    </Column>
10    <Column Column="System.State">
11      <Value>Proposed</Value>
12    </Column>
13    <Column Column="Microsoft.VSTS.Common.HowFoundCategory">
14      <Value>Manual Testing</Value>
15    </Column>
16    <Column Column="Microsoft.VSTS.Common.Severity">
17      <Value>4</Value>
18    </Column>
19    <Column Column="System.ChangedDate" Type="DateTime">
20      <Value>2011-02-06T20:34:00</Value>
21    </Column>
22    <Column Column="Microsoft.VSTS.Common.CreatedDate" Type="DateTime">
23      <Value>2011-02-06T20:34:00</Value>
24    </Column>
25    <Column Column="System.AssignedTo">
26      <Value>Hinshelwood, Martin; Borg, Steven</Value>
27    </Column>
28    <Column Column="System.AreaId" Type="Number">
29      <Value>108</Value>
30    </Column>
31    <Column Column="System.IterationId" Type="Number">
32      <Value>212</Value>
33    </Column>
34    <Column Column="System.WorkItemType">
35      <Value>Bug</Value>
36    </Column>
37    <Column Column="System.CreatedDate" Type="ServerDateTime">
38      <Value></Value>
39    </Column>
40    <Column Column="System.CreatedBy">
41      <Value>Hinshelwood, Martin</Value>
42    </Column>
43    <Column Column="System.ChangedBy">
44      <Value>Hinshelwood, Martin</Value>
45    </Column>
46    <Column Column="System.Reason">
47      <Value>Unknown</Value>
48    </Column>
49  </Columns>
50  <InsertText FieldName="System.Description" FieldDisplayName="Description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam at massa sem. Sed elementum, nisl sed bibendum consequat, justo libero sodales elit, a vehicula orci lorem et dui. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sit amet metus orci. Aenean vulputate condimentum lectus, vel vulputate sem aliquam quis.‏</InsertText>
51  <InsertText FieldName="Microsoft.VSTS.TCM.ReproSteps" FieldDisplayName="Repro Steps">Nullam in risus sed diam tincidunt fermentum sit amet non enim. Vestibulum tempus nibh eget nulla viverra iaculis. In a dolor ligula. Sed eget sem tellus, in tempor nisi. Maecenas venenatis cursus eros id rutrum. Nulla tristique, lectus a imperdiet vehicula, metus sapien mattis urna, a bibendum ligula nunc et nibh. Curabitur adipiscing hendrerit odio vel ornare.‏</InsertText>
52  <InsertText FieldName="System.History" FieldDisplayName="History">
53    &lt;p&gt;This is a dump of the original TTP data&lt;/p&gt;
54    &lt;p&gt;Imported by http://nwcadence.com&lt;/p&gt;
55
56    &lt;p&gt;(TFS Integration from 'TestTrackPro source' Id: 3280 (rev 1);)&lt;/p&gt;
57  </InsertText>
58</InsertWorkItem>

In order to find out what is happening with the data (ChangeGroups) you can run the following query against your tfs_IntegrationPlatform database:

 1SELECT grp.Name
 2    ,grp.Status
 3    ,[ChangeActionId]
 4    ,[ActionId]
 5    ,[SourceItem]
 6    ,[FromPath]
 7    ,[Version]
 8    ,[ActionData]
 9    ,[Backlogged]
10FROM [Tfs_IntegrationPlatform].[dbo].[RUNTIME_CHANGE_ACTION] as act
11JOIN [Tfs_IntegrationPlatform].[dbo].[RUNTIME_CHANGE_GROUPS] as grp on act.ChangeGroupId = grp.Id
12WHERE grp.Id = '3251' or grp.Id = '3255'

This will show you the actual data that is stored in the middle tier and allow you to maybe debug it. The result?

 1<WorkItemChanges Revision="1" WorkItemType="Bug" Author="Hinshelwood, Martin" ChangeDate="02/06/2011 13:03:00" WorkItemID="3268">
 2  <Columns>
 3    <Column DisplayName="Summary" ReferenceName="System.Title" Type="String">
 4      <Value>Some long text</Value>
 5    </Column>
 6    <Column DisplayName="Priority" ReferenceName="Microsoft.VSTS.Common.Priority" Type="String">
 7      <Value>1</Value>
 8    </Column>
 9    <Column DisplayName="Status" ReferenceName="System.State" Type="String">
10      <Value>Proposed</Value>
11    </Column>
12    <Column DisplayName="Found by" ReferenceName="Microsoft.VSTS.Common.HowFoundCategory" Type="String">
13      <Value>Manual Testing</Value>
14    </Column>
15    <Column DisplayName="Severity" ReferenceName="Microsoft.VSTS.Common.Severity" Type="String">
16      <Value>1</Value>
17    </Column>
18    <Column DisplayName="Date Modified" ReferenceName="System.ChangedDate" Type="String">
19      <Value>6/2/2011 1:03 PM</Value>
20    </Column>
21    <Column DisplayName="Date Created" ReferenceName="Microsoft.VSTS.Common.CreatedDate" Type="String">
22      <Value>6/1/2011 11:38 AM</Value>
23    </Column>
24    <Column DisplayName="Description" ReferenceName="System.Description" Type="String">
25      <Value>Some long text</Value>
26    </Column>
27    <Column DisplayName="Steps to Reproduce" ReferenceName="Microsoft.VSTS.TCM.ReproSteps" Type="String">
28      <Value>Some long text</Value>
29    </Column>
30    <Column DisplayName="Assigned To User" ReferenceName="System.AssignedTo" Type="String">
31      <Value>Dann, Ron</Value>
32    </Column>
33    <Column DisplayName="History" ReferenceName="System.History" Type="String">
34      <Value>Long histry that has been trunkated...
35</Value>
36    </Column>
37    <Column ReferenceName="System.AreaPath" Type="" DisplayName="">
38      <Value>TestTrackProImportGlobalizationReporting</Value>
39    </Column>
40    <Column ReferenceName="System.IterationPath" Type="" DisplayName="">
41      <Value>TestTrackProImportProduct 2.5</Value>
42    </Column>
43  </Columns>
44</WorkItemChanges>

This data is what is actually produced as a change to be saved to TFS. I am a little concerned that the dates are in a variety of formats, but it was one of the ones that resulted in the “index” error:

 1[02/06/2011 21:47:22] MigrationConsole.exe Error: 0 : WorkItemTracking: System.Web.Services.Protocols.SoapException: Index was out of range. Must be non-negative and less than the size of the collection.
 2[02/06/2011 21:47:22] Parameter name: index ---> Index was out of range. Must be non-negative and less than the size of the collection.
 3[02/06/2011 21:47:22] Parameter name: index
 4[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.RetryHandler.HandleSoapException(SoapException se)
 5[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
 6[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.Tfs2010WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
 7[02/06/2011 21:47:22]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsBatchUpdateHelper.Submit(Int32 firstItem, Int32 lastItem)
 8[02/06/2011 21:47:22] MigrationConsole.exe Information: 0 : WorkItemTracking: Unresolved conflict:
 9[02/06/2011 21:47:22]   Session: 583c945a-b2b8-4de3-8090-4a3126506984
10[02/06/2011 21:47:22]   Source: 3e1cfab9-910a-4a92-8c7a-25ff05ac5f48
11[02/06/2011 21:47:22]   Message: Cannot find applicable resolution rule.
12[02/06/2011 21:47:22]   Conflict Type: TFS WIT invalid submission conflict type
13[02/06/2011 21:47:22]   Conflict Type Reference Name: c9d80b52-bb8a-4f7b-a40c-f8f63d6fd374
14[02/06/2011 21:47:22]   Conflict Details: <?xml version="1.0"?>
15[02/06/2011 21:47:22] <InvalidSubmissionConflictDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
16[02/06/2011 21:47:22]   <ExceptionType>System.Web.Services.Protocols.SoapException</ExceptionType>
17[02/06/2011 21:47:22]   <ExceptionMessage>Index was out of range. Must be non-negative and less than the size of the collection.
18[02/06/2011 21:47:22] Parameter name: index ---&gt; Index was out of range. Must be non-negative and less than the size of the collection.
19[02/06/2011 21:47:22] Parameter name: index</ExceptionMessage>
20[02/06/2011 21:47:22]   <InnerExceptionType />
21[02/06/2011 21:47:22]   <InnerExceptionMessage />
22[02/06/2011 21:47:22]   <ActionData />
23[02/06/2011 21:47:22]   <SourceItemId>3268</SourceItemId>
24[02/06/2011 21:47:22]   <SourceItemRevision>1</SourceItemRevision>
25[02/06/2011 21:47:22] </InvalidSubmissionConflictDetails>

Hopefully someone on the team will be able to help me out, but so far I have not been able to get this running…

On an whim I decided that the Dates might be  the problem all along and that the “Index was out of range” issue was a red hearing. So I commented out all of the date fields in the configuration file and what do you know… the “Index was out of range” errors went way…

So I dutifully check all of the date input and redo it so that everything is in the correct time zone and that

 1Dim d As Date
 2If DateTime.TryParseExact(record.row(i).value, "g", dateProvider, DateTimeStyles.None, d) Then
 3' TODO: Timezone should not be hard coded
 4d = TimeZoneInfo.ConvertTimeToUtc(d, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"))
 5' This is a date but lets get some specific values
 6Select Case atc(i).name
 7    Case "Date Modified"
 8        newMigIt.ModifiedOn = d
 9    Case "Date Created"
10        newMigIt.CreatedOn = d
11End Select
12' Then add it to columns
13newMigIt.Columns.Add(atc(i).name, d.ToString("o")) ' TODO: Output format needs to be good

Figure: Refactored code to process the dates to the correct timezone

This did nothing! What I eventually had to do was to remove that mapping from the file. So no dates…

 1<MappedFields>
 2  <MappedField LeftName="Summary" RightName="System.Title" MapFromSide="Left" valueMap="" />
 3  <MappedField LeftName="Description" RightName="System.Description" MapFromSide="Left" valueMap="" />
 4  <MappedField LeftName="Severity" RightName="Microsoft.VSTS.Common.Severity" MapFromSide="Left" valueMap="SeverityMapTTP2TFS" />
 5  <MappedField LeftName="Status" RightName="System.State" MapFromSide="Left" valueMap="StatusMapTTP2TFS" />
 6  <MappedField LeftName="Reason" RightName="System.Reason" MapFromSide="Left" valueMap="ReasonMapTTP2TFS" />
 7  <MappedField LeftName="Priority" RightName="Microsoft.VSTS.Common.Priority" MapFromSide="Left" valueMap="PriorityMapTTP2TFS" />
 8  <MappedField LeftName="Steps to Reproduce" RightName="Microsoft.VSTS.TCM.ReproSteps" MapFromSide="Left" />
 9  <MappedField LeftName="History" RightName="System.History" MapFromSide="Left" />
10  <MappedField LeftName="Assigned To User" RightName="System.AssignedTo" MapFromSide="Left" valueMap="UserMapTTP2TFS" />
11  <MappedField LeftName="Verify Version" RightName="Microsoft.VSTS.Build.FoundIn" MapFromSide="Left" valueMap="VerifyVersionMapTTP2TFS" />
12  <MappedField LeftName="Closed By" RightName="System.ClosedBy" MapFromSide="Left" />
13  <MappedField LeftName="Found by" RightName="Microsoft.VSTS.Common.HowFoundCategory" MapFromSide="Left"  valueMap="HowFoundCategoryTFS" />
14  <!--<MappedField LeftName="Date Modified" RightName="System.ChangedDate" MapFromSide="Left" />-->
15  <!--<MappedField LeftName="Date Created" RightName="Microsoft.VSTS.Common.CreatedDate" MapFromSide="Left"  />-->
16  <!--<MappedField LeftName="Closed Date" RightName="System.ClosedDate" MapFromSide="Left" />-->
17  <!-- WORKAROUND using unused field: Manual Testing -->
18  <!--
19  <MappedField LeftName="@@MISSINGFIELD@@" RightName="Microsoft.VSTS.Common.Triage" MapFromSide="Left" valueMap="TfsTriageMapping" />
20  <MappedField LeftName="@@MISSINGFIELD@@" RightName="Microsoft.VSTS.Common.Regression" MapFromSide="Left" valueMap="TfsRegressionMapping" />
21  <MappedField LeftName="@@MISSINGFIELD@@" RightName="Microsoft.VSTS.Build.Changelist" MapFromSide="Left" valueMap="TfsChangelistMapping" />
22  <MappedField LeftName="Modified By" RightName="System.ChangedBy" MapFromSide="Left" />
23  <MappedField LeftName="Created By" RightName="System.CreatedBy" MapFromSide="Left" valueMap="" />
24  -->
25</MappedFields>

Figure: New mapping for Bugs

There are a number of things to note on the new mapping. After removing all of the Date fields I found that due to coning changes in the Adapter to achieve the “on behalf of” capability I have to remove both the “Modified By” and the “Created By” fields from the mapping otherwise I get a TF223001 error during the mapping.

Creating a WIT Adapter for the TFS Integration Platform for a source with no history  

Figure: Editing on behalf of

During the production run the “Created by [account]” will be the service account that Team Foundation Server runs under so it will be a little cleaner than having my name plastered all over it. Although it is OK to have the company name there Creating a WIT Adapter for the TFS Integration Platform for a source with no history

 1[03/06/2011 16:57:12] MigrationConsole.exe Information: 0 : WorkItemTracking: Processing ChangeGroup #1003, change 3206:1
 2[03/06/2011 16:57:13] MigrationConsole.exe Information: 0 : WorkItemTracking: WorkItem type 'Bug' does not contain field 'TfsMigrationTool.ReflectedWorkItemId'. Writing source item Id will be skipped.
 3[03/06/2011 16:57:13] MigrationConsole.exe Error: 0 : WorkItemTracking: System.Web.Services.Protocols.SoapException: TF223001: The update package contains more than one entry that sets the value of field System.ChangedBy for work item 1391. ---> TF223001: The update package contains more than one entry that sets the value of field System.ChangedBy for work item 1391.
 4[03/06/2011 16:57:13]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.RetryHandler.HandleSoapException(SoapException se)
 5[03/06/2011 16:57:13]    at Microsoft.TeamFoundation.WorkItemTracking.Proxy.WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
 6[03/06/2011 16:57:13]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.Tfs2010WorkItemServer.Update(String requestId, XmlElement package, XmlElement& result, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata)
 7[03/06/2011 16:57:13]    at Microsoft.TeamFoundation.Migration.Tfs2010WitAdapter.TfsBatchUpdateHelper.Submit(Int32 firstItem, Int32 lastItem)
 8[03/06/2011 16:57:13] MigrationConsole.exe Information: 0 : WorkItemTracking: Unresolved conflict:
 9[03/06/2011 16:57:13]   Session: adea805d-51df-489a-b2fd-9717b4af3703
10[03/06/2011 16:57:13]   Source: 6e3bdf70-f1ae-4cd5-8ee4-133c8aee0857
11[03/06/2011 16:57:13]   Message: Cannot find applicable resolution rule.
12[03/06/2011 16:57:13]   Conflict Type: TFS WIT invalid submission conflict type
13[03/06/2011 16:57:13]   Conflict Type Reference Name: c9d80b52-bb8a-4f7b-a40c-f8f63d6fd374
14[03/06/2011 16:57:13]   Conflict Details: <?xml version="1.0"?>
15[03/06/2011 16:57:13] <InvalidSubmissionConflictDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
16[03/06/2011 16:57:13]   <ExceptionType>System.Web.Services.Protocols.SoapException</ExceptionType>
17[03/06/2011 16:57:13]   <ExceptionMessage>TF223001: The update package contains more than one entry that sets the value of field System.ChangedBy for work item 1391. ---&gt; TF223001: The update package contains more than one entry that sets the value of field System.ChangedBy for work item 1391.</ExceptionMessage>
18[03/06/2011 16:57:13]   <InnerExceptionType />
19[03/06/2011 16:57:13]   <InnerExceptionMessage />
20[03/06/2011 16:57:13]   <ActionData />
21[03/06/2011 16:57:13]   <SourceItemId>3206</SourceItemId>
22[03/06/2011 16:57:13]   <SourceItemRevision>1</SourceItemRevision>
23[03/06/2011 16:57:13] </InvalidSubmissionConflictDetails>

Figure: When there are duplicate entries you get a TF223001

Once I got rid of the duplicate mappings I started getting data through and I can now get back to the route problem of “Edit” now that “Add” is working again.

Woot…

Software Development Troubleshooting Pragmatic Thinking System Configuration Technical Mastery
Comments

Related blog posts

No related videos found.

Connect with Martin Hinshelwood

If you've made it this far, it's worth connecting with our principal consultant and coach, Martin Hinshelwood, for a 30-minute 'ask me anything' call.

Our Happy Clients​

We partner with businesses across diverse industries, including finance, insurance, healthcare, pharmaceuticals, technology, engineering, transportation, hospitality, entertainment, legal, government, and military sectors.​

Cognizant Microsoft Business Group (MBG) Logo
Capita Secure Information Solutions Ltd Logo
Slaughter and May Logo
Higher Education Statistics Agency Logo
New Signature Logo
DFDS Logo
Boxit Document Solutions Logo
Big Data for Humans Logo
Genus Breeding Ltd Logo
Freadom Logo
Philips Logo
Flowmaster (a Mentor Graphics Company) Logo
YearUp.org Logo
Lockheed Martin Logo
Emerson Process Management Logo
Microsoft Logo
Milliman Logo
MacDonald Humfrey (Automation) Ltd. Logo
Nottingham County Council Logo
Ghana Police Service Logo
Washington Department of Enterprise Services Logo
Washington Department of Transport Logo
Royal Air Force Logo
Department of Work and Pensions (UK) Logo
DFDS Logo
Boxit Document Solutions Logo
Xceptor - Process and Data Automation Logo
Healthgrades Logo
Bistech Logo
Kongsberg Maritime Logo