コード例 #1
0
        public bool InitializeOISTree(Com_Dimension inputDimen, AdvTree OISTree)
        {
            try
            {
                OISTree.BeginUpdate();

                //泡泡
                Node singleDimen = new Node();
                singleDimen.Text = inputDimen.ballon.ToString();

                foreach (Node i in OISTree.Nodes)
                {
                    if (i.Cells[0].Text == inputDimen.ballon.ToString())
                    {
                        OISTree.EndUpdate();
                        return(true);
                    }
                }

                //Dimension
                Cell       dimension      = new Cell();
                WebBrowser tempWebBrowser = new WebBrowser();
                tempWebBrowser.Size = new Size(200, 25);
                tempWebBrowser.ScrollBarsEnabled = false;
                string htmlPath = "";
                CaxExcel.CreateHTML(inputDimen, out htmlPath);
                tempWebBrowser.Url      = new Uri(htmlPath);
                dimension.HostedControl = tempWebBrowser;
                singleDimen.Cells.Add(dimension);

                //刀號
                Cell toolNo = new Cell();
                toolNo.Text = inputDimen.toolNoControl;
                singleDimen.Cells.Add(toolNo);

                OISTree.Nodes.Add(singleDimen);

                OISTree.EndUpdate();
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
        private void OK_Click(object sender, EventArgs e)
        {
            CaxPart.SaveAll();

            //Part上傳
            List <string> ListPartName = new List <string>();

            status = CaxMEUpLoad.UploadPart(DicPartDirData, out ListPartName);
            //status = Function.UploadPart(DicPartDirData, out ListPartName);
            if (!status)
            {
                this.Close();
                return;
            }
            System.IO.File.WriteAllLines(string.Format(@"{0}\{1}\{2}", sDownUpLoadDat.Server_ShareStr, "OP" + cCaxMEUpLoad.OpNum, "PartNameText_OIS.txt"), ListPartName.ToArray());
            //新增TE的下載文件
            if (TEDownloadText.Count > 0)
            {
                string PartNameText_CAM = string.Format(@"{0}\{1}\{2}", sDownUpLoadDat.Server_ShareStr, "OP" + cCaxMEUpLoad.OpNum, "PartNameText_CAM.txt");
                foreach (string i in TEDownloadText)
                {
                    using (StreamWriter sw = File.AppendText(PartNameText_CAM))
                    {
                        sw.WriteLine(i);
                    }
                }
            }

            #region (註解)Excel上傳

            /*
             * //Excel上傳
             * if (File.Exists(sExcelDirData.ExcelIPQCLocalDir))
             * {
             *  try
             *  {
             *      File.Copy(sExcelDirData.ExcelIPQCLocalDir, sExcelDirData.ExcelIPQCServerDir, true);
             *  }
             *  catch (System.Exception ex)
             *  {
             *      CaxLog.ShowListingWindow("IPQC.xls上傳失敗");
             *      this.Close();
             *  }
             * }
             *
             * if (File.Exists(sExcelDirData.ExcelSelfCheckLocalDir))
             * {
             *  try
             *  {
             *      File.Copy(sExcelDirData.ExcelSelfCheckLocalDir, sExcelDirData.ExcelSelfCheckServerDir, true);
             *  }
             *  catch (System.Exception ex)
             *  {
             *      CaxLog.ShowListingWindow("SelfCheck.xls上傳失敗");
             *      this.Close();
             *  }
             * }
             *
             * if (File.Exists(sExcelDirData.ExcelIQCLocalDir))
             * {
             *  try
             *  {
             *      File.Copy(sExcelDirData.ExcelIQCLocalDir, sExcelDirData.ExcelIQCServerDir, true);
             *  }
             *  catch (System.Exception ex)
             *  {
             *      CaxLog.ShowListingWindow("IQC.xls上傳失敗");
             *      this.Close();
             *  }
             * }
             *
             * if (File.Exists(sExcelDirData.ExcelFAILocalDir))
             * {
             *  try
             *  {
             *      File.Copy(sExcelDirData.ExcelFAILocalDir, sExcelDirData.ExcelFAIServerDir, true);
             *  }
             *  catch (System.Exception ex)
             *  {
             *      CaxLog.ShowListingWindow("FAI.xls上傳失敗");
             *      this.Close();
             *  }
             * }
             *
             * if (File.Exists(sExcelDirData.ExcelFQCLocalDir))
             * {
             *  try
             *  {
             *      File.Copy(sExcelDirData.ExcelFQCLocalDir, sExcelDirData.ExcelFQCServerDir, true);
             *  }
             *  catch (System.Exception ex)
             *  {
             *      CaxLog.ShowListingWindow("FQC.xls上傳失敗");
             *      this.Close();
             *  }
             * }
             */
            #endregion


            int          SheetCount  = 0;
            NXOpen.Tag[] SheetTagAry = null;
            theUfSession.Draw.AskDrawings(out SheetCount, out SheetTagAry);

            List <NXOpen.Drawings.DrawingSheet> listDrawingSheet = new List <NXOpen.Drawings.DrawingSheet>();
            for (int i = 0; i < SheetCount; i++)
            {
                //打開Sheet並記錄所有OBJ
                NXOpen.Drawings.DrawingSheet CurrentSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[i]);
                listDrawingSheet.Add(CurrentSheet);
            }
            #region 輸出OIS
            //輸出PDF
            if (ExportPFD.Checked == true)
            {
                //建立PFD資料夾
                string PFDFullPath = string.Format(@"{0}\{1}", sDownUpLoadDat.Local_Folder_OIS, cCaxMEUpLoad.PartName + "_OIS" + cCaxMEUpLoad.OpNum + ".pdf");
                CaxME.CreateOISPDF(listDrawingSheet, PFDFullPath);
                //OIS資料夾上傳
                status = CaxPublic.DirectoryCopy(sDownUpLoadDat.Local_Folder_OIS, sDownUpLoadDat.Server_Folder_OIS, true);
                if (!status)
                {
                    MessageBox.Show("OIS資料夾複製失敗,請聯繫開發工程師");
                    this.Close();
                }
            }
            #endregion

            #region 資料上傳至Database
            //取得WorkPart資訊並檢查資料是否完整
            DadDimension.WorkPartAttribute sWorkPartAttribute = new DadDimension.WorkPartAttribute();
            //status = Function.GetWorkPartAttribute(workPart, out sWorkPartAttribute);
            status = DadDimension.GetWorkPartAttribute(workPart, out sWorkPartAttribute);
            if (!status)
            {
                MessageBox.Show("量測資訊不足,僅上傳CAD檔案,上傳完成!");
                this.Close();
                return;
            }

            #region 取得所有量測尺寸資料

            /*
             * //取得泡泡特徵,並記錄總共有幾個泡泡,後續比對數量用
             * IdSymbolCollection BallonCollection = workPart.Annotations.IdSymbols;
             * IdSymbol[] BallonAry = BallonCollection.ToArray();
             * int balloonCount = 0;
             * foreach (IdSymbol i in BallonAry)
             * {
             *  try
             *  {
             *      i.GetStringAttribute("BalloonAtt");
             *      balloonCount++;
             *  }
             *  catch (System.Exception ex)
             *  {
             *      continue;
             *  }
             * }
             *
             * List<CaxME.DimensionData> listDimensionData = new List<CaxME.DimensionData>();
             * List<int> listBalloonCount = new List<int>();
             * NXOpen.Drawings.DrawingSheet FirstSheet = null;
             * while (listBalloonCount.Count != balloonCount)
             * {
             *  for (int i = 0; i < SheetCount; i++)
             *  {
             *      //打開Sheet並記錄所有OBJ
             *      NXOpen.Drawings.DrawingSheet CurrentSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[i]);
             *      if (CurrentSheet.Name == "S1")
             *      {
             *          FirstSheet = CurrentSheet;
             *      }
             *      CurrentSheet.Open();
             *      CurrentSheet.View.UpdateDisplay();
             *      DisplayableObject[] SheetObj = CurrentSheet.View.AskVisibleObjects();
             *      status = CaxME.RecordDimension(SheetObj, sWorkPartAttribute, ref listDimensionData);
             *      if (!status)
             *      {
             *          this.Close();
             *          return;
             *      }
             *  }
             *  foreach (CaxME.DimensionData i in listDimensionData)
             *  {
             *      if (!listBalloonCount.Contains(i.ballonNum))
             *      {
             *          listBalloonCount.Add(i.ballonNum);
             *      }
             *  }
             *
             * }
             */
            //List<CaxME.DimensionData> listDimensionData = new List<CaxME.DimensionData>();
            List <DadDimension>          listDimensionData = new List <DadDimension>();
            NXOpen.Drawings.DrawingSheet FirstSheet        = null;
            for (int i = 0; i < SheetCount; i++)
            {
                //打開Sheet並記錄所有OBJ
                NXOpen.Drawings.DrawingSheet CurrentSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[i]);
                if (CurrentSheet.Name == "S1")
                {
                    FirstSheet = CurrentSheet;
                }
                CurrentSheet.Open();
                CurrentSheet.View.UpdateDisplay();
                DisplayableObject[] SheetObj = CurrentSheet.View.AskVisibleObjects();
                status = Com_Dimension.RecordDimension(SheetObj, sWorkPartAttribute, ref listDimensionData);
                if (!status)
                {
                    this.Close();
                    return;
                }
            }
            #endregion



            //切回首頁
            if (FirstSheet != null)
            {
                FirstSheet.Open();
            }


            //由料號查Com_PEMain
            Com_PEMain cCom_PEMain = new Com_PEMain();
            status = CaxSQL.GetCom_PEMain(cCaxMEUpLoad.CusName, cCaxMEUpLoad.PartName, cCaxMEUpLoad.CusRev, cCaxMEUpLoad.OpRev, out cCom_PEMain);
            if (!status)
            {
                return;
            }
            //由Com_PEMain和Op查Com_PartOperation
            Com_PartOperation cCom_PartOperation = new Com_PartOperation();
            status = CaxSQL.GetCom_PartOperation(cCom_PEMain, cCaxMEUpLoad.OpNum, out cCom_PartOperation);
            if (!status)
            {
                return;
            }


            #region (註解)由excelType查meExcelSrNo
            //Sys_MEExcel sysMEExcel = new Sys_MEExcel();
            //try
            //{
            //    sysMEExcel = session.QueryOver<Sys_MEExcel>().Where(x => x.meExcelType == meExcelType).SingleOrDefault<Sys_MEExcel>();
            //}
            //catch (System.Exception ex)
            //{
            //    MessageBox.Show("資料庫中沒有此料號的紀錄,故無法上傳量測尺寸,僅成功上傳實體檔案");
            //    return;
            //}
            #endregion

            #region 比對資料庫MEMain是否有同筆數據
            IList <Com_MEMain> ListCom_MEMain = new List <Com_MEMain>();
            CaxSQL.GetListCom_MEMain(out ListCom_MEMain);

            bool       Is_Exist         = false;
            Com_MEMain currentComMEMain = new Com_MEMain();
            foreach (Com_MEMain i in ListCom_MEMain)
            {
                if (i.comPartOperation == cCom_PartOperation)
                {
                    Is_Exist         = true;
                    currentComMEMain = i;
                    break;
                }
            }
            #endregion

            #region 如果本次上傳的資料不存在於資料庫,則開始上傳資料;如果已存在資料庫,則詢問是否要更新尺寸
            bool Is_Update = true;
            if (Is_Exist)
            {
                if (eTaskDialogResult.Yes == CaxPublic.ShowMsgYesNo("此料號已存在上一次的標註尺寸資料,是否更新?"))
                {
                    #region 刪除Com_Dimension資料表
                    IList <Com_Dimension> ListCom_Dimension = new List <Com_Dimension>();
                    CaxSQL.GetListCom_Dimension(currentComMEMain, out ListCom_Dimension);
                    foreach (Com_Dimension i in ListCom_Dimension)
                    {
                        CaxSQL.Delete <Com_Dimension>(i);
                    }
                    #endregion

                    #region 刪除Com_MEMain資料表
                    Com_MEMain cCom_MEMain = new Com_MEMain();
                    CaxSQL.GetCom_MEMain(cCom_PartOperation, out cCom_MEMain);
                    CaxSQL.Delete <Com_MEMain>(cCom_MEMain);
                    #endregion
                }
                else
                {
                    Is_Update = false;
                }
            }
            if (Is_Update)
            {
                #region 整理資料並上傳
                try
                {
                    Com_MEMain cCom_MEMain = new Com_MEMain();
                    cCom_MEMain.comPartOperation = cCom_PartOperation;
                    //cCom_MEMain.sysMEExcel = sysMEExcel;
                    cCom_MEMain.partDescription = sWorkPartAttribute.partDescription;
                    cCom_MEMain.createDate      = sWorkPartAttribute.createDate;
                    cCom_MEMain.material        = sWorkPartAttribute.material;
                    cCom_MEMain.draftingVer     = sWorkPartAttribute.draftingVer;

                    IList <Com_Dimension> listCom_Dimension = new List <Com_Dimension>();
                    foreach (DadDimension i in listDimensionData)
                    {
                        Com_Dimension cCom_Dimension = new Com_Dimension();
                        cCom_Dimension.MappingData(i);
                        cCom_Dimension.comMEMain = cCom_MEMain;
                        listCom_Dimension.Add(cCom_Dimension);
                        //Com_Dimension cCom_Dimension = new Com_Dimension();
                        //cCom_Dimension.comMEMain = cCom_MEMain;
                        //CaxME.MappingData(i, ref cCom_Dimension);
                        //listCom_Dimension.Add(cCom_Dimension);
                    }
                    cCom_MEMain.comDimension = listCom_Dimension;
                    CaxSQL.Save <Com_MEMain>(cCom_MEMain);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("上傳資料庫時發生錯誤,僅上傳實體檔案");
                }
                #endregion
            }

            #endregion


            #endregion

            CaxPart.Save();
            MessageBox.Show("上傳完成!");
            this.Close();
        }