Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with TfsEmbededImagesTool and Rules #2603

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
Expand Down Expand Up @@ -158,6 +159,9 @@ private string UploadedAndRetrieveAttachmentLinkUrl(string matchedSourceUri, str

return attachRef.Url;
}
catch (Exception ex) {
throw ex;
}
finally
{
if (File.Exists(fullImageFilePath))
Expand Down Expand Up @@ -239,9 +243,33 @@ private WorkItem GetDummyWorkItem(WorkItemType type = null)

_targetDummyWorkItem = type.NewWorkItem();
_targetDummyWorkItem.Title = TargetDummyWorkItemTitle;

var fails = _targetDummyWorkItem.Validate();
if (fails.Count > 0)
{
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.");
Log.LogDebug("--------------------------------------------------------------------------------------------------------------------");
Log.LogDebug("--------------------------------------------------------------------------------------------------------------------");
foreach (Field f in fails)
{
Log.LogDebug("Invalid Field Object:\r\n{Field}", f.ToJson());
}
Log.LogDebug("--------------------------------------------------------------------------------------------------------------------");
Log.LogDebug("--------------------------------------------------------------------------------------------------------------------");
}
Log.LogTrace("TfsEmbededImagesTool::GetDummyWorkItem::Save()");


_targetDummyWorkItem.Save();
Log.LogDebug("EmbededImagesRepairEnricher: Dummy workitem {id} created on the target collection.", _targetDummyWorkItem.Id);
//_targetProject.Store.DestroyWorkItems(new List<int> { _targetDummyWorkItem.Id });

if (_targetDummyWorkItem.Id == 0)
{
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.");
} else
{
Log.LogDebug("TfsEmbededImagesTool: Dummy workitem {id} created on the target collection.", _targetDummyWorkItem.Id);
//_targetProject.Store.DestroyWorkItems(new List<int> { _targetDummyWorkItem.Id });
}
}
_DummyWorkItemCount++;
return _targetDummyWorkItem;
Expand Down
Loading