diff --git a/UpdateIPTParam/SampleAutomation.cs b/UpdateIPTParam/SampleAutomation.cs index e8d0fdd..ea3286b 100644 --- a/UpdateIPTParam/SampleAutomation.cs +++ b/UpdateIPTParam/SampleAutomation.cs @@ -59,15 +59,11 @@ public async Task RunAsync(Document doc) string data = System.IO.File.ReadAllText(paramsPath); LogTrace("After reading " + paramsJsonFile); - //this errors out :-s >> LogTrace($"Params content = {data}"); JObject jParamsRoot = JObject.Parse(data); string text = jParamsRoot.ToString(Formatting.None); Trace.WriteLine(text); - //LogTrace("Updating..."); - //asm.Update2(true); - var directUpload = false; do { directUpload = jParamsRoot["directUpload"].Value(); @@ -85,8 +81,8 @@ public async Task RunAsync(Document doc) if (directUpload) { var outputPngCallback = jParamsRoot["outputPngCallback"].Value(); - await UploadFile(outputPngUrl, outputPngFile); - _ = UploadData(outputPngCallback, "{ }"); + await UploadFileAsync(outputPngUrl, outputPngFile); + _ = UploadDataAsync(outputPngCallback, "{ }"); } } @@ -95,8 +91,7 @@ public async Task RunAsync(Document doc) string positionData = SavePositions(asm.ComponentDefinition); if (directUpload) { - //_ = UploadFile(outputJsonUrl, outputJsonFile); - _ = UploadData(outputJsonUrl, positionData); + _ = UploadDataAsync(outputJsonUrl, positionData); } } @@ -114,7 +109,7 @@ public async Task RunAsync(Document doc) if (directUpload) { - _ = UploadFile(outputZipUrl, outputZipFile); + _ = UploadFileAsync(outputZipUrl, outputZipFile); } } @@ -122,14 +117,14 @@ public async Task RunAsync(Document doc) if (directUpload) { - jParamsRoot = await GetData(jParamsRoot["dataCallback"].Value()); + jParamsRoot = await GetDataAsync(jParamsRoot["dataCallback"].Value()); } } while (directUpload); } catch (Exception e) { LogTrace("RunAsync. Processing failed: {0}", e.ToString()); } } - public async Task UploadFile(string url, string fileName) + public async Task UploadFileAsync(string url, string fileName) { LogTrace("[UploadFile]"); LogTrace(url + " / " + fileName); @@ -145,7 +140,7 @@ public async Task UploadFile(string url, string fileName) } } - public async Task UploadData(string url, string data) + public async Task UploadDataAsync(string url, string data) { try { @@ -166,7 +161,7 @@ public async Task UploadData(string url, string data) catch (Exception e) { LogTrace("UploadData. Processing failed: {0}", e.ToString()); } } - public async Task GetData(string url) + public async Task GetDataAsync(string url) { LogTrace("[GetData]"); LogTrace(url); diff --git a/forgesample/Controllers/DesignAutomationController.cs b/forgesample/Controllers/DesignAutomationController.cs index 5097076..c11d8e3 100644 --- a/forgesample/Controllers/DesignAutomationController.cs +++ b/forgesample/Controllers/DesignAutomationController.cs @@ -164,13 +164,13 @@ public async Task UploadOssFiles([FromBody]JObject appBundleSpecs dynamic res = await objects.UploadObjectAsync(BucketKey, fileName, (int)streamReader.BaseStream.Length, streamReader.BaseStream, "application/octet-stream"); - _ = TranslateFile(res.objectId, null); + _ = TranslateFileAsync(res.objectId, null); } return Ok(); } - private async Task TranslateFile(string objectId, string rootFileName) + private async Task TranslateFileAsync(string objectId, string rootFileName) { dynamic oauth = await OAuthController.GetInternalAsync(); @@ -366,7 +366,7 @@ public async Task CreateActivity([FromBody]JObject activitySpecs) /// /// Define a new activity /// - public static async Task IsInCache(string fileName) + public static async Task IsInCacheAsync(string fileName) { dynamic oauth = await OAuthController.GetInternalAsync(); ObjectsApi objects = new ObjectsApi(); @@ -405,7 +405,7 @@ public async Task StartWorkitems([FromBody]JObject input) string pngFileName = hash + ".png"; string jsonFileName = browserConnectionId + ".json"; - if (useCache && await IsInCache(zipFileName)) + if (useCache && await IsInCacheAsync(zipFileName)) { double[] cells = new double[] { 1, 0, 0, 0, @@ -414,7 +414,7 @@ public async Task StartWorkitems([FromBody]JObject input) 0, 0, 0, 1 }; - _ = SendPictureUrlToClient(browserConnectionId, pngFileName); + _ = SendPictureUrlToClientAsync(browserConnectionId, pngFileName); JObject data = new JObject( new JProperty("components", @@ -426,7 +426,7 @@ public async Task StartWorkitems([FromBody]JObject input) ) ) ); - _ = SendComponentsDataToClient(browserConnectionId, data); + _ = SendComponentsDataToClientAsync(browserConnectionId, data); return Ok(new { PngWorkItemId = pngWorkItemId, @@ -437,7 +437,7 @@ public async Task StartWorkitems([FromBody]JObject input) if (keepWorkitem) { - sessionWorkItemId = await CreateSessionWorkItem( + sessionWorkItemId = await CreateSessionWorkItemAsync( input, new Dictionary() { { "Authorization", "Bearer " + oauth.access_token } }, browserConnectionId, @@ -455,7 +455,7 @@ public async Task StartWorkitems([FromBody]JObject input) }); } - pngWorkItemId = await CreateWorkItem( + pngWorkItemId = await CreateWorkItemAsync( input, new Dictionary() { { "Authorization", "Bearer " + oauth.access_token } }, browserConnectionId, @@ -466,7 +466,7 @@ public async Task StartWorkitems([FromBody]JObject input) if (useCache) { - zipWorkItemId = await CreateWorkItem( + zipWorkItemId = await CreateWorkItemAsync( input, new Dictionary() { { "Authorization", "Bearer " + oauth.access_token } }, browserConnectionId, @@ -476,7 +476,7 @@ public async Task StartWorkitems([FromBody]JObject input) ); } - jsonWorkItemId = await CreateWorkItem( + jsonWorkItemId = await CreateWorkItemAsync( input, new Dictionary() { { "Content-Type", "application/json" } }, browserConnectionId, @@ -492,7 +492,7 @@ public async Task StartWorkitems([FromBody]JObject input) SessionWorkItemId = sessionWorkItemId }); } - private async Task CreateWorkItem(JObject input, Dictionary headers, string browserConnectionId, string outputName, string fileName, string url) + private async Task CreateWorkItemAsync(JObject input, Dictionary headers, string browserConnectionId, string outputName, string fileName, string url) { input["directUpload"] = false; input[outputName] = url; @@ -530,7 +530,7 @@ private async Task CreateWorkItem(JObject input, Dictionary CreateSessionWorkItem(JObject input, Dictionary headers, string browserConnectionId, string jsonFileName, string pngFileName, string zipFileName) + private async Task CreateSessionWorkItemAsync(JObject input, Dictionary headers, string browserConnectionId, string jsonFileName, string pngFileName, string zipFileName) { if (zipFileName != null) { @@ -583,13 +583,13 @@ private async Task CreateSessionWorkItem(JObject input, Dictionary CreateSignedResourceAsync(string fileName, string acc return signedUrl.Data.signedUrl; } - private async Task SendPictureUrlToClient(string id, string pngFile) + private async Task SendPictureUrlToClientAsync(string id, string pngFile) { System.Diagnostics.Debug.WriteLine("SendPictureUrlToClient: " + pngFile); @@ -644,10 +644,10 @@ public async Task OnData([FromRoute] string fileType, [FromQuery] // urnBase, something like "urn:adsk.objects:os.object:rgm0mo9jvssd2ybedk9mrtxqtwsa61y0-designautomation/" if (fileType == "json") - _ = SendComponentsDataToClient(id, data); + _ = SendComponentsDataToClientAsync(id, data); if (fileType == "png") - _ = SendPictureUrlToClient(id, outputFile); + _ = SendPictureUrlToClientAsync(id, outputFile); return Ok(); } @@ -658,7 +658,7 @@ public async Task OnData([FromRoute] string fileType, [FromQuery] /// [HttpGet] [Route("api/forge/designautomation/data")] - public async Task GetData([FromQuery] string id) + public async Task GetDataAsync([FromQuery] string id) { System.Diagnostics.Debug.WriteLine("GetData"); @@ -680,7 +680,7 @@ public async Task OnComplete(string id, string outputFile, [FromB { // your webhook should return immediately! we can use Hangfire to schedule a job JObject bodyJson = JObject.Parse((string)body.ToString()); - _ = SendStringToClient(id, bodyJson.ToString()); + _ = SendStringToClientAsync(id, bodyJson.ToString()); if (_runningWorkitems.ContainsKey(id) && _runningWorkitems[id] == bodyJson["id"].Value()) { @@ -692,17 +692,17 @@ public async Task OnComplete(string id, string outputFile, [FromB byte[] bs = client.DownloadData(request); string report = System.Text.Encoding.Default.GetString(bs); - _ = SendStringToClient(id, report); + _ = SendStringToClientAsync(id, report); if (outputFile.EndsWith(".png")) { - _ = SendPictureUrlToClient(id, outputFile); + _ = SendPictureUrlToClientAsync(id, outputFile); } if (outputFile.EndsWith(".zip")) { string objectId = "urn:adsk.objects:os.object:" + BucketKey + "/" + outputFile; - _ = TranslateFile(objectId, "shelves.iam"); + _ = TranslateFileAsync(objectId, "shelves.iam"); } } catch (Exception e) diff --git a/forgesample/wwwroot/bundles/UpdateIPTParam.bundle.zip b/forgesample/wwwroot/bundles/UpdateIPTParam.bundle.zip index fa288f1..3c32e8f 100644 Binary files a/forgesample/wwwroot/bundles/UpdateIPTParam.bundle.zip and b/forgesample/wwwroot/bundles/UpdateIPTParam.bundle.zip differ