Esempio n. 1
0
        private void Oper1comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //清空ListView資訊
            listView.Items.Clear();
            //取得當前選取的製程序
            CurrentOper1 = Oper1comboBox.Text;

            //建立Server路徑資料
            string Server_IP       = cMETE_Download_Upload_Path.Server_IP;
            string Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr;

            Server_Folder_MODEL   = cMETE_Download_Upload_Path.Server_Folder_MODEL;
            Server_MEDownloadPart = cMETE_Download_Upload_Path.Server_MEDownloadPart;
            Server_IPQC           = cMETE_Download_Upload_Path.Server_IPQC;
            Server_SelfCheck      = cMETE_Download_Upload_Path.Server_SelfCheck;
            Server_IQC            = cMETE_Download_Upload_Path.Server_IQC;
            Server_FAI            = cMETE_Download_Upload_Path.Server_FAI;

            //取代字串成正確路徑
            Server_ShareStr       = Server_ShareStr.Replace("[Server_IP]", Server_IP);
            Server_ShareStr       = Server_ShareStr.Replace("[CusName]", CurrentCusName);
            Server_ShareStr       = Server_ShareStr.Replace("[PartNo]", CurrentPartNo);
            Server_ShareStr       = Server_ShareStr.Replace("[CusRev]", CurrentCusRev);
            Server_ShareStr       = Server_ShareStr.Replace("[OpRev]", CurrentOpRev);
            Server_Folder_MODEL   = Server_Folder_MODEL.Replace("[Server_ShareStr]", Server_ShareStr);
            Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Server_ShareStr]", Server_ShareStr);
            Server_MEDownloadPart = Server_MEDownloadPart.Replace("[PartNo]", CurrentPartNo);
            Server_IPQC           = Server_IPQC.Replace("[Server_IP]", Server_IP);
            Server_SelfCheck      = Server_SelfCheck.Replace("[Server_IP]", Server_IP);
            Server_IQC            = Server_IQC.Replace("[Server_IP]", Server_IP);
            Server_FAI            = Server_FAI.Replace("[Server_IP]", Server_IP);

            #region (註解)判斷IPQC.xls是否存在
            //if (!File.Exists(Server_IPQC))
            //{
            //    listView.Items.Add("IPQC樣板(IPQC.xls)不存在,無法下載");
            //    return;
            //}
            //listView.Items.Add("IPQC樣板:" + Path.GetFileName(Server_IPQC));
            #endregion

            #region (註解)判斷SelfCheck.xls是否存在
            //if (!File.Exists(Server_SelfCheck))
            //{
            //    listView.Items.Add("SelfCheck樣板(SelfCheck.xls)不存在,無法下載");
            //    return;
            //}
            //listView.Items.Add("SelfCheck樣板:" + Path.GetFileName(Server_SelfCheck));
            #endregion

            #region (註解)判斷IQC.xls是否存在
            //if (!File.Exists(Server_IQC))
            //{
            //    listView.Items.Add("IQC樣板(IQC.xls)不存在,無法下載");
            //    return;
            //}
            //listView.Items.Add("IQC樣板:" + Path.GetFileName(Server_IQC));
            #endregion

            #region (註解)判斷FAI.xls是否存在
            //if (!File.Exists(Server_FAI))
            //{
            //    listView.Items.Add("FAI樣板(FAI.xls)不存在,無法下載");
            //    return;
            //}
            //listView.Items.Add("FAI樣板:" + Path.GetFileName(Server_FAI));
            #endregion

            #region (2016.12.29註解)判斷客戶檔案是否存在
            //Server_Folder_MODEL = string.Format(@"{0}\{1}", Server_Folder_MODEL, CurrentPartNo + ".prt");
            //if (!File.Exists(Server_Folder_MODEL))
            //{
            //    listView.Items.Add("客戶檔案不存在,無法下載");
            //    buttonDownload.Enabled = false;
            //    return;
            //}
            //listView.Items.Add("客戶檔案:" + Path.GetFileName(Server_Folder_MODEL));
            #endregion

            //暫存一個Server_MEDownloadPart,目的要讓程式每次都能有[Oper1]可取代
            tempServer_MEDownloadPart = Server_MEDownloadPart;

            #region 將選取到的Oper1紀錄成DicSeleOper1(Key = 製程序,Value = ServerPartPath)

            DicSeleOper1         = new Dictionary <string, string>();
            ListDownloadPartPath = new List <string>();


            if (CurrentOper1 == "全部下載")
            {
                for (int i = 0; i < Oper1comboBox.Items.Count; i++)
                {
                    if (Oper1comboBox.Items[i].ToString() == "全部下載")
                    {
                        continue;
                    }
                    //判斷OP資料夾內是否有PartNameText_OIS.txt,如果有,表示有上傳過,則讀取裡面檔案資料進行下載
                    string PartNameText_OISPath = string.Format(@"{0}\{1}\{2}", Server_ShareStr, "OP" + Oper1comboBox.Items[i].ToString(), "PartNameText_OIS.txt");
                    if (File.Exists(PartNameText_OISPath))
                    {
                        //取得已上傳過的檔案名稱
                        string[] PartNameText_OISData = System.IO.File.ReadAllLines(PartNameText_OISPath);
                        //開始記錄每個零件的路徑
                        foreach (string ii in PartNameText_OISData)
                        {
                            Server_MEDownloadPart = string.Format(@"{0}\{1}", Server_ShareStr, ii);
                            ListDownloadPartPath.Add(Server_MEDownloadPart);
                        }
                    }
                    else
                    {
                        Server_MEDownloadPart = tempServer_MEDownloadPart;
                        Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", Oper1comboBox.Items[i].ToString());
                        ListDownloadPartPath.Add(Server_MEDownloadPart);
                    }
                }
            }
            else
            {
                //判斷OP資料夾內是否有PartNameText_OIS.txt,如果有,表示有上傳過,則讀取裡面檔案資料進行下載
                string PartNameText_OISPath = string.Format(@"{0}\{1}\{2}", Server_ShareStr, "OP" + CurrentOper1, "PartNameText_OIS.txt");
                if (File.Exists(PartNameText_OISPath))
                {
                    //取得已上傳過的檔案名稱
                    string[] PartNameText_OISData = System.IO.File.ReadAllLines(PartNameText_OISPath);
                    //開始記錄每個零件的路徑
                    foreach (string i in PartNameText_OISData)
                    {
                        Server_MEDownloadPart = string.Format(@"{0}\{1}", Server_ShareStr, i);
                        ListDownloadPartPath.Add(Server_MEDownloadPart);
                    }
                }
                else
                {
                    Server_MEDownloadPart = tempServer_MEDownloadPart;
                    Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", CurrentOper1);
                    ListDownloadPartPath.Add(Server_MEDownloadPart);
                }
            }

            #endregion

            #region 判斷製程檔案是否存在

            foreach (string i in ListDownloadPartPath)
            {
                //判斷Part檔案是否存在
                if (!File.Exists(i))
                {
                    listView.Items.Add("Part檔案:");
                    listView.Items.Add(Path.GetFileName(i) + "不存在,請再次確認");
                    buttonDownload.Enabled = false;
                    return;
                }
                listView.Items.Add("Part檔案:" + Path.GetFileName(i));
            }

            buttonDownload.Enabled = true;

            #endregion
        }
Esempio n. 2
0
        private void Oper1comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //清空ListView資訊
            listView.Items.Clear();
            //取得當前選取的製程序
            CurrentOper1 = Oper1comboBox.Text;

            //建立Server路徑資料
            string Server_IP       = cMETE_Download_Upload_Path.Server_IP;
            string Server_ShareStr = cMETE_Download_Upload_Path.Server_ShareStr;

            Server_MODEL          = cMETE_Download_Upload_Path.Server_MODEL;
            Server_MEDownloadPart = cMETE_Download_Upload_Path.Server_MEDownloadPart;
            Server_IPQC           = cMETE_Download_Upload_Path.Server_IPQC;
            Server_SelfCheck      = cMETE_Download_Upload_Path.Server_SelfCheck;
            Server_IQC            = cMETE_Download_Upload_Path.Server_IQC;
            Server_FAI            = cMETE_Download_Upload_Path.Server_FAI;

            //取代字串成正確路徑
            Server_ShareStr       = Server_ShareStr.Replace("[Server_IP]", Server_IP);
            Server_ShareStr       = Server_ShareStr.Replace("[CusName]", CurrentCusName);
            Server_ShareStr       = Server_ShareStr.Replace("[PartNo]", CurrentPartNo);
            Server_ShareStr       = Server_ShareStr.Replace("[CusRev]", CurrentCusRev);
            Server_MODEL          = Server_MODEL.Replace("[Server_ShareStr]", Server_ShareStr);
            Server_MODEL          = Server_MODEL.Replace("[PartNo]", CurrentPartNo);
            Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Server_ShareStr]", Server_ShareStr);
            Server_MEDownloadPart = Server_MEDownloadPart.Replace("[PartNo]", CurrentPartNo);
            Server_IPQC           = Server_IPQC.Replace("[Server_IP]", Server_IP);
            Server_SelfCheck      = Server_SelfCheck.Replace("[Server_IP]", Server_IP);
            Server_IQC            = Server_IQC.Replace("[Server_IP]", Server_IP);
            Server_FAI            = Server_FAI.Replace("[Server_IP]", Server_IP);

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

            #region 判斷SelfCheck.xls是否存在
            if (!File.Exists(Server_SelfCheck))
            {
                listView.Items.Add("SelfCheck樣板(SelfCheck.xls)不存在,無法下載");
                return;
            }
            listView.Items.Add("SelfCheck樣板:" + Path.GetFileName(Server_SelfCheck));
            #endregion

            #region 判斷IQC.xls是否存在
            if (!File.Exists(Server_IQC))
            {
                listView.Items.Add("IQC樣板(IQC.xls)不存在,無法下載");
                return;
            }
            listView.Items.Add("IQC樣板:" + Path.GetFileName(Server_IQC));
            #endregion

            #region 判斷FAI.xls是否存在
            if (!File.Exists(Server_FAI))
            {
                listView.Items.Add("FAI樣板(FAI.xls)不存在,無法下載");
                return;
            }
            listView.Items.Add("FAI樣板:" + Path.GetFileName(Server_FAI));
            #endregion

            #region 判斷客戶檔案是否存在
            if (!File.Exists(Server_MODEL))
            {
                listView.Items.Add("客戶檔案不存在,無法下載");
                return;
            }
            listView.Items.Add("客戶檔案:" + Path.GetFileName(Server_MODEL));
            #endregion

            //暫存一個Server_MEDownloadPart,目的要讓程式每次都能有[Oper1]可取代
            tempServer_MEDownloadPart = Server_MEDownloadPart;

            #region 將選取到的Oper1紀錄成DicSeleOper1(Key = 製程序,Value = ServerPartPath)

            DicSeleOper1         = new Dictionary <string, string>();
            ListDownloadPartPath = new List <string>();


            if (CurrentOper1 == "全部下載")
            {
                for (int i = 0; i < Oper1comboBox.Items.Count; i++)
                {
                    if (Oper1comboBox.Items[i].ToString() == "全部下載")
                    {
                        continue;
                    }
                    //判斷OP資料夾內是否有PartNameText_OIS.txt,如果有,表示有上傳過,則讀取裡面檔案資料進行下載
                    string PartNameText_OISPath = string.Format(@"{0}\{1}\{2}", Server_ShareStr, "OP" + Oper1comboBox.Items[i].ToString(), "PartNameText_OIS.txt");
                    if (File.Exists(PartNameText_OISPath))
                    {
                        //取得已上傳過的檔案名稱
                        string[] PartNameText_OISData = System.IO.File.ReadAllLines(PartNameText_OISPath);
                        //開始記錄每個零件的路徑
                        foreach (string ii in PartNameText_OISData)
                        {
                            Server_MEDownloadPart = string.Format(@"{0}\{1}", Server_ShareStr, ii);
                            ListDownloadPartPath.Add(Server_MEDownloadPart);
                        }
                    }
                    else
                    {
                        Server_MEDownloadPart = tempServer_MEDownloadPart;
                        Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", Oper1comboBox.Items[i].ToString());
                        ListDownloadPartPath.Add(Server_MEDownloadPart);
                    }


                    /*
                     * Server_MEDownloadPart = tempServer_MEDownloadPart;
                     * Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", Oper1comboBox.Items[i].ToString());
                     *
                     * string ServerPartPath = "";
                     * status = DicSeleOper1.TryGetValue(Oper1comboBox.Items[i].ToString(), out ServerPartPath);
                     * if (!status)
                     * {
                     *  DicSeleOper1.Add(Oper1comboBox.Items[i].ToString(), Server_MEDownloadPart);
                     * }
                     */
                }
            }
            else
            {
                //判斷OP資料夾內是否有PartNameText_OIS.txt,如果有,表示有上傳過,則讀取裡面檔案資料進行下載
                string PartNameText_OISPath = string.Format(@"{0}\{1}\{2}", Server_ShareStr, "OP" + CurrentOper1, "PartNameText_OIS.txt");
                if (File.Exists(PartNameText_OISPath))
                {
                    //取得已上傳過的檔案名稱
                    string[] PartNameText_OISData = System.IO.File.ReadAllLines(PartNameText_OISPath);
                    //開始記錄每個零件的路徑
                    foreach (string i in PartNameText_OISData)
                    {
                        Server_MEDownloadPart = string.Format(@"{0}\{1}", Server_ShareStr, i);
                        ListDownloadPartPath.Add(Server_MEDownloadPart);
                    }
                }
                else
                {
                    Server_MEDownloadPart = tempServer_MEDownloadPart;
                    Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", CurrentOper1);
                    ListDownloadPartPath.Add(Server_MEDownloadPart);
                }
            }


            /*
             * if (File.Exists(PartNameText_OISPath))
             * {
             *  //取得已上傳過的檔案名稱
             *  string[] PartNameText_OISData = System.IO.File.ReadAllLines(PartNameText_OISPath);
             *  //開始記錄每個零件的路徑
             *  foreach (string i in PartNameText_OISData)
             *  {
             *      Server_MEDownloadPart = string.Format(@"{0}\{1}", Server_ShareStr, i);
             *      ListDownloadPartPath.Add(Server_MEDownloadPart);
             *      //DicSeleOper1.Add(CurrentOper1, Server_MEDownloadPart);
             *  }
             * }
             * else
             * {
             *  if (CurrentOper1 == "全部下載")
             *  {
             *      for (int i = 0; i < Oper1comboBox.Items.Count; i++)
             *      {
             *          if (Oper1comboBox.Items[i].ToString() == "全部下載")
             *          {
             *              continue;
             *          }
             *          Server_MEDownloadPart = tempServer_MEDownloadPart;
             *          Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", Oper1comboBox.Items[i].ToString());
             *
             *          string ServerPartPath = "";
             *          status = DicSeleOper1.TryGetValue(Oper1comboBox.Items[i].ToString(), out ServerPartPath);
             *          if (!status)
             *          {
             *              DicSeleOper1.Add(Oper1comboBox.Items[i].ToString(), Server_MEDownloadPart);
             *          }
             *      }
             *  }
             *  else
             *  {
             *      Server_MEDownloadPart = tempServer_MEDownloadPart;
             *      Server_MEDownloadPart = Server_MEDownloadPart.Replace("[Oper1]", CurrentOper1);
             *      DicSeleOper1.Add(CurrentOper1, Server_MEDownloadPart);
             *  }
             * }
             */


            #endregion

            #region 判斷製程檔案是否存在

            foreach (string i in ListDownloadPartPath)
            {
                //判斷Part檔案是否存在
                if (!File.Exists(i))
                {
                    listView.Items.Add("Part檔案" + Path.GetFileName(i) + "不存在,請再次確認");
                    return;
                }
                listView.Items.Add("Part檔案:" + Path.GetFileName(i));
            }

            /*
             * foreach (KeyValuePair<string, string> kvp in DicSeleOper1)
             * {
             *  if (!File.Exists(kvp.Value))
             *  {
             *      listView.Items.Add("製程序" + kvp.Key + "檔案不存在,無法下載");
             *      return;
             *  }
             *  listView.Items.Add("製程序檔案:" + Path.GetFileName(kvp.Value));
             * }
             */

            #endregion
        }