Created
December 6, 2023 14:31
-
-
Save chuongmep/fdb21e3e883e0d52248a42e170720d17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<Status> ExecuteWorkItem(string token, string projectId, string versionId, string modelName, | |
string callBackUrl) | |
{ | |
Console.WriteLine("ActivityId: " + _configuration.ActivityFullName); | |
dynamic downloadUrl = await BuildDownloadURL(token, projectId, versionId).ConfigureAwait(false); | |
Console.WriteLine("Download URL: " + downloadUrl.Url); | |
XrefTreeArgument treeArgument = await BuildUploadURL(token).ConfigureAwait(false); | |
Console.WriteLine("TreeArgument: " + treeArgument.Url); | |
WorkItem workItemSpec = new WorkItem() | |
{ | |
ActivityId = _configuration.ActivityFullName, | |
Arguments = new Dictionary<string, IArgument>() | |
{ | |
// {"inputFile", downloadUrl}, | |
{"inputFile", new XrefTreeArgument() | |
{ | |
Url = downloadUrl, | |
PathInZip = modelName + ".rvt", | |
Verb = Verb.Put, | |
}}, | |
{"result", treeArgument}, | |
{"onComplete", new XrefTreeArgument {Verb = Verb.Post, Url = callBackUrl}} | |
}, | |
LimitProcessingTimeSec = 3600, | |
}; | |
Console.WriteLine("Start Create WorkItem"); | |
WorkItemStatus workItemStatus = await _designAutomation.CreateWorkItemAsync(workItemSpec).ConfigureAwait(false); | |
Console.WriteLine("WorkItemStatus: " + workItemStatus.Status); | |
Console.WriteLine("Working Item Id: " + workItemStatus.Id); | |
// wait until the work item is finished | |
Status status = default; | |
while (!workItemStatus.Status.IsDone()) | |
{ | |
await Task.Delay(TimeSpan.FromSeconds(2)).ConfigureAwait(false); | |
workItemStatus = await _designAutomation.GetWorkitemStatusAsync(workItemStatus.Id).ConfigureAwait(false); | |
Console.WriteLine("WorkItemStatus: " + workItemStatus.Status); | |
Console.WriteLine("Result:" + workItemStatus.ReportUrl); | |
if(workItemStatus.ReportUrl != null) | |
WriteReportTxt(workItemStatus.ReportUrl); | |
status = workItemStatus.Status; | |
} | |
// get number after ?version= | |
string version = versionId.Split("=")[1]; | |
string downloadOutput = DownloadOutput(version, token, treeArgument); | |
return status; | |
//UploadFile(downloadOutput,modelName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment