private async Task <bool> TryPutResult(XQueueResult result) { var content = JsonConvert.SerializeObject(result); log.Info($"Try to put submission checking result into xqueue. Url: {putResultUrl}, content: {content}"); var formContent = new Dictionary <string, string> { { "xqueue_header", result.header }, { "xqueue_body", result.body } }; var response = await client.PostAsync(putResultUrl, new FormUrlEncodedContent(formContent)); if (response.StatusCode == HttpStatusCode.Moved || response.StatusCode == HttpStatusCode.Found) { log.Warn("Redirected to the login page. Try to authorize again"); await Login(); throw new Exception("Redirected to the login page. Try to authorize again"); } if (!response.IsSuccessStatusCode) { log.Warn($"Unexpected response status code while putting results to xqueue: {response.StatusCode}"); throw new Exception($"Unexpected response status code while putting results to xqueue: {response.StatusCode}"); } var responseContent = await response.Content.ReadAsStringAsync(); log.Info($"XQueue returned following content: {responseContent}"); var parsedResponse = responseContent.DeserializeJson <XQueueResponse>(); return(parsedResponse.ReturnCode == 0); }
public async Task <bool> PutResult(XQueueResult result) { return(await FuncUtils.TrySeveralTimesAsync(() => TryPutResult(result), 5, () => Task.Delay(TimeSpan.FromMilliseconds(1)))); }