/// <summary>
            /// Create a scene from the uploaded files.
            /// </summary>
            /// <returns></returns>
            /// <exception cref="NotSupportedException">Unsupported 3D file format</exception>
            public Scene LoadScene()
            {
                if (SourceFormat == null)
                {
                    throw new NotSupportedException("Unsupported 3D file format");
                }
                var loadOpt = sourceFormat.CreateLoadOptions();

                loadOpt.FileSystem = CreateFileSystem();
                var   id    = statsService.BeforeOpenSession(app, fileNames.Id);
                Scene scene = new Scene();

                scene.Open(fileNames.GetFileName(SourceFile, mainFile), loadOpt);
                statsService.AfterLoadScene(id);
                return(scene);
            }
 private FileFormat DetectFormat(StorageFileNames fileNames, MetaDataT metaData, out int mainFile)
 {
     mainFile = -1;
     if (metaData.InputFilenames == null || metaData.InputFilenames.Length == 0)
     {
         return(null);
     }
     for (int i = 0; i < metaData.InputFilenames.Length; i++)
     {
         var inputFile = fileNames.GetFileName(SourceFile, i);
         using (var fs = FileIO.OpenRead(inputFile))
         {
             var sourceFmt = FileFormat.Detect(fs, metaData.InputFilenames[i]);
             if (sourceFmt != null)
             {
                 mainFile = i;
                 return(sourceFmt);
             }
         }
     }
     return(null);
 }
        /// <summary>
        /// Upload the uploaded files to local disk
        /// </summary>
        /// <param name="fileNames"></param>
        /// <param name="files"></param>
        /// <returns></returns>
        protected MetaDataT SaveUploadedFiles(StorageFileNames fileNames, IFormFileCollection files)
        {
            var fileId         = 0;
            var inputFileNames = new string[files.Count];

            foreach (var file in files)
            {
                if (file.Length > MaximumInputSize)
                {
                    throw new Exception("Uploaded file is too large!");
                }

                inputFileNames[fileId] = Path.GetFileName(file.FileName);
                // Prepare a path in which the result file will be
                // Check directroy already exist or not
                try
                {
                    using (FileStream fs = FileIO.Create(fileNames.GetFileName(SourceFile, fileId)))
                    {
                        file.CopyTo(fs);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Failed to save uploaded file, session id = {0}", fileNames.Id);
                    OperationFailed(e);
                }
                fileId++;
            }
            _logger.LogInformation("Uploaded file to {0}", fileNames.Id);
            var metaData = new MetaDataT()
            {
                InputFilenames = inputFileNames
            };

            SetMetaData(fileNames, metaData);
            return(metaData);
        }