Пример #1
0
 //Close Expedition
 private void CloseExpedition()
 {
     if (pcbDoc != null)
     {
         if (pcbDoc.Save())
         {
             Thread.Sleep(1000);
             WriteLog(MsgSvr.Info, "Saving Document ...\t Done !");
         }
         else
         {
             WriteLog(MsgSvr.Err, "Saving Document ...\t Failed !");
         }
         if (pcbDoc.Close(true))
         {
             Thread.Sleep(1000);
             WriteLog(MsgSvr.Info, "Closing Document ...\t Done !");
         }
         else
         {
             WriteLog(MsgSvr.Err, "Closing Document ...\t Failed !");
         }
         pcbDoc = null;
     }
     else
     {
         WriteLog(MsgSvr.Err, "Closing Document ...\t Error !");
     }
     if (pcbApp != null)
     {
         pcbApp.Quit();
         Thread.Sleep(1000);
         pcbApp = null;
         WriteLog(MsgSvr.Info, "Closing Application ...\t Done !");
     }
     else
     {
         WriteLog(MsgSvr.Err, "Closing Application ...\t Failed !");
     }
 }
Пример #2
0
 //Open Expedition
 private void OpenExpedition()
 {
     //WriteLog(MsgSvr.Info, "Openning Expedition ... ...");
     if (flag != 0)
     {
         try
         {
             pcbApp = (MGCPCB.ExpeditionPCBApplication)Microsoft.VisualBasic.Interaction.GetObject(null, "MGCPCB.ExpeditionPCBApplication");
         }
         catch (Exception ex)
         {
             string msg = "Getting Expedition Instance Error !";
             msg += ex.ToString();
             WriteLog(MsgSvr.Err, msg);
         }
         Thread.Sleep(1000);
         try
         {
             pcbDoc = pcbApp.ActiveDocument;
         }
         catch (Exception ex)
         {
             string msg = "Opening Document Error :\r\n";
             msg += ex.ToString();
             WriteLog(MsgSvr.Err, msg);
             //pcbApp.Quit();
         }
     }
     else
     {
         try
         {
             System.Type t = System.Type.GetTypeFromProgID("MGCPCB.ExpeditionPCBApplication");
             pcbApp = (MGCPCB.ExpeditionPCBApplication)System.Activator.CreateInstance(t);
         }
         catch (Exception ex)
         {
             string msg = "Creating Expedition Instance Error !";
             msg += ex.ToString();
             WriteLog(MsgSvr.Err, msg);
         }
         Thread.Sleep(1000);
         try
         {
             pcbDoc = pcbApp.OpenDocument(strPcbDocPath);
         }
         catch (Exception ex)
         {
             string msg = "Opening Document Error :\r\n";
             msg += ex.ToString();
             WriteLog(MsgSvr.Err, msg);
             pcbApp.Quit();
         }
     }
     if (this.ValidateServer())
     {
         pcbApp.UnlockServer(true);
         pcbApp.Gui.ActiveMode = EPcbMode.epcbModePlace;
         pcbApp.Visible        = true;
         pcbApp.Gui.CursorBusy(false);
         pcbApp.Gui.SuppressTrivialDialogs = true;
         //compsCollection = pcbDoc.get_Components(EPcbSelectionType.epcbSelectAll, EPcbComponentType.epcbCompGeneral, EPcbCelltype.epcbCelltypePackage, "");
         //netsCollection = pcbDoc.get_Nets(EPcbSelectionType.epcbSelectAll, true, "");
         //此处需将所有网络,器件全部统计归集到集合里面再做处理
         pcbDoc.OnSelectionChange += new _IMGCPCBDocumentEvents_OnSelectionChangeEventHandler(OnSelectionChange);
         pcbDoc.OnPreClose        += new _IMGCPCBDocumentEvents_OnPreCloseEventHandler(OnPreClose);
     }
     else
     {
         WriteLog(MsgSvr.Err, "Failed to Validate PCB Document !");
     }
 }