Ejemplo n.º 1
0
        /// <summary>
        /// Validate the Create request e.g that the file has been uploaded and parameters are as expected.
        /// </summary>
        public static void ValidateUpsertImportedFileRequest(FlowFile file, Guid projectUid,
                                                             ImportedFileType importedFileType, DxfUnitsType dxfUnitsType,
                                                             DateTime fileCreatedUtc, DateTime fileUpdatedUtc,
                                                             string importedBy, DateTime?surveyedUtc, Guid?parentUid, double?offset)
        {
            if (file == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ProjectErrorCodesProvider.GetErrorNumberwithOffset(27),
                                                                       ProjectErrorCodesProvider.FirstNameWithOffset(27)));
            }

            if (file.flowFilename.Length > MAX_FILE_NAME_LENGTH || string.IsNullOrEmpty(file.flowFilename) ||
                file.flowFilename.IndexOfAny(Path.GetInvalidPathChars()) > 0)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ProjectErrorCodesProvider.GetErrorNumberwithOffset(28),
                                                                       ProjectErrorCodesProvider.FirstNameWithOffset(28)));
            }

            if (string.IsNullOrEmpty(file.path) || file.path.IndexOfAny(Path.GetInvalidPathChars()) > 0)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ProjectErrorCodesProvider.GetErrorNumberwithOffset(29),
                                                                       ProjectErrorCodesProvider.FirstNameWithOffset(29)));
            }

            ValidateUpsertImportedFileRequest(projectUid, importedFileType, dxfUnitsType, fileCreatedUtc, fileUpdatedUtc, importedBy, surveyedUtc, file.flowFilename, parentUid, offset);
        }
Ejemplo n.º 2
0
        public void DynamicAddwithOffsetTest()
        {
            var projectErrorCodesProvider = new ProjectErrorCodesProvider();

            Assert.Equal(64, projectErrorCodesProvider.DynamicCount);
            Assert.Equal("Missing ProjectUID.", projectErrorCodesProvider.FirstNameWithOffset(5));
            Assert.Equal("LegacyImportedFileId has not been generated.", projectErrorCodesProvider.FirstNameWithOffset(50));
        }
Ejemplo n.º 3
0
 static ImportFileV6ValidationTests()
 {
     projectErrorCodesProvider = new ProjectErrorCodesProvider();
 }