public RemoteProcedureCall SubmitRemoteProcedureCallRequest(RemoteProcedureCall remoteProcedureCall) { using var commandWrapper = new ModelsDatabaseCommandWrapper(connectionDetails.ConnectionString); var sqlCommand = commandWrapper.Command; sqlCommand.CommandText = "INSERT INTO RemoteProcedureCalls (remote_procedure_name, execution_context, arguments) " + "OUTPUT Inserted.request_id, Inserted.request_status " + "VALUES (@remoteProcedureName, @executionContext, @arguments)"; sqlCommand.Parameters.Add(new SqlParameter("@remoteProcedureName", System.Data.SqlDbType.Text, remoteProcedureCall.RemoteProcedureName.Length)).Value = remoteProcedureCall.RemoteProcedureName; sqlCommand.Parameters.Add(new SqlParameter("@executionContext", System.Data.SqlDbType.Text, remoteProcedureCall.ExecutionContextJsonString.Length)).Value = remoteProcedureCall.ExecutionContextJsonString; sqlCommand.Parameters.Add(new SqlParameter("@arguments", System.Data.SqlDbType.Text, remoteProcedureCall.ArgumentsJsonString.Length)).Value = remoteProcedureCall.ArgumentsJsonString; sqlCommand.Prepare(); var dataReader = sqlCommand.ExecuteReader(); dataReader.Read(); remoteProcedureCall.RequestId = (Guid)dataReader.GetValue(0); string statusString = (string)dataReader.GetValue(1); remoteProcedureCall.SetStatus(statusString); return(remoteProcedureCall); }
public RemoteProcedureCall GetUpdatedRPCRequestStatus(RemoteProcedureCall remoteProcedureCall) { using var commandWrapper = new ModelsDatabaseCommandWrapper(connectionDetails.ConnectionString); var sqlCommand = commandWrapper.Command; // TODO: add the timeout. Also add a timeout to connection open. // sqlCommand.CommandText = "SELECT request_status, result FROM RemoteProcedureCalls WHERE request_id = @requestId"; sqlCommand.Parameters.Add(new SqlParameter("@requestId", System.Data.SqlDbType.UniqueIdentifier)).Value = remoteProcedureCall.RequestId; sqlCommand.Prepare(); using var dataReader = sqlCommand.ExecuteReader(); dataReader.Read(); remoteProcedureCall.SetStatus((string)dataReader.GetValue(0)); if (!dataReader.IsDBNull(1)) { remoteProcedureCall.ResultJsonString = (string)dataReader.GetValue(1); } return(remoteProcedureCall); }