Created
July 31, 2017 07:54
-
-
Save sommereder/d55d0fed403bf1e788418acc5f7f407d to your computer and use it in GitHub Desktop.
Revisions
-
Mario Hofer created this gist
Jul 31, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ public string RunTasksAndGetResponse(int pNumTasks = 0) { if (mRequestJson != null && mResponseJson != null) // check for necessary files { string lResponseString = "{\"ActionResult\":{\"Result\": \"ERROR: Timeout reached while executing eggPlant task(s).\",\"Expected\":[],\"Received\":[],\"Screenshots\":[]}}"; Stopwatch lRequestStopwatch = Stopwatch.StartNew(); TimeSpan lRequestTimeout = TimeSpan.FromSeconds((pNumTasks > 1 ? 5 : 10) * 60 * pNumTasks); string lCampaignId = CreateCampaign(mRequestJson, mResponseJson); // create campaign by requesting the API string lCampaignStatus = GetCampaignStatus(lCampaignId); // update campaign status while (lCampaignStatus != "finished" && lRequestStopwatch.Elapsed < lRequestTimeout) // while campaign not finished and timeout not reached { Console.WriteLine(lRequestStopwatch); lCampaignStatus = GetCampaignStatus(lCampaignId); // update campaign status Thread.Sleep(5 * 1000); // rest for five seconds } if (lCampaignStatus == "finished") { SaveCampaignResult(lCampaignId, mTargetFolder); // save campaign results into target folder lResponseString = SeparateResultFilesAndGetResponse(); // separate result and return response file as string } return lResponseString; } return null; // return null if not all requirements are met }