Beispiel #1
0
        public async Task UpdateZoomLevelsInDatabase(object parameters)
        {
            RasterTileNotificationParameters result;

            try
            {
                result = JObject.FromObject(parameters).ToObject <RasterTileNotificationParameters>();
            }
            catch (Exception e)
            {
                log.LogError(e, "Bad parameters passed to generated DXF tiles notification");

                /*
                 * throw new ServiceException(HttpStatusCode.InternalServerError,
                 * new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                 *  "Wrong parameters passed to generated DXF tiles notification"));
                 */
                return;
            }

            log.LogInformation($"Received {ProjectFileRasterTilesGeneratedNotification.PROJECT_FILE_RASTER_TILES_GENERATED_KEY} notification: {JsonConvert.SerializeObject(result)}");

            var existing = await projectRepo.GetImportedFile(result.FileUid.ToString());

            //Check file is still there, user may have deleted it in the meanwhile
            if (existing != null)
            {
                await ImportedFileRequestDatabaseHelper.UpdateImportedFileInDb(
                    existing, existing.FileDescriptor, existing.SurveyedUtc, result.MinZoomLevel, result.MaxZoomLevel,
                    existing.FileCreatedUtc, existing.FileUpdatedUtc, existing.ImportedBy, log, serviceExceptionHandler, projectRepo);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Processes the Upsert
        /// </summary>
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            var importedFile = CastRequestObjectTo <UpdateImportedFile>(item, errorCode: 68);

            var existingImportedFile = await projectRepo.GetImportedFile(importedFile.ImportedFileUid.ToString());

            if (existingImportedFile == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ProjectErrorCodesProvider.GetErrorNumberwithOffset(122),
                                                                       ProjectErrorCodesProvider.FirstNameWithOffset(122)));
            }

            if (importedFile.IsTRexDesignFileType)
            {
                await ImportedFileRequestHelper.NotifyTRexUpdateFile(importedFile.ProjectUid,
                                                                     importedFile.ImportedFileType, importedFile.FileDescriptor.FileName, importedFile.ImportedFileUid,
                                                                     importedFile.SurveyedUtc,
                                                                     log, customHeaders, serviceExceptionHandler,
                                                                     tRexImportFileProxy);
            }

            if (importedFile.ImportedFileType == ImportedFileType.Linework ||
                importedFile.ImportedFileType == ImportedFileType.GeoTiff)
            {
                string dcFileName = null;
                if (importedFile.ImportedFileType == ImportedFileType.Linework)
                {
                    var project = await ProjectRequestHelper.GetProject(importedFile.ProjectUid, new Guid(customerUid), new Guid(userId), log, serviceExceptionHandler, cwsProjectClient, customHeaders);

                    dcFileName = DataOceanFileUtil.DataOceanFileName(project.CoordinateSystemFileName, false, importedFile.ProjectUid, null);
                }

                var jobRequest = TileGenerationRequestHelper.CreateRequest(
                    importedFile.ImportedFileType,
                    customerUid,
                    importedFile.ProjectUid.ToString(),
                    existingImportedFile.ImportedFileUid,
                    importedFile.DataOceanRootFolder,
                    importedFile.DataOceanFileName,
                    dcFileName,
                    importedFile.DxfUnitsTypeId,
                    importedFile.SurveyedUtc);
                await schedulerProxy.ScheduleVSSJob(jobRequest, customHeaders);
            }

            // if all succeeds, update Db and  put update to kafka que
            var updateImportedFileEvent = await ImportedFileRequestDatabaseHelper.UpdateImportedFileInDb(existingImportedFile,
                                                                                                         existingImportedFile.FileDescriptor,
                                                                                                         importedFile.SurveyedUtc, existingImportedFile.MinZoomLevel, existingImportedFile.MaxZoomLevel,
                                                                                                         importedFile.FileCreatedUtc, importedFile.FileUpdatedUtc, userEmailAddress,
                                                                                                         log, serviceExceptionHandler, projectRepo);

            var fileDescriptor = new ImportedFileDescriptorSingleResult(
                (await ImportedFileRequestDatabaseHelper.GetImportedFileList(importedFile.ProjectUid.ToString(), log, userId, projectRepo))
                .ToImmutableList()
                .FirstOrDefault(f => f.ImportedFileUid == importedFile.ImportedFileUid.ToString())
                );

            log.LogInformation(
                $"UpdateImportedFileExecutor. entry {(fileDescriptor.ImportedFileDescriptor == null ? "not " : "")}retrieved from DB : {JsonConvert.SerializeObject(fileDescriptor)}");

            return(fileDescriptor);
        }