Ejemplo n.º 1
0
        /// <summary> Moves the document from file cabinet to document tray. </summary>
        /// <remarks>
        /// This implementation does not preserve index values when moving the document.
        ///
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Document to be moved. </param>
        /// <param name="fileCabinet"> File cabinet where document is currently located. </param>
        /// <param name="documentTray"> Document tray document has to be moved into. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult MoveDocumentFromFileCabinetToBasketAndDropIndexValues(Document document, FileCabinet fileCabinet, FileCabinet documentTray)
        {
            var sourceDocument = new Document
            {
                Id = document.Id,
                // Needed in order to preserve document name.
                // (other index values will get lost)
                Fields = new List <DocumentIndexField> {
                    DocumentIndexField.Create("DWWBDOCNAME", document.Title)
                }
            };

            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List <Document>()
                {
                    sourceDocument
                },
                KeepSource          = false, // the document will be moved, NOT copied
                SourceFileCabinetId = fileCabinet.Id
            };

            // All index values that were set in file cabinet will get lost here!
            return(documentTray.PostToTransferRelationForDocumentsQueryResult(transferInfo));
        }
Ejemplo n.º 2
0
        private static void UploadDocument(Organization organization)
        {
            Console.WriteLine("UploadDocument");

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

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

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                Document metaDocument = new Document()
                {
                    Fields = new List <DocumentIndexField>()
                    {
                        //Create index value => field name, value
                        DocumentIndexField.Create("NAME", "TestUploadChange")
                    }
                };

                fileCabinet.EasyUploadDocument(new FileInfo[] { new FileInfo(fileInfoPath), },
                                               metaDocument);
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        static private void ChangeIndexValuesForSingleDocument(Document document)
        {
            var indexValues = new List <DocumentIndexField>
            {
                DocumentIndexField.Create("DOCTYPE", "Example"),
                DocumentIndexField.Create("DATE", System.DateTime.Now),
                DocumentIndexField.Create("STATUS", "Changed")
            };

            var result = platformClient.ChangeIndexValues(document, indexValues);
        }
Ejemplo n.º 5
0
        private static void UploadDocument(Organization organization)
        {
            Console.WriteLine("UploadDocument");

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

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

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

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

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

                        dialog.EasyUploadDocument(new FileInfo[] { new FileInfo(fileInfoPath) }, metaDocument);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 static private void StoreDocumentLocatedInDocumentTrayIntoFileCabinet(string documentTrayName, string fileCabinetName, int documentId)
 {
     var document     = GetDocumentById(documentTrayName, true, documentId);
     var documentTray = platformClient.GetDocumentTray(documentTrayName);
     var fileCabinet  = platformClient.GetFileCabinet(fileCabinetName);
     var indexValues  = new List <DocumentIndexField>
     {
         DocumentIndexField.Create("COMPANY", "Springfield Nuclear Power Plant"),
         DocumentIndexField.Create("CONTACT", "Homer"),
         DocumentIndexField.Create("SUBJECT", "Workshop"),
         DocumentIndexField.Create("DOCTYPE", "Example"),
         DocumentIndexField.Create("DATE", System.DateTime.Now),
         DocumentIndexField.Create("STATUS", "Done")
     };
     var queryResult = platformClient.StoreDocumentFromBasketToFileCabinet(document, documentTray, fileCabinet, indexValues);
 }
Ejemplo n.º 7
0
        private static ItemChoiceType GetCorrectItemChoiceTypeFromFileCabinetFields(DocumentIndexField field, List <FileCabinetField> fileCabinetFields)
        {
            FileCabinetField fileCabinetField = fileCabinetFields.FirstOrDefault(f => f.DBFieldName == field.FieldName);

            //Do nothing in case of field is not a null value
            if (field.IsNull == false)
            {
                return(field.ItemElementName);
            }

            // Change nothing by default because of fields who aren't in the FileCabinetFields
            switch (fileCabinetField?.DWFieldType)
            {
            case DWFieldType.Date:
                return(ItemChoiceType.Date);

            case DWFieldType.DateTime:
                return(ItemChoiceType.DateTime);

            case DWFieldType.Decimal:
                return(ItemChoiceType.Decimal);

            case DWFieldType.Keyword:
                return(ItemChoiceType.Keywords);

            case DWFieldType.Memo:
                return(ItemChoiceType.Memo);

            case DWFieldType.Numeric:
                return(ItemChoiceType.Int);

            case DWFieldType.Table:
                return(ItemChoiceType.Table);

            case DWFieldType.Text:
                return(ItemChoiceType.String);

            default:
                return(field.ItemElementName);
            }
        }
Ejemplo n.º 8
0
        private static void TransferFromFileCabinetToFileCabinetWithFields(Organization organization)
        {
            Console.WriteLine("TransferFromFileCabinetToFileCabinetWithFields");
            string destinationFileCabinetId = "00000000-0000-0000-0000-000000000000";
            string sourceFileCabinetId      = "00000000-0000-0000-0000-000000000000";
            int    sourceDocId = 6;

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

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

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

                DocumentsQueryResult documentsQueryResult =
                    destinationFileCabinet.PostToTransferRelationForDocumentsQueryResult(documentsTransferInfo);
            }
        }
Ejemplo n.º 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);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 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}"));
                }
            }
        }
Ejemplo n.º 11
0
        private static void UploadDocumentWithTableField(Organization organization)
        {
            Console.WriteLine("UploadDocumentWithTableField");

            string fileCabinetId = "00000000-0000-0000-0000-000000000000";
            string fileInfoPath  = @"C:\Temp\cat.jpg";

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

            if (fileCabinet == null)
            {
                Console.WriteLine("FileCabinet is null!");
            }
            else
            {
                fileCabinet = fileCabinet.GetFileCabinetFromSelfRelation();
                List <FileCabinetField> fields = fileCabinet.Fields;

                foreach (var tableField in fields.Where(f => f.DWFieldType == DWFieldType.Table))
                {
                    List <FileCabinetFieldBase> tableFieldColumns = tableField.TableFieldColumns;

                    foreach (var tableFieldColumn in tableFieldColumns)
                    {
                        var Label       = tableFieldColumn.DisplayName;
                        var DBFieldName = tableFieldColumn.DBFieldName;
                    }
                }

                DocumentIndexField tableDocumentIndexField = new DocumentIndexField()
                {
                    FieldName       = "ANCESTRY",
                    ItemElementName = ItemChoiceType.Table,
                    Item            = new DocumentIndexFieldTable()
                    {
                        Row = new List <DocumentIndexFieldTableRow>
                        {
                            new DocumentIndexFieldTableRow()
                            {
                                ColumnValue = new List <DocumentIndexField>()
                                {
                                    DocumentIndexField.Create("FIELD_NAME", "Mupil"),
                                    DocumentIndexField.Create("ANCES_RELATION", "Father"),
                                    DocumentIndexField.CreateDate("ANCES_BIRTHDAY", DateTime.Now.AddYears(-7)),
                                    DocumentIndexField.Create("ANCES_WEIGHT", 5)
                                }
                            },
                            new DocumentIndexFieldTableRow()
                            {
                                ColumnValue = new List <DocumentIndexField>()
                                {
                                    DocumentIndexField.Create("FIELD_NAME", "Fala"),
                                    DocumentIndexField.Create("ANCES_RELATION", "Mother"),
                                    DocumentIndexField.CreateDate("ANCES_BIRTHDAY", DateTime.Now.AddYears(-6)),
                                    DocumentIndexField.Create("ANCES_WEIGHT", 4.3m)
                                }
                            }
                        }
                    }
                };

                Document metaDocument = new Document()
                {
                    Fields = new List <DocumentIndexField>()
                    {
                        //Create index value => field name, value
                        DocumentIndexField.Create("NAME", "TestUpload with table field"),
                        tableDocumentIndexField
                    }
                };

                fileCabinet.EasyUploadDocument(new FileInfo[] { new FileInfo(fileInfoPath), },
                                               metaDocument);
            }
        }