コード例 #1
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));
                }
            }
        }
コード例 #2
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);
                    }
                }
            }
        }
コード例 #3
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}"));
                }
            }
        }
コード例 #4
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);
                        }
                    }
                }
            }
        }
コード例 #5
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}"));
                }
            }
        }
コード例 #6
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);
                            }
                        }
                    }
                }
            }
        }
コード例 #7
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));
                    }
                }
            }
        }
コード例 #8
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);
                }
            }
        }
コード例 #9
0
        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));
                    }
                }
            }
        }
コード例 #10
0
        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));
                    }
                }
            }
        }
コード例 #11
0
        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);
                }
            }
        }
コード例 #12
0
        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);
                        }
                    }
                }
            }
        }
コード例 #13
0
        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);
                }
            }
        }
コード例 #14
0
        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);
                            }
                        }
                    }
                }
            }
        }
コード例 #15
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);
                    }
                }
            }
        }