Пример #1
0
        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_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 建立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 複製Server客戶檔案到Local_Folder_MODEL資料夾內

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

            //建立Local_Folder_MODEL資料夾內客戶檔案路徑
            string Local_CusPartFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_MODEL));

            //判斷是否存在,不存在則開始複製
            if (!File.Exists(Local_CusPartFullPath))
            {
                File.Copy(Server_MODEL, Local_CusPartFullPath, true);
            }

            #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;

            //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 (KeyValuePair <string, string> kvp in DicSeleOper1)
            {
                //判斷製程序檔案是否存在
                Server_MEDownloadPart = tempServer_MEDownloadPart;
                Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", kvp.Key);
                status = System.IO.File.Exists(Server_MEDownloadPart);
                if (!status)
                {
                    MessageBox.Show("製程序檔案" + Path.GetFileName(Server_MEDownloadPart) + "不存在,請再次確認");
                    return;
                }

                //建立Local_ShareStr資料夾內製程序檔案路徑
                string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileName(Server_MEDownloadPart));

                //開始複製
                File.Copy(Server_MEDownloadPart, Local_Oper1PartFullPath, true);
            }

            #endregion

            #region (註解中)自動開啟檔案組立架構

            /*
             * //組件存在,直接開啟任務組立
             * BasePart newAsmPart;
             * status = CaxPart.OpenBaseDisplay(Local_Oper1PartFullPath, out newAsmPart);
             * if (!status)
             * {
             *  CaxLog.ShowListingWindow("組立開啟失敗!");
             *  return;
             * }
             *
             * //將客戶檔案組裝進來
             * string NewCusPartName = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileNameWithoutExtension(Server_MODEL) + "_" + CurrentOper1 + ".prt");
             *
             * //複製客戶檔案並更名(料號+製程序.prt)後放到新路徑(本機Globaltek\Task\料號\版次\)
             * File.Copy(Local_CusPartFullPath, NewCusPartName, true);
             * `
             * //開始組裝
             * NXOpen.Assemblies.Component newComponent = null;
             * status = CaxAsm.AddComponentToAsmByDefault(NewCusPartName, out newComponent);
             * if (!status)
             * {
             *  CaxLog.ShowListingWindow("ERROR,組裝失敗!");
             *  return;
             * }
             */
            #endregion

            //CaxAsm.SetWorkComponent(null);
            MessageBox.Show("下載完成!");
            this.Close();
            //CaxPart.Save();
        }
Пример #2
0
        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_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 建立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 複製Server客戶檔案到Local_Folder_MODEL資料夾內

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

            //建立Local_Folder_MODEL資料夾內客戶檔案路徑
            string Local_CusPartFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_MODEL));

            //判斷是否存在,不存在則開始複製
            if (!File.Exists(Local_CusPartFullPath))
            {
                try
                {
                    File.Copy(Server_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))
            {
                listView.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 建立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;

            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;
                        }
                    }
                }
            }
            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;
                    }
                }
            }

            /*
             * //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)
            {
                //判斷Part檔案是否存在
                if (!File.Exists(i))
                {
                    CaxLog.ShowListingWindow("製程序檔案" + Path.GetFileName(i) + "不存在,請再次確認");
                    //MessageBox.Show("製程序檔案" + Path.GetFileName(i) + "不存在,請再次確認");
                    this.Close();
                }
                //建立Local_ShareStr資料夾內製程序檔案路徑
                string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", 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

            MessageBox.Show("下載完成!");


            this.Close();
        }
Пример #3
0
        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();
        }
Пример #4
0
        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.29註解)建立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.29註解)複製Server客戶檔案到Local_Folder_MODEL資料夾內

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

            //建立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 (註解)複製IPQC.xls到Local_Folder_MODEL資料夾內

            ////判斷IPQC.xls是否存在
            //if (!File.Exists(Server_IPQC))
            //{
            //    listView.Items.Add("IPQC樣板(IPQC.xls)不存在,無法下載");
            //    return;
            //}

            ////建立Local_Folder_MODEL資料夾內客戶檔案路徑
            //string Local_IPQCFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_IPQC));

            ////判斷是否存在,不存在則開始複製
            //if (!File.Exists(Local_IPQCFullPath))
            //{
            //    try
            //    {
            //        File.Copy(Server_IPQC, Local_IPQCFullPath, true);
            //    }
            //    catch (System.Exception ex)
            //    {
            //        CaxLog.ShowListingWindow("IPQC.xls下載失敗");
            //        this.Close();
            //    }

            //}

            #endregion

            #region (註解)複製SelfCheck.xls到Local_Folder_MODEL資料夾內
            ////判斷SelfCheck.xls是否存在
            //if (!File.Exists(Server_SelfCheck))
            //{
            //    listView.Items.Add("SelfCheck樣板(SelfCheck.xls)不存在,無法下載");
            //    return;
            //}

            ////建立Local_Folder_MODEL資料夾內客戶檔案路徑
            //string Local_SelfCheckFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_SelfCheck));

            ////判斷是否存在,不存在則開始複製
            //if (!File.Exists(Local_SelfCheckFullPath))
            //{
            //    try
            //    {
            //        File.Copy(Server_SelfCheck, Local_SelfCheckFullPath, true);
            //    }
            //    catch (System.Exception ex)
            //    {
            //        CaxLog.ShowListingWindow("SelfCheck.xls下載失敗");
            //        this.Close();
            //    }

            //}
            #endregion

            #region (註解)複製IQC.xls到Local_Folder_MODEL資料夾內

            ////判斷IPQC.xls是否存在
            //if (!File.Exists(Server_IQC))
            //{
            //    listView.Items.Add("IQC樣板(IQC.xls)不存在,無法下載");
            //    return;
            //}

            ////建立Local_Folder_MODEL資料夾內客戶檔案路徑
            //string Local_IQCFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_IQC));

            ////判斷是否存在,不存在則開始複製
            //if (!File.Exists(Local_IQCFullPath))
            //{
            //    try
            //    {
            //        File.Copy(Server_IQC, Local_IQCFullPath, true);
            //    }
            //    catch (System.Exception ex)
            //    {
            //        CaxLog.ShowListingWindow("IQC.xls複製失敗");
            //        this.Close();
            //    }

            //}

            #endregion

            #region (註解)複製FAI.xls到Local_Folder_MODEL資料夾內

            ////判斷IPQC.xls是否存在
            //if (!File.Exists(Server_FAI))
            //{
            //    listView.Items.Add("FAI樣板(FAI.xls)不存在,無法下載");
            //    return;
            //}

            ////建立Local_Folder_MODEL資料夾內客戶檔案路徑
            //string Local_FAIFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_FAI));

            ////判斷是否存在,不存在則開始複製
            //if (!File.Exists(Local_FAIFullPath))
            //{
            //    try
            //    {
            //        File.Copy(Server_FAI, Local_FAIFullPath, true);
            //    }
            //    catch (System.Exception ex)
            //    {
            //        CaxLog.ShowListingWindow("FAI.xls複製失敗");
            //        this.Close();
            //    }

            //}

            #endregion

            #region 先刪除本機中該製程的OPxxx->OIS資料夾
            //刪除本機OPxxx資料夾路徑
            foreach (string i in Oper1comboBox.Items)
            {
                if (Oper1comboBox.Text == "全部下載")
                {
                    if (i == "全部下載")
                    {
                        continue;
                    }
                }
                else
                {
                    if (i != Oper1comboBox.Text)
                    {
                        continue;
                    }
                }
                Local_Folder_OIS = sDownUpLoadDat.Local_Folder_OIS;
                Local_Folder_OIS = Local_Folder_OIS.Replace("[Oper1]", i);
                if (Directory.Exists(Local_Folder_OIS))
                {
                    Directory.Delete(Local_Folder_OIS, true);
                }
            }
            //for (int i = 0; i < Oper1comboBox.Items.Count; i++)
            //{
            //    if (Oper1comboBox.Text != Oper1comboBox.Items[i].ToString() & Oper1comboBox.Text != "全部下載")
            //    {
            //        continue;
            //    }
            //    string Local_OPxxxPath = string.Format(@"{0}\{1}\{2}", sDownUpLoadDat.Local_ShareStr, "OP" + Oper1comboBox.Items[i].ToString(), "OIS");
            //    if (Directory.Exists(Local_OPxxxPath))
            //    {
            //        Directory.Delete(Local_OPxxxPath, true);
            //    }
            //    string Local_MEpartPath = string.Format(@"{0}\{1}", sDownUpLoadDat.Local_ShareStr, PartNocomboBox.Text + "_ME_" + Oper1comboBox.Items[i].ToString() + ".prt");
            //    if (File.Exists(Local_MEpartPath))
            //    {
            //        File.Delete(Local_MEpartPath);
            //    }
            //}
            #endregion

            #region 建立Local_Folder_CAM、Local_Folder_OIS資料夾
            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);
                }
            }
            //暫存一個tempLocal_Folder_CAM、Local_Folder_OIS,目的要讓程式每次都能有[Oper1]可取代

            /*
             * tempLocal_Folder_CAM = Local_Folder_CAM;
             * tempLocal_Folder_OIS = Local_Folder_OIS;
             *
             * 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;
             *          }
             *      }
             *  }
             * }
             * 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;
             *      }
             *  }
             * }
             */
            /*
             * //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)
            {
                //刪除本機檔案,_ME_的檔案已經在前面有刪除了,可能要修改一下統一在這邊刪除
                string Local_Part = string.Format(@"{0}\{1}", sDownUpLoadDat.Local_ShareStr, Path.GetFileName(i));
                if (File.Exists(Local_Part))
                {
                    File.Delete(Local_Part);
                }

                //判斷Part檔案是否存在
                if (!File.Exists(i))
                {
                    CaxLog.ShowListingWindow("製程序檔案" + Path.GetFileName(i) + "不存在,無法下載");
                    continue;
                }
                //建立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) + "下載失敗");
                    continue;
                }
            }

            /*
             * foreach (string i in ListDownloadPartPath)
             * {
             *  //刪除本機OISpart
             *  string Local_OISpart = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileName(i));
             *  if (File.Exists(Local_OISpart))
             *  {
             *      File.Delete(Local_OISpart);
             *  }
             *
             *  //判斷Part檔案是否存在
             *  if (!File.Exists(i))
             *  {
             *      CaxLog.ShowListingWindow("製程序檔案" + Path.GetFileName(i) + "不存在,請再次確認");
             *      //MessageBox.Show("製程序檔案" + Path.GetFileName(i) + "不存在,請再次確認");
             *      this.Close();
             *  }
             *  //建立Local_ShareStr資料夾內製程序檔案路徑
             *  string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileName(i));
             *  //開始複製
             *  try
             *  {
             *      File.Copy(i, Local_Oper1PartFullPath, true);
             *  }
             *  catch (System.Exception ex)
             *  {
             *      CaxLog.ShowListingWindow(Path.GetFileName(i) + "下載失敗");
             *      this.Close();
             *  }
             * }
             */
            #endregion

            MessageBox.Show("下載完成!");
            this.Close();
        }
Пример #5
0
        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_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 建立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 複製Server客戶檔案到Local_Folder_MODEL資料夾內

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

            //建立Local_Folder_MODEL資料夾內客戶檔案路徑
            string Local_CusPartFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_MODEL));

            //判斷是否存在,不存在則開始複製
            if (!File.Exists(Local_CusPartFullPath))
            {
                try
                {
                    File.Copy(Server_MODEL, Local_CusPartFullPath, true);
                }
                catch (System.Exception ex)
                {
                    CaxLog.ShowListingWindow("客戶檔案複製失敗");
                    this.Close();
                }
            }

            #endregion

            #region 複製IPQC.xls到Local_Folder_MODEL資料夾內

            //判斷IPQC.xls是否存在
            if (!File.Exists(Server_IPQC))
            {
                listView.Items.Add("IPQC樣板(IPQC.xls)不存在,無法下載");
                return;
            }

            //建立Local_Folder_MODEL資料夾內客戶檔案路徑
            string Local_IPQCFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_IPQC));

            //判斷是否存在,不存在則開始複製
            if (!File.Exists(Local_IPQCFullPath))
            {
                try
                {
                    File.Copy(Server_IPQC, Local_IPQCFullPath, true);
                }
                catch (System.Exception ex)
                {
                    CaxLog.ShowListingWindow("IPQC.xls下載失敗");
                    this.Close();
                }
            }

            #endregion

            #region 複製SelfCheck.xls到Local_Folder_MODEL資料夾內
            //判斷SelfCheck.xls是否存在
            if (!File.Exists(Server_SelfCheck))
            {
                listView.Items.Add("SelfCheck樣板(SelfCheck.xls)不存在,無法下載");
                return;
            }

            //建立Local_Folder_MODEL資料夾內客戶檔案路徑
            string Local_SelfCheckFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_SelfCheck));

            //判斷是否存在,不存在則開始複製
            if (!File.Exists(Local_SelfCheckFullPath))
            {
                try
                {
                    File.Copy(Server_SelfCheck, Local_SelfCheckFullPath, true);
                }
                catch (System.Exception ex)
                {
                    CaxLog.ShowListingWindow("SelfCheck.xls下載失敗");
                    this.Close();
                }
            }
            #endregion

            #region 複製IQC.xls到Local_Folder_MODEL資料夾內

            //判斷IPQC.xls是否存在
            if (!File.Exists(Server_IQC))
            {
                listView.Items.Add("IQC樣板(IQC.xls)不存在,無法下載");
                return;
            }

            //建立Local_Folder_MODEL資料夾內客戶檔案路徑
            string Local_IQCFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_IQC));

            //判斷是否存在,不存在則開始複製
            if (!File.Exists(Local_IQCFullPath))
            {
                try
                {
                    File.Copy(Server_IQC, Local_IQCFullPath, true);
                }
                catch (System.Exception ex)
                {
                    CaxLog.ShowListingWindow("IQC.xls複製失敗");
                    this.Close();
                }
            }

            #endregion

            #region 複製FAI.xls到Local_Folder_MODEL資料夾內

            //判斷IPQC.xls是否存在
            if (!File.Exists(Server_FAI))
            {
                listView.Items.Add("FAI樣板(FAI.xls)不存在,無法下載");
                return;
            }

            //建立Local_Folder_MODEL資料夾內客戶檔案路徑
            string Local_FAIFullPath = string.Format(@"{0}\{1}", Local_Folder_MODEL, Path.GetFileName(Server_FAI));

            //判斷是否存在,不存在則開始複製
            if (!File.Exists(Local_FAIFullPath))
            {
                try
                {
                    File.Copy(Server_FAI, Local_FAIFullPath, true);
                }
                catch (System.Exception ex)
                {
                    CaxLog.ShowListingWindow("FAI.xls複製失敗");
                    this.Close();
                }
            }

            #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;

            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;
                        }
                    }
                }
            }
            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;
                    }
                }
            }

            /*
             * //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 複製ServerPart檔案到Local資料夾內
            foreach (string i in ListDownloadPartPath)
            {
                //判斷Part檔案是否存在
                if (!File.Exists(i))
                {
                    CaxLog.ShowListingWindow("製程序檔案" + Path.GetFileName(i) + "不存在,請再次確認");
                    //MessageBox.Show("製程序檔案" + Path.GetFileName(i) + "不存在,請再次確認");
                    this.Close();
                }
                //建立Local_ShareStr資料夾內製程序檔案路徑
                string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", 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_MEDownloadPart = tempServer_MEDownloadPart;
             *  //Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", kvp.Key);
             *  status = System.IO.File.Exists(kvp.Value);
             *  if (!status)
             *  {
             *      MessageBox.Show("製程序檔案" + Path.GetFileName(kvp.Value) + "不存在,請再次確認");
             *      return;
             *  }
             *
             *  //建立Local_ShareStr資料夾內製程序檔案路徑
             *  string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileName(kvp.Value));
             *
             *  //開始複製
             *  File.Copy(kvp.Value, Local_Oper1PartFullPath, true);
             *
             *
             *  status = System.IO.File.Exists(Server_MEDownloadPart);
             *  if (!status)
             *  {
             *      MessageBox.Show("製程序檔案" + Path.GetFileName(Server_MEDownloadPart) + "不存在,請再次確認");
             *      return;
             *  }
             *
             *  //建立Local_ShareStr資料夾內製程序檔案路徑
             *  string Local_Oper1PartFullPath = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileName(Server_MEDownloadPart));
             *
             *  //開始複製
             *  File.Copy(Server_MEDownloadPart, Local_Oper1PartFullPath, true);
             *
             * }
             */

            #endregion

            #region (註解中)自動開啟檔案組立架構

            /*
             * //組件存在,直接開啟任務組立
             * BasePart newAsmPart;
             * status = CaxPart.OpenBaseDisplay(Local_Oper1PartFullPath, out newAsmPart);
             * if (!status)
             * {
             *  CaxLog.ShowListingWindow("組立開啟失敗!");
             *  return;
             * }
             *
             * //將客戶檔案組裝進來
             * string NewCusPartName = string.Format(@"{0}\{1}", Local_ShareStr, Path.GetFileNameWithoutExtension(Server_MODEL) + "_" + CurrentOper1 + ".prt");
             *
             * //複製客戶檔案並更名(料號+製程序.prt)後放到新路徑(本機Globaltek\Task\料號\版次\)
             * File.Copy(Local_CusPartFullPath, NewCusPartName, true);
             * `
             * //開始組裝
             * NXOpen.Assemblies.Component newComponent = null;
             * status = CaxAsm.AddComponentToAsmByDefault(NewCusPartName, out newComponent);
             * if (!status)
             * {
             *  CaxLog.ShowListingWindow("ERROR,組裝失敗!");
             *  return;
             * }
             */
            #endregion

            //CaxAsm.SetWorkComponent(null);
            MessageBox.Show("下載完成!");
            this.Close();
            //CaxPart.Save();
        }