예제 #1
0
        static private void ChangeIndexValuesForSeveralDocumentsAtOnce(string fileCabinetName)
        {
            // File cabinet documents are stored in.
            var fileCabinet = platformClient.GetFileCabinet(fileCabinetName);

            var query = new DialogExpression()
            {
                Operation = DialogExpressionOperation.And,
                Condition = new List <DialogExpressionCondition>()
                {
                    DialogExpressionCondition.Create(fieldName: "DOCTYPE", value: "Test Page"),
                    DialogExpressionCondition.Create(fieldName: "COMPANY", value: "Springfield Nuclear Power Plant")
                }
            };

            var indexValues = new List <DocumentIndexField>
            {
                DocumentIndexField.Create("STATUS", "Changed in batch"),
                DocumentIndexField.Create("DATE", System.DateTime.Now),
            };

            // Check which data the return value contains!
            // It could be useful for your implementation; especially the property ErrorMessage.
            var result = platformClient.ChangeIndexValuesInBatch(fileCabinet, query, indexValues);
        }
예제 #2
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}"));
                        }
                    }
                }
            }
        }
예제 #3
0
        static private Document GetDocumentById(string targetName, bool isDocumentTray, int documentId)
        {
            var query = new DialogExpression()
            {
                Operation = DialogExpressionOperation.And,
                Condition = new List <DialogExpressionCondition>()
                {
                    DialogExpressionCondition.Create(fieldName: "DWDOCID", value: documentId.ToString())
                },
            };

            return(platformClient.GetDocumentsByQuery(targetName, isDocumentTray, query).FirstOrDefault());
        }
예제 #4
0
        public static List <DialogExpressionCondition> GetDialogExpressionConditions(DlgInfos dlgInfos)
        {
            List <DialogExpressionCondition> dialogExpressionConditions = new List <DialogExpressionCondition>();

            foreach (var item in dlgInfos.Values)
            {
                if (item.Item != null && item.ItemElementName.ToLower() == "string")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "decimal")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "int")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "memo")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "date")
                {
                    DateTime dateTime = DateTime.Parse(item.Item.ToString());
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: dateTime.Date.ToString("s", CultureInfo.CreateSpecificCulture("en-US"))));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "datetime")
                {
                    DateTime dateTime = DateTime.Parse(item.Item.ToString());
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: dateTime.ToString("s", CultureInfo.CreateSpecificCulture("en-US"))));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "keywords")
                {
                    var key = JsonConvert.DeserializeObject <DocumentIndexFieldKeywords>(item.Item.ToString());

                    foreach (var keyword in key.Keyword)
                    {
                        dialogExpressionConditions.Add(DialogExpressionCondition.Create(item.FieldName, keyword));
                    }
                }
            }
            return(dialogExpressionConditions);
        }
예제 #5
0
        static private List <Document> GetDocumentsThatMeetSearchCriteriaSpecified(string targetName, bool isDocumentTray)
        {
            var query = new DialogExpression()
            {
                Operation = DialogExpressionOperation.And,
                Condition = new List <DialogExpressionCondition>()
                {
                    DialogExpressionCondition.Create(fieldName: "DWSTOREUSER", value: userName),
                    DialogExpressionCondition.Create(fieldName: "TOTAL_EFFORT", valueFrom: "10", valueTo: "50"),
                    DialogExpressionCondition.Create(fieldName: "KEYWORD", value: "five")
                },
                SortOrder = new List <SortedField>
                {
                    SortedField.Create("DWWBDOCNAME", SortDirection.Desc)
                }
            };

            return(platformClient.GetDocumentsByQuery(targetName, isDocumentTray, query));
        }
예제 #6
0
        static private List <Document> SearchForDocumentsInSeveralFileCabinets(string firstFileCabinetName, string secondFileCabinetName)
        {
            var query = new DialogExpression()
            {
                Operation = DialogExpressionOperation.Or,
                Condition = new List <DialogExpressionCondition>()
                {
                    DialogExpressionCondition.Create(fieldName: "DWSTOREUSER", value: userName)
                },
                SortOrder = new List <SortedField>
                {
                    SortedField.Create("DWWBDOCNAME", SortDirection.Desc)
                },
                AdditionalCabinets = new List <string>()
                {
                    platformClient.GetFileCabinet(secondFileCabinetName).Id
                }
            };

            return(platformClient.GetDocumentsByQuery(firstFileCabinetName, isDocumentTray: false, query: query));
        }
예제 #7
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);
                        }
                    }
                }
            }
        }
예제 #8
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}"));
                }
            }
        }
예제 #9
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);
                            }
                        }
                    }
                }
            }
        }
예제 #10
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}"));
                }
            }
        }
예제 #11
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);
                }
            }
        }
예제 #12
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 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));
                    }
                }
            }
        }
        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 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);
                            }
                        }
                    }
                }
            }
        }
예제 #16
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));
                }
            }
        }
예제 #17
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);
                    }
                }
            }
        }
예제 #18
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);
                    }
                }
            }
        }