示例#1
0
        public async Task <HttpStatusCode> ImportOnlineCases(string url, string instrumentDataPath)
        {
            var model = new InstrumentDataDto
            {
                InstrumentDataPath = instrumentDataPath
            };

            var stringContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
            var response      = await _httpClient.PostAsync(url, stringContent);

            return(response.StatusCode);
        }
示例#2
0
        public async Task ImportOnlineDataAsync(InstrumentDataDto instrumentDataDto, string serverParkName,
                                                string instrumentName, string tempFilePath)
        {
            instrumentDataDto.ThrowExceptionIfNull("InstrumentDataDto");
            instrumentDataDto.InstrumentDataPath.ThrowExceptionIfNullOrEmpty("instrumentDataDto.InstrumentDataPath");
            serverParkName.ThrowExceptionIfNullOrEmpty("serverParkName");
            instrumentName.ThrowExceptionIfNullOrEmpty("instrumentName");
            tempFilePath.ThrowExceptionIfNullOrEmpty("tempFilePath");

            await DownloadDatabaseFilesFromBucketAsync(instrumentDataDto.InstrumentDataPath, tempFilePath);

            var databaseFile = _fileService.GetDatabaseFile(tempFilePath, instrumentName);

            _caseService.ImportOnlineDatabaseFile(databaseFile, instrumentName, serverParkName);
        }
        public void SetUpTests()
        {
            _fileServiceMock    = new Mock <IFileService>(MockBehavior.Strict);
            _nisraServiceMock   = new Mock <INisraFileImportService>(MockBehavior.Strict);
            _storageServiceMock = new Mock <ICloudStorageService>(MockBehavior.Strict);
            _loggingMock        = new Mock <ILoggingService>();
            _mockSequence       = new MockSequence();

            _serverParkName = "ServerParkA";
            _instrumentName = "OPN2010A";
            _bucketPath     = "OPN2010A";
            _tempPath       = @"c:\temp\GUID";

            _instrumentDataDto = new InstrumentDataDto {
                InstrumentDataPath = _bucketPath
            };

            _sut = new InstrumentDataService(
                _fileServiceMock.Object,
                _nisraServiceMock.Object,
                _storageServiceMock.Object,
                _loggingMock.Object);
        }
        public async Task <IHttpActionResult> PostInstrumentWithDataAsync([FromUri] string serverParkName,
                                                                          [FromUri] string instrumentName, [FromBody] InstrumentDataDto instrumentDataDto)
        {
            var tempPath = _configurationProvider.TempPath;

            try
            {
                _loggingService.LogInfo($"Attempting to import instrument '{instrumentName}' with data on server park '{serverParkName}'");
                await _instrumentDataService.ImportOnlineDataAsync(instrumentDataDto, serverParkName, instrumentName, tempPath);

                return(Created("{Request.RequestUri}", instrumentDataDto));
            }
            finally
            {
                tempPath.CleanUpTempFiles();
                _loggingService.LogInfo($"Removed temporary files and folder '{tempPath}'");
            }
        }