public ECM(string pecmLogin, string pecmPassword, string pecmUser, string pecmURL, int pecmCompany, int pecmRootFolder, string pimageDir, Boolean pupload, Boolean pproxy) { this.ecmLogin = pecmLogin; this.ecmPassword = pecmPassword; this.ecmUser = pecmUser; this.ecmURL = pecmURL; this.ecmCompany = pecmCompany; this.ecmRootFolder = pecmRootFolder; this.imageDir = pimageDir; this.upload = pupload; this.proxy = pproxy; docService = new ECMDocService.DocumentServiceService(); if (!ecmURL.EndsWith("/")) { ecmURL += "/"; } docService.Url = ecmURL + "DocumentService"; if (proxy) docService.Proxy = WebRequest.GetSystemWebProxy(); folderService = new ECMFolderService.FolderServiceService(); folderService.Url = ecmURL + "FolderService"; if (proxy) folderService.Proxy = WebRequest.GetSystemWebProxy(); //searchService = new ECMSearchService.SearchDocumentServiceService(); //searchService.Url = ecmURL + "/SearchDocumentService"; //if (proxy) // searchService.Proxy = WebRequest.GetSystemWebProxy(); // Busca o documento (pasta) raiz onde as imagens serão salvas. rootFolder = getECMRootFolder(); // 2013-05-30: Por algum motivo desconhecido, as vezes não acha a pasta raiz. if (rootFolder == null) { LOG.imprimeLog("WARN: Algo saiu errado, nao conseguiu achar a pasta raiz, faz pausa e tenta novamente."); pause(); rootFolder = getECMRootFolder(); if (rootFolder == null) { LOG.imprimeLog("ERRO: Algo saiu errado, nao conseguiu achar a pasta raiz, faz pausa e tenta novamente."); } } }
/** * Cria um novo documento. */ private ECMFolderService.documentDto createECMFolder(string name, int parentId) { ECMFolderService.webServiceMessage[] result = folderService.createSimpleFolder(ecmLogin, ecmPassword, ecmCompany, parentId, ecmUser, name); if (result == null) { throw new Exception("Nao conseguiu criar uma pasta no FLuig [createECMFolder()]"); } ECMFolderService.documentDto folder = new ECMFolderService.documentDto(); folder.companyId = result[0].companyId; folder.documentDescription = result[0].documentDescription; folder.documentId = result[0].documentId; folder.version = result[0].version; return folder; }
/** * Cria um novo folder. */ private ECMFolderService.documentDto createFolder(string name, int parentId) { LOG.imprimeLog(System.DateTime.Now + " ========= createFolder - 1 - Vai criar folder: " + name + " (parent=" + parentId + ")"); ECMFolderService.webServiceMessage[] result = folderService.createSimpleFolder(this.ecmLogin, this.ecmPassword, this.ecmCompany, parentId, this.ecmUser, name); ECMFolderService.documentDto folder = new ECMFolderService.documentDto(); folder.companyId = result[0].companyId; folder.documentDescription = result[0].documentDescription; folder.documentId = result[0].documentId; folder.version = result[0].version; LOG.imprimeLog(System.DateTime.Now + " ========= createFolder - 2 - Criado folder: " + folder.documentId + "=" + folder.documentDescription); return folder; }
private ECMFolderService.documentDto getRootFolder() { if (this._rootFolder != null) { return this._rootFolder; } this._rootFolder = _getRootFolder(); if (this._rootFolder == null) { LOG.imprimeLog("WARN: Algo saiu errado, nao conseguiu achar a pasta raiz, faz pausa e tenta novamente."); pause(); _rootFolder = getRootFolder(); if (_rootFolder == null) { throw new Exception("Nao foi possivel achar a pasta raiz no ECM"); } } return this._rootFolder; }
public void convert() { LOG.imprimeLog(System.DateTime.Now + " ======= convert - 1 - Iniciando a conversao"); ECMFolderService.documentDto[] fdocs = folderService.getFolder(this.ecmLogin, this.ecmPassword, this.ecmCompany, this.ecmRootFolder, this.ecmUser); ECMFolderService.documentDto fromRoot = fdocs[0]; ECMFolderService.documentDto[] folders = folderService.getSubFolders(this.ecmLogin, this.ecmPassword, this.ecmCompany, fromRoot.documentId, this.ecmUser); for (int i = 0; i < folders.Length; i++) { ECMFolderService.documentDto folder = folders[i]; LOG.imprimeLog(System.DateTime.Now + " ======= convert - 2 - " + folder.documentId + "(" + folder.documentDescription + ")"); if (folder.documentDescription.Length > 1) { this._rootFolder = null; this.ecmFolder = folder.documentDescription; ECMFolderService.documentDto root = this.getRootFolder(); LOG.imprimeLog(System.DateTime.Now + " ======= convert - 3 - Nome da pasta destino: " + this.ecmFolder); LOG.imprimeLog(System.DateTime.Now + " ======= convert - 4 - mover de " + folder.documentId + "(" + folder.documentDescription + ") para " + root.documentId + "(" + root.documentDescription + ")"); ECMFolderService.documentDto[] files = folderService.getChildren(this.ecmLogin, this.ecmPassword, this.ecmCompany, folder.documentId, this.ecmUser); int?[] ids = new int?[files.Length]; for (int j = 0; j < files.Length; j++) { ECMFolderService.documentDto file = files[j]; LOG.imprimeLog(System.DateTime.Now + " ======= convert - 5 - preparando para mover arquivo: " + file.documentId + "(" + file.documentDescription + ")"); ids[j] = file.documentId; } if (ids.Length > 0) { LOG.imprimeLog(System.DateTime.Now + " ======= convert - 6 - vai mover: " + ids.Length + " arquivos"); docService.moveDocument(this.ecmLogin, this.ecmPassword, this.ecmCompany, ids, this.ecmUser, root.documentId); LOG.imprimeLog(System.DateTime.Now + " ======= convert - 7 - Pronto!"); } else { LOG.imprimeLog(System.DateTime.Now + " ======= convert - 8 - A pasta esta vazia"); } folderService.deleteDocument(this.ecmLogin, this.ecmPassword, this.ecmCompany, folder.documentId, this.ecmUser); LOG.imprimeLog(System.DateTime.Now + " ======= convert - 9 - Removeu a pasta origem"); } else { LOG.imprimeLog(System.DateTime.Now + " ======= convert - 10 - Ignorando por ser tamanho 1: " + folder.documentId + " - " + folder.documentDescription); } LOG.imprimeLog(System.DateTime.Now + " ========================================="); } }