private static void ListAllDialogs(Organization organization) { Console.WriteLine("ListAllDialogs"); string fileCabinetId = "00000000-0000-0000-0000-000000000000"; FileCabinet fileCabinet = organization.GetFileCabinetsFromFilecabinetsRelation().FileCabinet .FirstOrDefault(fc => fc.Id == fileCabinetId); if (fileCabinet == null) { Console.WriteLine("FileCabinet is null!"); } else { DialogInfos dialogInfos = fileCabinet.GetDialogInfosFromDialogsRelation(); if (dialogInfos == null) { Console.WriteLine("DialogInfo is null!"); } else { Console.WriteLine("Dialogs"); dialogInfos.Dialog.ForEach(d => Console.WriteLine($"ID: {d.Id} - DisplayName: {d.DisplayName} - Type: {d.Type}")); } } }
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}")); } } } } }
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); } } } }
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)); } } }
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); } } } } }
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}")); } } }
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); } } } } } }
/// <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}")); } } }
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); } } }
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); } } } } } }
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); } } } }