Exemplo n.º 1
0
        //Use IEdmBatchGet to check out several files, it is more efficient repeatedly calling LockFile.
        private static FileCheckOutResult LockFiles(IEdmVault5 vault, string[] filePaths, bool bLockReferenceFiles)
        {
            try
            {
                IEdmVault7   vault7      = vault as IEdmVault7;
                IEdmBatchGet batchGetter = vault7.CreateUtility(EdmUtility.EdmUtil_BatchGet);
                for (int i = 0; i < filePaths.Length; ++i)
                {
                    IEdmFile5   edmFile;
                    IEdmFolder5 edmFolder;
                    if (!GetFileFromPath(vault, filePaths[i], out edmFile, out edmFolder))
                    {
                        return(FileCheckOutResult.UNKNOWN_ERROR);
                    }

                    batchGetter.AddSelectionEx((EdmVault5)vault, edmFile.ID, edmFolder.ID, null);
                }

                int cmdFlag = bLockReferenceFiles ? (int)(EdmGetCmdFlags.Egcf_LockReferencedFilesToo | EdmGetCmdFlags.Egcf_Lock) : (int)EdmGetCmdFlags.Egcf_Lock;
                batchGetter.CreateTree(0, cmdFlag);
                batchGetter.GetFiles(0);

                return(FileCheckOutResult.OK);
            }
            catch (Exception ex)
            {
                return(FileCheckOutResult.UNKNOWN_ERROR);
            }
        }
Exemplo n.º 2
0
        public static bool Get(IEdmVault7 vault, List <Files.Info> files)
        {
            var status = false;

            Logger.Add($"Получение {files?.Count} файлов из PDM");
            try
            {
                batchGetter = (IEdmBatchGet)vault.CreateUtility(EdmUtility.EdmUtil_BatchGet);
                foreach (var file in files)
                {
                    try
                    {
                        batchGetter.AddSelectionEx((EdmVault5)vault, file.IdPDM, file.FolderID, file.CurrentVersion);
                    }
                    catch (Exception ex)
                    {
                        Logger.Add($"Ошибка при получении:{ex.Message} Path: {file.FullFilePath} IdPDM: {file.IdPDM} FolderID: {file.FolderID} Version: {file.CurrentVersion}");
                    }
                }
                if ((batchGetter != null))
                {
                    batchGetter.CreateTree(0, (int)EdmGetCmdFlags.Egcf_SkipUnlockedWritable);
                    batchGetter.GetFiles(0, null);
                }
            }
            catch (COMException ex)
            {
                Logger.Add("ERROR BatchGet HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Add("ERROR BatchGet HRESULT = 0x" + ex.StackTrace + "\n" + ex.Message);
            }
            return(status);
        }
Exemplo n.º 3
0
        //TODO: BatchGet
        public void BatchGet(List<TaskParam> listType)
        {
            batchGetter = (IEdmBatchGet)HostingForm.Vault2.CreateUtility(EdmUtility.EdmUtil_BatchGet);

            var i = 0;
            foreach (var taskVar in listType)
            {

                aFile = HostingForm.Vault1.GetFileFromPath(taskVar.FullFilePath, out ppoRetParentFolder);

                aPos = aFile.GetFirstFolderPosition();

                aFolder = aFile.GetNextFolder(aPos);

                batchGetter.AddSelectionEx((EdmVault5)HostingForm.Vault1, aFile.ID, aFolder.ID, taskVar.CurrentVersion);
            }

            //batchUnlocker.AddSelection((EdmVault5)vault, ppoSelection);

            if ((batchGetter != null))
            {
                batchGetter.CreateTree(0, (int)EdmGetCmdFlags.Egcf_Nothing);

                ////fileCount = batchGetter.FileCount;
                //fileList = (IEdmSelectionList6)batchGetter.GetFileList((int)EdmGetFileListFlag.Egflf_GetLocked + (int)EdmGetFileListFlag.Egflf_GetFailed + (int)EdmGetFileListFlag.Egflf_GetRetrieved + (int)EdmGetFileListFlag.Egflf_GetUnprocessed);

                //aPos = fileList.GetHeadPosition();

                ////str = "Getting " + fileCount + " files: ";
                //while (!(aPos.IsNull))
                //{
                //    fileList.GetNext2(aPos, out poSel);
                //    //str = str + Constants.vbLf + poSel.mbsPath;
                //}

                //MsgBox(str)

                //var retVal = batchGetter.ShowDlg(this.Handle.ToInt32());
                // No dialog if checking out only one file

                //if ((retVal))
                //{
                batchGetter.GetFiles(0, null);
                //}
            }
        }