private void comboBoxNCgroup_SelectedIndexChanged(object sender, EventArgs e) { PostPanel.Rows.Clear(); //清空superGrid資料&機台資訊 OperPanel.Rows.Clear(); MachineNo.Text = ""; //取得comboBox資料 CurrentNCGroup = comboBoxNCgroup.Text; #region 建立NC資料夾 string Is_Local = ""; Is_Local = Environment.GetEnvironmentVariable("UGII_ENV_FILE"); if (Is_Local != null) { //CaxPublic.GetAllPath("TE", displayPart.FullPath, out sPartInfo, ref cMETE_Download_Upload_Path); //if (!cMETE_Download_Upload_Path.Local_Folder_CAM.Contains("Oper1")) //{ // NCFolderPath = string.Format(@"{0}\{1}_{2}", cMETE_Download_Upload_Path.Local_Folder_CAM, CurrentNCGroup, "NC"); //} //else //{ // NCFolderPath = string.Format(@"{0}\{1}_{2}", Path.GetDirectoryName(displayPart.FullPath), CurrentNCGroup, "NC"); //} if (displayPart.FullPath.Contains("D:\\Globaltek\\Task")) { CaxPublic.GetAllPath("TE", displayPart.FullPath, out sPartInfo, ref cMETE_Download_Upload_Path); NCFolderPath = string.Format(@"{0}\{1}_{2}", cMETE_Download_Upload_Path.Local_Folder_CAM, CurrentNCGroup, "NC"); } else { NCFolderPath = string.Format(@"{0}\{1}_{2}", System.IO.Path.GetDirectoryName(displayPart.FullPath), CurrentNCGroup, "NC"); } } else { NCFolderPath = string.Format(@"{0}\{1}_{2}", Path.GetDirectoryName(displayPart.FullPath), CurrentNCGroup, "NC"); } if (!Directory.Exists(NCFolderPath)) { System.IO.Directory.CreateDirectory(NCFolderPath); } #endregion //取得選擇的NC foreach (NXOpen.CAM.NCGroup ncGroup in NCGroupAry) { if (CurrentNCGroup == ncGroup.Name) { SelectNCGroup = ncGroup; } } //取得Group下的所有OP OperationObj = SelectNCGroup.GetMembers(); #region 填值到SuperGridOperPanel GridRow gridRow = new GridRow(); foreach (KeyValuePair <string, string> kvp in DicNCData) { if (CurrentNCGroup != kvp.Key) { continue; } string[] splitOperName = kvp.Value.Split(','); for (int i = 0; i < splitOperName.Length; i++) { gridRow = new GridRow(false, splitOperName[i], ""); OperPanel.Rows.Add(gridRow); } } #endregion //填機台到MachineNo欄位並取得對應後處理器 try { this.MachineNo.Text = PostProcessorDlg.SelectNCGroup.GetStringAttribute("MachineNo"); } catch (Exception exception) { this.MachineNo.Text = ""; } if (this.MachineNo.Text == "") { gridRow = new GridRow(""); PostProcessorDlg.PostPanel.Rows.Add(gridRow); for (int k = 0; k < (int)PostProcessorDlg.TemplatePostData.Length; k++) { if (k > 6) { string templatePostData = PostProcessorDlg.TemplatePostData[k]; char[] chrArray = new char[] { ',' }; gridRow = new GridRow(templatePostData.Split(chrArray)[0]); PostProcessorDlg.PostPanel.Rows.Add(gridRow); } } } else { gridRow = new GridRow(""); PostProcessorDlg.PostPanel.Rows.Add(gridRow); ISession session = MyHibernateHelper.SessionFactory.OpenSession(); List <string> strs = new List <string>(); string[] strArrays1 = this.MachineNo.Text.Split(new char[] { ',' }); int num = 0; while (num < (int)strArrays1.Length) { string str = strArrays1[num]; Sys_MachineNo sysMachineNo = session.QueryOver <Sys_MachineNo>().Where((Sys_MachineNo x) => x.machineNo == str).SingleOrDefault <Sys_MachineNo>(); if (sysMachineNo.postprocessor != null) { string[] strArrays2 = sysMachineNo.postprocessor.Split(new char[] { ',' }); for (int l = 0; l < (int)strArrays2.Length; l++) { string str1 = strArrays2[l]; if (!strs.Contains(str1)) { strs.Add(str1); } } num++; } else { for (int m = 0; m < (int)PostProcessorDlg.TemplatePostData.Length; m++) { if (m > 6) { string templatePostData1 = PostProcessorDlg.TemplatePostData[m]; char[] chrArray1 = new char[] { ',' }; gridRow = new GridRow(templatePostData1.Split(chrArray1)[0]); PostProcessorDlg.PostPanel.Rows.Add(gridRow); } } break; } } foreach (string str2 in strs) { gridRow = new GridRow(str2); PostProcessorDlg.PostPanel.Rows.Add(gridRow); } } /* * try * { * MachineNo.Text = SelectNCGroup.GetStringAttribute("MachineNo"); * //postprocessor = SelectNCGroup.GetStringAttribute("postprocessor"); * } * catch (System.Exception ex) * { * MachineNo.Text = ""; * postprocessor = ""; * } * * if (postprocessor != "") * { * string[] splitPostProcessor = postprocessor.Split(','); * string empty = ""; * row = new GridRow(empty); * PostPanel.Rows.Add(row); * for (int i = 0; i < splitPostProcessor.Length; i++) * { * row = new GridRow(splitPostProcessor[i]); * PostPanel.Rows.Add(row); * } #region 在ShopDoc中有指定機台並且有後處理 * if (splitPostProcessor.Length == 1) * { * //如果只有一個後處理,則自動對應 * for (int i = 0; i < OperPanel.Rows.Count;i++ ) * { * OperPanel.GetCell(i, 2).Value = splitPostProcessor[0]; * } * } #endregion * } * else * { #region 在ShopDoc中沒指定機台or有指定機台但沒有後處理,則顯示全部後處理 * string empty = ""; * row = new GridRow(empty); * PostPanel.Rows.Add(row); * for (int i = 0; i < TemplatePostData.Length; i++) * { * if (i > 6) * { * string PostName = TemplatePostData[i].Split(',')[0]; * row = new GridRow(PostName); * PostPanel.Rows.Add(row); * } * } #endregion * } */ }
public bool Doit() { try { int module_id; theUfSession.UF.AskApplicationModule(out module_id); if (module_id != UFConstants.UF_APP_CAM) { MessageBox.Show("請先轉換為加工模組後再執行!"); return(false); } if (!GetToolListPath(out ToolListPath)) { MessageBox.Show("取得ToolList.xls失敗"); return(false); } //取得正確路徑,拆零件路徑字串取得客戶名稱、料號、版本 status = CaxPublic.GetAllPath("TE", displayPart.FullPath, out sPartInfo, ref cMETE_Download_Upload_Path); if (!status) { Is_Local = null; } //此條件判斷是否為走系統的零件 if (!displayPart.FullPath.Contains("Task")) { Is_Local = null; } if (Is_Local == null) { PartNo = Path.GetFileNameWithoutExtension(displayPart.FullPath); } else { PartNo = sPartInfo.PartNo; } //取得所有GroupAry,用來判斷Group的Type決定是NC、Tool、Geometry NXOpen.CAM.NCGroup[] NCGroupAry = displayPart.CAMSetup.CAMGroupCollection.ToArray(); //取得所有OperationAry NXOpen.CAM.Operation[] OperationAry = displayPart.CAMSetup.CAMOperationCollection.ToArray(); #region 取得相關資訊,填入DIC DicNCData = new Dictionary <string, List <OperData> >(); foreach (NXOpen.CAM.NCGroup ncGroup in NCGroupAry) { if (!IsNC(ncGroup)) { continue; } if (!ncGroup.Name.Contains("OP")) { MessageBox.Show("請先手動將Group名稱:" + ncGroup.Name + ",改為正確格式,再重新啟動功能!"); return(false); } //取得此NCGroup下的所有Oper CAMObject[] OperGroup = ncGroup.GetMembers(); foreach (NXOpen.CAM.Operation item in OperGroup) { bool cheValue; List <OperData> listOperData = new List <OperData>(); cheValue = DicNCData.TryGetValue(ncGroup.Name, out listOperData); if (!cheValue) { listOperData = new List <OperData>(); } bool chk = true; foreach (OperData i in listOperData) { if (i.ToolNumber == "T" + CaxOper.AskOperToolNumber(item)) { chk = false; break; } } if (!chk) { continue; } OperData sOperData = new OperData(); GetOperToolAttr(item, ref sOperData); listOperData.Add(sOperData); DicNCData[ncGroup.Name] = listOperData; } } //將DicNCData的key存入程式群組下拉選單中 foreach (KeyValuePair <string, List <OperData> > kvp in DicNCData) { comboBoxNCName.Items.Add(kvp.Key); } if (comboBoxNCName.Items.Count == 1) { comboBoxNCName.Text = comboBoxNCName.Items[0].ToString(); } #endregion } catch (System.Exception ex) { return(false); } return(true); }
private void ExportMainProg_Click(object sender, EventArgs e) { List <string> ExportData = new List <string>(); for (int i = 0; i < listView3.Items.Count; i++) { ExportData.Add(listView3.Items[i].Text); } for (int i = 0; i < listView1.Items.Count; i++) { ExportData.Add(listView1.Items[i].Text); } for (int i = 0; i < listView4.Items.Count; i++) { ExportData.Add(listView4.Items[i].Text); } //建立NC資料夾 string Is_Local = "", NCFolderPath = ""; Is_Local = Environment.GetEnvironmentVariable("UGII_ENV_FILE"); if (Is_Local != "") { CaxPublic.GetAllPath("TE", displayPart.FullPath, ref cMETE_Download_Upload_Path); NCFolderPath = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Local_Folder_CAM, "NC"); } else { NCFolderPath = string.Format(@"{0}\{1}", Path.GetDirectoryName(displayPart.FullPath), "NC"); } if (!Directory.Exists(NCFolderPath)) { System.IO.Directory.CreateDirectory(NCFolderPath); } //設定輸出路徑 string ExportPath = string.Format(@"{0}\{1}", NCFolderPath, NewGroupName); //string NCFolderPath = string.Format(@"{0}\{1}", Path.GetDirectoryName(displayPart.FullPath), "NC"); //if (!Directory.Exists(NCFolderPath)) //{ // System.IO.Directory.CreateDirectory(NCFolderPath); //} //string ExportPath = string.Format(@"{0}\{1}", Path.GetDirectoryName(displayPart.FullPath), NewGroupName); if (chb_Heidenhain.Checked == true) { for (int i = 0; i < ExportData.Count; i++) { ExportData[i] = i.ToString() + " " + ExportData[i]; } ExportPath = ExportPath + ".h"; } else if (chb_Simens.Checked == true) { for (int i = 0; i < ExportData.Count; i++) { ExportData[i] = "N" + i.ToString() + " " + ExportData[i]; } ExportPath = ExportPath + ".MPF"; } System.IO.StreamWriter file = new System.IO.StreamWriter(ExportPath); for (int i = 0; i < ExportData.Count; i++) { file.Write(ExportData[i] + "\r\n"); } file.Close(); this.Hide(); UI.GetUI().NXMessageBox.Show("恭喜", NXMessageBox.DialogType.Information, "主程式編輯完成!"); this.Show(); }
private void PostProcessorDlg_Load(object sender, EventArgs e) { //取得METEDownload_Upload資料 status = CaxGetDatData.GetMETEDownload_Upload(out cMETE_Download_Upload_Path); if (!status) { MessageBox.Show("取得METEDownload_Upload失敗"); return; } //取得所有GroupAry,用來判斷Group的Type決定是NC、Tool、Geometry NCGroupAry = displayPart.CAMSetup.CAMGroupCollection.ToArray(); //取得所有operationAry OperationAry = displayPart.CAMSetup.CAMOperationCollection.ToArray(); #region 建立NC資料夾 string Is_Local = ""; Is_Local = Environment.GetEnvironmentVariable("UGII_ENV_FILE"); if (Is_Local != "") { CaxPublic.GetAllPath("TE", displayPart.FullPath, ref cMETE_Download_Upload_Path); NCFolderPath = string.Format(@"{0}\{1}", cMETE_Download_Upload_Path.Local_Folder_CAM, "NC"); } else { NCFolderPath = string.Format(@"{0}\{1}", Path.GetDirectoryName(displayPart.FullPath), "NC"); } if (!Directory.Exists(NCFolderPath)) { System.IO.Directory.CreateDirectory(NCFolderPath); } #endregion #region 取得相關資訊,填入Dic DicNCData = new Dictionary <string, string>(); foreach (NXOpen.CAM.NCGroup ncGroup in NCGroupAry) { int type; int subtype; theUfSession.Obj.AskTypeAndSubtype(ncGroup.Tag, out type, out subtype); //判斷是否為Program群組 if (type != UFConstants.UF_machining_task_type) { continue; } foreach (NXOpen.CAM.Operation item in OperationAry) { //取得父層的群組(回傳:NCGroup XXXX) string NCProgramTag = item.GetParent(CAMSetup.View.ProgramOrder).ToString(); NCProgramTag = Regex.Replace(NCProgramTag, "[^0-9]", ""); if (NCProgramTag == ncGroup.Tag.ToString()) { bool cheValue; string OperName = ""; cheValue = DicNCData.TryGetValue(ncGroup.Name, out OperName); if (!cheValue) { OperName = item.Name; DicNCData.Add(ncGroup.Name, OperName); } else { OperName = OperName + "," + item.Name; DicNCData[ncGroup.Name] = OperName; } } } } #endregion //將DicProgName的key存入程式群組下拉選單中 comboBoxNCgroup.Items.AddRange(DicNCData.Keys.ToArray()); #region 將控制器名稱填入SuperGridPostPanel GridRow row = new GridRow(); //-----暫時使用版本(路徑指向UG) string TemplateRoot = string.Format(@"{0}\{1}\{2}\{3}", Environment.GetEnvironmentVariable("UGII_BASE_DIR"), "MACH", "resource", "postprocessor"); string TemplatePostPath = string.Format(@"{0}\{1}", TemplateRoot, "template_post.dat"); string[] TemplatePostData = System.IO.File.ReadAllLines(TemplatePostPath); //-----發佈使用版本(Server需有MACH檔案) //string[] TemplatePostData = CaxGetDatData.GetTemplatePostData(); if (TemplatePostData.Length == 0) { CaxLog.ShowListingWindow("template_post.dat為空,請檢查!"); } string empty = ""; row = new GridRow(empty); PostPanel.Rows.Add(row); for (int i = 0; i < TemplatePostData.Length; i++) { if (i > 6) { string PostName = TemplatePostData[i].Split(',')[0]; row = new GridRow(PostName); PostPanel.Rows.Add(row); } } #endregion }
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 }
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 }