public void ShowWindowPdmTest() { string parentFilePath = @"C:\EPDMVaults\Training\Built Parts\Block1.sldprt"; string varName = "Document Number"; string vaultName = "Training"; IEdmVault13 vault = VaultSingleton.Instance; VaultHelper h = new VaultHelper(vault); string loginError; if (!h.TryLoginAuto(vaultName, out loginError)) { Assert.Fail(); } IEdmFolder5 parentFolder; IEdmFile5 file = (IEdmFile5)vault.GetFileFromPath(parentFilePath, out parentFolder); var fileVars = (IEdmEnumeratorVariable10)file.GetEnumeratorVariable(); object oVal; bool success = fileVars.GetVar2(varName, "@", parentFolder.ID, out oVal); var window = new AAFileRefsWindow(); // do search and gret results... var search = new VaultSearch(vault); AAFileRef[] results = search.SearchForFileRefs(oVal.ToString()); var vm = new AAFileRefsViewModel(parentFilePath, results, () => window.Close()); window.DataContext = vm; window.ShowDialog(); if (vm.OkWasClicked) { var fileRefsSvc = new CustomRefsService(vault); string[] chilPaths = vm.Results .Where(x => x.IsIncluded) .Select(x => x.Path).ToArray(); fileRefsSvc.AddCustomReferences(file.ID, chilPaths); } }
public void OnCmd(ref EdmCmd poCmd, ref Array ppoData) { try { //// TODO: This is useful for showing child windows properly //poCmd.mlParentWnd; switch (poCmd.meCmdType) { case EdmCmdType.EdmCmd_Menu: if (poCmd.mlCmdID == 1) { //// TODO: Only supporting single selection for now. //foreach(EdmCmdData d in ppoData) //{ // d.mbsStrData1 = //} var fileData = (EdmCmdData)ppoData.GetValue(0); string fileName = fileData.mbsStrData1; int fileId = fileData.mlObjectID1; int folderId = fileData.mlObjectID3; IEdmVault16 vault = (IEdmVault16)poCmd.mpoVault; IEdmFile5 file = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, fileId); IEdmFolder5 parentFolder = (IEdmFolder5)vault.GetObject(EdmObjectType.EdmObject_Folder, folderId); string parentFilePath = file.GetLocalPath(parentFolder.ID); var fileVars = (IEdmEnumeratorVariable10)file.GetEnumeratorVariable(); // get the variable object oVal; bool success = fileVars.GetVar2(VARIABLE_NAME, "@", parentFolder.ID, out oVal); if (file.IsLocked) { MessageBox.Show("The file must be checked in."); } else if (oVal == null) { MessageBox.Show($"The variable '{VARIABLE_NAME}' has no value."); } else { var window = new AAFileRefsWindow(); // do search and gret results... var search = new VaultSearch(vault); AAFileRef[] results = search.SearchForFileRefs(oVal.ToString()); var vm = new AAFileRefsViewModel(parentFilePath, results, () => window.Close()); window.DataContext = vm; window.ShowDialog(); if (vm.OkWasClicked) { var fileRefsSvc = new CustomRefsService(vault); string[] chilPaths = vm.Results .Where(x => x.IsIncluded) .Select(x => x.Path).ToArray(); fileRefsSvc.AddCustomReferences(file.ID, chilPaths); } } } break; case EdmCmdType.EdmCmd_PostAdd: break; default: break; } } catch (Exception ex) { #if Debug MessageBox.Show(ex.ToString()); #else MessageBox.Show(ex.Message); #endif } }