/// <summary>
        /// Retrieves a list of changes between source and target documents
        /// </summary>
        /// <param name="request">Request. <see cref="PostChangesRequest" /></param>
        /// <returns><see cref="List<ChangeInfo>"/></returns>
        public List <ChangeInfo> PostChanges(PostChangesRequest request)
        {
            // verify the required parameter 'comparisonOptions' is set
            if (request.comparisonOptions == null)
            {
                throw new ApiException(400, "Missing required parameter 'comparisonOptions' when calling PostChanges");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetServerUrl() + "/comparison/changes";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            var postBody = SerializationHelper.Serialize(request.comparisonOptions); // http body (model) parameter
            var response = this.apiInvoker.InvokeApi(
                resourcePath,
                "POST",
                postBody,
                null,
                null);

            if (response != null)
            {
                return((List <ChangeInfo>)SerializationHelper.Deserialize(response, typeof(List <ChangeInfo>)));
            }

            return(null);
        }
        public static void Run()
        {
            var apiInstance = new CompareApi(Constants.GetConfig());

            try
            {
                var options = new ComparisonOptions
                {
                    SourceFile = new FileInfo
                    {
                        FilePath = "source_files/word/source.docx"
                    },
                    TargetFiles = new List <FileInfo> {
                        new FileInfo {
                            FilePath = "target_files/word/target.docx"
                        }
                    }
                };

                var request = new PostChangesRequest(options);

                var changes = apiInstance.PostChanges(request);
                Console.WriteLine("Changes count: " + changes.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
Пример #3
0
        public void PostChangesTest()
        {
            PostChangesRequest request = new PostChangesRequest(GetComparisonRequest("source.docx", new List <string> {
                "target.docx"
            }));
            var response = ChangesApi.PostChanges(request);

            Assert.IsInstanceOf <List <ComparisonChange> >(response, "response is List<ComparisonChange>");
        }
        public static void Run()
        {
            var apiInstance = new CompareApi(Constants.GetConfig());

            try
            {
                var options = new ComparisonOptions
                {
                    SourceFile = new FileInfo
                    {
                        FilePath = "source_files/word/source.docx"
                    },
                    TargetFiles = new List <FileInfo> {
                        new FileInfo {
                            FilePath = "target_files/word/target.docx"
                        }
                    },
                    Settings = new Settings
                    {
                        CalculateComponentCoordinates = true
                    }
                };

                var request = new PostChangesRequest(options);

                var changes = apiInstance.PostChanges(request);
                foreach (var change in changes.Take(2))
                {
                    Console.WriteLine("Change Type: {0}, X: {1}, Y: {2}, Text: {3}", change.Type, change.Box.X, change.Box.Y, change.Text);
                }

                Console.WriteLine("...");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
Пример #5
0
        /// <summary>
        /// Returns json result with set of changes between documents
        /// </summary>
        /// <param name="request">Request. <see cref="PostChangesRequest" /></param>
        /// <returns><see cref="List<ComparisonChange>"/></returns>
        public List <ComparisonChange> PostChanges(PostChangesRequest request)
        {
            // create path and map variables
            var resourcePath = this.configuration.GetApiRootUrl() + "/comparison/compareDocuments/changes";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            var postBody = SerializationHelper.Serialize(request.Request); // http body (model) parameter

            try
            {
                var response = this.apiInvoker.InvokeApi(
                    resourcePath,
                    "POST",
                    postBody,
                    null,
                    null);
                if (response != null)
                {
                    return((List <ComparisonChange>)SerializationHelper.Deserialize(response, typeof(List <ComparisonChange>)));
                }

                return(null);
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }

                throw;
            }
        }
        public static void Run()
        {
            var apiInstance = new CompareApi(Common.MyAppSid, Common.MyAppKey);

            try
            {
                var options = new Options()
                {
                    // Set source file
                    SourceFile = new FileInfo()
                    {
                        FilePath    = "Comparisondocs\\source_protected.docx",
                        Password    = "******",
                        StorageName = Common.MyStorage
                    },
                    OutputPath = "Comparisondocs\\result_multi_protected.docx",
                    Settings   = new Settings
                    {
                        GenerateSummaryPage        = true,
                        ShowDeletedContent         = true,
                        StyleChangeDetection       = true,
                        UseFramesForDelInsElements = false,
                        MetaData                       = null,
                        DetailLevel                    = "Low",
                        DiagramMasterSetting           = null,
                        CalculateComponentCoordinates  = false,
                        CloneMetadata                  = "Default",
                        MarkDeletedInsertedContentDeep = false,
                        Password                       = "******",
                        PasswordSaveOption             = "User",
                        DeletedItemsStyle              = new ItemsStyle
                        {
                            BeginSeparatorString = "",
                            EndSeparatorString   = "",
                            FontColor            = "16711680",
                            HighlightColor       = "16711680",
                            Bold          = false,
                            Italic        = false,
                            StrikeThrough = false
                        },
                        InsertedItemsStyle = new ItemsStyle
                        {
                            BeginSeparatorString = "",
                            EndSeparatorString   = "",
                            FontColor            = "255",
                            HighlightColor       = "255",
                            Bold          = false,
                            Italic        = false,
                            StrikeThrough = false
                        },
                        StyleChangedItemsStyle = new ItemsStyle
                        {
                            BeginSeparatorString = "",
                            EndSeparatorString   = "",
                            FontColor            = "65280",
                            HighlightColor       = "65280",
                            Bold          = false,
                            Italic        = false,
                            StrikeThrough = false
                        },
                    },
                };

                // Set target file
                var      targets    = new List <FileInfo>();
                FileInfo targetFile = new FileInfo()
                {
                    FilePath    = "Comparisondocs\\target_protected.docx",
                    Password    = "******",
                    StorageName = Common.MyStorage
                };

                targets.Add(targetFile);
                options.TargetFiles = targets.ToList();

                // Create request object.
                var request = new PostChangesRequest(options);

                // Execute api method.
                var response = apiInstance.PostChanges(request);

                Console.WriteLine("Expected response type is List<ChangeInfo>: " + response.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling Comparison CompareApi: " + e.Message);
            }
        }