public int CheckPdf(int documentId, IEdmFile5 filedrw, string pathpdf) { try { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(); command.CommandText = "SELECT * FROM PDF WHERE DocumentId = '" + documentId + "'"; command.Connection = connection; int temp = Convert.ToInt16(command.ExecuteScalar()); if (temp != 0) { var reader = command.ExecuteReader(); if (reader.Read()) { string filename = filedrw.Name.Replace(".SLDDRW", ".pdf"); System.IO.File.WriteAllBytes(pathpdf + @"\" + filename, (byte[])reader["Blob"]); } } return(temp); } } catch (Exception e) { MessageBox.Show(e.Message); throw; } }
public string DetermineConfig(IEdmFile5 Part, IEdmVault7 vault, string partnumber) { string retval = "@"; EdmStrLst5 list = Part.GetConfigurations(); IEdmPos5 pos = list.GetHeadPosition(); Config_Select config = new Config_Select(vault, Part, partnumber); pos = list.GetHeadPosition(); for (int i = 0; i < list.Count; i++) { string itemtoadd = list.GetNext(pos); if (itemtoadd != "@") config.config_cbo.Items.Add(itemtoadd); } config.config_cbo.SelectedIndex = 0; config.ShowDialog(); retval = config.SelectedConfig; if (config.DialogResult == System.Windows.Forms.DialogResult.Cancel) return ""; return retval; }
public string DetermineConfig(IEdmFile5 Part, IEdmVault7 vault, EdmCmdData file) { string retval = "@"; EdmStrLst5 list = Part.GetConfigurations(); IEdmPos5 pos = list.GetHeadPosition(); Config_Select config = new Config_Select(vault, file); pos = list.GetHeadPosition(); for (int i = 0; i < list.Count; i++) { config.config_cbo.Items.Add(list.GetNext(pos)); } config.config_cbo.SelectedIndex = 0; config.ShowDialog(); if (config.DialogResult == System.Windows.Forms.DialogResult.Cancel) return ""; return retval; }
private static bool AddFile2Vault(IEdmVault5 vault, string filePath, out IEdmFile5 edmFile) { edmFile = null; try { IEdmFolder9 parentFolder = vault.GetFolderFromPath(Path.GetDirectoryName(filePath)) as IEdmFolder9; if (parentFolder == null) { //文件夹也是新增的 string fileFolder = Path.GetDirectoryName(filePath).ToLower(); string vaultPath = vault.RootFolderPath.ToLower(); fileFolder = fileFolder.Replace(vault.RootFolderPath.ToLower(), ""); string[] subFolders = fileFolder.Split('/', '\\'); if (!RecursivelyAddFolder(vault, vault.RootFolder, subFolders, out parentFolder)) { return(false); } } int addFileStatus; parentFolder.AddFile2(0, filePath, out addFileStatus, "", (int)EdmAddFlag.EdmAdd_Simple); IEdmFolder5 folder; return(GetFileFromPath(vault, filePath, out edmFile, out folder)); } catch (Exception ex) { return(false); } }
public void BrowseButton_Click(System.Object sender, System.EventArgs e) { try { //Set the initial directory in the Select a file dialog OpenFileDialog1.InitialDirectory = vault1.RootFolderPath; //Show the Select a file dialog System.Windows.Forms.DialogResult DialogResult; DialogResult = OpenFileDialog1.ShowDialog(); if (!(DialogResult == System.Windows.Forms.DialogResult.OK)) { // Do nothing } else { // Browse for a file whose serial number to set // File's data card must have a Part Number associated // with a serial number generator and must be checked out string fileName = OpenFileDialog1.FileName; FileListBox.Items.Add(fileName); IEdmFolder5 retFolder = default(IEdmFolder5); aFile = vault1.GetFileFromPath(fileName, out retFolder); } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ProcCheck(IEdmFile5 file, IEdmFile5 filedrw, int version, byte[] binar) { try { string sqlExpression = "PDFcheck"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(sqlExpression, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@DocumentID", SqlDbType.Int).Value = filedrw.ID; command.Parameters.Add("@Version", SqlDbType.Int).Value = filedrw.CurrentVersion; command.Parameters.Add("@Blob", SqlDbType.Image).Value = binar; command.ExecuteNonQuery(); } } catch (Exception e) { MessageBox.Show(e.Message); throw; } }
public FileReference GetFileReference(string filePath) { IEdmFolder5 folder; IEdmFile5 file = _vault.GetFileFromPath(filePath, out folder); IEdmReference5 fileRef = file.GetReferenceTree(folder.ID); return(GetFileReferencesRecursive(fileRef, "A")); }
public void OnCmd(ref EdmCmd poCmd, ref System.Array ppoData) { //public void OnCmd(ref EdmCmd poCmd, ref EdmCmdData[] ppoData) //{ EdmVault5 vault = (EdmVault5)poCmd.mpoVault; if (poCmd.meCmdType == EdmCmdType.EdmCmd_Menu) { if (poCmd.mlCmdID == 1) { if (ppoData.Length < 0) { System.Windows.Forms.MessageBox.Show("请选择一个文件"); return; } if (ppoData.Length > 1) { System.Windows.Forms.MessageBox.Show("只能选择一个文件"); return; } int fileId = 0; int parentFolderId = 0; foreach (EdmCmdData AffectedFile in ppoData) { fileId = AffectedFile.mlObjectID1; parentFolderId = AffectedFile.mlObjectID3; } if (fileId == 0) { System.Windows.Forms.MessageBox.Show("请选择一个文件"); return; } ExportExcelForm form = new ExportExcelForm(); IEdmFile5 file = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, fileId); IEdmFolder5 folder = (IEdmFolder5)vault.GetObject(EdmObjectType.EdmObject_Folder, parentFolderId); string filePath = folder.LocalPath + "\\" + file.Name; form.selectFile = filePath; if (form.ShowDialog() == DialogResult.OK) { string outFile = form.saveFilePath; FormStatusBar statusBar = new FormStatusBar("明细表导出", "正在导出,请稍后...."); statusBar.UserCustomEvent += (obj) => { exportExcel(vault, form.selectFile, form.saveFilePath); }; statusBar.ShowDialog(); } GC.Collect(); } } }
public bool GetAsmIndoFromFile(IEdmVault5 poVault, string filePath, SldAsm asmPrd) { IEdmFolder5 opParentFolder; IEdmFile5 poFile = poVault.GetFileFromPath(filePath, out opParentFolder); IEdmEnumeratorVariable5 enumVar = poFile.GetEnumeratorVariable(); if (filePath == "") { return(false); } asmPrd.path = filePath; // object tmpVar; if (enumVar.GetVar("代号", "@", out tmpVar)) { asmPrd.number = tmpVar.ToString(); asmPrd.ztdm = asmPrd.number.Substring(0, asmPrd.number.IndexOf(".")); asmPrd.zjdm = asmPrd.number.Substring(asmPrd.number.IndexOf(".") + 1); } if (enumVar.GetVar("名称", "@", out tmpVar)) { asmPrd.name = tmpVar.ToString(); } if (enumVar.GetVar("设计", "@", out tmpVar)) { asmPrd.bzr = tmpVar.ToString(); } if (enumVar.GetVar("设计日期", "@", out tmpVar)) { asmPrd.bzsj = ((DateTime)tmpVar).ToString("%y/%m/%d"); } if (enumVar.GetVar("批准", "@", out tmpVar)) { asmPrd.pzr = tmpVar.ToString(); } if (enumVar.GetVar("批准日期", "@", out tmpVar)) { asmPrd.pzsj = ((DateTime)tmpVar).ToString("%y/%m/%d"); } if (enumVar.GetVar("阶段标记", "@", out tmpVar)) { asmPrd.jdbj = tmpVar.ToString(); } if (enumVar.GetVar("设备型号", "@", out tmpVar)) { asmPrd.sbxh = tmpVar.ToString(); } if (enumVar.GetVar("Project Name", "@", out tmpVar)) { asmPrd.projName = tmpVar.ToString(); } return(true); }
private static bool TryRefreshFile(IEdmFile5 file) { try { file.Refresh(); return(true); } catch (Exception ex) { return(false); } }
public void FileObj(List <BomShell> boomShellList, string pathpdf) { try { foreach (var item in boomShellList) { if (item.FileName != "" && item.PartNumber != "") { IEdmFolder5 folder; string pathfile = item.FolderPath + @"\" + item.FileName; IEdmFile5 file = Vault.GetFileFromPath(pathfile, out folder); file.GetFileCopy(0, 0, 0, (int)EdmGetFlag.EdmGet_Simple); string filepath = file.GetLocalPath(folder.ID); string pathdrw = item.FolderPath + @"\" + item.PartNumber + ".SLDDRW"; IEdmFile5 filedrw = Vault.GetFileFromPath(pathdrw, out folder); if (filedrw != null) { filedrw.GetFileCopy(0, 0, 0, (int)EdmGetFlag.EdmGet_Simple); var filepathdrw = filedrw.GetLocalPath(folder.ID); int filedrwId = filedrw.ID; if (CheckPdf(filedrwId, filedrw, pathpdf) != 0) { CheckPdf(filedrwId, filedrw, pathpdf); } else { LoadPdf lp = new LoadPdf(); string newpath = lp.PdfLoad(filepathdrw, true, pathpdf); byte[] bytes = BinaryPdf(newpath); ProcCheck(file, filedrw, filedrw.CurrentVersion, bytes); } } } } SolidWorksAdapter.KillProcsses("SLDWORKS"); SolidWorksAdapter.DisposeSOLID(); MessageBox.Show("PDF файлы успешно сохранены"); this.Hide(); } catch (Exception e) { MessageBox.Show(e.Message); throw; } }
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} файлов."); }
private void GetCardList() { notBusy = false; try { vault = new EdmVault5(); vault.LoginAuto(selectedVault, 0); if (vault.IsLoggedIn) { IEdmFile5 file = vault.GetFileFromPath(selectedFile, out IEdmFolder5 folder); IEdmCard5 card = folder.GetCard(Path.GetExtension(selectedFile).Substring(1)); Object variableName = selectedVariable; IEdmCardControl7 cardControl = (IEdmCardControl7)card.GetControl(card.GetControlID(ref variableName)); if (cardControl.GetControlVariableList(file.ID, out String[] cardListStrings))
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); }
public void AddFileRef(ref EdmListFile[] BatchListFiles, ref int curIndex, int curLevel, ref List <FileRef> FileRefs) { try { while (curIndex < BatchListFiles.Length) { EdmListFile curListFile = BatchListFiles[curIndex]; //If the depth level of this listfile is < //the current depth level then... if (curListFile.mlParam > curLevel) { //Create a new FileRefs list FileRefs[FileRefs.Count - 1].FileRefs = new List <FileRef>(); List <FileRef> fRef = FileRefs[FileRefs.Count - 1].FileRefs; //Recurse using a new FileRefs list AddFileRef(ref BatchListFiles, ref curIndex, curListFile.mlParam, ref fRef); } else { //Create a new FileRef object to hold //the file information FileRef FileRef = new FileRef(); //Assign the FileRef properties FileRef.CheckedOutBy = curListFile.mbsLockUser; FileRef.CurrentState = curListFile.moCurrentState.mbsStateName; object[] columnData = (object[])curListFile.moColumnData; FileRef.Description = (string)columnData[0]; IEdmFile5 File = default(IEdmFile5); File = (IEdmFile5)vault1.GetObject(EdmObjectType.EdmObject_File, curListFile.mlFileID); FileRef.FileName = File.Name; FileRef.LatestRevision = curListFile.mbsRevisionName; FileRef.LatestVersion = Convert.ToString(curListFile.mlLatestVersion); FileRef.Number = (string)columnData[1]; FileRef.FileRefs = null; //Add the FileRef to this level's list FileRefs.Add(FileRef); curIndex += 1; } } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public SldBsp GetSldPrdInfoFromFile(IEdmVault5 poVault, string filePath) { SldBsp bspPrt = null; IEdmFolder5 opParentFolder; //bspPrt = new SldBuy(); IEdmFile5 poFile = poVault.GetFileFromPath(filePath, out opParentFolder); if (poFile == null) { bspPrt = new SldPrt(); bspPrt.type = 1; return(bspPrt); } IEdmEnumeratorVariable5 enumVar = poFile.GetEnumeratorVariable(); if (enumVar == null) { return(null); } object tmpVar; string partType = ""; if (enumVar.GetVar("Part Type", "@", out tmpVar)) { partType = tmpVar.ToString(); } if (partType == "自制件") { bspPrt = new SldPrt(); bspPrt.type = 1; SldPrt prt = (SldPrt)bspPrt; if (enumVar.GetVar("工艺路线", "@", out tmpVar)) { prt.route = tmpVar.ToString(); } } else if (partType == "标准件") { bspPrt = new SldStd(); bspPrt.type = 2; } else { bspPrt = new SldBuy(); bspPrt.type = 3; } bspPrt.path = filePath; return(bspPrt); }
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); } }
private static bool TryLockFile(IEdmFile5 file, IEdmFolder5 parentFolder, out int?edmResultCode) { try { file.LockFile(parentFolder.ID, 0, (int)EdmLockFlag.EdmLock_Simple); edmResultCode = null; return(true); } catch (System.Runtime.InteropServices.COMException ex) { edmResultCode = ex.ErrorCode; return(false); } }
private static bool TryGetFileLocalCopy(IEdmFile5 file) { try { object version = file.CurrentVersion; Log.WriteLog(version.ToString()); file.GetFileCopy(0, ref version); return(true); } catch (Exception ex) { return(false); } }
private static bool TryUnlockFile(IEdmFile5 file, out int?edmResultCode) { try { file.UnlockFile(0, ""); edmResultCode = null; return(true); } catch (System.Runtime.InteropServices.COMException ex) { edmResultCode = ex.ErrorCode; return(false); } }
public Config_Select(IEdmVault7 vault, IEdmFile5 part, string SearchPart) { InitializeComponent(); this.SizeChanged += Config_Select_SizeChanged; Vault = vault; Part = part; //SearchTerm = SearchPart; //StartMethod = "part"; }
public void GetReferencedFiles(IEdmReference10 Reference, string FilePath, int Level, string ProjectName, ref Dictionary <string, string> RefFilesDictionary) { try { bool Top = false; if (Reference == null) { //This is the first time this function is called for this //reference tree; i.e., this is the root Top = true; //Add the top-level file path to the dictionary RefFilesDictionary.Add(FilePath, Level.ToString()); IEdmFile5 File = null; IEdmFolder5 ParentFolder = null; File = vault1.GetFileFromPath(FilePath, out ParentFolder); //Get the reference tree for this file Reference = (IEdmReference10)File.GetReferenceTree(ParentFolder.ID); GetReferencedFiles(Reference, "", Level + 1, ProjectName, ref RefFilesDictionary); } else { //Execute this code when this function is called recursively; //i.e., this is not the top-level IEdmReference in the tree //Recursively traverse the references IEdmPos5 pos = default(IEdmPos5); IEdmReference10 Reference2 = (IEdmReference10)Reference; pos = Reference2.GetFirstChildPosition3(ProjectName, Top, true, (int)EdmRefFlags.EdmRef_File, "", 0); IEdmReference10 @ref = default(IEdmReference10); while ((!pos.IsNull)) { @ref = (IEdmReference10)Reference.GetNextChild(pos); RefFilesDictionary.Add(@ref.FoundPath, Level.ToString()); GetReferencedFiles(@ref, "", Level + 1, ProjectName, ref RefFilesDictionary); } } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static bool TryGetVaribleValue(IEdmFile5 file, string cfgName, string variableName, out string varibleValue) { varibleValue = null; try { IEdmEnumeratorVariable5 vars = file.GetEnumeratorVariable(); object retValue; if (!vars.GetVar(variableName, cfgName, out retValue)) { return(false); } varibleValue = retValue.ToString(); return(true); } catch (Exception ex) { return(false); } }
public static void SetVariable(IEdmVault7 vault, List <Files.Info> files) { try { foreach (var fileVar in files) { var filePath = fileVar.FolderPath + "\\" + fileVar.ConvertFile; fileNameErr = filePath; IEdmFolder5 folder; aFile = vault.GetFileFromPath(filePath, out folder); var pEnumVar = (IEdmEnumeratorVariable8)aFile.GetEnumeratorVariable();; pEnumVar.SetVar("Revision", "", fileVar.CurrentVersion); } } catch (COMException ex) { Logger.Add("ERROR BatchSetVariable файл: " + fileNameErr + ", " + ex.Message); } }
private static bool GetFileFromPath(IEdmVault5 vault, string filePath, out IEdmFile5 file, out IEdmFolder5 parentFolder) { file = null; parentFolder = null; if (vault == null) { return(false); } try { file = vault.GetFileFromPath(filePath, out parentFolder); return(file != null && parentFolder != null); } catch (Exception ex) { return(false); } }
/// <summary> /// 【10】获取文件版本 /// </summary> /// <param name="path">文件在PDM中路径</param> /// <returns></returns> public static int GetDrawVersion(string path) { if (vault == null) { vault = new EdmVault5(); } if (!vault.IsLoggedIn) { vault.LoginAuto(VaultName, new Control().Handle.ToInt32()); } IEdmFolder5 retFolder = default(IEdmFolder5); //aFile = vault1.GetFileFromPath(FileName, out retFolder); IEdmFile5 file = null; file = vault.GetFileFromPath(path, out retFolder); IEdmEnumeratorVersion5 enumVersion; enumVersion = (IEdmEnumeratorVersion5)file; return(enumVersion.VersionCount); }
private static bool TryGetConfigurations(IEdmFile5 file, out List <string> cfgs) { cfgs = new List <string>(); try { EdmStrLst5 cfgList = file.GetConfigurations(); IEdmPos5 pos = cfgList.GetHeadPosition(); while (!pos.IsNull) { string cfgName = cfgList.GetNext(pos); cfgs.Add(cfgName); } return(true); } catch (Exception ex) { return(false); } }
private void DrawBitmapPreview(IEdmFile5 file) { //try //{ // IEdmEnumeratorVariable5 varEnum = default(IEdmEnumeratorVariable5); // varEnum = (IEdmEnumeratorVariable5)file.GetEnumeratorVariable(); // IEdmBitmap5 preview = default(IEdmBitmap5); // preview = varEnum.GetThumbnail(); // if (preview == null) // return; // preview.Draw(this.Handle.ToInt32(), 45, 220, 0, 0); //} //catch (System.Runtime.InteropServices.COMException ex) //{ // MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} }
/// <summary> /// Registration or unregistation files by their paths and registration status. /// </summary> /// <param name="filePath"></param> /// <param name="isRegistration"></param> public void CheckInOutPdm(string pathToFile, bool registration) { var retryCount = 5; try { IEdmFolder5 oFolder; IEdmFile5 edmFile5 = PdmExemplar.GetFileFromPath(pathToFile, out oFolder); edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_Simple); if (!registration) // Разрегистрировать { while (!edmFile5.IsLocked && retryCount > 0) { edmFile5.LockFile(oFolder.ID, 0); retryCount--; } } if (registration) // Зарегистрировать { while (edmFile5.IsLocked && retryCount > 0) { edmFile5.UnlockFile(oFolder.ID, ""); retryCount--; Thread.Sleep(50); } } } catch (Exception exception) { retryCount--; Thread.Sleep(200); if (retryCount == 0) { // } throw exception; } }
static string GetRevision(IEdmVault7 vault, int TaskType, string filePath) { var variable = ""; try { var aFolder = default(IEdmFolder5); aFile = vault.GetFileFromPath(filePath, out aFolder); object oVarRevision; if (aFile == null) { variable = "0"; } else { var pEnumVar = (IEdmEnumeratorVariable8)aFile.GetEnumeratorVariable(); pEnumVar.GetVar("Revision", "", out oVarRevision); if (oVarRevision == null) { variable = "0"; } else { variable = oVarRevision.ToString(); } } } catch (COMException ex) { Logger.Add("Batch.Get HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { Logger.Add("Batch.Get Error " + ex.Message); } return(variable); }
/// <summary> /// Traverses an argument vault folder object recursively and returns a <see cref="Folder"/> instance /// representing the complete hierarchical tree structure of the vault folder in question. /// This method could be VERY SLOW depending on the size and depth of the folder structure being traversed. /// </summary> /// <param name="folder"></param> /// <returns></returns> public static Folder GetFolderTree(IEdmFolder5 folder) { Folder folderOut = new Folder() { Id = folder.ID, ParentFolderId = folder.ParentFolder == null ? null : new int?(folder.ParentFolder.ID), // This guards against a potential NullReferenceException only for the vault root folder because it will have a null ParentFolder value. Name = folder.Name, Path = folder.LocalPath, }; IEdmPos5 pos = folder.GetFirstFilePosition(); while (!pos.IsNull) { IEdmFile5 edmFile = folder.GetNextFile(pos); var file = new File() { Id = edmFile.ID, Name = edmFile.Name, Path = edmFile.GetLocalPath(folder.ID) // TODO: AcmePartNo = .... }; folderOut.Files.Add(file); } pos = folder.GetFirstSubFolderPosition(); while (!pos.IsNull) { IEdmFolder5 subFolder = folder.GetNextSubFolder(pos); folderOut.Subfolders.Add( GetFolderTree(subFolder)); } return(folderOut); }
/// <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); } }
public IEdmFile5 CopyFileIntoVault(string path, string Destination) { IEdmFile5 Outfile = vault.GetFileFromPath(Destination, out IEdmFolder5 fld); if (Outfile != null) { if (!Outfile.IsLocked) { Outfile.LockFile(fld.ID, 0, 0); } System.IO.File.Copy(path, Destination, true); return(Outfile); } else { fld = vault.GetFolderFromPath(Path.GetDirectoryName(Destination)); if (fld != null) { int id = ((IEdmFolder8)fld).AddFile2(0, path, out int err, "", (int)EdmAddFlag.EdmAdd_UniqueVarDelayCheck); return((IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, id)); } return(null); } }
public bool HaveUpToDateItemRef(EdmCmdData file,IEdmFile5 Part, IEdmVault7 vault) { bool retval = false; long Local = Part.GetLocalVersionNo(file.mlObjectID3); int Server = Part.CurrentVersion; if (Local == Server) retval = true; return retval; }
public bool HaveUpToDateItemRef(IEdmFile5 Part, IEdmVault7 vault) { bool retval = false; long Local = Part.GetLocalVersionNo(Part.GetLocalPath(0)); int Server = Part.CurrentVersion; if (Local == Server) retval = true; return retval; }
//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); //} } }
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); } }
public void BatchDelete(List<TaskParam> listType) { var batchDeleter = (IEdmBatchDelete2)HostingForm.Vault2.CreateUtility(EdmUtility.EdmUtil_BatchDelete); IEdmFolder5 ppoRetParentFolder; foreach (var fileName in listType) { if (fileName.Revision == "") continue; aFile = HostingForm.Vault1.GetFileFromPath(fileName.FullFilePath, out ppoRetParentFolder); aPos = aFile.GetFirstFolderPosition(); aFolder = aFile.GetNextFolder(aPos); // Add selected file to the batch batchDeleter.AddFileByPath(fileName.FullFilePath); } // Move files and folder to the Recycle Bin batchDeleter.ComputePermissions(true, null); batchDeleter.CommitDelete(0, null); }
/// <summary> /// Syncs local version of a file with the current version in the vault /// </summary> /// <param name="Part"></param> /// <param name="vault"></param> /// <returns></returns> public bool UpdateItemRef(EdmCmdData file,IEdmFile5 Part, IEdmVault7 vault) { bool retval = false; if (!HaveUpToDateItemRef(file,Part, vault)) { DialogResult dr = MessageBox.Show("This requires that you get the latest version of this file. Continue?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Part.GetFileCopy(0, 0, 0, (int)EdmGetFlag.EdmGet_RefsVerLatest, ""); retval = true; } else retval = false; } else retval = true; return retval; }
public string DetermineConfig(IEdmFile5 Part, IEdmVault7 vault,EdmCmdData file, string SearchTerm) { string retval = "@"; EdmStrLst5 list = Part.GetConfigurations(); IEdmPos5 pos = list.GetHeadPosition(); Config_Select config; if (SearchTerm != "") config = new Config_Select(vault, Part, SearchTerm); else config = new Config_Select(vault, file); for (int i = 0; i < list.Count; i++) { string name = list.GetNext(pos); if (name != "@") { object number; object area; object mass; IEdmEnumeratorVariable5 var = Part.GetEnumeratorVariable(); var.GetVar("Number", name, out number); var.GetVar("NetWeight", name, out mass); var.GetVar("SurfaceArea", name, out area); if (number != null && mass != null && area != null) { config.config_cbo.Items.Add(name); } } } config.config_cbo.SelectedIndex = 0; config.ShowDialog(); retval = config.SelectedConfig; if (config.DialogResult == System.Windows.Forms.DialogResult.Cancel) return ""; return retval; }