//more efficient than using TryUnlockFile for checking in multiple files. private static FileCheckInResult UnlockFiles(IEdmVault5 vault, string[] filePaths) { try { IEdmVault7 vault7 = vault as IEdmVault7; IEdmBatchUnlock batchUnlocker = (IEdmBatchUnlock)vault7.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); EdmSelItem[] selItems = new EdmSelItem[filePaths.Length]; for (int i = 0; i < filePaths.Length; ++i) { IEdmFile5 edmFile; IEdmFolder5 edmFolder; if (!GetFileFromPath(vault, filePaths[i], out edmFile, out edmFolder)) { return(FileCheckInResult.UNKNOWN_ERROR); } selItems[i].mlDocID = edmFile.ID; selItems[i].mlProjID = edmFolder.ID; } batchUnlocker.AddSelection(vault as EdmVault5, ref selItems); //这里必然有异常o(╥﹏╥)o batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); batchUnlocker.UnlockFiles(0); return(FileCheckInResult.OK); } catch (Exception ex) { return(FileCheckInResult.UNKNOWN_ERROR); } }
public static void UnLock(IEdmVault7 vault, List <Files.Info> files) { Logger.Add($"Начало регистрации {files?.Count} файлов."); try { ppoSelection = new EdmSelItem[files.Count]; batchUnlocker = (IEdmBatchUnlock)vault.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); var i = 0; foreach (var file in files) { try { var filePath = file.FolderPath + "\\" + file.ConvertFile; fileNameErr = filePath; IEdmFolder5 folder = default(IEdmFolder5); aFile = vault.GetFileFromPath(filePath, out folder); aPos = aFile.GetFirstFolderPosition(); aFolder = aFile.GetNextFolder(aPos); ppoSelection[i] = new EdmSelItem(); ppoSelection[i].mlDocID = aFile.ID; ppoSelection[i].mlProjID = aFolder.ID; i = i + 1; } catch (Exception ex) { Logger.Add($"Ошибка при добавлении файла на регистрацию: {ex.Message} Path: {file.FullFilePath} IdPDM: {file.IdPDM} FolderID: {file.FolderID} Version: {file.CurrentVersion}"); } } // Add selections to the batch of files to check in batchUnlocker.AddSelection((EdmVault5)vault, ppoSelection); if ((batchUnlocker != null)) { batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed); batchUnlocker.UnlockFiles(0, null); } } catch (COMException ex) { Logger.Add("ERROR BatchUnLock файл: '" + fileNameErr + "', " + ex.StackTrace + " " + ex.Message); } catch (Exception ex) { Logger.Add("ERROR BatchUnLock: '" + fileNameErr + "', " + ex.StackTrace + " " + ex.Message); } Logger.Add($"Завершена регистрации {files?.Count} файлов."); }
public void BatchUnLock(List<TaskParam> listType) { ppoSelection = new EdmSelItem[listType.Count]; batchUnlocker = (IEdmBatchUnlock)HostingForm.Vault2.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); RootFolder = HostingForm.Vault1.RootFolderPath; var i = 0; foreach (var fileName in listType) { var filePath = RootFolder + fileName.FolderPath + fileName.FileName; if (HostingForm.Vault1.GetFileFromPath(filePath, out ppoRetParentFolder) == null) continue; aFile = HostingForm.Vault1.GetFileFromPath(filePath, out ppoRetParentFolder); aPos = aFile.GetFirstFolderPosition(); aFolder = aFile.GetNextFolder(aPos); ppoSelection[i] = new EdmSelItem(); ppoSelection[i].mlDocID = aFile.ID; ppoSelection[i].mlProjID = aFolder.ID; i = i + 1; } // Add selections to the batch of files to check in batchUnlocker.AddSelection((EdmVault5)HostingForm.Vault1, ppoSelection); if ((batchUnlocker != null)) { batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed); aPos = fileList.GetHeadPosition(); while (!(aPos.IsNull)) { fileList.GetNext2(aPos, out poSel); } //retVal = batchUnlocker.ShowDlg(this.Handle.ToInt32()); batchUnlocker.UnlockFiles(0, null); } }