// Generic DELMIA recipe-download — performed DIRECTLY on the composed DelmiaReceiver child // (mirrors how MesMoveIn writes the MESReceiver child) instead of delegating via CallScript. // No side logic; the receiver's own DelmiaReceiver.Download method holds the same handshake. var recv = Children["DelmiaRecv"]; System.Func IsTrue = v => { var s=v?.ToString(); return (v is bool b && b)||s=="1"||string.Equals(s,"true",System.StringComparison.OrdinalIgnoreCase); }; System.Func P = k => Parameters.ContainsKey(k) ? Parameters[k] : null; if (!IsTrue(recv.Attributes["ReadyFlag"])) return new { Result=false, ResultText="Receiver ready flag not set to true" }; try { recv.Attributes["RecipeProcessedFlag"] = false; var data = new System.Collections.Generic.Dictionary { { "DownloadPath", P("DownloadPath") }, { "WorkOrderNumber", P("WorkOrderNumber") }, { "PartNumber", P("PartNumber") }, { "JobStepNumber", P("JobStepNumber") }, { "Username", P("Username") }, }; if (!await recv.Attributes.WriteBatchAndWaitAsync(data, "RecipeDownloadFlag", true, "RecipeProcessedFlag", true, System.TimeSpan.FromSeconds(25))) return new { Result=false, ResultText="Timeout waiting for recipe to be processed" }; return new { Result = IsTrue(recv.Attributes["RecipeProcessResult"]), ResultText = recv.Attributes["RecipeProcessResultText"]?.ToString() ?? "" }; } catch (Exception ex) { return new { Result=false, ResultText="RecipeDownload failed: " + ex.Message }; }