/// <summary> /// 初始化PCDmis应用,并设置APPEVENT事件 /// </summary> public void InitialPCDmis() { ClosePCDmis(); //try //{ _pcdApplication = null; _pcdProgramManager = null; _pcdAppEvents = null; Type t = Type.GetTypeFromProgID("PCDLRN.Application"); SetPCDmisOffline(t); //是否以离线方式启动PCDMIS _pcdApplication = (PCDLRN.Application)Activator.CreateInstance(t); _pcdApplication.UserExit = true; // 用户无法手动退出PCDMIS _IsInitialed = _pcdApplication.WaitUntilReady((int)_timeout.TotalSeconds); // 等待初始化完成 Thread.Sleep(5000); // 等待PCDmils创建完成 _pcdApplication.Visible = true; _pcdProgramManager = _pcdApplication.PartPrograms; _pcdAppEvents = _pcdApplication.ApplicationEvents; _pcdAppEvents.OnCloseExecutionDialog += _pcdAppEvents_OnCloseExecutionDialog; _pcdAppEvents.OnClosePartProgram += _pcdAppEvents_OnClosePartProgram; _pcdAppEvents.OnSavePartProgram += _pcdAppEvents_OnSavePartProgram; _pcdApplication.SetActive(); _IsInitialed = true; //} //catch (Exception ex) //{ // // 启动失败的处理方式 // throw ex; //} }
/// <summary> /// 开启并初始化PCDMIS /// </summary> public void InitialPCDmis() { // 关闭先前的PCDMIS ClosePCDmis(); try { Type t = Type.GetTypeFromProgID("PCDLRN.Application"); //SetPCDmisOffline(t); //是否以离线方式启动PCDMIS _pcdApp = (PCDLRN.Application)Activator.CreateInstance(t); _pcdApp.UserExit = false; _pcdApp.Visible = true; if (_pcdApp.SetActive()) { _pcdApp.Maximize(); } _partPrograms = _pcdApp.PartPrograms; _pcdAppEvents = _pcdApp.ApplicationEvents; _pcdAppEvents.OnCloseExecutionDialog += _pcdAppEvents_OnCloseExecutionDialog;; } catch (Exception ex) { // 启动失败的处理方式 } _IsInitialed = true; }