public async Task DownloadFileAsync(string remoteFile, IAbsoluteDirectoryPath destinationPath, IReadOnlyCollection <Uri> remotes, CancellationToken token, int limit, Func <IAbsoluteFilePath, bool> confirmValidity) { using (var scoreMirrorSelector = _createMirrorSelectorWithLimit(limit, remotes)) { await DownloadFileAsync(remoteFile, destinationPath, scoreMirrorSelector.Value, token, confirmValidity, RepositoryRemote.CalculateHttpFallbackAfter(limit)) .ConfigureAwait(false); } }
public void AnalyzeReports() { while (true) { Thread.Sleep(5000); foreach (CSTask task in RepositoryRemote.GetCSTasksToValidate()) { ProcessTaskReports(task); } } }
public void ProcessTaskReports(CSTask task) { Dictionary <string, int> answersMap = new Dictionary <string, int>(); List <double> listOfAnswersIndex = new List <double>(); Dictionary <int, int> answersIncentive = null; List <InteractiveReport> listResports = new List <InteractiveReport>(); InteractiveReport intReport = null; IncentiveAssigned incentive = null; int index = 1; object taskReward = null; string txId = null; //creates association between answer Index and answerId //this will allow to sort the answers to calculate the z-score modified foreach (TaskAnswer answer in task.InteractiveTask.Answers) { answersMap.Add(answer.AnswerId, index); index++; } foreach (string reportID in task.ReportsID.Values.ToList()) { //get report from repository intReport = RepositoryRemote.GetInteractiveReportsByID(reportID); //add the first report result if (answersMap.ContainsKey(intReport.Result.AnswerId)) { listOfAnswersIndex.Add(answersMap[intReport.Result.AnswerId]); } listResports.Add(intReport); } if (listOfAnswersIndex.Count == 0) { Log.Debug("No Answers to Process"); return; } //get for each answer its reward value answersIncentive = DataQualityProcess(listOfAnswersIndex); incentive = this.IncentiveScheme.Incentive.CompleteTaskIncentive(); foreach (InteractiveReport report in listResports) { index = answersMap[report.Result.AnswerId]; incentive.IncentiveQty = answersIncentive[index]; this.IncentiveScheme.RewardUser(report.UserID, incentive, out taskReward, out txId); this.RepositoryRemote.SaveReportReward(task.TaskID, report.ReportID, (Dictionary <string, string>)taskReward, txId); } }
public Task DownloadFileAsync(string remoteFile, IAbsoluteDirectoryPath destinationPath, IMirrorSelector selector, int limit, CancellationToken token) => DownloadFileAsync(remoteFile, destinationPath, selector, token, x => true, RepositoryRemote.CalculateHttpFallbackAfter(limit));