private string generateBatchFile()
{
try
{
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
csvPath = Path.Combine(path, "Imported_WorkItem_Ids.csv"),
batchPath = Path.Combine(path, "UndoImport.bat"),
exePath = Path.Combine(path, "DeleteWorkItems.exe");
using (TextWriter csvFile = File.CreateText(csvPath))
{
var firsId = true;
foreach (var wit in newlyImported.Values)
{
csvFile.Write("{0}{1}", (firsId ? "" : ","), wit.Id);
firsId = false;
}
}
using (TextWriter batchFile = File.CreateText(batchPath))
{
var tfsProject = serverUri + "/" + project;
batchFile.WriteLine("\"{0}\" /Project={1} /Ids=\"{2}\"", exePath, tfsProject, csvPath);
}
return batchPath;
}
catch (Exception ex)
{
importSummary.Warnings.Add(
string.Format("Failed to generate batchfile for removing imported tickets ({0}).", ex.Message));
return "";
}
}