public static bool CopyNCToDesktop(string cus, string partNo, string cusVer, string opVer, string op1, string ncName) { try { string NCFolderPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}\{6}\{7}", OutputForm.EnvVariables.env_Task, cus, partNo, cusVer, opVer, "OP" + op1, "CAM", ncName); string DeskTopPath = string.Format(@"{0}\{1}_{2}_{3}\{4}", Environment.GetFolderPath(Environment.SpecialFolder.Desktop), partNo, cusVer, opVer, ncName); if (!Directory.Exists(DeskTopPath)) { Directory.CreateDirectory(DeskTopPath); } status = CaxPublic.DirectoryCopy(NCFolderPath, DeskTopPath, false); if (!status) { MessageBox.Show("CAM資料夾複製失敗,請聯繫開發工程師"); return(false); } } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); return(false); } return(true); }
private void OK_Click(object sender, EventArgs e) { CaxPart.SaveAll(); #region Part上傳 List <string> ListPartName = new List <string>(); status = CaxUpLoad.UploadPart(DicPartDirData, out ListPartName); if (!status) { this.Close(); return; } System.IO.File.WriteAllLines(string.Format(@"{0}\{1}\{2}", sDownUpLoadDat.Server_ShareStr, "OP" + cCaxTEUpLoad.OpNum, "PartNameText_CAM.txt"), ListPartName.ToArray()); #endregion //CAM資料夾上傳 status = CaxPublic.DirectoryCopy(sDownUpLoadDat.Local_Folder_CAM, sDownUpLoadDat.Server_Folder_CAM, true); if (!status) { MessageBox.Show("CAM資料夾複製失敗,請聯繫開發工程師"); this.Close(); } #region (註解中)Excel上傳 /* * if (File.Exists(sExcelDirData.ExcelShopDocLocalDir)) * { * try * { * File.Copy(sExcelDirData.ExcelShopDocLocalDir, sExcelDirData.ExcelShopDocServerDir, true); * } * catch (System.Exception ex) * { * CaxLog.ShowListingWindow("ShopDoc.xls上傳失敗"); * this.Close(); * } * } */ #endregion #region (註解)NC上傳 /* * if (Directory.Exists(sNCProgramDirData.NCProgramLocalDir)) * { * try * { * CaxPublic.DirectoryCopy(sNCProgramDirData.NCProgramLocalDir, sNCProgramDirData.NCProgramServerDir, true); * } * catch (System.Exception ex) * { * CaxLog.ShowListingWindow("NC上傳失敗"); * this.Close(); * } * } */ #endregion #region (註解)上傳至資料庫 /* * NCGroup[] NCGroupAry = displayPart.CAMSetup.CAMGroupCollection.ToArray(); * Dictionary<string, Function.OperData> DicNCData = new Dictionary<string, Function.OperData>(); * status = Function.GetNCProgramData(NCGroupAry, out DicNCData); * if (!status) * { * MessageBox.Show("取得NC資料失敗,無法上傳至數據庫,僅上傳NX檔案"); * goto finish; * } * * Com_PEMain comPEMain = new Com_PEMain(); * status = Function.GetCom_PEMain(sPartInfo, out comPEMain); * if (!status) * { * MessageBox.Show("資料庫無此筆料號,僅上傳NX檔案"); * goto finish; * } * * Com_PartOperation comPartOperation = new Com_PartOperation(); * status = Function.GetCom_PartOperation(sPartInfo, comPEMain, out comPartOperation); * if (!status) * { * MessageBox.Show("資料庫無此筆料號,僅上傳NX檔案"); * goto finish; * } * * foreach (KeyValuePair<string,Function.OperData> kvp in DicNCData) * { * Com_TEMain ComTEMain = session.QueryOver<Com_TEMain>() * .Where(x => x.comPartOperation == comPartOperation) * .And(x => x.ncGroupName == kvp.Key) * .SingleOrDefault(); * if (ComTEMain == null) * { * //表示未插入過此NC資料,直接插入 * * } * } */ #endregion //finish: MessageBox.Show("上傳完成!"); this.Close(); }
private void Upload_Click(object sender, EventArgs e) { try { int SheetCount = 0; NXOpen.Tag[] SheetTagAry = null; theUfSession.Draw.AskDrawings(out SheetCount, out SheetTagAry); //判斷是否需要出PDF List <DrawingSheet> drawingSheets = new List <DrawingSheet>(); for (int j = 0; j < SheetCount; j++) { drawingSheets.Add((DrawingSheet)NXObjectManager.Get(SheetTagAry[j])); } if (this.ExportPDF.Checked) { if (!Directory.Exists(this.L_Folder)) { Directory.CreateDirectory(this.L_Folder); } string str1 = string.Format(@"{0}\{1}.pdf", this.L_Folder, Path.GetFileNameWithoutExtension(FixInsUploadDlg.displayPart.FullPath)); CaxME.CreateOISPDF(drawingSheets, str1); //傳OIS圖到SERVER if (!Directory.Exists(S_Folder)) { System.IO.Directory.CreateDirectory(S_Folder); } CaxPublic.DirectoryCopy(this.L_Folder, S_Folder, true); } //取得WorkPart資訊並檢查資料是否完整 DadDimension.WorkPartAttribute sWorkPartAttribute = new DadDimension.WorkPartAttribute(); status = DadDimension.GetWorkPartAttribute(workPart, out sWorkPartAttribute); if (!status) { if (this.ExportPDF.Checked) { MessageBox.Show("量測資訊不足,僅上傳PDF檔案,上傳完成!"); } else { MessageBox.Show("量測資訊不足,無法上傳資料!"); } this.Close(); return; } //if (sWorkPartAttribute.draftingVer == "" || sWorkPartAttribute.draftingDate == "" || // sWorkPartAttribute.partDescription == "" || sWorkPartAttribute.material == "") //{ // MessageBox.Show("量測資訊不足"); // this.Close(); // return; //} //取得所有量測尺寸資料 List <DadDimension> listDimensionData = new List <DadDimension>(); for (int i = 0; i < SheetCount; i++) { //打開Sheet並記錄所有OBJ NXOpen.Drawings.DrawingSheet CurrentSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry[i]); CurrentSheet.Open(); CurrentSheet.View.UpdateDisplay(); DisplayableObject[] SheetObj = CurrentSheet.View.AskVisibleObjects(); status = Com_FixDimension.RecordFixDimension(SheetObj, sWorkPartAttribute, ref listDimensionData); if (!status) { this.Close(); return; } } //將圖片存到本機Globaltek內 for (int i = 0; i < PicNameStr.Length; i++) { string destFileName = string.Format(@"{0}\{1}", this.L_Folder, PicNameStr[i]); File.Copy(PicPathStr[i], destFileName, true); } //由料號查Com_PEMain Com_PEMain cCom_PEMain = new Com_PEMain(); status = CaxSQL.GetCom_PEMain(cCaxUpLoad.CusName, cCaxUpLoad.PartName, cCaxUpLoad.CusRev, cCaxUpLoad.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, cCaxUpLoad.OpNum, out cCom_PartOperation); if (!status) { return; } #region 比對資料庫FixInspection是否有同筆數據 bool Is_Exit = true; Com_FixInspection cCom_FixInspection = new Com_FixInspection(); CaxSQL.GetCom_FixInspection(cCom_PartOperation, Path.GetFileNameWithoutExtension(workPart.FullPath), out cCom_FixInspection); if (cCom_FixInspection == null) { Is_Exit = false; } if (Is_Exit && eTaskDialogResult.Yes == CaxPublic.ShowMsgYesNo("此檢、治具已存在上一筆資料,是否更新?")) { #region 刪除Com_FixDimension IList <Com_FixDimension> listComFixDimension = new List <Com_FixDimension>(); CaxSQL.GetListCom_FixDimension(cCom_FixInspection, out listComFixDimension); foreach (Com_FixDimension i in listComFixDimension) { CaxSQL.Delete <Com_FixDimension>(i); } #endregion #region 刪除Com_FixInspection CaxSQL.Delete <Com_FixInspection>(cCom_FixInspection); #endregion Is_Exit = false; } if (!Is_Exit) { cCom_FixInspection = new Com_FixInspection() { comPartOperation = cCom_PartOperation, fixinsDescription = this.Desc.Text, fixinsERP = this.ERPNo.Text, fixinsNo = this.FixInsNo.Text, fixPicPath = this.S_PicPath, fixPartName = Path.GetFileNameWithoutExtension(FixInsUploadDlg.workPart.FullPath) }; IList <Com_FixDimension> listCom_FixDimension = new List <Com_FixDimension>(); foreach (DadDimension i in listDimensionData) { //Com_FixDimension cCom_FixDimension = new Com_FixDimension() //{ // comFixInspection = comFixInspection //}; ////cCom_FixDimension.comFixInspection = comFixInspection; //CaxME.MappingData(i, ref cCom_FixDimension); //listCom_FixDimension.Add(cCom_FixDimension); Com_FixDimension cCom_FixDimension = new Com_FixDimension(); cCom_FixDimension.MappingData(i); cCom_FixDimension.comFixInspection = cCom_FixInspection; listCom_FixDimension.Add(cCom_FixDimension); } cCom_FixInspection.comFixDimension = listCom_FixDimension; CaxSQL.Save <Com_FixInspection>(cCom_FixInspection); //傳OIS圖到SERVER if (!Directory.Exists(S_Folder)) { System.IO.Directory.CreateDirectory(S_Folder); } CaxPublic.DirectoryCopy(this.L_Folder, S_Folder, true); } #endregion MessageBox.Show("上傳完成"); base.Close(); } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } }
private void OK_Click(object sender, EventArgs e) { //Part上傳 List <string> ListPartName = new List <string>(); string[] PartText; foreach (KeyValuePair <string, PartDirData> kvp in DicPartDirData) { //判斷Part是否存在 if (!File.Exists(kvp.Value.PartLocalDir)) { CaxLog.ShowListingWindow("Part不存在,無法上傳"); return; } try { File.Copy(kvp.Value.PartLocalDir, kvp.Value.PartServer1Dir, true); } catch (System.Exception ex) { CaxLog.ShowListingWindow(Path.GetFileName(kvp.Value.PartLocalDir) + "上傳失敗"); this.Close(); } ListPartName.Add(kvp.Key + ".prt"); } PartText = ListPartName.ToArray(); System.IO.File.WriteAllLines(string.Format(@"{0}\{1}", Server_OP_Folder, "PartNameText_CAM.txt"), PartText); //Excel上傳 if (File.Exists(sExcelDirData.ExcelShopDocLocalDir)) { try { File.Copy(sExcelDirData.ExcelShopDocLocalDir, sExcelDirData.ExcelShopDocServerDir, true); } catch (System.Exception ex) { CaxLog.ShowListingWindow("ShopDoc.xls上傳失敗"); this.Close(); } } //NC上傳 //判斷NC是否存在 if (Directory.Exists(sNCProgramDirData.NCProgramLocalDir)) { try { CaxPublic.DirectoryCopy(sNCProgramDirData.NCProgramLocalDir, sNCProgramDirData.NCProgramServerDir, true); } catch (System.Exception ex) { CaxLog.ShowListingWindow("NC上傳失敗"); this.Close(); } } MessageBox.Show("上傳完成!"); this.Close(); }
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(); }
private void buttonDownload_Click(object sender, EventArgs e) { //建立Local路徑資料 //string Local_IP = cMETE_Download_Upload_Path.Local_IP; //string Local_ShareStr = cMETE_Download_Upload_Path.Local_ShareStr; //Local_Folder_MODEL = cMETE_Download_Upload_Path.Local_Folder_MODEL; //Local_Folder_CAM = cMETE_Download_Upload_Path.Local_Folder_CAM; //Local_Folder_OIS = cMETE_Download_Upload_Path.Local_Folder_OIS; //取代字串成正確路徑 //Local_ShareStr = Local_ShareStr.Replace("[Local_IP]", Local_IP); //Local_ShareStr = Local_ShareStr.Replace("[CusName]", CurrentCusName); //Local_ShareStr = Local_ShareStr.Replace("[PartNo]", CurrentPartNo); //Local_ShareStr = Local_ShareStr.Replace("[CusRev]", CurrentCusRev); //Local_ShareStr = Local_ShareStr.Replace("[OpRev]", CurrentOpRev); //Local_Folder_MODEL = Local_Folder_MODEL.Replace("[Local_ShareStr]", Local_ShareStr); //Local_Folder_CAM = Local_Folder_CAM.Replace("[Local_ShareStr]", Local_ShareStr); //Local_Folder_OIS = Local_Folder_OIS.Replace("[Local_ShareStr]", Local_ShareStr); #region (2016.12.30註解)建立Local_Folder_MODEL資料夾 //if (!File.Exists(Local_Folder_MODEL)) //{ // try // { // System.IO.Directory.CreateDirectory(Local_Folder_MODEL); // } // catch (System.Exception ex) // { // MessageBox.Show(ex.ToString()); // return; // } //} #endregion #region (2016.12.30註解)複製Server客戶檔案到Local_Folder_MODEL資料夾內 /* * //判斷客戶檔案是否存在 * status = System.IO.File.Exists(Server_Folder_MODEL); * if (!status) * { * MessageBox.Show("指定的檔案不存在,請再次確認"); * return; * } * * //建立Local_Folder_MODEL資料夾內客戶檔案路徑 * string Local_CusPartFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_Folder_MODEL)); * * //判斷是否存在,不存在則開始複製 * if (!File.Exists(Local_CusPartFullPath)) * { * try * { * File.Copy(Server_Folder_MODEL, Local_CusPartFullPath, true); * } * catch (System.Exception ex) * { * CaxLog.ShowListingWindow("客戶檔案複製失敗"); * this.Close(); * } * } */ #endregion #region (註解)複製ShopDoc.xls到Local_Folder_MODEL資料夾內 /* * //判斷ShopDoc.xls是否存在 * if (!File.Exists(Server_ShopDoc)) * { * listBox1.Items.Add("刀具路徑與清單樣板(ShopDoc.xls)不存在,無法下載"); * return; * } * * //建立Local_Folder_MODEL資料夾內客戶檔案路徑 * string Local_ShopDocFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_ShopDoc)); * * //判斷是否存在,不存在則開始複製 * if (!File.Exists(Local_ShopDocFullPath)) * { * try * { * File.Copy(Server_ShopDoc, Local_ShopDocFullPath, true); * } * catch (System.Exception ex) * { * CaxLog.ShowListingWindow("ShopDoc.xls下載失敗"); * this.Close(); * } * } */ #endregion #region 先刪除本機中該製程的OPxxx->CAM資料夾、TEpart檔 //刪除本機OPxxx資料夾路徑 foreach (string i in Oper1comboBox.Items) { if (Oper1comboBox.Text == "全部下載") { if (i == "全部下載") { continue; } } else { if (i != Oper1comboBox.Text) { continue; } } Local_Folder_CAM = sDownUpLoadDat.Local_Folder_CAM; Local_Folder_CAM = Local_Folder_CAM.Replace("[Oper1]", i); if (Directory.Exists(Local_Folder_CAM)) { Directory.Delete(Local_Folder_CAM, true); } } /* * for (int i = 0; i < Oper1comboBox.Items.Count; i++) * { * if (CurrentOper1 != Oper1comboBox.Items[i].ToString() & CurrentOper1 != "全部下載") * { * continue; * } * string Local_OPxxxPath = string.Format(@"{0}\{1}\{2}", Local_ShareStr, "OP" + Oper1comboBox.Items[i].ToString(), "CAM"); * if (Directory.Exists(Local_OPxxxPath)) * { * Directory.Delete(Local_OPxxxPath, true); * } * string Local_TEpartPath = string.Format(@"{0}\{1}", Local_ShareStr, CurrentPartNo + "_TE_" + Oper1comboBox.Items[i].ToString() + ".prt"); * if (File.Exists(Local_TEpartPath)) * { * File.Delete(Local_TEpartPath); * } * } */ /* * string Local_OPxxxPath = string.Format(@"{0}\{1}\{2}", Local_ShareStr, "OP" + CurrentOper1, "CAM"); * if (Directory.Exists(Local_OPxxxPath)) * { * Directory.Delete(Local_OPxxxPath, true); * } * string Local_TEpartPath = string.Format(@"{0}\{1}", Local_ShareStr, CurrentPartNo + "_TE_" + CurrentOper1 + ".prt"); * if (File.Exists(Local_TEpartPath)) * { * File.Delete(Local_TEpartPath); * } */ #endregion #region 建立Local_Folder_CAM、Local_Folder_OIS資料夾 //暫存一個tempLocal_Folder_CAM、Local_Folder_OIS,目的要讓程式每次都能有[Oper1]可取代 //tempLocal_Folder_CAM = Local_Folder_CAM; //tempLocal_Folder_OIS = Local_Folder_OIS; //tempServer_Folder_CAM = Server_Folder_CAM; ListDownloadCAMPath = new List <CAMPath>(); foreach (string i in Oper1comboBox.Items) { if (Oper1comboBox.Text == "全部下載") { if (i == "全部下載") { continue; } } else { if (i != Oper1comboBox.Text) { continue; } } Local_Folder_CAM = sDownUpLoadDat.Local_Folder_CAM; Local_Folder_OIS = sDownUpLoadDat.Local_Folder_OIS; Local_Folder_CAM = Local_Folder_CAM.Replace("[Oper1]", i); Local_Folder_OIS = Local_Folder_OIS.Replace("[Oper1]", i); if (!File.Exists(Local_Folder_CAM)) { System.IO.Directory.CreateDirectory(Local_Folder_CAM); } if (!File.Exists(Local_Folder_OIS)) { System.IO.Directory.CreateDirectory(Local_Folder_OIS); } Server_Folder_CAM = sDownUpLoadDat.Server_Folder_CAM; Server_Folder_CAM = Server_Folder_CAM.Replace("[Oper1]", i.ToString()); CAMPath sCAMPath = new CAMPath(); sCAMPath.L_CAM_Path = Local_Folder_CAM; sCAMPath.S_CAM_Path = Server_Folder_CAM; ListDownloadCAMPath.Add(sCAMPath); } /* * if (CurrentOper1 == "全部下載") * { * for (int i = 0; i < Oper1comboBox.Items.Count; i++) * { * if (Oper1comboBox.Items[i].ToString() == "全部下載") * { * continue; * } * Local_Folder_CAM = tempLocal_Folder_CAM; * Local_Folder_OIS = tempLocal_Folder_OIS; * Local_Folder_CAM = Local_Folder_CAM.Replace("[Oper1]", Oper1comboBox.Items[i].ToString()); * Local_Folder_OIS = Local_Folder_OIS.Replace("[Oper1]", Oper1comboBox.Items[i].ToString()); * if (!File.Exists(Local_Folder_CAM)) * { * try * { * System.IO.Directory.CreateDirectory(Local_Folder_CAM); * } * catch (System.Exception ex) * { * MessageBox.Show(ex.ToString()); * return; * } * } * if (!File.Exists(Local_Folder_OIS)) * { * try * { * System.IO.Directory.CreateDirectory(Local_Folder_OIS); * } * catch (System.Exception ex) * { * MessageBox.Show(ex.ToString()); * return; * } * } * Server_Folder_CAM = tempServer_Folder_CAM; * Server_Folder_CAM = Server_Folder_CAM.Replace("[Oper1]", Oper1comboBox.Items[i].ToString()); * CAMPath sCAMPath = new CAMPath(); * sCAMPath.L_CAM_Path = Local_Folder_CAM; * sCAMPath.S_CAM_Path = Server_Folder_CAM; * ListDownloadCAMPath.Add(sCAMPath); * } * } * else * { * Local_Folder_CAM = tempLocal_Folder_CAM; * Local_Folder_OIS = tempLocal_Folder_OIS; * Local_Folder_CAM = Local_Folder_CAM.Replace("[Oper1]", CurrentOper1); * Local_Folder_OIS = Local_Folder_OIS.Replace("[Oper1]", CurrentOper1); * if (!File.Exists(Local_Folder_CAM)) * { * try * { * System.IO.Directory.CreateDirectory(Local_Folder_CAM); * } * catch (System.Exception ex) * { * MessageBox.Show(ex.ToString()); * return; * } * } * if (!File.Exists(Local_Folder_OIS)) * { * try * { * System.IO.Directory.CreateDirectory(Local_Folder_OIS); * } * catch (System.Exception ex) * { * MessageBox.Show(ex.ToString()); * return; * } * } * Server_Folder_CAM = tempServer_Folder_CAM; * Server_Folder_CAM = Server_Folder_CAM.Replace("[Oper1]", CurrentOper1); * CAMPath sCAMPath = new CAMPath(); * sCAMPath.L_CAM_Path = Local_Folder_CAM; * sCAMPath.S_CAM_Path = Server_Folder_CAM; * ListDownloadCAMPath.Add(sCAMPath); * } */ /* * //DicSeleOper1(Key = 製程序,Value = ServerPartPath) * foreach (KeyValuePair<string, string> kvp in DicSeleOper1) * { * Local_Folder_CAM = tempLocal_Folder_CAM; * Local_Folder_OIS = tempLocal_Folder_OIS; * Local_Folder_CAM = Local_Folder_CAM.Replace("[Oper1]", kvp.Key); * Local_Folder_OIS = Local_Folder_OIS.Replace("[Oper1]", kvp.Key); * if (!File.Exists(Local_Folder_CAM)) * { * try * { * System.IO.Directory.CreateDirectory(Local_Folder_CAM); * } * catch (System.Exception ex) * { * MessageBox.Show(ex.ToString()); * return; * } * } * if (!File.Exists(Local_Folder_OIS)) * { * try * { * System.IO.Directory.CreateDirectory(Local_Folder_OIS); * } * catch (System.Exception ex) * { * MessageBox.Show(ex.ToString()); * return; * } * } * } */ #endregion #region 複製Server製程序檔案到Local資料夾內 foreach (string i in ListDownloadPartPath) { //刪除本機TEpart string Local_TEpart = string.Format(@"{0}\{1}", sDownUpLoadDat.Local_ShareStr, Path.GetFileName(i)); if (File.Exists(Local_TEpart)) { File.Delete(Local_TEpart); } //判斷Part檔案是否存在 if (!File.Exists(i)) { CaxLog.ShowListingWindow("製程序檔案" + Path.GetFileName(i) + "不存在,請再次確認"); this.Close(); } //建立Local_ShareStr資料夾內製程序檔案路徑 string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", sDownUpLoadDat.Local_ShareStr, Path.GetFileName(i)); //開始複製 try { File.Copy(i, Local_Oper1PartFullPath, true); } catch (System.Exception ex) { CaxLog.ShowListingWindow(Path.GetFileName(i) + "下載失敗"); this.Close(); } } /* * foreach (KeyValuePair<string, string> kvp in DicSeleOper1) * { * //判斷製程序檔案是否存在 * Server_TEDownloadPart = tempServer_TEDownloadPart; * Server_TEDownloadPart = Server_TEDownloadPart.Replace("[Oper1]", kvp.Key); * status = System.IO.File.Exists(Server_TEDownloadPart); * if (!status) * { * MessageBox.Show("製程序檔案" + Path.GetFileName(Server_TEDownloadPart) + "不存在,請再次確認"); * return; * } * * //建立Local_ShareStr資料夾內製程序檔案路徑 * string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileName(Server_TEDownloadPart)); * * //開始複製 * File.Copy(Server_TEDownloadPart, Local_Oper1PartFullPath, true); * } */ #endregion #region 複製ServerCAM資料夾到Local資料夾內 foreach (CAMPath i in ListDownloadCAMPath) { status = CaxPublic.DirectoryCopy(i.S_CAM_Path, i.L_CAM_Path, true); if (!status) { MessageBox.Show("CAM資料夾複製失敗,請聯繫開發工程師"); this.Close(); } } #endregion MessageBox.Show("下載完成!"); this.Close(); }