public void InitializeLabel()
        {
            try
            {
                FixInsNo.Text = workPart.GetStringAttribute("PARTNUMBERPOS");
                ERPNo.Text    = workPart.GetStringAttribute("ERPCODEPOS");
                Desc.Text     = workPart.GetStringAttribute("PARTDESCRIPTIONPOS");

                this.ExportPDF.Checked = true;

                this.Is_Local = Environment.GetEnvironmentVariable("UGII_ENV_FILE");
                if (this.Is_Local != null)
                {
                    CaxAsm.GetRootAssemblyPart(FixInsUploadDlg.workPart.Tag, out FixInsUploadDlg.rootPart);
                    //string directoryName = Path.GetDirectoryName(FixInsUploadDlg.rootPart.FullPath);
                    char[] chrArray = new char[] { '\\' };
                    //this.splitFullPath = directoryName.Split(chrArray);
                    if (this.Is_Local.Contains("ME"))
                    {
                        cCaxMEUpLoad = new CaxMEUpLoad();
                        cCaxMEUpLoad.SplitMEFixInsPartFullPath(FixInsUploadDlg.rootPart.FullPath);
                        cCaxUpLoad = cCaxMEUpLoad;
                    }
                    else if (this.Is_Local.Contains("TE"))
                    {
                        cCaxTEUpLoad = new CaxTEUpLoad();
                        cCaxTEUpLoad.SplitTEFixInsPartFullPath(FixInsUploadDlg.rootPart.FullPath);
                        cCaxUpLoad = cCaxTEUpLoad;
                    }
                    this.L_Folder = string.Format(@"{0}\OP{1}\OIS\{2}", Path.GetDirectoryName(FixInsUploadDlg.workPart.FullPath), cCaxUpLoad.OpNum, Path.GetFileNameWithoutExtension(FixInsUploadDlg.workPart.FullPath));
                    if (!Directory.Exists(this.L_Folder))
                    {
                        Directory.CreateDirectory(this.L_Folder);
                    }
                    object[] globaltekTaskDir = new object[] { CaxEnv.GetGlobaltekTaskDir(), cCaxUpLoad.CusName, cCaxUpLoad.PartName, cCaxUpLoad.CusRev, cCaxUpLoad.OpRev, cCaxUpLoad.OpNum, Path.GetFileNameWithoutExtension(FixInsUploadDlg.workPart.FullPath) };
                    this.S_Folder = string.Format(@"{0}\{1}\{2}\{3}\{4}\OP{5}\OIS\{6}", globaltekTaskDir);
                }
                else
                {
                    MessageBox.Show("請使用系統環境開啟NX,並確認此料號是由系統建立");
                    base.Close();
                }

                /*
                 * //由檔案路徑拆出:料號、客戶版次、製程版次、OP
                 * splitFullPath = Path.GetDirectoryName(workPart.FullPath).Split('\\');
                 * op1 = Path.GetFileNameWithoutExtension(workPart.FullPath).Split(new string[] { "OIS" }, StringSplitOptions.RemoveEmptyEntries)[1];
                 * op1 = op1.Substring(0, 3);
                 *
                 * //建立SERVER圖片目錄
                 * S_Folder = string.Format(@"{0}\{1}\{2}\{3}\{4}\OP{5}\OIS\{6}", CaxEnv.GetGlobaltekTaskDir(), splitFullPath[3], splitFullPath[4], splitFullPath[5], splitFullPath[6], op1, Path.GetFileNameWithoutExtension(workPart.FullPath));
                 */
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("請先執行【檢、治具】使用的PartInformation");
                this.Close();
            }
        }
Esempio n. 2
0
        private void BomListDlg_Load(object sender, EventArgs e)
        {
            try
            {
                //advTree1.BeginUpdate();

                //加入MOT總組立檔案
                Node node = new Node();
                node.Tag  = (NXOpen.Assemblies.Component)displayPart.ComponentAssembly.RootComponent;
                node.Text = Path.GetFileNameWithoutExtension(displayPart.FullPath);
                advTree1.Nodes.Add(node);
                node.ExpandVisibility = eNodeExpandVisibility.Visible;

                //加入所有子Comp
                NXOpen.Assemblies.Component        clickComp = (NXOpen.Assemblies.Component)node.Tag;
                List <NXOpen.Assemblies.Component> compAry   = new List <NXOpen.Assemblies.Component>();
                status = CaxAsm.GetCompChildren(clickComp, ref compAry, false);
                if (!status)
                {
                    MessageBox.Show("尋找子Component失敗,請聯繫開發工程師");
                    this.Close();
                }

                foreach (NXOpen.Assemblies.Component i in compAry)
                {
                    status = InsertSubComponent(node, i);
                    if (!status)
                    {
                        MessageBox.Show("插入子Component失敗,請聯繫開發工程師");
                        this.Close();
                    }
                }

                //比對歷史BomList,並將新增的零件上紅色



                //advTree1.EndUpdate();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 3
0
        public static bool GetComponentPath(Part displayPart, METE_Download_Upload_Path cMETE_Download_Upload_Path, ListView listView1, ref Dictionary <string, PartDirData> DicPartDirData)
        {
            try
            {
                PartDirData sPartDirData = new PartDirData();
                sPartDirData.PartLocalDir   = displayPart.FullPath;
                sPartDirData.PartServer1Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, Path.GetFileName(displayPart.FullPath));
                //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
                DicPartDirData.Add(Path.GetFileNameWithoutExtension(displayPart.FullPath), sPartDirData);
                listView1.Items.Add(Path.GetFileName(displayPart.FullPath));

                NXOpen.Assemblies.ComponentAssembly casm             = displayPart.ComponentAssembly;
                List <NXOpen.Assemblies.Component>  ListChildrenComp = new List <NXOpen.Assemblies.Component>();
                CaxAsm.GetCompChildren(casm.RootComponent, ref ListChildrenComp);
                foreach (NXOpen.Assemblies.Component i in ListChildrenComp)
                {
                    string ServerPartPath = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, i.DisplayName + ".prt");

                    if (!DicPartDirData.TryGetValue(i.DisplayName, out sPartDirData))
                    {
                        sPartDirData = sPartDirData = new PartDirData();
                        if (!File.Exists(string.Format(@"{0}\{1}", Path.GetDirectoryName(displayPart.FullPath), i.DisplayName + ".prt")))
                        {
                            MessageBox.Show("零件:" + i.DisplayName + "找不到,請檢察本機資料夾是否存在");
                            return(false);
                        }
                        sPartDirData.PartLocalDir   = string.Format(@"{0}\{1}", Path.GetDirectoryName(displayPart.FullPath), i.DisplayName + ".prt");
                        sPartDirData.PartServer1Dir = ServerPartPath;
                        DicPartDirData.Add(i.DisplayName, sPartDirData);
                        listView1.Items.Add(i.DisplayName + ".prt");
                    }
                    //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
                }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        //插入子Comp,如果
        private bool InsertSubComponent(Node parent, NXOpen.Assemblies.Component comp)
        {
            try
            {
                List <NXOpen.Assemblies.Component> childrenCompAry = new List <NXOpen.Assemblies.Component>();
                CaxAsm.GetCompChildren(comp, ref childrenCompAry, false);

                Node node = new Node();
                node.Tag  = (NXOpen.Assemblies.Component)NXObjectManager.Get(comp.Tag);
                node.Text = Path.GetFileNameWithoutExtension(comp.DisplayName);
                //node.Style = new ElementStyle();
                //node.Style.TextColor = Color.Red;
                node.CheckBoxVisible = true;

                //判斷搜出來的子comp是否還有他的子comp,如果有就加入"+"符號,如果沒有表示最後一階層
                if (childrenCompAry.Count > 0)
                {
                    node.ExpandVisibility = eNodeExpandVisibility.Visible;
                }
                parent.Nodes.Add(node);

                foreach (NXOpen.Assemblies.Component i in childrenCompAry)
                {
                    status = InsertSubComponent(node, i);
                    if (!status)
                    {
                        MessageBox.Show("插入子Component失敗,請聯繫開發工程師");
                        this.Close();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        public static bool PartFilePath(Part displayPart, PartInfo sPartInfo, System.Windows.Forms.ListView listView1, out Dictionary <string, TEUpload.TEUploadDlg.PartDirData> DicPartDirData)
        {
            DicPartDirData = new Dictionary <string, TEUpload.TEUploadDlg.PartDirData>();
            try
            {
                //總組立
                TEUpload.TEUploadDlg.PartDirData sPartDirData = new TEUpload.TEUploadDlg.PartDirData();
                sPartDirData.PartLocalDir   = displayPart.FullPath;
                sPartDirData.PartServer1Dir = string.Format(@"{0}\{1}", TEUploadDlg.cMETE_Download_Upload_Path.Server_ShareStr, Path.GetFileName(displayPart.FullPath));
                DicPartDirData.Add(Path.GetFileNameWithoutExtension(displayPart.FullPath), sPartDirData);
                listView1.Items.Add(Path.GetFileName(displayPart.FullPath));

                //子Comp
                NXOpen.Assemblies.ComponentAssembly casm             = displayPart.ComponentAssembly;
                List <NXOpen.Assemblies.Component>  ListChildrenComp = new List <NXOpen.Assemblies.Component>();
                CaxAsm.GetCompChildren(casm.RootComponent, ref ListChildrenComp);
                foreach (NXOpen.Assemblies.Component i in ListChildrenComp)
                {
                    string ServerPartPath = string.Format(@"{0}\{1}", TEUploadDlg.cMETE_Download_Upload_Path.Server_ShareStr, i.DisplayName + ".prt");

                    if (!DicPartDirData.TryGetValue(i.DisplayName, out sPartDirData))
                    {
                        sPartDirData = new TEUpload.TEUploadDlg.PartDirData();
                        sPartDirData.PartLocalDir   = string.Format(@"{0}\{1}", Path.GetDirectoryName(displayPart.FullPath), i.DisplayName + ".prt");
                        sPartDirData.PartServer1Dir = ServerPartPath;
                        DicPartDirData.Add(i.DisplayName, sPartDirData);
                        listView1.Items.Add(i.DisplayName + ".prt");
                    }
                    //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
                }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 6
0
        private void buttonOpenTask_Click(object sender, EventArgs e)
        {
            #region 檢查是否有選擇組裝方式

            if (SeleOperValue == "001")
            {
                if (check001HasBillet.Checked == false && check001NoBillet.Checked == false)
                {
                    MessageBox.Show("請選擇一種組裝方式");
                    return;
                }
                if (check001HasBillet.Checked == true && check001NoBillet.Checked == false)
                {
                    if (label001.Text == "")
                    {
                        MessageBox.Show("請選擇一個零件當作胚料檔,或勾選無胚料檔");
                        return;
                    }
                }
            }
            else if (SeleOperValue == "900")
            {
            }
            else
            {
                if (checkWHasBillet.Checked == false && checkWNoBillet.Checked == false)
                {
                    MessageBox.Show("請選擇一種組裝方式");
                    return;
                }
                if (checkWHasBillet.Checked == true && checkWHasBillet.Checked == false)
                {
                    if (labelW.Text == "")
                    {
                        MessageBox.Show("請選擇一個前段工序檔當作此工序零件檔,或勾選無前段工序檔");
                        return;
                    }
                }
            }

            #endregion

            string Local_CAMPartFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}", CaxEnv.GetLocalTaskDir(),
                                                         CurrentCusName,
                                                         CurrentPartNo,
                                                         CurrentCusVer,
                                                         SelePartName);
            string Local_ModelPartFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetLocalTaskDir(),
                                                           CurrentCusName,
                                                           CurrentPartNo,
                                                           CurrentCusVer,
                                                           "MODEL",
                                                           CurrentPartNo + ".prt");
            string Local_ShareStrPartFullPath = string.Format(@"{0}\{1}\{2}\{3}", CaxEnv.GetLocalTaskDir(),
                                                              CurrentCusName,
                                                              CurrentPartNo,
                                                              CurrentCusVer);
            //組件存在,直接開啟任務組立
            BasePart newAsmPart;
            status = CaxPart.OpenBaseDisplay(Local_CAMPartFullPath, out newAsmPart);
            if (!status)
            {
                CaxLog.ShowListingWindow("組立開啟失敗!");
                return;
            }

            //判斷組件是否曾經被開啟。如已被開啟過,則開啟檔案後離開;反之則塞上屬性(Title=IsOpend,Value=Y)並組裝客戶零件與胚料零件
            string checkIsOpened = "";
            try
            {
                checkIsOpened = newAsmPart.GetStringAttribute("IsOpened");
                if (checkIsOpened == "Y")
                {
                    CaxPart.Save();
                    this.Close();
                    return;
                }
            }
            catch (System.Exception ex)
            {
                newAsmPart.SetAttribute("IsOpened", "Y");
            }

            NXOpen.Assemblies.Component newComponent = null;

            #region 組裝客戶檔案

            string Local_NewModelPartFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}", CaxEnv.GetLocalTaskDir(),
                                                              CurrentCusName,
                                                              CurrentPartNo,
                                                              CurrentCusVer,
                                                              CurrentPartNo + ".prt");
            //判斷是否已經有客戶檔案,如果沒有則複製過來
            if (!System.IO.File.Exists(Local_NewModelPartFullPath))
            {
                File.Copy(Local_ModelPartFullPath, Local_NewModelPartFullPath, true);
            }

            status = CaxAsm.AddComponentToAsmByDefault(Local_NewModelPartFullPath, out newComponent);
            if (!status)
            {
                CaxLog.ShowListingWindow("ERROR,組裝失敗!");
                return;
            }

            #endregion

            CaxAsm.SetWorkComponent(null);

            #region 建立二階製程檔

            string Local_CurrentOperPartFullPath = "";
            if (groupBox001.Enabled == true)
            {
                if (check001NoBillet.Checked == true)
                {
                    //選擇無胚料檔--新建檔案(檔名:料號+製程序)
                    Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, CurrentPartNo + "_TE_" + SeleOperValue + ".prt");
                    if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
                    {
                        status = CaxAsm.CreateNewEmptyComp(Local_CurrentOperPartFullPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立二階製程檔失敗");
                            return;
                        }
                    }
                }
                else
                {
                    //選擇有胚料檔--組裝胚料檔(檔名:胚料檔原始名稱)
                    Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, label001.Text);
                    if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
                    {
                        status = CaxAsm.AddComponentToAsmByDefault(Local_CurrentOperPartFullPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("001胚料檔組裝失敗");
                            return;
                        }
                    }
                }
            }
            else if (groupBox900.Enabled == true)
            {
            }
            else
            {
                if (checkWNoBillet.Checked == true)
                {
                    //選擇無胚料檔--新建檔案(檔名:料號+製程序)
                    Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, CurrentPartNo + "_TE_" + SeleOperValue + ".prt");
                    if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
                    {
                        status = CaxAsm.CreateNewEmptyComp(Local_CurrentOperPartFullPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立二階製程檔失敗");
                            return;
                        }
                    }
                }
                else
                {
                    //選擇有胚料檔--組裝胚料檔(檔名:胚料檔原始名稱)
                    Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, labelW.Text);
                    if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
                    {
                        status = CaxAsm.AddComponentToAsmByDefault(Local_CurrentOperPartFullPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("W階胚料檔組裝失敗");
                            return;
                        }
                    }
                }
            }

            #endregion

            CaxPart.Save();
            this.Close();
        }
Esempio n. 7
0
        private void buttonOpenTask_Click(object sender, EventArgs e)
        {
            #region (註解)檢查是否有選擇組裝方式

            /*
             * if (SeleOperValue == "001")
             * {
             *  if (check001HasBillet.Checked == false && check001NoBillet.Checked == false)
             *  {
             *      MessageBox.Show("請選擇一種組裝方式");
             *      return;
             *  }
             *  if (check001HasBillet.Checked == true && check001NoBillet.Checked == false)
             *  {
             *      if (label001.Text == "")
             *      {
             *          MessageBox.Show("請選擇一個零件當作胚料檔,或勾選無胚料檔");
             *          return;
             *      }
             *  }
             * }
             * else if (SeleOperValue == "900")
             * {
             *
             * }
             * else
             * {
             *  if (checkWHasBillet.Checked == false && checkWNoBillet.Checked == false)
             *  {
             *      MessageBox.Show("請選擇一種組裝方式");
             *      return;
             *  }
             *  if (checkWHasBillet.Checked == true && checkWHasBillet.Checked == false)
             *  {
             *      if (labelW.Text == "")
             *      {
             *          MessageBox.Show("請選擇一個前段工序檔當作此工序零件檔,或勾選無前段工序檔");
             *          return;
             *      }
             *  }
             * }
             */
            #endregion

            string Local_CAMPartFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetLocalTaskDir(),
                                                         CurrentCusName,
                                                         CurrentPartNo,
                                                         CurrentCusVer,
                                                         CurrentOpVer,
                                                         SelePartName);

            string Local_ModelPartFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}\{6}", CaxEnv.GetLocalTaskDir(),
                                                           CurrentCusName,
                                                           CurrentPartNo,
                                                           CurrentCusVer,
                                                           CurrentOpVer,
                                                           "MODEL",
                                                           CurrentPartNo + ".prt");

            string Local_ShareStrPartFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}", CaxEnv.GetLocalTaskDir(),
                                                              CurrentCusName,
                                                              CurrentPartNo,
                                                              CurrentCusVer,
                                                              CurrentOpVer);

            //組件存在,直接開啟任務組立
            BasePart newAsmPart;
            status = CaxPart.OpenBaseDisplay(Local_CAMPartFullPath, out newAsmPart);
            if (!status)
            {
                CaxLog.ShowListingWindow("組立開啟失敗!");
                return;
            }

            if (check001HasBillet.Checked == true || check001NoBillet.Checked == true ||
                checkWHasBillet.Checked == true || checkWNoBillet.Checked == true)
            {
                #region 組裝客戶檔案
                NXOpen.Assemblies.Component newComponent = null;
                string Local_NewModelPartFullPath        = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetLocalTaskDir(),
                                                                         CurrentCusName,
                                                                         CurrentPartNo,
                                                                         CurrentCusVer,
                                                                         CurrentOpVer,
                                                                         CurrentPartNo + ".prt");
                //判斷是否已經有客戶檔案,如果沒有則複製過來
                if (!System.IO.File.Exists(Local_NewModelPartFullPath))
                {
                    File.Copy(Local_ModelPartFullPath, Local_NewModelPartFullPath, true);
                }

                status = CaxAsm.AddComponentToAsmByDefault(Local_NewModelPartFullPath, out newComponent);
                if (!status)
                {
                    MessageBox.Show("客戶檔案組裝失敗!");
                    this.Close();
                    return;
                }
                #endregion

                CaxAsm.SetWorkComponent(null);

                #region 建立三階製程檔

                string Local_CurrentOperPartFullPath = "";
                if (groupBox001.Enabled == true)
                {
                    #region 001
                    //組立"胚料檔"
                    if (check001HasBillet.Checked == true & System.IO.File.Exists(label001BilletPath))
                    {
                        //複製檔案到任務資料夾
                        string tempBilletPath = label001BilletPath;
                        tempBilletPath = tempBilletPath.Replace(Path.GetDirectoryName(tempBilletPath), Path.GetDirectoryName(Local_NewModelPartFullPath));
                        File.Copy(label001BilletPath, tempBilletPath, true);

                        status = CaxAsm.AddComponentToAsmByDefault(tempBilletPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("001胚料檔組裝失敗");
                            return;
                        }
                    }

                    //組立"料號_TE_xxx"
                    Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, CurrentPartNo + "_TE_" + SeleOperValue + ".prt");
                    if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
                    {
                        status = CaxAsm.CreateNewEmptyComp(Local_CurrentOperPartFullPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立三階製程檔失敗");
                            return;
                        }
                    }
                    #endregion
                }
                else if (groupBox900.Enabled == true)
                {
                }
                else
                {
                    #region W階
                    //組立"前段製程檔"
                    if (checkWHasBillet.Checked == true & System.IO.File.Exists(labelWBilletPath))
                    {
                        //複製檔案到任務資料夾
                        string tempBilletPath = labelWBilletPath;
                        tempBilletPath = tempBilletPath.Replace(Path.GetDirectoryName(tempBilletPath), Path.GetDirectoryName(Local_NewModelPartFullPath));
                        File.Copy(labelWBilletPath, tempBilletPath, true);

                        status = CaxAsm.AddComponentToAsmByDefault(tempBilletPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("W階胚料檔組裝失敗");
                            return;
                        }
                    }

                    //組立"料號_ME_OISxxx"
                    Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, CurrentPartNo + "_TE_" + SeleOperValue + ".prt");
                    if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
                    {
                        status = CaxAsm.CreateNewEmptyComp(Local_CurrentOperPartFullPath, out newComponent);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立三階製程檔失敗");
                            return;
                        }
                    }
                    #endregion
                }

                #endregion
            }

            /*
             * //判斷組件是否曾經被開啟。如已被開啟過,則開啟檔案後離開;反之則塞上屬性(Title=IsOpend,Value=Y)並組裝客戶零件與胚料零件
             * string checkIsOpened = "";
             * try
             * {
             *  checkIsOpened = newAsmPart.GetStringAttribute("ISOPENED");
             *  if (checkIsOpened == "Y")
             *  {
             *      CaxPart.Save();
             *      this.Close();
             *      return;
             *  }
             * }
             * catch (System.Exception ex)
             * {
             *  newAsmPart.SetAttribute("ISOPENED", "Y");
             * }
             *
             * NXOpen.Assemblies.Component newComponent = null;
             *
             #region 組裝客戶檔案
             *
             * string Local_NewModelPartFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}", CaxEnv.GetLocalTaskDir(),
             *                                                                         CurrentCusName,
             *                                                                         CurrentPartNo,
             *                                                                         CurrentCusVer,
             *                                                                         CurrentPartNo + ".prt");
             * //判斷是否已經有客戶檔案,如果沒有則複製過來
             * if (!System.IO.File.Exists(Local_NewModelPartFullPath))
             * {
             *  File.Copy(Local_ModelPartFullPath, Local_NewModelPartFullPath, true);
             * }
             *
             * status = CaxAsm.AddComponentToAsmByDefault(Local_NewModelPartFullPath, out newComponent);
             * if (!status)
             * {
             *  CaxLog.ShowListingWindow("ERROR,組裝失敗!");
             *  return;
             * }
             *
             #endregion
             *
             * CaxAsm.SetWorkComponent(null);
             *
             #region 建立三階製程檔
             *
             * string Local_CurrentOperPartFullPath = "";
             * if (groupBox001.Enabled == true)
             * {
             *  if (check001NoBillet.Checked == true)
             *  {
             *      //選擇無胚料檔--新建檔案(檔名:料號_TE_製程序)
             *      Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, CurrentPartNo + "_TE_" + SeleOperValue + ".prt");
             *      if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
             *      {
             *          status = CaxAsm.CreateNewEmptyComp(Local_CurrentOperPartFullPath, out newComponent);
             *          if (!status)
             *          {
             *              CaxLog.ShowListingWindow("建立二階製程檔失敗");
             *              return;
             *          }
             *      }
             *  }
             *  else
             *  {
             *      //選擇有胚料檔--組裝胚料檔(檔名:胚料檔原始名稱)
             *      Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, label001.Text);
             *      if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
             *      {
             *          status = CaxAsm.AddComponentToAsmByDefault(Local_CurrentOperPartFullPath, out newComponent);
             *          if (!status)
             *          {
             *              CaxLog.ShowListingWindow("001胚料檔組裝失敗");
             *              return;
             *          }
             *      }
             *  }
             * }
             * else if (groupBox900.Enabled == true)
             * {
             * }
             * else
             * {
             #region W階
             *  //組立"前段製程檔"
             *  if (checkWHasBillet.Checked == true & System.IO.File.Exists(labelWBilletPath))
             *  {
             *      //複製檔案到任務資料夾
             *      string tempBilletPath = labelWBilletPath;
             *      tempBilletPath = tempBilletPath.Replace(Path.GetDirectoryName(tempBilletPath), Path.GetDirectoryName(Local_NewModelPartFullPath));
             *      File.Copy(labelWBilletPath, tempBilletPath, true);
             *
             *      status = CaxAsm.AddComponentToAsmByDefault(tempBilletPath, out newComponent);
             *      if (!status)
             *      {
             *          CaxLog.ShowListingWindow("W階胚料檔組裝失敗");
             *          return;
             *      }
             *  }
             *
             *  //選擇無前段製程檔案--新建檔案(檔名:料號_TE_製程序)
             *  Local_CurrentOperPartFullPath = string.Format(@"{0}\{1}", Local_ShareStrPartFullPath, CurrentPartNo + "_TE_" + SeleOperValue + ".prt");
             *  if (!System.IO.File.Exists(Local_CurrentOperPartFullPath))
             *  {
             *      status = CaxAsm.CreateNewEmptyComp(Local_CurrentOperPartFullPath, out newComponent);
             *      if (!status)
             *      {
             *          CaxLog.ShowListingWindow("建立三階製程檔失敗");
             *          return;
             *      }
             *  }
             #endregion
             * }
             *
             #endregion
             */

            CaxPart.Save();
            this.Close();
        }
Esempio n. 8
0
        private void MEUploadDlg_Load(object sender, EventArgs e)
        {
            //取得METEDownload_Upload.dat
            CaxGetDatData.GetMETEDownload_Upload(out cMETE_Download_Upload_Path);

            //取得料號
            PartNoLabel.Text = Path.GetFileNameWithoutExtension(displayPart.FullPath).Split('_')[0];
            OISLabel.Text    = Path.GetFileNameWithoutExtension(displayPart.FullPath).Split('_')[1];

            //將Local_Folder_OIS先暫存起來,然後改變成Server路徑
            tempLocal_Folder_OIS = cMETE_Download_Upload_Path.Local_Folder_OIS;

            CaxPublic.GetAllPath("ME", displayPart.FullPath, ref cMETE_Download_Upload_Path);

            /*
             * //拆零件路徑字串取得客戶名稱、料號、版本
             * string PartFullPath = displayPart.FullPath;
             * string[] SplitPath = PartFullPath.Split('\\');
             * PartInfo.CusName = SplitPath[3];
             * PartInfo.PartNo = SplitPath[4];
             * PartInfo.CusRev = SplitPath[5];
             * PartInfo.OpNum = Path.GetFileNameWithoutExtension(displayPart.FullPath).Split(new string[] { "OIS" }, StringSplitOptions.RemoveEmptyEntries)[1];
             *
             #region 取代Server路徑字串
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[Server_IP]", cMETE_Download_Upload_Path.Server_IP);
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[CusName]", PartInfo.CusName);
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[PartNo]", PartInfo.PartNo);
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[CusRev]", PartInfo.CusRev);
             * Server_OP_Folder = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OpNum);
             #endregion
             *
             #region 取代Local路徑字串
             * //將Local_Folder_OIS先暫存起來,然後改變成Server路徑
             * tempLocal_Folder_OIS = cMETE_Download_Upload_Path.Local_Folder_OIS;
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[Local_IP]", cMETE_Download_Upload_Path.Local_IP);
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[CusName]", PartInfo.CusName);
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[PartNo]", PartInfo.PartNo);
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[CusRev]", PartInfo.CusRev);
             * cMETE_Download_Upload_Path.Local_Folder_OIS = cMETE_Download_Upload_Path.Local_Folder_OIS.Replace("[Local_ShareStr]", cMETE_Download_Upload_Path.Local_ShareStr);
             * cMETE_Download_Upload_Path.Local_Folder_OIS = cMETE_Download_Upload_Path.Local_Folder_OIS.Replace("[Oper1]", PartInfo.OpNum);
             #endregion
             */

            DicPartDirData = new Dictionary <string, PartDirData>();
            #region 處理Part的路徑
            //預先加入總組立檔
            PartDirData sPartDirData = new PartDirData();
            sPartDirData.PartLocalDir   = displayPart.FullPath;
            sPartDirData.PartServer1Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, Path.GetFileName(displayPart.FullPath));
            //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
            DicPartDirData.Add(Path.GetFileNameWithoutExtension(displayPart.FullPath), sPartDirData);
            listView1.Items.Add(Path.GetFileName(displayPart.FullPath));

            //加入Comp資訊
            NXOpen.Assemblies.ComponentAssembly casm = displayPart.ComponentAssembly;
            //NXOpen.Assemblies.Component[] compary = casm.RootComponent.GetChildren();
            List <NXOpen.Assemblies.Component> ListChildrenComp = new List <NXOpen.Assemblies.Component>();
            CaxAsm.GetCompChildren(casm.RootComponent, ref ListChildrenComp);
            foreach (NXOpen.Assemblies.Component i in ListChildrenComp)
            {
                sPartDirData = new PartDirData();

                //判斷Server是否已存在此檔案,如果有就不上傳
                string ServerPartPath = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, Path.GetFileName(((Part)i.Prototype).FullPath));
                if (File.Exists(ServerPartPath))
                {
                    if (!((Part)i.Prototype).FullPath.Contains(PartInfo.OpNum))
                    {
                        continue;
                    }
                }
                sPartDirData.PartLocalDir   = ((Part)i.Prototype).FullPath;
                sPartDirData.PartServer1Dir = ServerPartPath;
                DicPartDirData.Add(i.Name, sPartDirData);
                listView1.Items.Add(Path.GetFileName(((Part)i.Prototype).FullPath));
                //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
            }
            #endregion

            #region 處理Excel的路徑
            string[] FolderFile = System.IO.Directory.GetFileSystemEntries(cMETE_Download_Upload_Path.Local_Folder_OIS, "*.xls");
            //篩選出IPQC、SelfCheck
            List <string> List_ExcelIPQC      = new List <string>();
            List <string> List_ExcelSelfCheck = new List <string>();
            List <string> List_ExcelIQC       = new List <string>();
            List <string> List_ExcelFAI       = new List <string>();
            foreach (string i in FolderFile)
            {
                if (i.Contains("IPQC"))
                {
                    List_ExcelIPQC.Add(i);
                }
                if (i.Contains("SelfCheck"))
                {
                    List_ExcelSelfCheck.Add(i);
                }
                if (i.Contains("IQC"))
                {
                    List_ExcelIQC.Add(i);
                }
                if (i.Contains("FAI"))
                {
                    List_ExcelFAI.Add(i);
                }
            }

            long ExcelIPQCFileTime      = new long();
            long ExcelSelfCheckFileTime = new long();
            long ExcelIQCFileTime       = new long();
            long ExcelFAIFileTime       = new long();

            #region 處理IPQC
            foreach (string i in List_ExcelIPQC)
            {
                System.IO.FileInfo ExcelInfo = new System.IO.FileInfo(i);
                if (ExcelInfo.LastAccessTime.ToFileTime() > ExcelIPQCFileTime)
                {
                    ExcelIPQCFileTime = ExcelInfo.LastAccessTime.ToFileTime();
                    sExcelDirData.ExcelIPQCLocalDir = i;
                    string Server_Folder_OIS = "";
                    Server_Folder_OIS = tempLocal_Folder_OIS.Replace("[Local_ShareStr]", cMETE_Download_Upload_Path.Server_ShareStr);
                    Server_Folder_OIS = Server_Folder_OIS.Replace("[Oper1]", PartInfo.OpNum);
                    sExcelDirData.ExcelIPQCServerDir = string.Format(@"{0}\{1}", Server_Folder_OIS, ExcelInfo.Name);
                }
            }
            if (List_ExcelIPQC.Count != 0)
            {
                listView1.Items.Add(Path.GetFileName(sExcelDirData.ExcelIPQCLocalDir));
            }
            #endregion

            #region 處理SelfCheck
            foreach (string i in List_ExcelSelfCheck)
            {
                System.IO.FileInfo ExcelInfo = new System.IO.FileInfo(i);
                if (ExcelInfo.LastAccessTime.ToFileTime() > ExcelSelfCheckFileTime)
                {
                    ExcelSelfCheckFileTime = ExcelInfo.LastAccessTime.ToFileTime();
                    sExcelDirData.ExcelSelfCheckLocalDir = i;
                    string Server_Folder_OIS = "";
                    Server_Folder_OIS = tempLocal_Folder_OIS.Replace("[Local_ShareStr]", cMETE_Download_Upload_Path.Server_ShareStr);
                    Server_Folder_OIS = Server_Folder_OIS.Replace("[Oper1]", PartInfo.OpNum);
                    sExcelDirData.ExcelSelfCheckServerDir = string.Format(@"{0}\{1}", Server_Folder_OIS, ExcelInfo.Name);
                }
            }
            if (List_ExcelSelfCheck.Count != 0)
            {
                listView1.Items.Add(Path.GetFileName(sExcelDirData.ExcelSelfCheckLocalDir));
            }
            #endregion

            #region 處理IQC
            foreach (string i in List_ExcelIQC)
            {
                System.IO.FileInfo ExcelInfo = new System.IO.FileInfo(i);
                if (ExcelInfo.LastAccessTime.ToFileTime() > ExcelIQCFileTime)
                {
                    ExcelIQCFileTime = ExcelInfo.LastAccessTime.ToFileTime();
                    sExcelDirData.ExcelIQCLocalDir = i;
                    string Server_Folder_OIS = "";
                    Server_Folder_OIS = tempLocal_Folder_OIS.Replace("[Local_ShareStr]", cMETE_Download_Upload_Path.Server_ShareStr);
                    Server_Folder_OIS = Server_Folder_OIS.Replace("[Oper1]", PartInfo.OpNum);
                    sExcelDirData.ExcelIQCServerDir = string.Format(@"{0}\{1}", Server_Folder_OIS, ExcelInfo.Name);
                }
            }
            if (List_ExcelIQC.Count != 0)
            {
                listView1.Items.Add(Path.GetFileName(sExcelDirData.ExcelIQCLocalDir));
            }
            #endregion

            #region 處理FAI
            foreach (string i in List_ExcelFAI)
            {
                System.IO.FileInfo ExcelInfo = new System.IO.FileInfo(i);
                if (ExcelInfo.LastAccessTime.ToFileTime() > ExcelFAIFileTime)
                {
                    ExcelFAIFileTime = ExcelInfo.LastAccessTime.ToFileTime();
                    sExcelDirData.ExcelFAILocalDir = i;
                    string Server_Folder_OIS = "";
                    Server_Folder_OIS = tempLocal_Folder_OIS.Replace("[Local_ShareStr]", cMETE_Download_Upload_Path.Server_ShareStr);
                    Server_Folder_OIS = Server_Folder_OIS.Replace("[Oper1]", PartInfo.OpNum);
                    sExcelDirData.ExcelFAIServerDir = string.Format(@"{0}\{1}", Server_Folder_OIS, ExcelInfo.Name);
                }
            }
            if (List_ExcelFAI.Count != 0)
            {
                listView1.Items.Add(Path.GetFileName(sExcelDirData.ExcelFAILocalDir));
            }
            #endregion
            #endregion
        }
Esempio n. 9
0
        private void TEUploadDlg_Load(object sender, EventArgs e)
        {
            //取得METEDownload_Upload.dat
            CaxGetDatData.GetMETEDownload_Upload(out cMETE_Download_Upload_Path);

            //取得料號
            PartNoLabel.Text = Path.GetFileNameWithoutExtension(displayPart.FullPath).Split('_')[0];
            OISLabel.Text    = Path.GetFileNameWithoutExtension(displayPart.FullPath).Split('_')[1];

            //將Local_Folder_OIS先暫存起來,然後改變成Server路徑
            tempLocal_Folder_CAM = cMETE_Download_Upload_Path.Local_Folder_CAM;

            CaxPublic.GetAllPath("TE", displayPart.FullPath, ref cMETE_Download_Upload_Path);


            /*
             * //拆零件路徑字串取得客戶名稱、料號、版本
             * string PartFullPath = displayPart.FullPath;
             * string[] SplitPath = PartFullPath.Split('\\');
             * PartInfo.CusName = SplitPath[3];
             * PartInfo.PartNo = SplitPath[4];
             * PartInfo.CusRev = SplitPath[5];
             * PartInfo.OpNum = Regex.Replace(Path.GetFileNameWithoutExtension(displayPart.FullPath).Split('_')[1], "[^0-9]", "");
             *
             #region 取代Server路徑字串
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[Server_IP]", cMETE_Download_Upload_Path.Server_IP);
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[CusName]", PartInfo.CusName);
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[PartNo]", PartInfo.PartNo);
             * cMETE_Download_Upload_Path.Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr.Replace("[CusRev]", PartInfo.CusRev);
             * Server_OP_Folder = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OpNum);
             #endregion
             *
             #region 取代Local路徑字串
             * //將Local_Folder_OIS先暫存起來,然後改變成Server路徑
             * tempLocal_Folder_CAM = cMETE_Download_Upload_Path.Local_Folder_CAM;
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[Local_IP]", cMETE_Download_Upload_Path.Local_IP);
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[CusName]", PartInfo.CusName);
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[PartNo]", PartInfo.PartNo);
             * cMETE_Download_Upload_Path.Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr.Replace("[CusRev]", PartInfo.CusRev);
             * cMETE_Download_Upload_Path.Local_Folder_CAM = cMETE_Download_Upload_Path.Local_Folder_CAM.Replace("[Local_ShareStr]", cMETE_Download_Upload_Path.Local_ShareStr);
             * cMETE_Download_Upload_Path.Local_Folder_CAM = cMETE_Download_Upload_Path.Local_Folder_CAM.Replace("[Oper1]", PartInfo.OpNum);
             #endregion
             */

            DicPartDirData = new Dictionary <string, PartDirData>();
            #region 處理Part的路徑
            //預先加入總組立檔
            PartDirData sPartDirData = new PartDirData();
            sPartDirData.PartLocalDir   = displayPart.FullPath;
            sPartDirData.PartServer1Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, Path.GetFileName(displayPart.FullPath));
            //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
            DicPartDirData.Add(Path.GetFileNameWithoutExtension(displayPart.FullPath), sPartDirData);
            listView1.Items.Add(Path.GetFileName(displayPart.FullPath));

            //加入Comp資訊
            NXOpen.Assemblies.ComponentAssembly casm             = displayPart.ComponentAssembly;
            List <NXOpen.Assemblies.Component>  ListChildrenComp = new List <NXOpen.Assemblies.Component>();
            CaxAsm.GetCompChildren(casm.RootComponent, ref ListChildrenComp);
            foreach (NXOpen.Assemblies.Component i in ListChildrenComp)
            {
                sPartDirData = new PartDirData();

                //判斷Server是否已存在此檔案,如果有就不上傳
                string ServerPartPath = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, Path.GetFileName(((Part)i.Prototype).FullPath));
                if (File.Exists(ServerPartPath))
                {
                    if (!((Part)i.Prototype).FullPath.Contains(PartInfo.OpNum))
                    {
                        continue;
                    }
                }
                sPartDirData.PartLocalDir   = ((Part)i.Prototype).FullPath;
                sPartDirData.PartServer1Dir = ServerPartPath;
                DicPartDirData.Add(i.Name, sPartDirData);
                listView1.Items.Add(Path.GetFileName(((Part)i.Prototype).FullPath));
                //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
            }
            //foreach (NXOpen.Assemblies.Component i in ListChildrenComp)
            //{
            //    sPartDirData = new PartDirData();
            //    sPartDirData.PartLocalDir = ((Part)i.Prototype).FullPath;
            //    sPartDirData.PartServer1Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, Path.GetFileName(((Part)i.Prototype).FullPath));
            //    //sPartDirData.PartServer2Dir = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Server_ShareStr, "OP" + PartInfo.OIS);
            //    DicPartDirData.Add(i.Name, sPartDirData);
            //    listView1.Items.Add(Path.GetFileName(((Part)i.Prototype).FullPath));
            //}
            #endregion

            #region 處理Excel的路徑
            string[] FolderFile        = System.IO.Directory.GetFileSystemEntries(cMETE_Download_Upload_Path.Local_Folder_CAM, "*.xls");
            string   Server_Folder_CAM = "";
            Server_Folder_CAM = tempLocal_Folder_CAM.Replace("[Local_ShareStr]", cMETE_Download_Upload_Path.Server_ShareStr);
            Server_Folder_CAM = Server_Folder_CAM.Replace("[Oper1]", PartInfo.OpNum);
            long FileTime = new long();
            for (int i = 0; i < FolderFile.Length; i++)
            {
                System.IO.FileInfo ExcelInfo = new System.IO.FileInfo(FolderFile[i]);
                if (ExcelInfo.LastAccessTime.ToFileTime() > FileTime)
                {
                    FileTime = ExcelInfo.LastAccessTime.ToFileTime();
                    sExcelDirData.ExcelShopDocLocalDir  = FolderFile[i];
                    sExcelDirData.ExcelShopDocServerDir = string.Format(@"{0}\{1}", Server_Folder_CAM, ExcelInfo.Name);
                }
            }
            if (File.Exists(sExcelDirData.ExcelShopDocLocalDir))
            {
                listView1.Items.Add(Path.GetFileName(sExcelDirData.ExcelShopDocLocalDir));
            }
            #endregion

            #region 處理NC程式的路徑
            string Local_NC_Folder = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Local_Folder_CAM, "NC");
            if (Directory.Exists(Local_NC_Folder))
            {
                sNCProgramDirData.NCProgramLocalDir  = Local_NC_Folder;
                sNCProgramDirData.NCProgramServerDir = string.Format(@"{0}\{1}", Server_Folder_CAM, "NC");
                listView1.Items.Add("NC資料夾");
            }
            #endregion
        }
Esempio n. 10
0
        private void OK_Click(object sender, EventArgs e)
        {
            //先關閉所有檔案
            CaxPart.CloseAllParts();

            try
            {
                if (Is_OldPart == true)
                {
                    //定義總組立檔案、二階檔案、三階檔案名稱
                    string AsmCompFileFullPath       = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekEnvDir(), "Task", comboBoxOldCusName.Text, comboBoxOldPartNo.Text, comboBoxOldCusRev.Text.ToUpper(), comboBoxOldPartNo.Text + "_MOT.prt");
                    string SecondFileFullPath        = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekEnvDir(), "Task", comboBoxOldCusName.Text, comboBoxOldPartNo.Text, comboBoxOldCusRev.Text.ToUpper(), comboBoxOldPartNo.Text + "_OP" + "[Oper1]" + ".prt");
                    string ThirdFileFullPath_OIS     = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekEnvDir(), "Task", comboBoxOldCusName.Text, comboBoxOldPartNo.Text, comboBoxOldCusRev.Text.ToUpper(), comboBoxOldPartNo.Text + "_OIS" + "[Oper1]" + ".prt");
                    string ThirdFileFullPath_CAM     = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekEnvDir(), "Task", comboBoxOldCusName.Text, comboBoxOldPartNo.Text, comboBoxOldCusRev.Text.ToUpper(), comboBoxOldPartNo.Text + "_OP" + "[Oper1]" + "_CAM.prt");
                    string OPFolderPath              = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekEnvDir(), "Task", comboBoxOldCusName.Text, comboBoxOldPartNo.Text, comboBoxOldCusRev.Text.ToUpper(), "OP" + "[Oper1]");
                    string tempSecondFileFullPath    = SecondFileFullPath;
                    string tempThirdFileFullPath_OIS = ThirdFileFullPath_OIS;
                    string tempThirdFileFullPath_CAM = ThirdFileFullPath_CAM;
                    string tempOPFolderPath          = OPFolderPath;


                    #region 開啟總組立
                    if (File.Exists(AsmCompFileFullPath))
                    {
                        //組件存在,直接開啟任務組立
                        BasePart newAsmPart;
                        status = CaxPart.OpenBaseDisplay(AsmCompFileFullPath, out newAsmPart);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("組立開啟失敗,料號不可有中文字!");
                            return;
                        }
                    }
                    else
                    {
                        CaxLog.ShowListingWindow("開啟失敗:找不到總組立" + Path.GetFileNameWithoutExtension(AsmCompFileFullPath));
                        return;
                    }
                    #endregion

                    #region 建立新插入的製程
                    NXOpen.Assemblies.Component tempComp;

                    foreach (string i in ListAddOper)
                    {
                        //設定一階為WorkComp
                        CaxAsm.SetWorkComponent(null);

                        //建立二階檔案
                        SecondFileFullPath = tempSecondFileFullPath;
                        SecondFileFullPath = SecondFileFullPath.Replace("[Oper1]", i);
                        status             = CaxAsm.CreateNewEmptyComp(SecondFileFullPath, out tempComp);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立二階製程檔失敗");
                            return;
                        }

                        //取得二階所有comp
                        List <NXOpen.Assemblies.Component> ChildenComp = new List <NXOpen.Assemblies.Component>();
                        CaxAsm.GetCompChildren(out ChildenComp);

                        foreach (NXOpen.Assemblies.Component ii in ChildenComp)
                        {
                            if (ii.Name == Path.GetFileNameWithoutExtension(SecondFileFullPath).ToUpper())
                            {
                                CaxAsm.SetWorkComponent(ii);
                            }
                        }

                        //建立三階檔案
                        ThirdFileFullPath_OIS = tempThirdFileFullPath_OIS;
                        ThirdFileFullPath_CAM = tempThirdFileFullPath_CAM;

                        ThirdFileFullPath_OIS = ThirdFileFullPath_OIS.Replace("[Oper1]", i);
                        ThirdFileFullPath_CAM = ThirdFileFullPath_CAM.Replace("[Oper1]", i);
                        status = CaxAsm.CreateNewEmptyComp(ThirdFileFullPath_OIS, out tempComp);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立三階OIS檔失敗");
                            return;
                        }
                        status = CaxAsm.CreateNewEmptyComp(ThirdFileFullPath_CAM, out tempComp);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立三階CAM檔失敗");
                            return;
                        }
                    }
                    #endregion

                    #region 建立新插入的製程資料夾
                    foreach (string i in ListAddOper)
                    {
                        OPFolderPath = tempOPFolderPath;
                        OPFolderPath = OPFolderPath.Replace("[Oper1]", i);
                        string OISFolderPath = string.Format(@"{0}\{1}", OPFolderPath, "OIS");
                        string CAMFolderPath = string.Format(@"{0}\{1}", OPFolderPath, "CAM");

                        if (!File.Exists(OISFolderPath))
                        {
                            try
                            {
                                System.IO.Directory.CreateDirectory(OISFolderPath);
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                                return;
                            }
                        }
                        if (!File.Exists(CAMFolderPath))
                        {
                            try
                            {
                                System.IO.Directory.CreateDirectory(CAMFolderPath);
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                                return;
                            }
                        }
                    }
                    #endregion

                    #region 將值儲存起來
                    cPECreateData.CusName       = comboBoxOldCusName.Text;
                    cPECreateData.PartNo        = comboBoxOldPartNo.Text;
                    cPECreateData.CusRev        = comboBoxOldCusRev.Text.ToUpper();
                    cPECreateData.ListOperation = new List <Operation>();
                    Operation cOperation = new Operation();
                    cPECreateData.Oper1Ary = new List <string>();
                    cPECreateData.Oper2Ary = new List <string>();
                    for (int i = 0; i < panel.Rows.Count; i++)
                    {
                        if (panel.Rows.Count == 0)
                        {
                            MessageBox.Show("尚未選擇製程序與製程別!");
                            return;
                        }

                        if (panel.GetCell(i, 1).Value.ToString() == "")
                        {
                            MessageBox.Show("製程序" + panel.GetCell(i, 0).Value + "尚未選取製程別!");
                            return;
                        }

                        cOperation       = new Operation();
                        cOperation.Oper1 = panel.GetCell(i, 0).Value.ToString();
                        cOperation.Oper2 = panel.GetCell(i, 1).Value.ToString();

                        cPECreateData.ListOperation.Add(cOperation);

                        cPECreateData.Oper1Ary.Add(panel.GetCell(i, 0).Value.ToString());
                        cPECreateData.Oper2Ary.Add(panel.GetCell(i, 1).Value.ToString());
                    }
                    #endregion

                    #region 寫出PECreateData.dat
                    string PECreateDataJsonDat = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekTaskDir(), CurrentOldCusName, CurrentOldPartNo, CurrentOldCusRev, "MODEL", "PECreateData.dat");
                    status = CaxFile.WriteJsonFileData(PECreateDataJsonDat, cPECreateData);
                    if (!status)
                    {
                        MessageBox.Show("PECreateData.dat 輸出失敗...");
                        return;
                    }
                    #endregion
                }
                else
                {
                    #region 取得客戶名稱

                    CusName = comboBoxCusName.Text;
                    if (CusName == "")
                    {
                        MessageBox.Show("尚未填寫客戶!");
                        return;
                    }

                    #endregion

                    #region 取得料號

                    PartNo = textPartNo.Text;
                    if (PartNo == "")
                    {
                        MessageBox.Show("尚未填寫料號!");
                        return;
                    }

                    #endregion

                    #region 取得客戶版次

                    CusRev = textCusRev.Text;
                    if (CusRev == "")
                    {
                        MessageBox.Show("尚未填寫客戶版次!");
                        return;
                    }

                    #endregion

                    #region 取得檔案路徑

                    if (PartPath == "-1")
                    {
                        MessageBox.Show("尚未選擇客戶檔案!");
                        return;
                    }

                    #endregion

                    #region 定義根目錄

                    //定義MODEL資料夾路徑
                    string ModelFolderFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekEnvDir(), "Task", CusName, PartNo, CusRev.ToUpper(), "MODEL");

                    //定義總組立檔案名稱
                    string AsmCompFileFullPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}", CaxEnv.GetGlobaltekEnvDir(), "Task", CusName, PartNo, CusRev.ToUpper(), PartNo + "_MOT.prt");

                    //定義CAM資料夾路徑、OIS資料夾路徑、三階檔案路徑
                    string CAMFolderPath = "", OISFolderPath = "", ThridOperPartPath = "";

                    #endregion

                    #region 建立MODEL資料夾

                    if (!File.Exists(ModelFolderFullPath))
                    {
                        try
                        {
                            System.IO.Directory.CreateDirectory(ModelFolderFullPath);
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            return;
                        }
                    }

                    #endregion

                    #region 複製客戶檔案到MODEL資料夾內

                    //判斷客戶的檔案是否存在
                    status = System.IO.File.Exists(PartPath);
                    if (!status)
                    {
                        MessageBox.Show("指定的檔案不存在,請再次確認");
                        return;
                    }

                    //建立MODEL資料夾內客戶檔案路徑
                    string CustomerPartFullPath = string.Format(@"{0}\{1}", ModelFolderFullPath, PartNo + ".prt");

                    //開始複製
                    if (!System.IO.File.Exists(CustomerPartFullPath))
                    {
                        File.Copy(PartPath, CustomerPartFullPath, true);
                    }


                    #endregion

                    #region 將值儲存起來

                    cPECreateData.CusName = CusName;
                    cPECreateData.PartNo  = PartNo;
                    cPECreateData.CusRev  = CusRev.ToUpper();
                    //cPE_OutPutDat.PartPath = PartPath;
                    cPECreateData.ListOperation = new List <Operation>();
                    Operation cOperation = new Operation();
                    cPECreateData.Oper1Ary = new List <string>();
                    cPECreateData.Oper2Ary = new List <string>();
                    for (int i = 0; i < panel.Rows.Count; i++)
                    {
                        if (panel.Rows.Count == 0)
                        {
                            MessageBox.Show("尚未選擇製程序與製程別!");
                            return;
                        }

                        if (panel.GetCell(i, 1).Value.ToString() == "")
                        {
                            MessageBox.Show("製程序" + panel.GetCell(i, 0).Value + "尚未選取製程別!");
                            return;
                        }

                        cOperation       = new Operation();
                        cOperation.Oper1 = panel.GetCell(i, 0).Value.ToString();
                        cOperation.Oper2 = panel.GetCell(i, 1).Value.ToString();

                        //建立CAM資料夾路徑
                        CAMFolderPath = string.Format(@"{0}\{1}\{2}", Path.GetDirectoryName(AsmCompFileFullPath), "OP" + panel.GetCell(i, 0).Value.ToString(), "CAM");

                        //儲存CAM資料夾路徑
                        //cOperation.CAMFolderPath = CAMFolderPath;

                        //建立CAM資料夾
                        if (!File.Exists(CAMFolderPath))
                        {
                            try
                            {
                                System.IO.Directory.CreateDirectory(CAMFolderPath);
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                                return;
                            }
                        }

                        //建立OIS資料夾路徑
                        OISFolderPath = string.Format(@"{0}\{1}\{2}", Path.GetDirectoryName(AsmCompFileFullPath), "OP" + panel.GetCell(i, 0).Value.ToString(), "OIS");

                        //儲存OIS資料夾路徑
                        //cOperation.OISFolderPath = OISFolderPath;

                        //建立OIS資料夾
                        if (!File.Exists(OISFolderPath))
                        {
                            try
                            {
                                System.IO.Directory.CreateDirectory(OISFolderPath);
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                                return;
                            }
                        }

                        //建立三階檔案路徑
                        ThridOperPartPath = Path.GetDirectoryName(AsmCompFileFullPath);

                        cPECreateData.ListOperation.Add(cOperation);

                        cPECreateData.Oper1Ary.Add(panel.GetCell(i, 0).Value.ToString());
                        cPECreateData.Oper2Ary.Add(panel.GetCell(i, 1).Value.ToString());
                    }

                    #endregion

                    #region (註解中)複製MODEL內的客戶檔案到料號資料夾內,並更名XXX_MOT.prt

                    /*
                     * //判斷要複製的檔案是否存在
                     * status = System.IO.File.Exists(destFileName_Model);
                     * if (!status)
                     * {
                     *  MessageBox.Show("指定的檔案不存在,請再次確認");
                     *  return;
                     * }
                     *
                     * //建立目的地(客戶版次)檔案全路徑
                     * string destFileName_CusRev = string.Format(@"{0}\{1}\{2}\{3}", CaxEnv.GetGlobalTekEnvDir(), PartNo, CusRev.ToUpper(), PartNo + "_MOT.prt");
                     *
                     * //開始複製
                     * File.Copy(destFileName_Model, destFileName_CusRev, true);
                     */
                    #endregion

                    #region 自動建立總組立檔案架構,並組立相關製程

                    status = CaxAsm.CreateNewAsm(AsmCompFileFullPath);
                    if (!status)
                    {
                        CaxLog.ShowListingWindow("建立一階總組立檔失敗");
                        return;
                    }

                    CaxPart.Save();


                    string OPCompName = "";
                    NXOpen.Assemblies.Component tempComp;
                    //List<double> ListOperDouble = new List<double>();
                    //for (int i = 0; i < cPE_OutPutDat.ListOperation.Count; i++)
                    //{
                    //    ListOperDouble.Add(Convert.ToDouble(cPE_OutPutDat.ListOperation[i].Oper1));
                    //}
                    //ListOperDouble.Sort();

                    for (int i = 0; i < cPECreateData.ListOperation.Count; i++)
                    {
                        //設定一階為WorkComp
                        CaxAsm.SetWorkComponent(null);

                        //建立二階製程檔
                        OPCompName = string.Format(@"{0}\{1}", Path.GetDirectoryName(AsmCompFileFullPath), PartNo + "_OP" + cPECreateData.ListOperation[i].Oper1 + ".prt");
                        status     = CaxAsm.CreateNewEmptyComp(OPCompName, out tempComp);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立二階製程檔失敗");
                            return;
                        }
                    }

                    string OISCompFullPath = "", CAMCompFullPath = "";

                    //取得二階所有comp
                    List <NXOpen.Assemblies.Component> ChildenComp = new List <NXOpen.Assemblies.Component>();
                    CaxAsm.GetCompChildren(out ChildenComp);

                    for (int i = 0; i < ChildenComp.Count; i++)
                    {
                        CaxAsm.SetWorkComponent(ChildenComp[i]);
                        string OperStr = ChildenComp[i].Name.Split(new string[] { "OP" }, StringSplitOptions.RemoveEmptyEntries)[1];

                        #region 建立三階CAM檔
                        //建立三階CAM檔
                        CAMCompFullPath = string.Format(@"{0}\{1}", Path.GetDirectoryName(AsmCompFileFullPath), PartNo + "_OP" + OperStr + "_CAM.prt");
                        status          = CaxAsm.CreateNewEmptyComp(CAMCompFullPath, out tempComp);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("建立三階CAM檔失敗");
                            return;
                        }
                        #endregion


                        #region 建立三階OIS檔
                        //先複製drafting_template.prt到OIS檔
                        string drafting_template_Path = string.Format(@"{0}\{1}", CaxEnv.GetGlobaltekEnvDir(), "drafting_template.prt");
                        OISCompFullPath = string.Format(@"{0}\{1}", Path.GetDirectoryName(AsmCompFileFullPath), PartNo + "_OIS" + OperStr + ".prt");
                        if (!File.Exists(drafting_template_Path))
                        {
                            CaxLog.ShowListingWindow("drafting_template.prt遺失,請聯繫開發工程師");
                            return;
                        }
                        System.IO.File.Copy(drafting_template_Path, OISCompFullPath, true);

                        //組立三階OIS檔
                        //status = CaxAsm.CreateNewEmptyComp(OISCompFullPath, out tempComp);
                        status = CaxAsm.AddComponentToAsmByDefault(OISCompFullPath, out tempComp);
                        if (!status)
                        {
                            CaxLog.ShowListingWindow("組立三階OIS檔失敗");
                            return;
                        }
                        #endregion
                    }

                    #endregion

                    #region 寫出PECreateData.dat

                    string PECreateDataJsonDat = string.Format(@"{0}\{1}", ModelFolderFullPath, "PECreateData.dat");
                    status = CaxFile.WriteJsonFileData(PECreateDataJsonDat, cPECreateData);
                    if (!status)
                    {
                        MessageBox.Show("PECreateData.dat 輸出失敗...");
                        return;
                    }

                    #endregion

                    #region (註解中)寫出METEDownloadData.dat

                    //string METEDownloadData = string.Format(@"{0}\{1}", CaxEnv.GetGlobaltekTaskDir(), "METEDownloadData.dat");
                    //METEDownloadData cMETEDownloadData = new METEDownloadData();

                    //if (File.Exists(METEDownloadData))
                    //{
                    //    #region METEDownloadData.dat檔案存在

                    //    status = CaxPublic.ReadMETEDownloadData(METEDownloadData, out cMETEDownloadData);
                    //    if (!status)
                    //    {
                    //        MessageBox.Show("METEDownloadData.dat讀取失敗...");
                    //        return;
                    //    }

                    //    int CusCount = 0, IndexOfCusName = -1;
                    //    for (int i = 0; i < cMETEDownloadData.EntirePartAry.Count; i++)
                    //    {
                    //        if (CusName != cMETEDownloadData.EntirePartAry[i].CusName)
                    //        {
                    //            CusCount++;
                    //        }
                    //        else
                    //        {
                    //            IndexOfCusName = i;
                    //            break;
                    //        }
                    //    }

                    //    //新的客戶且已經有METEDownloadDat.dat
                    //    if (CusCount == cMETEDownloadData.EntirePartAry.Count)
                    //    {
                    //        EntirePartAry cEntirePartAry = new EntirePartAry();
                    //        cEntirePartAry.CusName = CusName;
                    //        cEntirePartAry.CusPart = new List<CusPart>();

                    //        CusPart cCusPart = new CusPart();
                    //        cCusPart.PartNo = PartNo;
                    //        cCusPart.CusRev = new List<CusRev>();

                    //        CusRev cCusRev = new CusRev();
                    //        cCusRev.RevNo = CusRev.ToUpper();
                    //        cCusRev.OperAry1 = new List<string>();
                    //        cCusRev.OperAry2 = new List<string>();
                    //        cCusRev.OperAry1 = cPECreateData.Oper1Ary;
                    //        cCusRev.OperAry2 = cPECreateData.Oper2Ary;

                    //        cCusPart.CusRev.Add(cCusRev);
                    //        cEntirePartAry.CusPart.Add(cCusPart);
                    //        cMETEDownloadData.EntirePartAry.Add(cEntirePartAry);
                    //    }
                    //    //舊的客戶新增料號
                    //    else
                    //    {
                    //        //判斷料號是否已存在
                    //        int PartCount = 0; int IndexOfPartNo = -1;
                    //        for (int i = 0; i < cMETEDownloadData.EntirePartAry[IndexOfCusName].CusPart.Count; i++)
                    //        {
                    //            if (PartNo != cMETEDownloadData.EntirePartAry[IndexOfCusName].CusPart[i].PartNo)
                    //            {
                    //                PartCount++;
                    //            }
                    //            else
                    //            {
                    //                IndexOfPartNo = i;
                    //                break;
                    //            }
                    //        }

                    //        //舊的客戶且新的料號 PartCount == CusPart.Count 表示新的料號
                    //        if (PartCount == cMETEDownloadData.EntirePartAry[IndexOfCusName].CusPart.Count)
                    //        {
                    //            CusPart cCusPart = new CusPart();
                    //            cCusPart.PartNo = PartNo;
                    //            cCusPart.CusRev = new List<CusRev>();

                    //            CusRev cCusRev = new CusRev();
                    //            cCusRev.RevNo = CusRev.ToUpper();
                    //            cCusRev.OperAry1 = new List<string>();
                    //            cCusRev.OperAry2 = new List<string>();
                    //            cCusRev.OperAry1 = cPECreateData.Oper1Ary;
                    //            cCusRev.OperAry2 = cPECreateData.Oper2Ary;

                    //            cCusPart.CusRev.Add(cCusRev);
                    //            cMETEDownloadData.EntirePartAry[IndexOfCusName].CusPart.Add(cCusPart);
                    //        }
                    //        //舊的客戶且舊的料號新增客戶版次
                    //        else
                    //        {
                    //            CusRev cCusRev = new CusRev();
                    //            cCusRev.RevNo = CusRev.ToUpper();
                    //            cCusRev.OperAry1 = new List<string>();
                    //            cCusRev.OperAry1 = cPECreateData.Oper1Ary;

                    //            cMETEDownloadData.EntirePartAry[IndexOfCusName].CusPart[IndexOfPartNo].CusRev.Add(cCusRev);
                    //        }
                    //    }
                    //    /*
                    //    int PartCount = 0; int IndexOfPartNo = -1;
                    //    for (int i = 0; i < cMETEDownloadData.EntirePartAry.Count; i++)
                    //    {
                    //    if (PartNo != cMETEDownloadData.EntirePartAry[i].PartNo)
                    //    {
                    //    PartCount++;
                    //    }
                    //    else
                    //    {
                    //    IndexOfPartNo = i;
                    //    break;
                    //    }
                    //    }

                    //    //新的料號且已經有METEDownloadDat.dat
                    //    if (PartCount == cMETEDownloadData.EntirePartAry.Count)
                    //    {
                    //    EntirePartAry cEntirePartAry = new EntirePartAry();
                    //    cEntirePartAry.CusRev = new List<CusRev>();

                    //    CusRev cCusRev = new CusRev();
                    //    cCusRev.OperAry1 = new List<string>();
                    //    cCusRev.RevNo = CusRev.ToUpper();
                    //    cCusRev.OperAry1 = cPE_OutPutDat.Oper1Ary;

                    //    cEntirePartAry.CusName = CusName;
                    //    cEntirePartAry.PartNo = PartNo;
                    //    cEntirePartAry.CusRev.Add(cCusRev);

                    //    cMETEDownloadData.EntirePartAry.Add(cEntirePartAry);
                    //    }
                    //    //舊的料號新增客戶版次
                    //    else
                    //    {
                    //    CusRev cCusRev = new CusRev();
                    //    cCusRev.OperAry1 = new List<string>();
                    //    cCusRev.RevNo = CusRev.ToUpper();
                    //    cCusRev.OperAry1 = cPE_OutPutDat.Oper1Ary;

                    //    cMETEDownloadData.EntirePartAry[IndexOfPartNo].CusRev.Add(cCusRev);
                    //    }
                    //    */
                    //    #endregion
                    //}
                    //else
                    //{
                    //    #region METEDownloadData.dat檔案不存在

                    //    cMETEDownloadData.EntirePartAry = new List<EntirePartAry>();
                    //    EntirePartAry cEntirePartAry = new EntirePartAry();
                    //    cEntirePartAry.CusName = CusName;
                    //    cEntirePartAry.CusPart = new List<CusPart>();

                    //    CusPart cCusPart = new CusPart();
                    //    cCusPart.PartNo = PartNo;
                    //    cCusPart.CusRev = new List<CusRev>();

                    //    CusRev cCusRev = new CusRev();
                    //    cCusRev.RevNo = CusRev.ToUpper();
                    //    cCusRev.OperAry1 = new List<string>();
                    //    cCusRev.OperAry2 = new List<string>();
                    //    cCusRev.OperAry1 = cPECreateData.Oper1Ary;
                    //    cCusRev.OperAry2 = cPECreateData.Oper2Ary;

                    //    cCusPart.CusRev.Add(cCusRev);
                    //    cEntirePartAry.CusPart.Add(cCusPart);
                    //    cMETEDownloadData.EntirePartAry.Add(cEntirePartAry);

                    //    #endregion
                    //}

                    //status = CaxFile.WriteJsonFileData(METEDownloadData, cMETEDownloadData);
                    //if (!status)
                    //{
                    //    MessageBox.Show("METEDownloadData.dat輸出失敗...");
                    //    return;
                    //}

                    #endregion
                }

                CaxAsm.SetWorkComponent(null);
                CaxPart.Save();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (System.Exception ex)
            {
                CaxLog.ShowListingWindow(ex.ToString());
            }
        }