Esempio n. 1
0
        private async Task<bool> ProcessCalibrationRemoteData(string calibrationOverviewPath, string pacientId)
        {
            var calibrationOverviewSendDto = await DataManagerUtil.LoadJsonFileAsync<CalibrationOverviewSendDto>(calibrationOverviewPath);
            calibrationOverviewSendDto.PacientId = pacientId;

            var apiResponse = await ApiClient.Instance.SaveCalibrationOverview(calibrationOverviewSendDto);

            if (!apiResponse.Success) return false;

            File.Delete(calibrationOverviewPath);
            return true;
        }
Esempio n. 2
0
        private async Task<bool> ProcessMinigameRemoteData(string mingameOverviewPath, string pacientId)
        {
            var plataformOverviewSendDto = await DataManagerUtil.LoadJsonFileAsync<MinigameOverviewSendDto>(mingameOverviewPath);
            plataformOverviewSendDto.PacientId = pacientId;

            var apiResponse = await ApiClient.Instance.SaveMinigameOverview(plataformOverviewSendDto);

            if (!apiResponse.Success) return false;

            File.Delete(mingameOverviewPath);
            return true;
        }
Esempio n. 3
0
        private async Task<bool> AnalyzePacientRemoteDirectory(string pacientRemotePath)
        {
            var pacientId = Path.GetFileName(pacientRemotePath);
            var pacientFilePath = Directory.GetFiles(pacientRemotePath).FirstOrDefault();
            if (pacientFilePath != null)
            {
                ApiResponse<PacientDto> apiResponse;
                var jsonContent = DataManagerUtil.LoadJsonFile(pacientFilePath);
                if (Path.GetFileName(Path.GetDirectoryName(pacientRemotePath)).StartsWith("n"))
                {
                    apiResponse = await ApiClient.Instance.SavePacient(null, jsonContent);
                }
                else
                {
                    apiResponse = await ApiClient.Instance.UpdatePacient(null, pacientId, jsonContent);
                }

                if (!apiResponse.Success)
                    return false;

                pacientId = apiResponse.Data.Id;

                File.Delete(pacientFilePath);
            }

            var minigamesDirectory = Directory.GetDirectories(pacientRemotePath).FirstOrDefault(directoryName => string.Equals(Path.GetFileName(directoryName), "MinigamesData"));
            var plataformsDirectory = Directory.GetDirectories(pacientRemotePath).FirstOrDefault(directoryName => string.Equals(Path.GetFileName(directoryName), "PlataformsData"));
            var calibrationsDirectory = Directory.GetDirectories(pacientRemotePath).FirstOrDefault(directoryName => string.Equals(Path.GetFileName(directoryName), "CalibrationsData"));

            var remoteDataTasks = new List<Task<bool>>();

            if (minigamesDirectory != null)
                remoteDataTasks.AddRange(AnalyzeMinigamesDirectory(minigamesDirectory, pacientId));
            if (plataformsDirectory != null)
                remoteDataTasks.AddRange(AnalyzePlataformsDirectory(plataformsDirectory, pacientId));
            if (calibrationsDirectory != null)
                remoteDataTasks.AddRange(AnalyzeCalibrationsDirectory(calibrationsDirectory, pacientId));

            var result = await Task.WhenAll(remoteDataTasks);

            if (!result.All(x => x)) return false;

            Directory.Delete(pacientRemotePath, true);

            return true;
        }