public async Task <IActionResult> TestSendReceive([FromBody] XmlPageRequestBody xmlPageRequestBody) { ILogger logger = new ConsoleLogger(); JsonResult jsonResult; RequestResponseFrame responseFrame; object jsonObject; string methodName = "TestSendReceive"; logger.WriteEntry(methodName + " entry."); if (ModelState.IsValid) { logger.WriteEntry(methodName + " ModelState is valid."); string receiveUrl = xmlPageRequestBody.ReceiveUrl; string receiveSearch = xmlPageRequestBody.ReceiveSearch; GeneralClassLibrary.XmlPageRequestFrame xmlPageRequestFrame = new XmlPageRequestFrame(xmlPageRequestBody); // Transform the API request to an ITcpFrame. byte[] sendFrameBytes = xmlPageRequestFrame.ToByteArray(); RequestResponseFrame requestFrame = new RequestResponseFrame(sendFrameBytes); // Connect to the server and obtain a network stream. BufferedStream bufferedStream = await SendReceiveReply.ConnectToServer(RemoteHostName, RemotePortNumber, SizeStreamBuffer, logger); // Send and receive data via the stream. responseFrame = await SendReceiveReply.RequestReceiveResponse(bufferedStream, requestFrame, logger); ITcpFrame tcpFrame = responseFrame; byte[] replyFrameBytes = tcpFrame.FramePacket; IpcFrameBase ipcFrameBase = ( IpcFrameBase )IpcFrameBase.FromByteArray(replyFrameBytes); // Transform the ITcpFrame to an API response. logger.WriteEntry(methodName + " building the JSON result."); XmlPageReplyFrame xmlPageReplyFrame = ( XmlPageReplyFrame )ipcFrameBase; jsonObject = new { textArray = xmlPageReplyFrame.ResultList, isSuccess = true }; } else { logger.WriteEntry(methodName + " ModelState is not valid!"); jsonObject = new { textArray = new List <string>(), isSuccess = false }; } logger.WriteEntry(methodName + " exit."); jsonResult = new JsonResult(jsonObject); return(jsonResult); }
public string NavigateAndSync(BrowserForm browserForm, XmlPageRequestBody xmlPageRequestBody) { string result = this.NavigteToUrl(browserForm, xmlPageRequestBody.ReceiveUrl); return(result); }