示例#1
0
        private static void ListAllStoreDialogs(Organization organization)
        {
            Console.WriteLine("ListAllStoreDialogs");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromStoresRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfo is null!");
                }
                else
                {
                    Console.WriteLine("Store Dialogs");
                    dialogInfos.Dialog.ForEach(d => Console.WriteLine($"ID: {d.Id} - DisplayName: {d.DisplayName} - Type: {d.Type}"));
                }
            }
        }
示例#2
0
        private static void CreateDocumentApplicationPropertiesWithNewDocument(Organization organization)
        {
            Console.WriteLine("CreateDocumentApplicationPropertiesWithNewDocument");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document metaDocument = new Platform.ServerClient.Document();

                metaDocument.ApplicationProperties = new List <DocumentApplicationProperty>();

                metaDocument.ApplicationProperties.Add(new DocumentApplicationProperty()
                {
                    Name = "key1", Value = "Test"
                });
                metaDocument.ApplicationProperties.Add(new DocumentApplicationProperty()
                {
                    Name = "key2", Value = "Delete"
                });

                Platform.ServerClient.Document document =
                    fileCabinet.EasyUploadDocument(new FileInfo[] { new FileInfo("") }, metaDocument);
            }
        }
示例#3
0
        private static void MergeDocuments(Organization organization)
        {
            Console.WriteLine("MergeDocuments");

            string     fileCabinetId = "00000000-0000-0000-0000-000000000000";
            List <int> documentIds   = new List <int>()
            {
                1, 2
            };

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                ContentMergeOperationInfo contentMergeOperationInfo = new ContentMergeOperationInfo()
                {
                    Documents = documentIds,
                    Operation = ContentMergeOperation.Staple,
                    Force     = true
                };

                Platform.ServerClient.Document mergedDocument = fileCabinet.PutToContentMergeOperationRelationForDocument(contentMergeOperationInfo);
            }
        }
示例#4
0
        private static void TransferFromFileCabinetToFileCabinet(Organization organization)
        {
            Console.WriteLine("TransferFromFileCabinetToFileCabinet");

            string     fileCabinetId = "00000000-0000-0000-0000-000000000000";
            List <int> documentIds   = new List <int>()
            {
                8
            };
            string sourceFileCabinetId = "00000000-0000-0000-0000-000000000000";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                FileCabinetTransferInfo fileCabinetTransferInfo = new FileCabinetTransferInfo()
                {
                    KeepSource          = true,
                    SourceDocId         = documentIds,
                    SourceFileCabinetId = sourceFileCabinetId
                };

                DocumentsQueryResult documentsQueryResult =
                    fileCabinet.PostToTransferRelationForDocumentsQueryResult(fileCabinetTransferInfo);
            }
        }
示例#5
0
        private static void Query(Organization organization)
        {
            Console.WriteLine("Query");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            string dialogId      = "00000000-0000-0000-0000-000000000000";

            DialogExpression dialogExpression = new DialogExpression()
            {
                Operation = DialogExpressionOperation.And,
                Condition = new List <DialogExpressionCondition>()
                {
                    DialogExpressionCondition.Create("NAME", "T*")
                },
                Count     = 100,
                SortOrder = new List <SortedField>()
                {
                    SortedField.Create("NAME", SortDirection.Desc)
                }
            };

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == dialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult = dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        foreach (Document document in documentsQueryResult.Items)
                        {
                            Console.WriteLine($"ID {document.Id}");
                            Console.WriteLine("Fields");
                            document.Fields.ForEach(f => Console.WriteLine($"Name: {f.FieldName} - Item: {f.Item}"));
                        }
                    }
                }
            }
        }
示例#6
0
        private static void UploadDocument(Organization organization)
        {
            Console.WriteLine("UploadDocument");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            string dialogId      = "00000000-0000-0000-0000-000000000000";
            string fileInfoPath  = @"C:\Temp\Test.pdf";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromStoresRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfo is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == dialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        Document metaDocument = new Document()
                        {
                            Title  = "My Test Document",
                            Fields = new List <DocumentIndexField>()
                            {
                                //Create index value => field name, value
                                DocumentIndexField.Create("NAME", "TestUpload")
                            }
                        };

                        dialog.EasyUploadDocument(new FileInfo[] { new FileInfo(fileInfoPath) }, metaDocument);
                    }
                }
            }
        }
示例#7
0
        private static void ListAllDocuments(Organization organization)
        {
            Console.WriteLine("ListAllDocuments");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Console.WriteLine("Documents");
                //Be aware: Only first X documents are returned per default.
                fileCabinet.GetDocumentsQueryResultFromDocumentsRelation().Items.ForEach(d => Console.WriteLine($"ID: {d.Id}"));
            }
        }
示例#8
0
        private static void TransferFromFileCabinetToFileCabinetWithFields(Organization organization)
        {
            Console.WriteLine("TransferFromFileCabinetToFileCabinetWithFields");
            string destinationFileCabinetId = "00000000-0000-0000-0000-000000000000";
            string sourceFileCabinetId      = "00000000-0000-0000-0000-000000000000";
            int    sourceDocId = 6;

            FileCabinet destinationFileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                                 .FirstOrDefault(fc => fc.Id == destinationFileCabinetId);

            if (destinationFileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document sourceDocument = new Platform.ServerClient.Document
                {
                    Id     = sourceDocId,
                    Fields = new List <DocumentIndexField>()
                    {
                        DocumentIndexField.Create("NAME", "TestName"),
                        DocumentIndexField.Create("COLOR", "White/Red")
                    }
                };

                DocumentsTransferInfo documentsTransferInfo = new DocumentsTransferInfo()
                {
                    Documents = new List <Platform.ServerClient.Document>()
                    {
                        sourceDocument
                    },
                    KeepSource          = true,
                    SourceFileCabinetId = sourceFileCabinetId
                };

                DocumentsQueryResult documentsQueryResult =
                    destinationFileCabinet.PostToTransferRelationForDocumentsQueryResult(documentsTransferInfo);
            }
        }
        private static void SetStampOnPageWithBestPosition(Organization organization)
        {
            Console.WriteLine("SetStampOnPageWithBestPosition");

            string  queryDialogId = "00000000-0000-0000-0000-000000000000";
            string  fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int     documentId    = 1;
            string  SectionId     = "1-1";
            string  stampId       = "00000000-0000-0000-0000-000000000000";
            int     layer         = 1; //Layer can be 1 to 5
            DWPoint bestPosition;
            string  itemValue = "December";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    Section section = document.Sections.FirstOrDefault(s => s.Id == SectionId);

                    if (section == null)
                    {
                        Console.WriteLine("Section is null");
                    }
                    else
                    {
                        section = section.GetSectionFromSelfRelation();

                        Page page = section.Pages.GetPagesFromNextBlockRelation().Page.FirstOrDefault();

                        if (page == null)
                        {
                            Console.WriteLine("Page is null!");
                        }
                        else
                        {
                            bestPosition = page.PostToStampBestPositionRelationForDWPoint(new StampFormFieldValues()
                            {
                                StampId = stampId
                            });

                            if (bestPosition == null)
                            {
                                Console.WriteLine("BestPositon is null!");
                            }
                            else
                            {
                                StampPlacement stampPlacement = new StampPlacement()
                                {
                                    StampId  = stampId,
                                    Layer    = layer,
                                    Location = bestPosition,
                                    Field    = new List <FormFieldValue>()
                                    {
                                        new FormFieldValue()
                                        {
                                            Name       = "<#1>",
                                            TypedValue = new DocumentIndexFieldValue()
                                            {
                                                ItemElementName = ItemChoiceType.String,
                                                Item            = itemValue
                                            }
                                        }
                                    }
                                };

                                Annotation annotation = page.PostToStampRelationForAnnotation(stampPlacement);
                            }
                        }
                    }
                }
            }
        }
示例#10
0
        private static void DeleteSectionApplicationProperties(Organization organization)
        {
            Console.WriteLine("DeleteSectionApplicationProperties");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    Platform.ServerClient.Section section = document.Sections.FirstOrDefault();
                    if (section == null)
                    {
                        Console.WriteLine("Section is null!");
                    }
                    else
                    {
                        section = section.GetSectionFromSelfRelation();

                        DocumentApplicationProperties documentApplicationProperties = new DocumentApplicationProperties();
                        documentApplicationProperties.DocumentApplicationProperty = new List <DocumentApplicationProperty>();
                        documentApplicationProperties.DocumentApplicationProperty.Add(new DocumentApplicationProperty()
                        {
                            Name = "key2", Value = null
                        });

                        DocumentApplicationProperties resultDocumentApplicationProperties = section.PostToAppPropertiesRelationForDocumentApplicationProperties(
                            documentApplicationProperties);
                    }
                }
            }
        }
        private static void SetStampOnDocumentWithSpecificPosition(Organization organization)
        {
            Console.WriteLine("SetStampOnDocumentWithSpecificPosition");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;
            string stampId       = "00000000-0000-0000-0000-000000000000";
            int    layer         = 2; //Layer can be 1 to 5
            double locationX     = 100;
            double locationY     = 100;
            string itemValue     = "December";
            int    pageNumber    = 0;
            int    sectionNumber = 0;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = fileCabinet.GetDocumentsQueryResultFromDocumentsRelation()
                                                          .Items
                                                          .FirstOrDefault(d => d.Id == documentId);

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();


                    StampPlacement stampPlacement = new StampPlacement()
                    {
                        StampId  = stampId,
                        Layer    = layer,
                        Location = new DWPoint()
                        {
                            X = locationX,
                            Y = locationY
                        },
                        Field = new List <FormFieldValue>()
                        {
                            new FormFieldValue()
                            {
                                Name       = "<#1>",
                                TypedValue = new DocumentIndexFieldValue()
                                {
                                    ItemElementName = ItemChoiceType.String,
                                    Item            = itemValue
                                }
                            }
                        }
                    };

                    DocumentAnnotationsPlacement documentAnnotationsPlacement = new DocumentAnnotationsPlacement()
                    {
                        Annotations = new List <SectionAnnotationsPlacement>()
                        {
                            new SectionAnnotationsPlacement()
                            {
                                PageNumber           = pageNumber,
                                SectionNumber        = sectionNumber,
                                AnnotationsPlacement = new AnnotationsPlacement()
                                {
                                    Items = new List <object>()
                                    {
                                        stampPlacement
                                    }
                                }
                            }
                        }
                    };

                    DocumentAnnotations documentAnnotations = document.PostToAnnotationRelationForDocumentAnnotations(documentAnnotationsPlacement);
                }
            }
        }
示例#12
0
        private static void EditSection(Organization organization)
        {
            Console.WriteLine("UpdateIndexFields");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    var section = document.Sections.FirstOrDefault();

                    if (section == null)
                    {
                        Console.WriteLine("Section is null!");
                    }
                    else
                    {
                        section = section.GetSectionFromSelfRelation();

                        DeserializedHttpResponse <Stream> deserializedHttpResponse = section.PostToFileDownloadRelationForStreamAsync(new FileDownload()
                        {
                            TargetFileType = FileDownloadType.Auto // FileDownloadType.PDF / FileDownloadType.ZIP
                        }).Result;

                        HttpContentHeaders httpContentHeaders = deserializedHttpResponse.ContentHeaders;

                        string ContentType   = httpContentHeaders.ContentType.MediaType;
                        string DirectoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
                        string FileName      = Path.Combine(DirectoryPath, deserializedHttpResponse.GetFileName());
                        long?  ContentLength = httpContentHeaders.ContentLength;
                        Stream stream        = deserializedHttpResponse.Content;

                        Directory.CreateDirectory(DirectoryPath);

                        using (FileStream fileStream = File.Create(FileName))
                        {
                            if (stream.CanSeek)
                            {
                                stream.Seek(0, SeekOrigin.Begin);
                            }
                            stream.CopyTo(fileStream);
                        }

                        //edit your file here

                        section.EasyReplaceFile(new FileInfo(FileName));

                        Directory.Delete(DirectoryPath, true);
                    }
                }
            }
        }
示例#13
0
        private static void DownloadSection(Organization organization)
        {
            Console.WriteLine("DownloadSection");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    if (document.Sections.Count < 1)
                    {
                        Console.WriteLine("Document has not enough sections!");
                    }
                    else
                    {
                        Section section = document.Sections[1];

                        section = section.GetSectionFromSelfRelation();

                        DeserializedHttpResponse <Stream> deserializedHttpResponse = section.PostToFileDownloadRelationForStreamAsync(new FileDownload()
                        {
                            TargetFileType = FileDownloadType.Auto
                        }).Result;

                        HttpContentHeaders httpContentHeaders = deserializedHttpResponse.ContentHeaders;

                        string ContentType   = httpContentHeaders.ContentType.MediaType;
                        string FileName      = deserializedHttpResponse.GetFileName();
                        long?  ContentLength = httpContentHeaders.ContentLength;
                        Stream stream        = deserializedHttpResponse.Content;

                        using (FileStream fileStream = File.Create(Path.Combine(@"C:\Temp\", FileName)))
                        {
                            if (stream.CanSeek)
                            {
                                stream.Seek(0, SeekOrigin.Begin);
                            }
                            stream.CopyTo(fileStream);
                        }
                    }
                }
            }
        }
示例#14
0
        private static void UploadSection(Organization organization)
        {
            Console.WriteLine("UploadSection");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;
            string fileInfoPath  = @"C:\Temp\TestChange.json";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document.EasyUploadFile(new FileInfo(fileInfoPath));
                }
            }
        }
示例#15
0
        private static void UpdateIndexFieldsWithTableField(Organization organization)
        {
            Console.WriteLine("UpdateIndexFieldsWithTableField");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;

            string  tableFieldName              = "ANCESTRY";
            string  tableFieldSearchColumnName  = "FIELD_NAME";
            string  tableFieldSearchColumnValue = "";
            string  tableFieldChangeColumnName  = "ANCES_WEIGHT";
            decimal tableFieldChangeColumnValue = 4.5m;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    DocumentIndexField tableDocumentIndexField =
                        document.Fields.FirstOrDefault(f =>
                                                       f.FieldName == tableFieldName && f.ItemElementName == ItemChoiceType.Table);

                    if (tableDocumentIndexField == null)
                    {
                        Console.WriteLine("TableDocumentIndexField is null!");
                    }
                    else
                    {
                        DocumentIndexFieldTable existingDocumentIndexFieldTable = tableDocumentIndexField.Item as DocumentIndexFieldTable;

                        if (existingDocumentIndexFieldTable == null)
                        {
                            Console.WriteLine("ExistingDocumentIndexFieldTable is null!");
                        }
                        else if (existingDocumentIndexFieldTable.Row.Count < 1)
                        {
                            Console.WriteLine("ExistingDocumentIndexFieldTable Row count is 0.");
                        }
                        else
                        {
                            DocumentIndexFieldTableRow documentIndexFieldTableRow =
                                existingDocumentIndexFieldTable.Row.FirstOrDefault(r =>
                                                                                   r.ColumnValue.Exists(c => c.FieldName == tableFieldSearchColumnName && (string)c.Item == tableFieldSearchColumnValue));

                            DocumentIndexField columnDocumentIndexField =
                                documentIndexFieldTableRow?.ColumnValue.FirstOrDefault(c => c.FieldName == tableFieldChangeColumnName);

                            if (columnDocumentIndexField == null)
                            {
                                Console.WriteLine("ColumnDocumentIndexField is null!");
                            }
                            else
                            {
                                columnDocumentIndexField.Item = tableFieldChangeColumnValue;

                                DocumentIndexFields updatedTableIndexFields = new DocumentIndexFields()
                                {
                                    Field = new List <DocumentIndexField>()
                                    {
                                        tableDocumentIndexField
                                    }
                                };

                                DocumentIndexFields documentIndexField =
                                    document.PutToFieldsRelationForDocumentIndexFields(updatedTableIndexFields);
                            }
                        }
                    }
                }
            }
        }
示例#16
0
        private static void UpdateAllIndexFields(Organization organization)
        {
            Console.WriteLine("UpdateIndexFields");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    DocumentIndexFields fields = document.GetDocumentIndexFieldsFromFieldsRelation();
                    fileCabinet = fileCabinet.GetFileCabinetFromSelfRelation();
                    List <FileCabinetField> fileCabinetFields = fileCabinet.Fields;
                    fields.Field.ForEach(f =>
                    {
                        // Set correct field type
                        f.ItemElementName = GetCorrectItemChoiceTypeFromFileCabinetFields(f, fileCabinetFields);
                        // Change Value
                        if (f.FieldName == "NAME")
                        {
                            f.Item = "Change all test";
                        }
                    });

                    DocumentIndexFields result =
                        document.PutToFieldsRelationForDocumentIndexFields(fields);

                    Console.WriteLine($"Results");
                    result.Field.ForEach(f => Console.WriteLine($"FiledName: {f.FieldName} - Item: {f.Item}"));
                }
            }
        }
示例#17
0
        private static void DivideDocuments(Organization organization)
        {
            Console.WriteLine("DivideDocuments");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    ContentDivideOperationInfo contentDivideOperationInfo = new ContentDivideOperationInfo()
                    {
                        Operation = ContentDivideOperation.Unstaple,
                        Force     = true
                    };

                    DocumentsQueryResult dividedDocuments = document.PutToContentDivideOperationRelationForDocumentsQueryResult(contentDivideOperationInfo);
                }
            }
        }
示例#18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="organization"></param>
        private static void UpdateIndexFields(Organization organization)
        {
            Console.WriteLine("UpdateIndexFields");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    DocumentIndexFields documentIndexFields = new DocumentIndexFields()
                    {
                        Field = new List <DocumentIndexField>()
                        {
                            DocumentIndexField.Create("NAME", "TestChange"),
                            DocumentIndexField.CreateDate("DATE_OF_BIRTH", DateTime.Now)
                        }
                    };

                    DocumentIndexFields result =
                        document.PutToFieldsRelationForDocumentIndexFields(documentIndexFields);

                    Console.WriteLine($"Results");
                    result.Field.ForEach(f => Console.WriteLine($"FiledName: {f.FieldName} - Item: {f.Item}"));
                }
            }
        }
示例#19
0
        private static async Task LockDocument(Organization organization)
        {
            string clientIdentifier = "SampleDocumentLockApplication";

            //DocumentLock
            Console.WriteLine("LockDocument");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;
            string fileInfoPath  = @"C:\Temp\TestChange.json";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    DocumentLock documentLock = await document.LockAsync((exception) =>
                    {
                        Console.WriteLine(exception.Message);
                    }, clientIdentifier, 60);

                    using (documentLock)
                    {
                        await document.EasyUploadFileAsync(new FileInfo(fileInfoPath));
                    }
                }
            }
        }
        private static void SetAnnotationOnPage(Organization organization)
        {
            Console.WriteLine("SetAnnotationOnPage");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 1;
            string SectionId     = "1-1";
            int    layer         = 1; //Layer can be 1 to 5

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = fileCabinet.GetDocumentsQueryResultFromDocumentsRelation()
                                                          .Items
                                                          .FirstOrDefault(d => d.Id == documentId);

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    var section = document.Sections.FirstOrDefault(s => s.Id == SectionId);

                    if (section == null)
                    {
                        Console.WriteLine("Section is null");
                    }
                    else
                    {
                        section = section.GetSectionFromSelfRelation();

                        var page = section.Pages.GetPagesFromNextBlockRelation().Page.FirstOrDefault();

                        if (page == null)
                        {
                            Console.WriteLine("Page is null!");
                        }
                        else
                        {
                            var annotations = new Annotation()
                            {
                                Layer = new List <Layer>()
                                {
                                    new Layer()
                                    {
                                        Id    = layer,
                                        Items = new List <EntryBase>()
                                        {
                                            new TextEntry()
                                            {
                                                Location = new AnnotationRectangle()
                                                {
                                                    Left   = 100,
                                                    Top    = 100,
                                                    Width  = 200,
                                                    Height = 200
                                                },
                                                Value = "Test text",
                                                Font  = new Font()
                                                {
                                                    FontSize = 10 * 20,
                                                    FontName = "Arial"
                                                }
                                            },
                                            new RectEntry()
                                            {
                                                Location = new AnnotationRectangle()
                                                {
                                                    Left   = 300,
                                                    Top    = 300,
                                                    Width  = 200,
                                                    Height = 200
                                                },
                                                Filled  = true,
                                                Ellipse = true
                                            },
                                            new LineEntry()
                                            {
                                                From = new AnnotationPoint()
                                                {
                                                    X = 500, Y = 500
                                                },
                                                To = new AnnotationPoint()
                                                {
                                                    X = 800, Y = 800
                                                },
                                                Arrow = true,
                                            }
                                        }
                                    }
                                }
                            };

                            Annotation annotation = page.PostToAnnotationRelationForAnnotation(annotations);
                        }
                    }
                }
            }
        }
        private static void SetAnnotationOnDocument(Organization organization)
        {
            Console.WriteLine("SetAnnotationOnDocument");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            int    documentId    = 4;
            int    pageNumber    = 0;
            int    sectionNumber = 0;
            int    layer         = 1; //Layer can be 1 to 5

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = fileCabinet.GetDocumentsQueryResultFromDocumentsRelation()
                                                          .Items
                                                          .FirstOrDefault(d => d.Id == documentId);

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    document = document.GetDocumentFromSelfRelation();

                    Annotation annotation = new Annotation()
                    {
                        Layer = new List <Layer>()
                        {
                            new Layer()
                            {
                                Id    = layer,
                                Items = new List <EntryBase>()
                                {
                                    new TextEntry()
                                    {
                                        Location = new AnnotationRectangle()
                                        {
                                            Left   = 100,
                                            Top    = 100,
                                            Width  = 200,
                                            Height = 200
                                        },
                                        Value = "Test text",
                                        Font  = new Font()
                                        {
                                            FontSize = 10 * 20,
                                            FontName = "Arial"
                                        }
                                    },
                                    new RectEntry()
                                    {
                                        Location = new AnnotationRectangle()
                                        {
                                            Left   = 300,
                                            Top    = 300,
                                            Width  = 200,
                                            Height = 200
                                        },
                                        Filled  = true,
                                        Ellipse = true
                                    },
                                    new LineEntry()
                                    {
                                        From = new AnnotationPoint()
                                        {
                                            X = 500, Y = 500
                                        },
                                        To = new AnnotationPoint()
                                        {
                                            X = 800, Y = 800
                                        },
                                        Arrow = true,
                                    }
                                }
                            }
                        }
                    };

                    DocumentAnnotationsPlacement documentAnnotationsPlacement = new DocumentAnnotationsPlacement()
                    {
                        Annotations = new List <SectionAnnotationsPlacement>()
                        {
                            new SectionAnnotationsPlacement()
                            {
                                PageNumber           = pageNumber,
                                SectionNumber        = sectionNumber,
                                AnnotationsPlacement = new AnnotationsPlacement()
                                {
                                    Items = new List <object>()
                                    {
                                        annotation
                                    }
                                }
                            }
                        }
                    };

                    DocumentAnnotations documentAnnotations = document.PostToAnnotationRelationForDocumentAnnotations(documentAnnotationsPlacement);
                }
            }
        }
        private static void ReplaceAllSectionsInDocument(Organization organization)
        {
            Console.WriteLine("ReplaceAllSectionsInDocument");

            string queryDialogId = "00000000-0000-0000-0000-000000000000";

            List <string> newSectionsPath = new List <string> {
                @"C:\Temp\File1.pdf", @"C:\Temp\File2.pdf"
            };
            int documentId = 1;

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault();

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    //Delete all sections
                    document.Sections.ForEach(s => s.DeleteSelfRelation());

                    //Upload new sections
                    foreach (var newSectionPath in newSectionsPath)
                    {
                        document.EasyUploadFile(new FileInfo(newSectionPath));
                    }
                }
            }
        }
        private static void ReplaceSpecificSectionInDocument(Organization organization)
        {
            Console.WriteLine("ReplaceSpecificSectionInDocument");

            string queryDialogId  = "00000000-0000-0000-0000-000000000000";
            string fileCabinetId  = "00000000-0000-0000-0000-000000000000";
            int    documentId     = 1;
            string sectionId      = "1-1";
            string newSectionPath = @"C:\Temp\Test.pdf";

            FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
                                      .FirstOrDefault(fc => fc.Id == fileCabinetId);

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Platform.ServerClient.Document document = null;

                DialogExpression dialogExpression = new DialogExpression()
                {
                    Operation = DialogExpressionOperation.And,
                    Condition = new List <DialogExpressionCondition>()
                    {
                        DialogExpressionCondition.Create("DWDOCID", documentId.ToString())
                    },
                    Count     = 100,
                    SortOrder = new List <SortedField>()
                    {
                        SortedField.Create("DWDOCID", SortDirection.Desc)
                    }
                };

                DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation();

                if (dialogInfos == null)
                {
                    Console.WriteLine("DialogInfos is null!");
                }
                else
                {
                    DialogInfo dialog = dialogInfos.Dialog.FirstOrDefault(d => d.Id == queryDialogId);

                    if (dialog == null)
                    {
                        Console.WriteLine("Dialog is null!");
                    }
                    else
                    {
                        DocumentsQueryResult documentsQueryResult =
                            dialog.GetDialogFromSelfRelation().GetDocumentsResult(dialogExpression);

                        Console.WriteLine("Query Result");
                        document = documentsQueryResult.Items.FirstOrDefault();

                        document = document?.GetDocumentFromSelfRelation();
                    }
                }

                if (document == null)
                {
                    Console.WriteLine("Document is null!");
                }
                else
                {
                    //Get specific section(don't forget the self relation) and replace it
                    Section section = document.Sections.FirstOrDefault(s => s.Id == sectionId)?.GetSectionFromSelfRelation();

                    if (section == null)
                    {
                        Console.WriteLine("Section is null!");
                    }
                    else
                    {
                        section.EasyReplaceFile(new FileInfo(newSectionPath));
                    }
                }
            }
        }