|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.IO; |
| 4 | +using System.Linq.Expressions; |
4 | 5 | using System.Net; |
5 | 6 | using System.Net.Http; |
6 | 7 | using System.Net.Http.Headers; |
@@ -158,6 +159,9 @@ private string UploadedAndRetrieveAttachmentLinkUrl(string matchedSourceUri, str |
158 | 159 |
|
159 | 160 | return attachRef.Url; |
160 | 161 | } |
| 162 | + catch (Exception ex) { |
| 163 | + throw ex; |
| 164 | + } |
161 | 165 | finally |
162 | 166 | { |
163 | 167 | if (File.Exists(fullImageFilePath)) |
@@ -239,9 +243,33 @@ private WorkItem GetDummyWorkItem(WorkItemType type = null) |
239 | 243 |
|
240 | 244 | _targetDummyWorkItem = type.NewWorkItem(); |
241 | 245 | _targetDummyWorkItem.Title = TargetDummyWorkItemTitle; |
| 246 | + |
| 247 | + var fails = _targetDummyWorkItem.Validate(); |
| 248 | + if (fails.Count > 0) |
| 249 | + { |
| 250 | + Log.LogWarning("Dummy Work Item is not ready to save as it has some invalid fields. This may not result in an error. Enable LogLevel as 'Debug' in the config to see more."); |
| 251 | + Log.LogDebug("--------------------------------------------------------------------------------------------------------------------"); |
| 252 | + Log.LogDebug("--------------------------------------------------------------------------------------------------------------------"); |
| 253 | + foreach (Field f in fails) |
| 254 | + { |
| 255 | + Log.LogDebug("Invalid Field Object:\r\n{Field}", f.ToJson()); |
| 256 | + } |
| 257 | + Log.LogDebug("--------------------------------------------------------------------------------------------------------------------"); |
| 258 | + Log.LogDebug("--------------------------------------------------------------------------------------------------------------------"); |
| 259 | + } |
| 260 | + Log.LogTrace("TfsEmbededImagesTool::GetDummyWorkItem::Save()"); |
| 261 | + |
| 262 | + |
242 | 263 | _targetDummyWorkItem.Save(); |
243 | | - Log.LogDebug("EmbededImagesRepairEnricher: Dummy workitem {id} created on the target collection.", _targetDummyWorkItem.Id); |
244 | | - //_targetProject.Store.DestroyWorkItems(new List<int> { _targetDummyWorkItem.Id }); |
| 264 | + |
| 265 | + if (_targetDummyWorkItem.Id == 0) |
| 266 | + { |
| 267 | + throw new Exception("The Dummy work Item cant be created due to a save failure. This is likley due to required fields on the Task or First work items type."); |
| 268 | + } else |
| 269 | + { |
| 270 | + Log.LogDebug("TfsEmbededImagesTool: Dummy workitem {id} created on the target collection.", _targetDummyWorkItem.Id); |
| 271 | + //_targetProject.Store.DestroyWorkItems(new List<int> { _targetDummyWorkItem.Id }); |
| 272 | + } |
245 | 273 | } |
246 | 274 | _DummyWorkItemCount++; |
247 | 275 | return _targetDummyWorkItem; |
|
0 commit comments