|
9 | 9 | using MigrationTools._EngineV1.DataContracts; |
10 | 10 | using MigrationTools.DataContracts; |
11 | 11 | using Serilog; |
| 12 | +using static Microsoft.TeamFoundation.Client.CommandLine.Options; |
12 | 13 |
|
13 | 14 | namespace MigrationTools._EngineV1.Clients |
14 | 15 | { |
@@ -150,28 +151,36 @@ public override WorkItemData GetWorkItem(string id) |
150 | 151 |
|
151 | 152 | public override WorkItemData GetWorkItem(int id) |
152 | 153 | { |
| 154 | + if (id == 0) |
| 155 | + { |
| 156 | + throw new ArgumentOutOfRangeException("id", id, "id cant be empty."); |
| 157 | + } |
153 | 158 | var startTime = DateTime.UtcNow; |
154 | 159 | var timer = System.Diagnostics.Stopwatch.StartNew(); |
155 | 160 | WorkItem y; |
156 | 161 | try |
157 | 162 | { |
| 163 | + Log.Debug("TfsWorkItemMigrationClient::GetWorkItem({id})", id); |
158 | 164 | y = Store.GetWorkItem(id); |
159 | 165 | timer.Stop(); |
160 | 166 | Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "200", true)); |
161 | 167 | } |
162 | 168 | catch (Exception ex) |
163 | 169 | { |
164 | | - timer.Stop(); |
165 | | - Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "500", false)); |
166 | 170 | Telemetry.TrackException(ex, |
167 | 171 | new Dictionary<string, string> { |
168 | 172 | { "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() } |
169 | 173 | }, |
170 | 174 | new Dictionary<string, double> { |
171 | 175 | { "Time",timer.ElapsedMilliseconds } |
172 | 176 | }); |
173 | | - Log.Error(ex, "Unable to configure store"); |
| 177 | + Log.Error(ex, "Unable to GetWorkItem with id[{id}]", id); |
174 | 178 | throw; |
| 179 | + } finally |
| 180 | + { |
| 181 | + timer.Stop(); |
| 182 | + Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "500", false)); |
| 183 | + |
175 | 184 | } |
176 | 185 | return y?.AsWorkItemData(); |
177 | 186 | } |
@@ -273,6 +282,7 @@ private WorkItemStore GetWorkItemStore() |
273 | 282 | WorkItemStore store; |
274 | 283 | try |
275 | 284 | { |
| 285 | + Log.Debug("TfsWorkItemMigrationClient::GetWorkItemStore({InternalCollection}, {bypassRules})", _config.AsTeamProjectConfig().Collection, _bypassRules); |
276 | 286 | store = new WorkItemStore((TfsTeamProjectCollection)MigrationClient.InternalCollection, _bypassRules); |
277 | 287 | timer.Stop(); |
278 | 288 | Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItemStore", null, startTime, timer.Elapsed, "200", true)); |
|
0 commit comments