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(); } } }
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; } }