internal string createVersionContext(Record record, string barcode, int objectId) { DocumentManagement.DocumentManagementClient docManClient = new DocumentManagement.DocumentManagementClient(); DocumentManagement.OTAuthentication docManOTAuth = new DocumentManagement.OTAuthentication(); docManOTAuth.AuthenticationToken = getAuthToken(); string contextID = null; string comment = Utils.getRecognizedFileDescription("ru_RU"); try { contextID = docManClient.CreateDocumentContext(ref docManOTAuth, objectId, barcode, comment, false, null); } catch (Exception e) { log.Error(e, "Exception in method 'createVersionContext' while trying to create document context for object with parent id = '{0}'", new object[] { objectId }); } finally { if (docManClient != null) { docManClient.Close(); } } return(contextID); }
internal bool updateVersionDescription(String fileName, int objectId) { DocumentManagement.DocumentManagementClient docManClient = new DocumentManagement.DocumentManagementClient(); DocumentManagement.OTAuthentication docManOTAuth = new DocumentManagement.OTAuthentication(); docManOTAuth.AuthenticationToken = getAuthToken(); try { DocumentManagement.MetadataLanguage[] langs = docManClient.GetMetadataLanguages(ref docManOTAuth); string[] langsArray = Utils.getFromMetadataLangArray(langs); DocumentManagement.Version version = docManClient.GetVersion(ref docManOTAuth, objectId, 0); String versionName = version.Filename; if (versionName == Utils.replaceFileExtension(fileName, ".pdf")) { version.Comment = "Содержимое версии получено из сервиса распознавания ABBYY"; } docManClient.UpdateVersion(ref docManOTAuth, version); } catch (Exception e) { log.Error(e, "Exception in method 'updateVersionDescription' while trying to update description for object: {0}", new object[] { objectId }); return(false); } return(true); }
internal string getVersionContext(int objectId) { DocumentManagement.DocumentManagementClient docManClient = new DocumentManagement.DocumentManagementClient(); DocumentManagement.OTAuthentication docManOTAuth = new DocumentManagement.OTAuthentication(); docManOTAuth.AuthenticationToken = getAuthToken(); string contextID = null; try { contextID = docManClient.AddVersionContext(ref docManOTAuth, objectId, null); } catch (Exception e) { log.Error(e, "Exception in method 'getVersionContext' while trying to add version context for object: {0}", new object[] { objectId }); } return(contextID); }
public bool getVersionContent(Record record) { string token = this.getAuthToken(); if (String.IsNullOrEmpty(token)) { return(false); } DocumentManagement.DocumentManagementClient docManClient = new DocumentManagement.DocumentManagementClient(); DocumentManagement.OTAuthentication docManOTAuth = new DocumentManagement.OTAuthentication(); docManOTAuth.AuthenticationToken = token; byte[] content; DocumentManagement.Attachment attachment = null; try { attachment = docManClient.GetVersionContents(ref docManOTAuth, record.objectId, record.versionNum); if (attachment != null) { content = attachment.Contents; record.content = content; record.fileName = attachment.FileName; return(true); } else { //TODO: Add error record to log add counter incrementation into table and getVersionContent method log.Error("Failed to load content for record: " + record.ToString()); incrementIterationsCounter(record, "Failed to load content of record."); } } catch (Exception e) { log.Error(e, "Failed in method getVersionContent while trying to load content for record: " + record.ToString(), null); } return(false); }