/// <summary> /// Create the request from HL7 /// </summary> /// <param name="received"></param> /// <returns></returns> public static ExecuteServiceServerRequest FromMessage(string received) { var lines = received.Split(Request.NewRow.ToCharArray()); var rows = (from l in lines select l.Split(Request.Delimiter.ToCharArray())).ToArray(); var teamName = rows[0][2]; var teamId = int.Parse(rows[0][3]); var serviceName = rows[1][2]; var numSegments = int.Parse(rows[1][4]); var call = new RemoteServiceCall(serviceName, teamName, teamId); var request = new ExecuteServiceServerRequest(call); // Read the arguments for (int i = 0; i < numSegments; i++) { var row = rows[2 + i]; var pos = int.Parse(row[1]); var respName = row[2]; var dataType = ServiceArgument.TypeFromString(row[3]); var value = row[5]; var arg = new ServiceArgument(pos, respName, dataType); arg.Value = value; call.Args.Add(arg); } return(request); }
/// <summary> /// Execute service /// </summary> /// <param name="call">Execution information</param> /// <returns>Response</returns> public ExecuteServiceResponse ExecuteService(RemoteServiceCall call) { EnforceRegistered(); var response = IssueRequest(new ExecuteServiceRequest(TeamName, (int)TeamId, call)); if (response is ExecuteServiceResponse) { return((ExecuteServiceResponse)response); } else { throw ThrowFailureResponse(response); } }
/// <summary> /// /// </summary> /// <param name="teamName">Team name</param> /// <param name="teamId">Team id</param> /// <param name="call">Remote service call</param> public ExecuteServiceRequest(string teamName, int teamId, RemoteServiceCall call) : base("EXEC-SERVICE", teamName, teamId.ToString()) { Contents.Add("SRV"); Contents.Add(""); Contents.Add(call.ServiceName); Contents.Add(""); Contents.Add(call.Args.Count.ToString()); Contents.Add(""); Contents.Add(""); Contents.Add(NewRow); for (int i = 0; i < call.Args.Count; i++) { var arg = call.Args[i]; Contents.Add("ARG"); Contents.Add(arg.Position.ToString()); Contents.Add(arg.Name); Contents.Add(ServiceArgument.TypeToString(arg.DataType)); Contents.Add(""); Contents.Add(arg.Value); Contents.Add(NewRow); } }
/// <summary> /// /// </summary> /// <param name="call">Remote service call</param> private ExecuteServiceServerRequest(RemoteServiceCall call) { this.Call = call; }