static void Main(string[] args) { try { var vaultSource = new EdmVault5(); vaultSource.LoginAuto("Vents-PDM", 0); var oFolder = vaultSource.GetFolderFromPath(@"E:\Vents-PDM\Проекты\Blauberg\02-01-Panels"); Console.WriteLine(oFolder.ID); var edmFile5 = vaultSource.GetFileFromPath(@"E:\Vents-PDM\Проекты\Blauberg\02-01-Panels\02-01-2-6589.sldprt", out oFolder); Console.WriteLine(edmFile5.CurrentState); edmFile5.UndoLockFile(0, true); edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest); oFolder.DeleteFile(0, 262953, true); Console.WriteLine("Vents-PDM"); } catch (Exception exception) { Console.WriteLine(exception.Message); Console.ReadLine(); } }
public void ShowReferences(EdmVault5 vault, string filePath) { // ERROR: Not supported in C#: OnErrorStatement string projName = null; IEdmFile5 file = default(IEdmFile5); IEdmFolder5 folder = default(IEdmFolder5); file = vault.GetFileFromPath(filePath, out folder); IEdmReference5 @ref = default(IEdmReference5); @ref = file.GetReferenceTree(folder.ID, 0); AddReferences(@ref, 0, ref projName); }
internal static void GetIdPdm(string path, out string fileName, out int fileIdPdm, EdmVault5 edmVault5) { fileName = null; fileIdPdm = 0; try { IEdmFolder5 oFolder; var tries = 1; m1: Thread.Sleep(500); path = new FileInfo(path).FullName; var edmFile5 = edmVault5.GetFileFromPath(path, out oFolder); if (oFolder == null) { tries++; if (tries > 10) { return; } goto m1; } try { edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } fileName = edmFile5.Name; fileIdPdm = edmFile5.ID; } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
/// <summary> /// 【7】将文件复制到指定路径(硬盘)——导出 /// </summary> /// <param name="PathInVault">库文件夹根目录下相对路径</param> /// <param name="PathOutVault">本地具体路径</param> public static void CheckoutAndCopy(string PathInVault, string PathOutVault) { try { EdmVault5 vault = new EdmVault5(); vault.Login(LogName, PWD, VaultName); IEdmFile5 file = default(IEdmFile5); IEdmFolder5 folder = null; file = vault.GetFileFromPath(vault.RootFolderPath + PathInVault, out folder);//读取指定文件的位置,PathInVault库文件夹根目录下相对路径 file.LockFile(folder.ID, new System.Windows.Forms.Control().Handle.ToInt32()); file.UndoLockFile(new System.Windows.Forms.Control().Handle.ToInt32(), true); //Copy the file IEdmEnumeratorVersion5 verEnum = default(IEdmEnumeratorVersion5); verEnum = (IEdmEnumeratorVersion5)file; int Version = 0; Version = file.GetLocalVersionNo(folder.ID); IEdmVersion5 ver = default(IEdmVersion5); ver = verEnum.GetVersion(Version); ver.GetFileCopy(new System.Windows.Forms.Control().Handle.ToInt32(), PathOutVault);//PathOutVault本地具体路径 } catch (System.Runtime.InteropServices.COMException ex) { if (ex.ErrorCode.ToString() == "-2147220949") { MessageBox.Show("The selected file is not located in a file vault."); } else { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void Getbom(int bomId, string filePath, string bomConfiguration, EdmBomFlag bomFlag, out Exception exception) { exception = null; try { IEdmFolder5 oFolder; CheckPdmVault(); EdmFile7 = (IEdmFile7)_edmVault5.GetFileFromPath(filePath, out oFolder); var bomView = EdmFile7.GetComputedBOM(Convert.ToInt32(bomId), Convert.ToInt32(-1), bomConfiguration, (int)bomFlag); if (bomView == null) { return; } Array bomRows; Array bomColumns; bomView.GetRows(out bomRows); bomView.GetColumns(out bomColumns); var bomTable = new DataTable(); foreach (EdmBomColumn bomColumn in bomColumns) { bomTable.Columns.Add(new DataColumn { ColumnName = bomColumn.mbsCaption }); } //bomTable.Columns.Add(new DataColumn { ColumnName = "Путь" }); bomTable.Columns.Add(new DataColumn { ColumnName = "Уровень" }); bomTable.Columns.Add(new DataColumn { ColumnName = "КонфГлавнойСборки" }); bomTable.Columns.Add(new DataColumn { ColumnName = "ТипОбъекта" }); bomTable.Columns.Add(new DataColumn { ColumnName = "GetPathName" }); for (var i = 0; i < bomRows.Length; i++) { var cell = (IEdmBomCell)bomRows.GetValue(i); bomTable.Rows.Add(); for (var j = 0; j < bomColumns.Length; j++) { var column = (EdmBomColumn)bomColumns.GetValue(j); object value; object computedValue; string config; bool readOnly; cell.GetVar(column.mlVariableID, column.meType, out value, out computedValue, out config, out readOnly); if (value != null) { bomTable.Rows[i][j] = value; } else { bomTable.Rows[i][j] = null; } bomTable.Rows[i][j + 1] = cell.GetTreeLevel(); bomTable.Rows[i][j + 2] = bomConfiguration; bomTable.Rows[i][j + 3] = config; bomTable.Rows[i][j + 4] = cell.GetPathName(); } } _bomList = BomTableToBomList(bomTable); exception = null; } catch (Exception ex) { exception = ex; } }
internal static void BatchUnLock(List<VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5) { IEdmPos5 aPos; var batchUnlocker = (IEdmBatchUnlock2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); var i = 0; var ppoSelection = new EdmSelItem[filesList.Count]; foreach (var file in filesList) { var fileInfo = new FileInfo(file.LocalPartFileInfo); if (string.IsNullOrEmpty(fileInfo.Extension)) continue; IEdmFolder5 ppoRetParentFolder; IEdmFile5 aFile; try { aFile = edmVault5.GetFileFromPath(fileInfo.FullName, out ppoRetParentFolder); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); continue; } if (aFile != null) { try { aPos = aFile.GetFirstFolderPosition(); var aFolder = aFile.GetNextFolder(aPos); ppoSelection[i] = new EdmSelItem { mlDocID = aFile.ID, mlProjID = aFolder.ID }; i++; } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } } } // Add selections to the batch of files to check in batchUnlocker.AddSelection(edmVault5, ppoSelection); batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); batchUnlocker.Comment = filesList[0].MessageForCheckOut; var fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed); aPos = fileList.GetHeadPosition(); while (!(aPos.IsNull)) { EdmSelectionObject poSel; fileList.GetNext2(aPos, out poSel); } batchUnlocker.UnlockFiles(0); }
internal static void BatchUnLock(List <VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5) { IEdmPos5 aPos; var batchUnlocker = (IEdmBatchUnlock2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); var i = 0; var ppoSelection = new EdmSelItem[filesList.Count]; foreach (var file in filesList) { var fileInfo = new FileInfo(file.LocalPartFileInfo); if (string.IsNullOrEmpty(fileInfo.Extension)) { continue; } IEdmFolder5 ppoRetParentFolder; IEdmFile5 aFile; try { aFile = edmVault5.GetFileFromPath(fileInfo.FullName, out ppoRetParentFolder); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); continue; } if (aFile != null) { try { aPos = aFile.GetFirstFolderPosition(); var aFolder = aFile.GetNextFolder(aPos); ppoSelection[i] = new EdmSelItem { mlDocID = aFile.ID, mlProjID = aFolder.ID }; i++; } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } } } // Add selections to the batch of files to check in batchUnlocker.AddSelection(edmVault5, ppoSelection); batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); batchUnlocker.Comment = filesList[0].MessageForCheckOut; var fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed); aPos = fileList.GetHeadPosition(); while (!(aPos.IsNull)) { EdmSelectionObject poSel; fileList.GetNext2(aPos, out poSel); } batchUnlocker.UnlockFiles(0); }