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

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

                var changes = apiInstance.PostChanges(new PostChangesRequest(options));

                foreach (var change in changes)
                {
                    change.ComparisonAction = ChangeInfo.ComparisonActionEnum.Reject;
                }

                changes[0].ComparisonAction = ChangeInfo.ComparisonActionEnum.Accept;

                options.Changes = changes;

                var response = apiInstance.PutChangesDocument(new PutChangesDocumentRequest(options));

                Console.WriteLine("Output file link: " + response.Href);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
        public static void Run()
        {
            var apiInstance = new CompareApi(Common.MyAppSid, Common.MyAppKey);

            try
            {
                var options = new UpdatesOptions()
                {
                    // Set source file
                    SourceFile = new FileInfo()
                    {
                        FilePath    = "Comparisondocs\\source_protected.docx",
                        Password    = "******",
                        StorageName = Common.MyStorage
                    },
                    OutputPath = "Comparisondocs\\result_single_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();

                // Accept or reject changes.
                var changes = new List <ChangeInfo>
                {
                    new ChangeInfo {
                        Id = 0, ComparisonAction = "Accept"
                    },
                    new ChangeInfo {
                        Id = 1, ComparisonAction = "Reject"
                    }
                };
                options.Changes = changes.ToList();

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

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

                Console.WriteLine("Expected response type is Link: " + response.Href);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling Comparison CompareApi: " + e.Message);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PutChangesDocumentRequest"/> class.
 /// </summary>
 /// <param name="updatesOptions">Comparison options</param>
 public PutChangesDocumentRequest(UpdatesOptions updatesOptions)
 {
     this.updatesOptions = updatesOptions;
 }
예제 #4
0
        protected UpdatesOptions GetComparisonOptionsUpdates(TestFile sourceFile, List <TestFile> targetFiles)
        {
            var options = new UpdatesOptions
            {
                SourceFile = sourceFile.ToFileInfo(),
                OutputPath = "/resultFilePath/" + sourceFile.FileName,
                Settings   = new Settings
                {
                    GenerateSummaryPage        = true,
                    ShowDeletedContent         = true,
                    StyleChangeDetection       = true,
                    UseFramesForDelInsElements = false,
                    MetaData                      = null,
                    DetailsLevel                  = Settings.DetailsLevelEnum.Low,
                    DiagramMasterSetting          = null,
                    CalculateComponentCoordinates = false,
                    CloneMetadata                 = Settings.CloneMetadataEnum.Default,
                    Password                      = "******",
                    PasswordSaveOption            = Settings.PasswordSaveOptionEnum.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
                    },
                    ChangedItemsStyle = new ItemsStyle
                    {
                        BeginSeparatorString = "",
                        EndSeparatorString   = "",
                        FontColor            = "65280",
                        HighlightColor       = "65280",
                        Bold          = false,
                        Italic        = false,
                        StrikeThrough = false
                    },
                },
            };

            var targets = new List <FileInfo>();

            foreach (var targetFile in targetFiles)
            {
                targets.Add(targetFile.ToFileInfo());
            }
            options.TargetFiles = targets.ToList();


            var changes = new List <ChangeInfo>
            {
                new ChangeInfo {
                    Id = 0, ComparisonAction = ChangeInfo.ComparisonActionEnum.Accept
                },
                new ChangeInfo {
                    Id = 1, ComparisonAction = ChangeInfo.ComparisonActionEnum.Reject
                }
            };

            options.Changes = changes.ToList();

            return(options);
        }