public Stream Convert(Stream file, string fileName, string toFormat)
        {
            UploadFileRequest uploadFileRequest = new UploadFileRequest()
            {
                Path = fileName,
                File = file
            };

            CadCloudApi.UploadFile(uploadFileRequest);

            GetDrawingSaveAsRequest getDrawingSaveAsRequest = new GetDrawingSaveAsRequest()
            {
                Name         = fileName,
                OutputFormat = toFormat
            };

            var convertResult = CadCloudApi.GetDrawingSaveAs(getDrawingSaveAsRequest);

            DeleteFileRequest deleteFileRequest = new DeleteFileRequest()
            {
                Path = fileName
            };

            CadCloudApi.DeleteFile(deleteFileRequest);

            return(convertResult);
        }
        public void GetDrawingSaveAsTest(string formatExtension, bool saveResultToStorage, params string[] additionalExportFormats)
        {
            string name        = null;
            string cloudFolder = CloudTestFolder;
            string storage     = DefaultStorage;
            string outName     = null;

            List <string> formatsToExport = new List <string>(this.BasicExportFormats);

            foreach (string additionalExportFormat in additionalExportFormats)
            {
                if (!formatsToExport.Contains(additionalExportFormat))
                {
                    formatsToExport.Add(additionalExportFormat);
                }
            }

            foreach (var inputFile in InputTestFiles)
            {
                if (inputFile.Name.EndsWith(formatExtension))
                {
                    name = inputFile.Name;
                }
                else
                {
                    continue;
                }

                foreach (string format in formatsToExport)
                {
                    outName = $"{name}.{format}";

                    this.TestRawGetRequest(
                        $"Input drawing: {name}; Output format: {format}",
                        name,
                        outName,
                        saveResultToStorage,
                        delegate(string outPath)
                    {
                        var request = new GetDrawingSaveAsRequest(name, format, cloudFolder, outPath, storage);
                        return(CadApi.GetDrawingSaveAs(request));
                    },
                        cloudFolder,
                        storage);
                }
            }
        }
예제 #3
0
        // Export existing drawing to another format
        private void GetImageSaveAs()
        {
            var    cadApi   = new CadApi(AppKey, AppSid);
            string fileName = "01.026.385.01.0.I SOPORTE ENFRIADOR.dwg";
            // Possible values are jpg, bmp, psd, tiff, gif, png, j2k, wmf and pdf
            string formatToExport = "pdf";
            string destFileName   = "01.026.385.01.0.I SOPORTE ENFRIADOR.pdf";

            // Upload document to Cloud Storage
            uploadFileToCloudStorage(fileName);

            var request        = new GetDrawingSaveAsRequest(fileName, formatToExport, null, null, null);
            var responseStream = cadApi.GetDrawingSaveAs(request);

            // Save the output file to disk
            saveFileToDisk(responseStream, destFileName);
        }