public static string GetSwEpdRootFolderPath(string vaulName) { try { EdmVault5 vault = new EdmVault5(); vault.LoginAuto(vaulName, 0); return vault.RootFolderPath; } catch (Exception exception) { MessageBox.Show(exception.Message + "\n" + exception.StackTrace); return null; } }
/// <summary> /// 显示PDM视图 /// </summary> private void ShowPDMInfo() { try { IEdmVault5 vault1 = new EdmVault5(); vault = (IEdmVault11)vault1; EdmViewInfo[] Views = null; vault.GetVaultViews(out Views, false); VaultsComboBox.Items.Clear(); this.lblUserName.Text = ""; this.VaultsComboBox.Items.Add(Globals.VaultName); this.VaultsComboBox.Text = Globals.VaultName; this.lblVaultName.Text = string.Format("PDM库:{0}({1}) ", Globals.VaultName, Globals.DbServerIP); //获取并显示PDM登录信息 GetPDMLoginInfo(); this.Text = Globals.DEF_PROGRAM_NAME + " UserId=" + Globals.UserID;//程序名称 } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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(); } }
/// <summary> /// 设置文件卡自由变量的值(文件ID) /// </summary> /// <param name="_filePath">文件ID</param> /// <param name="_value">自由变量名称,变量值</param> /// <returns></returns> public static bool SetFileCardVariableValue(int _fileID, Dictionary <string, string> _value) { try { IEdmVault5 vault5 = new EdmVault5(); IEdmVault7 vault7 = (IEdmVault7)vault5; if (!vault5.IsLoggedIn) { vault5.Login(LogName, PWD, VaultName); } IEdmBatchUpdate2 update = default(IEdmBatchUpdate2); update = (IEdmBatchUpdate2)vault7.CreateUtility(EdmUtility.EdmUtil_BatchUpdate); IEdmVariableMgr5 variableMgr5 = (IEdmVariableMgr5)vault5; foreach (var key in _value.Keys) { //文件ID、变量ID、值、配置名称、 update.SetVar(_fileID, variableMgr5.GetVariable(key).ID, _value[key], "@", (int)EdmBatchFlags.EdmBatch_AllConfigs); } EdmBatchError2[] Errors = null; update.CommitUpdate(out Errors, null); return(true); } catch (Exception ex) { throw ex; } }
public void Form1_Load(System.Object sender, System.EventArgs e) { try { IEdmVault5 vault1 = new EdmVault5(); IEdmVault8 vault = (IEdmVault8)vault1; EdmViewInfo[] Views = null; vault.GetVaultViews(out Views, false); VaultsComboBox.Items.Clear(); foreach (EdmViewInfo View in Views) { VaultsComboBox.Items.Add(View.mbsVaultName); } if (VaultsComboBox.Items.Count > 0) { VaultsComboBox.Text = (string)VaultsComboBox.Items[0]; } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//获取用户列表 public static DataTable GetUserList() { DataTable dt = new DataTable(); if (dt.Columns.Count == 0) { dt.Columns.Add("UserName"); dt.Columns.Add("UserID"); dt.Columns.Add("IsLoggedIn"); dt.Columns.Add("Vault"); dt.Columns.Add("FullName"); dt.Columns.Add("UserData"); dt.Columns.Add("Initials"); dt.Columns.Add("ObjectType"); dt.Columns.Add("Email"); } DataRow dr = null; IEdmVault5 vault = new EdmVault5(); try { vault.Login(LogName, PWD, VaultName); } catch (Exception e) { MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } IEdmUserMgr5 UserMgr = default(IEdmUserMgr5); UserMgr = (IEdmUserMgr5)vault; IEdmPos5 UserPos = default(IEdmPos5); UserPos = UserMgr.GetFirstUserPosition(); while (!UserPos.IsNull) { dr = dt.NewRow(); IEdmUser5 user5 = UserMgr.GetNextUser(UserPos); IEdmUser6 user6 = (IEdmUser6)user5; IEdmUser7 user7 = (IEdmUser7)user5; IEdmUser8 user8 = (IEdmUser8)user5; IEdmUser9 user9 = (IEdmUser9)user5; IEdmUser10 user10 = (IEdmUser10)user5; dr["UserName"] = user5.Name; dr["UserID"] = user5.ID; dr["IsLoggedIn"] = user5.IsLoggedIn; dr["Vault"] = user5.Vault.Name; dr["FullName"] = user6.FullName; dr["UserData"] = user6.UserData; dr["Initials"] = user6.Initials; dr["ObjectType"] = user6.ObjectType; dr["Email"] = user10.Email; dt.Rows.Add(dr); } return(dt); }
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(); } } }
//获取用户ID public static string GetLoginID() { IEdmVault5 vault5 = new EdmVault5(); if (!vault5.IsLoggedIn) { vault5.LoginAuto(VaultName, new Control().Handle.ToInt32()); } IEdmVault11 valut11 = (IEdmVault11)vault5; return(valut11.GetLoggedInWindowsUserID(VaultName).ToString()); }
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 AuthoLogin(string vaultName, bool isRelogin = false) { this.VaultName = vaultName; if (isRelogin) { edmVeult5 = null; } if (!PdmExemplar.IsLoggedIn) { edmVeult5.LoginAuto(this.VaultName, 0); } }
/// <summary> /// 【5】为文件重命名 /// </summary> /// <param name="filepath">文件全名(包含路径)</param> /// <param name="newName">新名称</param> public static void ReName(string filepath, string newName) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile10 file = default(IEdmFile10); IEdmFolder5 ppoRetParentFolder; file = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); file.Rename(new Control().Handle.ToInt32(), newName); }
public static string GetSwEpdRootFolderPath(string vaulName) { try { EdmVault5 vault = new EdmVault5(); vault.LoginAuto(vaulName, 0); return(vault.RootFolderPath); } catch (Exception exception) { MessageBox.Show(exception.Message + "\n" + exception.StackTrace); return(null); } }
/// <summary> /// 【1】判断PDM是否登录,并返回根目录 /// </summary> public static string LoginPDM() { EdmVault5 vault5 = new EdmVault5(); if (!vault5.IsLoggedIn) { vault5.LoginAuto(VaultName, new Control().Handle.ToInt32()); } if (!vault5.IsLoggedIn) { MessageBox.Show("请先登录PDM系统!", "提示信息"); } return(RootPath = vault5.RootFolderPath.ToString()); }
public static void SetVault(string vaultName) { if (!string.IsNullOrEmpty(vaultName)) { VaultName = vaultName; _edmVault5 = null; } if (_edmVault5 == null) { _edmVault5 = new EdmVault5(); if (!_edmVault5.IsLoggedIn) { _edmVault5.LoginAuto(VaultName, 0); } } }
/// <summary> /// 【4.3】取消捡出指定文件 /// </summary> /// <param name="filepath">文件全名(包含路径)</param> public static void CancelCheckOut(string filepath) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile11 aFile = default(IEdmFile11); IEdmFolder5 ppoRetParentFolder; if (filepath.Length > 0) { aFile = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); aFile.UndoLockFile(new System.Windows.Forms.Control().Handle.ToInt32()); } }
//判断PDM是否登录,返回布尔值True/False public static bool IsLoginPDM() { //判断PDM是否登录 try { EdmVault5 vault5 = new EdmVault5(); if (!vault5.IsLoggedIn) { vault5.LoginAuto(VaultName, new Control().Handle.ToInt32()); } return(true); } catch (Exception ex) { throw new Exception("PDM未登录或已注销,请重新登录!" + "\r\n" + ex.Message); } }
/// <summary> /// 【4.4】文件是否被检入,true为检出状态。false为检入状态 /// </summary> /// <param name="filepath">文件全名(包含路径)</param> /// <returns></returns> public static bool IsLock(string filepath) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile11 aFile = default(IEdmFile11); IEdmFolder5 ppoRetParentFolder; if (filepath.Length > 0) { aFile = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); } return(aFile.IsLocked); }
/// <summary> /// 【2.1】根据路径获取ID /// </summary> /// <param name="filepath">文件路径(包含文件名)</param> /// <returns></returns> public static int GetFileID(string filepath) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile11 aFile = default(IEdmFile11); IEdmFolder5 ppoRetParentFolder; if (filepath.Length > 0) { aFile = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); //aFile.UnlockFile(new System.Windows.Forms.Control().Handle.ToInt32(), ""); } return(aFile.ID); }
private void PdmLogin(object Val1) { try { //Create a file vault interface and log into a vault IEdmVault5 vault = new EdmVault5(); vault.LoginAuto("CDI Controlled Documents", 32); SearchFiles(vault, Val1); } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + "\n" + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 获取当前的视图集合 /// </summary> /// <param name="_dictionaryName">字典名称,例如:SWClient</param> /// <param name="_keyName">键名称,例如:SWAddinsClientVersion</param> /// <returns>视图集合</returns> public static string GetDictionary(string _dictionaryName, string _keyName) { IEdmVault5 vault5 = new EdmVault5(); try { vault5.LoginAuto(VaultName, new Control().Handle.ToInt32()); } catch (Exception e) { throw e; } IEdmDictionary5 dic = vault5.GetDictionary(_dictionaryName, false); string value; dic.StringGetAt(_keyName, out value); //修改SOLIDWORKS插件版本信息 //dic.StringSetAt(_keyName, "1.3.0.2"); return(value); }
private void OnTaskRun(ref EdmCmd poCmd, ref EdmCmdData[] ppoData) { IEdmTaskInstance inst = default(IEdmTaskInstance); inst = (IEdmTaskInstance)poCmd.mpoExtra; IEdmVault5 vault = new EdmVault5(); try { for (int i = 0; i < ppoData.Length; i++) { if (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1 != 0) { vault = (IEdmVault5)poCmd.mpoVault; IEdmObject5 folderObject = vault.GetObject(EdmObjectType.EdmObject_Folder, ((EdmCmdData)ppoData.GetValue(i)).mlObjectID2); IEdmFolder5 ef = (IEdmFolder5)folderObject; IEdmObject5 fileObject = vault.GetObject(EdmObjectType.EdmObject_File, ((EdmCmdData)ppoData.GetValue(i)).mlObjectID1); string fullpath = ef.LocalPath + "\\" + fileObject.Name; DxfLoad dxfl = new DxfLoad(); var sp = dxfl.GetSpecification(fullpath, ""); dxfl.UpLoadDxf(sp); XmlFile xf = new XmlFile(); xf.DownloadXml(fullpath); } SolidWorksPdmAdapter.Instance.KillProcsses("SLDWORKS"); MessageObserver.Instance.SetMessage("End upload.\n"); } } catch (System.Runtime.InteropServices.COMException ex) { inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, ex.ErrorCode, "The test task failed!"); } catch (Exception ex) { MessageObserver.Instance.SetMessage(ex.Message); } }
private void OnMenu(ref EdmCmd poCmd, ref EdmCmdData[] ppoData) { try { Logger.Instance.RootDirectory = tempAppFolder; MessageObserver.Instance.ReceivedMessage += Program.Instance_ReceivedMessage; for (int i = 0; i < ppoData.Length; i++) { if (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1 != 0) { IEdmVault5 vault = new EdmVault5(); vault = (IEdmVault5)poCmd.mpoVault; IEdmObject5 folderObject = vault.GetObject(EdmObjectType.EdmObject_Folder, ((EdmCmdData)ppoData.GetValue(i)).mlObjectID3); IEdmFolder5 ef = (IEdmFolder5)folderObject; IEdmObject5 fileObject = vault.GetObject(EdmObjectType.EdmObject_File, ((EdmCmdData)ppoData.GetValue(i)).mlObjectID1); string fullpath = ef.LocalPath + "\\" + fileObject.Name; DxfLoad dxfl = new DxfLoad(); var sp = dxfl.GetSpecification(fullpath, ""); dxfl.UpLoadDxf(sp); //XmlFile xf = new XmlFile(); //xf.DownloadXml(fullpath); } SolidWorksPdmAdapter.Instance.KillProcsses("SLDWORKS"); //MessageObserver.Instance.SetMessage("End upload.\n"); } } catch (Exception ex) { MessageObserver.Instance.SetMessage(ex.Message); throw; } }
private string getVaultRootPath() { string path = null; try { IEdmVault5 vault = new EdmVault5(); vault.Login(_UserName, _Password, _VaultName); path = vault.RootFolderPath; path = vault.RootFolderPath.ToLower(); if (path.LastIndexOf(Path.DirectorySeparatorChar) != path.Length - 1) { path += Path.DirectorySeparatorChar; } } catch (Exception ex) { MessageBox.Show("库登录失败!"); } return(path); }
/// <summary> /// 【6】pdm库内复制文件,返回pdm中文件全路径(包含文件名) /// </summary> /// <param name="oldFile">旧文件位置</param> /// <param name="newFolder">新文件夹位置</param> public static string CopyFile(string oldFile, string newFolder) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile10 file = default(IEdmFile10); IEdmFolder5 ppoRetParentFolder; file = (IEdmFile11)vault2.GetFileFromPath(oldFile, out ppoRetParentFolder); IEdmFolder5 destFolder1 = default(IEdmFolder5); destFolder1 = vault2.GetFolderFromPath(newFolder);//新文件夹位置 IEdmFolder8 destFolder = (IEdmFolder8)destFolder1; int FileID = 0; int copyFileStatus; FileID = destFolder.CopyFile2(file.ID, ppoRetParentFolder.ID, new Control().Handle.ToInt32(), out copyFileStatus, "", (int)EdmCopyFlag.EdmCpy_Simple); return(destFolder1.LocalPath + "\\" + file.Name.Substring(file.Name.LastIndexOf('\\') + 1)); }
private static LoginResult Login(string vaultName, string userName, string password, out IEdmVault5 vault) { LoginResult retCode = ResultCodes.LoginResult.OK; vault = null; try { vault = new EdmVault5(); vault.Login(userName, password, vaultName); } catch (System.Runtime.InteropServices.COMException ex) { switch (ex.ErrorCode) { case (int)EdmResultErrorCodes_e.E_EDM_LOGIN_FAILED: retCode = ResultCodes.LoginResult.LOGIN_FAILED; break; case (int)EdmResultErrorCodes_e.E_EDM_CANT_OPEN_DATABASE: retCode = ResultCodes.LoginResult.CANT_OPEN_DATABASE; break; case -2147221164: //没有注册类 retCode = ResultCodes.LoginResult.PDM_CLIENT_DOESNT_EXIST; break; default: retCode = ResultCodes.LoginResult.UNKNOWN_ERROR; break; } } catch (Exception ex) { retCode = ResultCodes.LoginResult.UNKNOWN_ERROR; } return(retCode); }
void CheckPdmVault() { try { if (_edmVault5 == null) { _edmVault5 = new EdmVault5(); } _edmVault7 = _edmVault5; var ok = _edmVault5.IsLoggedIn; if (!ok) { _edmVault5.LoginAuto("Vents-PDM", 0); } } catch (Exception) { // ignored } }
private void LoginToEPDM() { if (vault5 == null) { vault5 = new EdmVault5(); vault7 = (IEdmVault7)vault5; } if (!vault5.IsLoggedIn) { try { vault5.LoginAuto("Production Vault", this.Handle.ToInt32()); } catch { MessageBox.Show("The Production Vault is Currently Unavailable"); return; } } validUser = CheckUser(); }
/// <summary> /// 【8】根据文件名称搜索路径,返回全部路径的集合,如果未搜索到返回null /// </summary> /// <param name="fileName">文件名称(不包含路径)</param> public static List <string> SearchPart(string fileName) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmSearch5 Search = (IEdmSearch5)vault2.CreateUtility(EdmUtility.EdmUtil_Search); Search.FileName = "%" + fileName + "%"; //模糊搜索 //Search.FileName = fileName;//命名搜索 IEdmSearchResult5 Result = Search.GetFirstResult(); //搜索第一个 List <string> lst = new List <string>(); //string filePath = string.Empty; while (Result != null) { lst.Add(Result.Path); Result = Search.GetNextResult();//搜索下一个 } return(lst); }
/// <summary> /// 【3】将文件添加到库中指定位置——导入,并返回pdm中文件全路径(包含文件名) /// </summary> /// <param name="FullName">要复制库外文件路径和名称</param> /// <param name="path">库中根目录下具体位置,如“\\03标准规范\\05技术通知单”</param> /// <returns></returns> public static string AddFile(string FullName, string path) { IEdmVault5 vault1 = new EdmVault5(); IEdmVault7 vault2 = (IEdmVault7)vault1; vault1.Login(LogName, PWD, VaultName);//使用管理员登录每个用户不同 // Add selected file to the root folder of the vault IEdmFolder5 Folder = default(IEdmFolder8); Folder = (IEdmFolder8)vault2.RootFolder; Folder = vault2.GetFolderFromPath(Folder.LocalPath + path); string name = FullName.Substring(FullName.LastIndexOf("\\") + 1); if (File.Exists(Folder.LocalPath + "\\" + name)) { MessageBox.Show("文件已经存在,请更改文件名称!", "提示信息"); return(""); } else { Folder.AddFile(new System.Windows.Forms.Control().Handle.ToInt32(), FullName, "", 0); } return(Folder.LocalPath + "\\" + name); }
/// <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 void ProcessTableAnn(BomTableAnnotation swBOMTableAnn, string ConfigName, SldAsm asmPrd) { int nNumRow = 0; string ItemNumber = null; string PartNumber = null; TableAnnotation swTableAnn = (TableAnnotation)swBOMTableAnn; Console.WriteLine(" Table Title " + swTableAnn.Title); IEdmVault5 vault = new EdmVault5(); vault.LoginAuto("科德研发部", 0); if (!vault.IsLoggedIn) { Console.WriteLine("登录PDM失败"); return; } nNumRow = swTableAnn.RowCount; swBOMTableAnn = (BomTableAnnotation)swTableAnn; for (int j = 0; j < swTableAnn.RowCount; j++) { // //for (int i = 0; i < swTableAnn.ColumnCount;i++ ) // Console.WriteLine(swTableAnn.get_Text(j, i)); //获取类别和特有信息 //if (j == swTableAnn.RowCount - 1)//最后一行为标题栏,跳过 // continue; string filePath = ""; string compName = ""; string compConfig = ""; int compCount = swBOMTableAnn.GetComponentsCount2(j, ConfigName, out ItemNumber, out PartNumber); for (int i = 0; i < compCount; i++) { Component2 comp2 = swBOMTableAnn.IGetComponents2(j, ConfigName, i); if (comp2 != null) { filePath = comp2.GetPathName(); compName = comp2.Name2; compConfig = comp2.ReferencedConfiguration; Console.WriteLine(" Component Name :" + comp2.Name2 + " Configuration Name : " + comp2.ReferencedConfiguration); Console.WriteLine(" Component Path :" + comp2.GetPathName()); } } if (filePath == "") { continue; } SldBsp bsp = GetSldPrdInfoFromFile(vault, filePath); if (bsp == null) { continue; } bsp.path = filePath; //SldBsp bsp = new SldBsp(); swTableAnn.get_Text(j, 0); //序号 bsp.number = swTableAnn.get_Text(j, 1); //代号 bsp.name = swTableAnn.get_Text(j, 2); //名称 string amout = swTableAnn.get_Text(j, 3); bsp.amout = amout == ""?0:int.Parse(amout); //数量 bsp.material = swTableAnn.get_Text(j, 4); //材料 string weight = swTableAnn.get_Text(j, 5); bsp.weight = weight == "" ? 0 : int.Parse(weight); //单重 bsp.totalWeight = bsp.weight * bsp.amout; // swTableAnn.get_Text(j, 6);//总重 bsp.remark = swTableAnn.get_Text(j, 7); //备注 string number = swTableAnn.get_Text(j, 8); //测试 if (bsp.number == "") { bsp.number = number; } if (bsp is SldPrt) { asmPrd.sldPrtList.Add((SldPrt)bsp); } else if (bsp is SldStd) { asmPrd.sldStdList.Add((SldStd)bsp); } else if (bsp is SldBuy) { asmPrd.sldBuyList.Add((SldBuy)bsp); } } return; }
public IEdmVault7 LogInVault() { EdmVault5 vault = new EdmVault5(); vault.LoginAuto("NORCO_PDM", 0); return vault; }
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 BatchAddFiles(List<VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5) { goto m1; #region Dll var edmVault7 = (IEdmVault7)edmVault5; AddinConvertTo.Classes.Batches.BatchAddFiles(edmVault7, ConvertVentsCadFiles(filesList)); return; #endregion m1: #region Code List<string> stringList = new List<string>(); #region Show // filesList.Select(x => x.LocalPartFileInfo).ToList(); //MessageBox.Show(stringList.Count.ToString(), "Count before"); //stringList = stringList.Distinct().ToList(); //MessageBox.Show(stringList.Count.ToString(), "Count after 2"); #endregion foreach (var item in filesList.OrderBy(x=>x.LocalPartFileInfo)) { var inf = new FileInfo(item.LocalPartFileInfo); if (stringList.Contains(inf.Name)) continue; stringList.Add(inf.FullName); } var files = ""; foreach (var file in stringList.Distinct()) { files = files + "\n" + file; } files = ""; try { var poAdder = (IEdmBatchAdd2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchAdd); foreach (var file in stringList.Distinct()) { var fileInfo = new FileInfo(file); var directoryName = fileInfo.Directory.FullName; files = files + $"\n File - {fileInfo.FullName} directory - {directoryName}"; poAdder.AddFileFromPathToPath(fileInfo.FullName, directoryName); } try { //MessageBox.Show(poAdder.CommitAdd(0, null).ToString()); poAdder.CommitAdd(-1, null); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm"); //MessageBox.Show(e.Message + "\n" + e.StackTrace, "2"); } } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm"); //MessageBox.Show(e.StackTrace, "BatchAddFiles"); } finally { //MessageBox.Show(files); } #endregion }
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); } }
void CheckPdmVault() { try { if (Vault1 == null) { Vault1 = new EdmVault5(); } Vault2 = (IEdmVault7)Vault1; var ok = Vault1.IsLoggedIn; if (!ok) { Vault1.LoginAuto("Vents-PDM", 0); } } catch (Exception ex) { MessageBox.Show(ex.Message + "; " + ex.StackTrace); } }