Esempio n. 1
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);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
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}"));
                }
            }
        }
Esempio n. 3
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}"));
                }
            }
        }