Exemplo n.º 1
0
        private void RaiseNewConnection()
        {
            var notification = new SaveAsNotification {
                Title = "New Connection"
            };

            SaveAsRequest.Raise(notification,
                                returned =>
            {
                if (returned == null || !returned.Confirmed || returned.SaveAs == null)
                {
                    return;
                }
                SaveAs = returned.SaveAs;
                if (ConnectionsModel.Connections.Contains(SaveAs))
                {
                    RaiseErrorNotification("A connection with the same name already exists.");
                    return;
                }
                ConnectionsModel.Connections.Add(SaveAs);
                ConnectionsModel.DeleteIsEnabled = false;
                ConnectionsModel.SaveIsEnabled   = true;
                ConnectionsModel.NewIsEnabled    = false;
                ConnectionsModel.Visibility      = "Visible";
            });
        }
Exemplo n.º 2
0
        public void TestSaveAsDocx()
        {
            string localName  = "45.pdf";
            string remoteName = "TestSaveAsFromPdfToDoc.pdf";

            this.UploadFileToStorage(
                remoteFolder + "/" + remoteName,
                null,
                null,
                File.ReadAllBytes(LocalTestDataFolder + localFolder + "/" + localName)
                );

            var request = new SaveAsRequest(
                name: remoteName,
                saveOptionsData: new SaveOptionsData()
            {
                SaveFormat = "docx",
                FileName   = BaseTestOutPath + "/TestSaveAsFromPdfToDoc.docx"
            },
                folder: remoteFolder
                );
            var actual = this.WordsApi.SaveAs(request);

            Assert.NotNull(actual.SaveResult);
            Assert.NotNull(actual.SaveResult.DestDocument);
        }
        public void TestReadmeCode()
        {
            var localName     = "test_multi_pages.docx";
            var pathToDocFile = BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName;

            var currenConfig = BaseTestContext.GetConfig();
            var clientSecret = currenConfig.ClientSecret;
            var clientId     = currenConfig.ClientId;
            var baseUrl      = currenConfig.BaseUrl;

            // Start README example
            var config = new Configuration
            {
                ClientId     = clientId,
                ClientSecret = clientSecret,
                ApiBaseUrl   = baseUrl,
            };

            var wordsApi = new WordsApi(config);

            using (var inputStream = new FileStream(pathToDocFile, FileMode.Open))
            {
                var uploadFileRequest = new UploadFileRequest(inputStream, "fileStoredInCloud.doc");
                wordsApi.UploadFile(uploadFileRequest);
            }

            var saveOptionsData = new SaveOptionsData {
                SaveFormat = "pdf", FileName = "destStoredInCloud.pdf"
            };
            var request = new SaveAsRequest("fileStoredInCloud.doc", saveOptionsData);

            wordsApi.SaveAs(request);

            // End README example

            WriteCodeToReadme();
        }