private void ClientFileToServerTemp() { #region try { //設定頁面狀態 this.ErrorMsgLabel.Text = ""; gv_ErrorData.Visible = false; this.hid_FrmStatus.Value = "fmProcess"; //LockPage(); System.Threading.Thread.Sleep(2000); string s_UploadPath = string.Empty; string s_BackPath = string.Empty; string s_LoginUser = string.Empty; ArrayList arl_FileUpload_Return = null; ArrayList arl_FileToTmp_Return = null; OUT04ProcessImportItem bco = new OUT04ProcessImportItem(ConnectionDB); #region 上傳檔案到AP端 //取得要上傳的路徑 s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "\\OUT\\"; s_LoginUser = Session["UID"].ToString(); arl_FileUpload_Return = bco.FileUpload(s_UploadPath, this.FileUpload1, s_LoginUser); #endregion if (arl_FileUpload_Return[0].ToString() == "FALSE")//檔案上傳至AP端錯誤 { #region this.ErrorMsgLabel.Text = "檔案上傳至AP端錯誤";//檔案上傳至AP端錯誤,後面直接不做了 #endregion } else if (arl_FileUpload_Return[0].ToString() == "TRUE")//檔案上傳至AP端正常 { #region #region 讀取 txt 資料 DataTable dtA = new DataTable(); dtA = this.MakeDT(); int N_UPLOAD = 0;//上傳筆數 try { FileStream fs = new FileStream(arl_FileUpload_Return[1].ToString(), FileMode.Open, FileAccess.Read); StreamReader m_streamReader = new StreamReader(fs, System.Text.Encoding.GetEncoding(950)); //使用StreamReader來讀取資料 m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin); string strLine = m_streamReader.ReadLine(); while (strLine != null && strLine != "") { DataRow drA = dtA.NewRow(); drA[0] = strLine; dtA.Rows.Add(drA); strLine = m_streamReader.ReadLine(); N_UPLOAD++; } } catch (Exception ex) { this.Response.Write(ex.Message); } #endregion #region 將檔案匯入TmpTable int N_TMP_CNT = 0; int N_TAB_CNT = 0; string ErrorMsg = ""; string V_RUN_STATUS = "N"; if (!((CheckBox)this.txtRunStatus).Checked) V_RUN_STATUS = "Y"; bco.FileToTmp(dtA, null, arl_FileUpload_Return[4].ToString(), V_RUN_STATUS, Session["UID"].ToString(), out ErrorMsg); bco.QueryItemTmpImportStat(Session["UID"].ToString(), out N_TMP_CNT, out N_TAB_CNT); #endregion //上傳結果 this.UploadStatusPanel1.UploadSum = N_UPLOAD; this.UploadStatusPanel1.UploadOK = N_TMP_CNT; this.UploadStatusPanel1.UploadNG = N_UPLOAD - N_TMP_CNT; //匯入結果 this.UploadStatusPanel1.ImportSum = N_TMP_CNT; this.UploadStatusPanel1.ImportOK = N_TAB_CNT; this.UploadStatusPanel1.ImportNG = N_TMP_CNT - N_TAB_CNT; #endregion } unLockPage(); this.hid_FrmStatus.Value = "fmBroswe"; } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 unLockPage(); this.hid_FrmStatus.Value = "fmBroswe"; } #endregion }