#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task <object> ActionAsync(CancellationToken cancelToken) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { return(FailableRun <object>(this, delegate { ++this.ActionExecuteCount; if (this.sequenceItem.load == null) { throw new NullReferenceException($"{nameof(this.sequenceItem)}.{nameof(this.sequenceItem.load)} missing"); } this.state.ProgressLog?.Progress($"Loading {this.sequenceItem.load.csv}..."); var scribanModel = new { run_id = this.state.RunId, command_args = this.state.CommandLineOptions, this.model, sequence_item = this.sequenceItem, unique_no = Program.unique_no++ }; var loadfile = ScribanUtil.ScribanParse(this.sequenceItem?.load?.csv ?? "", scribanModel); var csvRows = LoadFile(this.sequenceItem.load, loadfile); var noOfRows = csvRows?.Count() ?? 0; var stringContent = JsonConvert.SerializeObject(csvRows); var responseModel = SequenceItemStatic.GetResponseItems(this.state, this.sequenceItem, stringContent); // csvRows.ToList<dynamic>()); return responseModel; })); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task <object> ActionAsync(CancellationToken cancelToken) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { return(FailableRun <object>(this, delegate { ++this.ActionExecuteCount; if (this.sequenceItem.run == null) { throw new NullReferenceException($"{nameof(this.sequenceItem)}.{nameof(this.sequenceItem.run)} missing"); } this.state.ProgressLog?.Progress($"Running {this.sequenceItem.run.exec}..."); var scribanModel = new { run_id = this.state.RunId, command_args = this.state.CommandLineOptions, this.model, sequence_item = this.sequenceItem, unique_no = Program.unique_no++ }; // Exec run external program var workingExec = ScribanUtil.ScribanParse(this.sequenceItem?.run?.exec ?? "", scribanModel); var workingArgs = ScribanUtil.ScribanParse(this.sequenceItem?.run?.args ?? "", scribanModel); this.state.ProgressLog?.Progress($" running exec '{workingExec}', with args '{workingArgs}'..."); var itsStandardInput = (model != null) ? JsonConvert.SerializeObject(model) : ""; var execReturn = ProcessExecute(this.sequenceItem.run, workingExec, workingArgs, itsStandardInput); var responseContentLength = execReturn?.Length ?? 0; var responseContent = execReturn; var responseModel = SequenceItemStatic.GetResponseItems(this.state, this.sequenceItem, execReturn); return responseModel; })); }
public async Task <object> ActionAsync(CancellationToken cancelToken) { return(await FailableRun <Task <object> >(this, async delegate { ++this.ActionExecuteCount; if (this.sequenceItem.send == null) { throw new NullReferenceException($"{nameof(this.sequenceItem)}.{nameof(this.sequenceItem.send)} missing"); } var modelUrl = this.sequenceItem.send.url ?? ""; var scribanModel = new { run_id = this.state.RunId, command_args = this.state.CommandLineOptions, this.model, sequence_item = this.sequenceItem, unique_no = Program.unique_no++ }; this.WorkingUri = ScribanUtil.ScribanParse(this.sequenceItem.send.url, scribanModel); this.state.ProgressLog?.Progress($"Processing {this.WorkingUri}..."); dynamic responseModel = null; using (var client = MakeClientWithHeaders(this.state.CommandLineOptions, this.state.YamlOptions, this.sequenceItem)) { var http_response = await DoSendAction(client, scribanModel); this.IsFail = !http_response.IsSuccessStatusCode; var responseContentLength = http_response?.Content?.Headers?.ContentLength ?? 0; var responseContent = responseContentLength > 0 ? (await http_response?.Content?.ReadAsStringAsync()) : string.Empty; this.state.ProgressLog?.Progress($" received {responseContentLength} bytes..."); responseModel = SequenceItemStatic.GetResponseItems(this.state, this.sequenceItem, responseContent); SavingContentsEtc(Guid.NewGuid().ToString(), responseModel, http_response, responseContentLength, responseContent); } return responseModel; })); }