/********************************************************************** * * * abortExperiment() * * **********************************************************************/ /** <summary> This method gets called if a success parameter is "false". It forwards the error report to server. </summary> <remarks> insert detailed description for abortExperiment here... @cond INTERNAL documented by t.wilhelmer, 8.11.2015 @endcond </remarks> <param name="restAPI">In: RESTapi object with personalized x-apikey and userID </param> <param name="error">In: error report of concerning request/response </param> <returns>New status for state machine. </returns> */ public Status abortExperiment(RestAPI restAPI, string error) { POSTExperimentResponse postResponse = new POSTExperimentResponse(); string data = "{ \"success\": false," + "\"results\": \"An error occurred.\"," + "\"rerrorReport\":" + error + "}"; try { postResponse = (POSTExperimentResponse)restAPI.PUTrequest(RequestEndpoint.experiment, data); } catch (Exception e) { logger.errorLog("An exception occurred in abortExperiment() using apis/engine/experiment/" + RequestEndpoint.experiment); logger.errorLog("Exception message:"); logger.errorLog(e.Message); return Status.EXCEPTION; } return Status.CHECKFOREXPERIMENT; }
/********************************************************************** * * * returnData() * * **********************************************************************/ /** <summary> Sends experiment data to the server. </summary> <remarks> insert detailed description for returnData here... @cond INTERNAL documented by t.wilhelmer, 8.11.2015 @endcond </remarks> <param name="restAPI">In: RESTapi object with personalized x-apikey and userID </param> <returns>New status for state machine. </returns> */ public Status returnData(RestAPI restAPI) { POSTExperimentResponse postResponse = new POSTExperimentResponse(); string data = "{ \"success\":" + postExperimentRequest.success + "," + "\"results\":" + postExperimentRequest.results + "\"rerrorReport\":" + postExperimentRequest.errorReport + "}"; try { postResponse = (POSTExperimentResponse)restAPI.PUTrequest(RequestEndpoint.experiment, data); } catch(Exception e) { logger.errorLog("An exception occurred in returnData() using apis/engine/experiment/" + RequestEndpoint.experiment); logger.errorLog("Exception message:"); logger.errorLog(e.Message); return Status.EXCEPTION; } logger.log("returnData()"); logger.log("(" + postResponse.timestamp + ") - " + postResponse.message + "\n"); if (postResponse.success == true) { Console.WriteLine("Experiment data successfully transmitted to the lab server!\n"); return Status.CHECKFOREXPERIMENT; } else { errorReport = postExperimentRequest.errorReport; return Status.ERROR; } }