public void Insert(string rowid, string product, string program, string equipment, string tooling_no, string test_type, string test_item, string applied_dep, DateTime bom_dt, DateTime received_dt, string material, int sample, string remark, string dispatch_no, string unit, string employee) { using (SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate)) { StringBuilder sb = new StringBuilder(); sb.Append(" SELECT rowid,ra_no,product,program,equipment,tooling_no,test_type,test_item,applied_dep,manufacture_dt,received_dt,material,sample, "); sb.Append(" data_nuit,remark,status,send_date,employee,dispatch_no FROM EIPE.dbo.IPQC_Ra_Head where 1=0 "); rs.Open(sb.ToString()); rs.Add(); rs["rowid"] = rowid; rs["product"] = product; rs["program"] = program; rs["test_type"] = test_type; rs["test_item"] = test_item; rs["applied_dep"] = applied_dep; rs["manufacture_dt"] = bom_dt; rs["received_dt"] = received_dt; rs["material"] = material; rs["sample"] = sample; //rs["data_nuit"] = unit; rs["remark"] = remark; rs["status"] = 0; rs["employee"] = employee; rs["dispatch_no"] = dispatch_no; rs["tooling_no"] = tooling_no; /*-------------------------*/ if (!string.IsNullOrEmpty(equipment)) { rs["equipment"] = equipment; } EIPSysSha SysNum = new EIPSysSha(); string IPQC_RaNo = SysNum.GetNewSn("N103", DateTime.Now.ToString("yyMM")); rs["ra_no"] = IPQC_RaNo; rs.Update(); rs.Close(); } }
private void Save_Head() { EIPSysSha SysNum = new EIPSysSha(); Leica_Head Head = new Leica_Head(); Head.Create_User = CurrentUser.LogonID; Head.H_Operator = _h_operator; Head.Insp_Dt = _insp_date; Head.Insp_No = SysNum.GetNewSn("Q608", DateTime.Now.ToString("yyMM")); Head.Kind = _kind; Head.Product = ConvertToOption(_product); Head.Program = ConvertToOption(_program); Head.Result = _result; Head.ROWID = _head_id; Head.Status = Convert.ToInt16(status.Waite).ToString(); Head.Custmer = _custmer; Head.Insert(); }
protected void Page_Load(object sender, EventArgs e) { // mailprocess("201-1550001", "MATE02"); /* ================= 抓 ERP 資料進 EIP ================= */ // FileRoute 設定..暫存的目錄位置 string InitDirectory = @"D:\CBGI014_XML\ERP_Download\"; // 先抓 FTP 的資料 ArrayList FtpList = List("ftp://192.168.0.250/", "xmluser", "(XmlUser)"); foreach (string s in FtpList) { //Response.Write("AAA"); Response.Write(s.ToString()); //找到 自己要的檔名! if (s.ToUpper().IndexOf("CBGI014") != -1) { Response.Write("Go<br>"); //將目前FTP的XML抓下來 Download("ftp://192.168.0.250/" + s, InitDirectory, "xmluser", "(XmlUser)"); DeleteFileOnServer("ftp://192.168.0.250/" + s, "xmluser", "(XmlUser)"); } } //------------------------------------------------------------- string searchPattern = "*"; //可以指定目錄 或 //string InitDirectory = @"C:\"; // 取得目前工作目錄 //string InitDirectory = @"D:\XML"; //原始目錄 ArrayList MyFiles = new ArrayList(); DirectoryInfo di = new DirectoryInfo(InitDirectory); // 呼叫上面的函式 Get Files GetFiles(di, searchPattern, ref MyFiles); //Print it foreach (string s in MyFiles) { string sno = ""; int ver = 1; Guid rowid = Guid.NewGuid(); DBTransfer fs = new DBTransfer(); //try //{ if (s.IndexOf("CBGI014") != -1) { Response.Write("yes"); Response.Write("---------" + s.IndexOf("_") + "<br>"); System.Diagnostics.Debug.Write(s); //this.textBox3.AppendText(s + "\n"); Response.Write(s + "\n"); XmlDocument xDoc = new XmlDocument(); xDoc.Load((s)); XmlNodeList plantid = xDoc.GetElementsByTagName("PlantID"); XmlNodeList tc_cba00 = xDoc.GetElementsByTagName("tc_cba00"); XmlNodeList tc_cba01 = xDoc.GetElementsByTagName("tc_cba01"); XmlNodeList gem02_0 = xDoc.GetElementsByTagName("gem02-0"); XmlNodeList tc_cba02 = xDoc.GetElementsByTagName("tc_cba02"); XmlNodeList tc_cbauser = xDoc.GetElementsByTagName("tc_cbauser"); XmlNodeList gen02_1 = xDoc.GetElementsByTagName("gen02-1"); XmlNodeList tc_cbagrup = xDoc.GetElementsByTagName("tc_cbagrup"); #region 讀取XML 資料 XmlNodeList tc_cbb03 = xDoc.GetElementsByTagName("tc_cbb03"); XmlNodeList faj31 = xDoc.GetElementsByTagName("faj31"); XmlNodeList fajowner = xDoc.GetElementsByTagName("fajowner"); XmlNodeList tc_cbb04 = xDoc.GetElementsByTagName("tc_cbb04"); XmlNodeList tc_cbb05 = xDoc.GetElementsByTagName("tc_cbb05"); XmlNodeList aag02 = xDoc.GetElementsByTagName("aag02"); XmlNodeList tc_cbb22 = xDoc.GetElementsByTagName("tc_cbb22"); XmlNodeList tc_cbb06 = xDoc.GetElementsByTagName("tc_cbb06"); XmlNodeList tc_bgx02 = xDoc.GetElementsByTagName("tc_bgx02"); XmlNodeList tc_cbb07 = xDoc.GetElementsByTagName("tc_cbb07"); XmlNodeList tc_bgy02 = xDoc.GetElementsByTagName("tc_bgy02"); XmlNodeList tc_cbb08 = xDoc.GetElementsByTagName("tc_cbb08"); XmlNodeList fac02 = xDoc.GetElementsByTagName("fac02"); XmlNodeList tc_cbb18 = xDoc.GetElementsByTagName("tc_cbb18"); XmlNodeList tc_cbb09 = xDoc.GetElementsByTagName("tc_cbb09"); XmlNodeList tc_cbb091 = xDoc.GetElementsByTagName("tc_cbb091"); XmlNodeList tc_cbb10 = xDoc.GetElementsByTagName("tc_cbb10"); XmlNodeList tc_cbb11 = xDoc.GetElementsByTagName("tc_cbb11"); XmlNodeList tc_cbb12 = xDoc.GetElementsByTagName("tc_cbb12"); XmlNodeList tc_cbb13f = xDoc.GetElementsByTagName("tc_cbb13f"); XmlNodeList tc_cbb13 = xDoc.GetElementsByTagName("tc_cbb13"); XmlNodeList tc_cbb14f = xDoc.GetElementsByTagName("tc_cbb14f"); XmlNodeList tc_cbb14 = xDoc.GetElementsByTagName("tc_cbb14"); XmlNodeList tc_cbb19 = xDoc.GetElementsByTagName("tc_cbb19"); XmlNodeList tc_cbb15 = xDoc.GetElementsByTagName("tc_cbb15"); XmlNodeList azf03 = xDoc.GetElementsByTagName("azf03"); XmlNodeList tc_cbb16 = xDoc.GetElementsByTagName("tc_cbb16"); XmlNodeList tc_cbb21 = xDoc.GetElementsByTagName("tc_cbb21"); XmlNodeList tc_cbb17 = xDoc.GetElementsByTagName("tc_cbb17"); XmlNodeList tc_cbb171 = xDoc.GetElementsByTagName("tc_cbb171"); XmlNodeList faj26 = xDoc.GetElementsByTagName("faj26"); #endregion string titlesn = tc_cba00[0].InnerXml + "-" + gem02_0[0].InnerXml; Response.Write("---" + tc_cbb03.Count.ToString() + "----"); #region CBGI014_Head 單號不相同,將資料全數新增 // Response.Write("select * from eipb.dbo.APMI610_IN where pmk01 = '" + pmk01[0].InnerXml + "' and plantid='" + plantid[0].InnerXml + "' "); SmoothEnterprise.Database.DataSet hs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); hs.Open("select top 1 * from eipb.dbo.CBGI014_Head where File_sn = '" + s + "' order by ver desc"); //檢查單頭是否有重覆單據號碼 SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs.Open("select * from eipb.dbo.CBGI014_Head WHERE 1=0"); rs.Add(); //同一份預算檔案存在 if (!hs.EOF) { //取出舊單號 sno = hs["sn"].ToString(); //版次加1 ver = Int32.Parse(hs["ver"].ToString()) + 1; } else { EIPSysSha UseSha = new EIPSysSha(); sno = UseSha.GetNewSn("A501", DateTime.Now.ToString("yyMM")); } //rs["pmcano"] = pmcano[0].InnerXml; rs["rowid"] = rowid; rs["sn"] = sno; rs["ver"] = ver; rs["inidate"] = DateTime.Now.ToShortDateString(); //系統只有版本概念 //} //else //{ // rs.Open("select * from eipb.dbo.CBGI014_Head where File_sn = '" + s + "'");//檢查單頭是否有重覆單據號碼 // rs["moddate"] = DateTime.Now.ToShortDateString(); // //取出sno // sno = fs.GetTopfile("select sn from eipb.dbo.CBGI014_Head where File_sn = '" + s + "'"); //} string ftstr = plantid[0].InnerXml + "_cbgi014_" + tc_cba00[0].InnerXml + "_" + tc_cba01[0].InnerXml + "_" + tc_cba02[0].InnerXml.Substring(0, 1); if (plantid[0].InnerXml != "") { rs["plantID"] = plantid[0].InnerXml; } if (tc_cba00[0].InnerXml != "") { rs["tc_cba00"] = tc_cba00[0].InnerXml; } if (tc_cba01[0].InnerXml != "") { rs["tc_cba01"] = tc_cba01[0].InnerXml; } if (gem02_0[0].InnerXml != "") { rs["gem02_0"] = gem02_0[0].InnerXml; } if (tc_cba02[0].InnerXml != "") { rs["tc_cba02"] = tc_cba02[0].InnerXml; } if (tc_cbauser[0].InnerXml != "") { rs["tc_cbauser"] = tc_cbauser[0].InnerXml.Substring(0, 6); } if (tc_cbagrup[0].InnerXml != "") { rs["tc_cbagrup"] = tc_cbagrup[0].InnerXml; } if (gen02_1[0].InnerXml != "") { rs["gen02_1"] = gen02_1[0].InnerXml; } rs["File_sn"] = s; rs["Status"] = "N"; rs.Update(); rs.Close(); hs.Close(); #endregion #region CBGI014_Body 單號不相同,將資料全數新增 // Response.Write(tc_cbb03.Count.ToString() + "---"); for (int i = 0; i < tc_cbb03.Count; i++) { //SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs.Open("select * from eipb.dbo.CBGI014_Body WHERE 1=0"); rs.Add(); rs["sn"] = sno; rs["rowid"] = rowid; if (tc_cbb03[i].InnerXml != "") { rs["tc_cbb03"] = tc_cbb03[i].InnerXml; } if (faj31[i].InnerXml != "") { rs["faj31"] = faj31[i].InnerXml.Trim(); } if (fajowner[i].InnerXml != "") { rs["fajowner"] = fajowner[i].InnerXml; } if (tc_cbb04[i].InnerXml != "") { rs["tc_cbb04"] = tc_cbb04[i].InnerXml; } if (tc_cbb05[i].InnerXml != "") { rs["tc_cbb05"] = tc_cbb05[i].InnerXml; } if (tc_cbb22[i].InnerXml != "") { rs["tc_cbb22"] = tc_cbb22[i].InnerXml; } if (tc_cbb06[i].InnerXml != "") { rs["tc_cbb06"] = tc_cbb06[i].InnerXml; } if (tc_bgx02[i].InnerXml != "") { rs["tc_bgx02"] = tc_bgx02[i].InnerXml; } if (tc_cbb07[i].InnerXml != "") { rs["tc_cbb07"] = tc_cbb07[i].InnerXml; } if (tc_bgy02[i].InnerXml != "") { rs["tc_bgy02"] = tc_bgy02[i].InnerXml; } if (tc_cbb08[i].InnerXml != "") { rs["tc_cbb08"] = tc_cbb08[i].InnerXml; } if (fac02[i].InnerXml != "") { rs["fac02"] = fac02[i].InnerXml; } if (aag02[i].InnerXml != "") { rs["aag02"] = aag02[i].InnerXml; } if (tc_cbb18[i].InnerXml != "") { rs["tc_cbb18"] = tc_cbb18[i].InnerXml; } if (tc_cbb09[i].InnerXml != "") { rs["tc_cbb09"] = tc_cbb09[i].InnerXml; } if (tc_cbb091[i].InnerXml != "") { rs["tc_cbb091"] = tc_cbb091[i].InnerXml; } if (tc_cbb10[i].InnerXml != "") { rs["tc_cbb10"] = tc_cbb10[i].InnerXml; } if (tc_cbb11[i].InnerXml != "") { rs["tc_cbb11"] = tc_cbb11[i].InnerXml; } if (tc_cbb12[i].InnerXml != "") { rs["tc_cbb12"] = tc_cbb12[i].InnerXml; } if (tc_cbb13[i].InnerXml != "") { rs["tc_cbb13"] = tc_cbb13[i].InnerXml; } if (tc_cbb13f[i].InnerXml != "") { rs["tc_cbb13f"] = tc_cbb13f[i].InnerXml; } if (tc_cbb14[i].InnerXml != "") { rs["tc_cbb14"] = tc_cbb14[i].InnerXml; } if (tc_cbb14f[i].InnerXml != "") { rs["tc_cbb14f"] = tc_cbb14f[i].InnerXml; } if (tc_cbb19[i].InnerXml != "") { rs["tc_cbb19"] = tc_cbb19[i].InnerXml; } if (tc_cbb15[i].InnerXml != "") { rs["tc_cbb15"] = tc_cbb15[i].InnerXml; } if (azf03[i].InnerXml != "") { rs["azf03"] = azf03[i].InnerXml; } if (tc_cbb16[i].InnerXml != "") { rs["tc_cbb16"] = tc_cbb16[i].InnerXml; } if (tc_cbb21[i].InnerXml != "") { rs["tc_cbb21"] = tc_cbb21[i].InnerXml; } if (tc_cbb17[i].InnerXml != "") { rs["tc_cbb17"] = tc_cbb17[i].InnerXml; } if (tc_cbb171[i].InnerXml != "") { rs["tc_cbb171"] = tc_cbb171[i].InnerXml; } if (faj26[i].InnerXml != "") { rs["faj26"] = faj26[i].InnerXml; } rs.Update(); rs.Close(); } #endregion string sumSql = ""; #region 匯總明細資料to CBGI014_SUM hs.Open(" SELECT tc_cbb06,tc_cbb07,tc_cbb13,convert(int, substring(tc_cbb091,5,2)) math,SUM(tc_cbb10) total " + " FROM [EIPB].[dbo].[CBGI014_Body] where rowid='" + rowid + "'" + " group by tc_cbb06,tc_cbb07,tc_cbb13,tc_cbb091 "); while (!hs.EOF) { string Ma = "M" + hs["math"].ToString(); string sumcount = fs.GetTopfile("select COUNT(*) from EIPB.dbo.CBGI014_sum " + " where rowid='" + rowid + "' and tc_cbb06='" + hs["tc_cbb06"].ToString() + "' and tc_cbb07='" + hs["tc_cbb07"].ToString() + "' and unp='" + hs["tc_cbb13"].ToString() + "'"); if (sumcount != "0") { sumSql = "update EIPB.dbo.CBGI014_sum set " + Ma + "='" + hs["total"].ToString() + "' where " + "rowid='" + rowid + "' and tc_cbb06='" + hs["tc_cbb06"].ToString() + "' and tc_cbb07='" + hs["tc_cbb07"].ToString() + "' and unp='" + hs["tc_cbb13"].ToString() + "'"; } else { sumSql = "insert into EIPB.dbo.CBGI014_sum(rowid,tc_cbb06,tc_cbb07,unp," + Ma + ")values " + " ('" + rowid + "','" + hs["tc_cbb06"].ToString() + "','" + hs["tc_cbb07"].ToString() + "','" + hs["tc_cbb13"].ToString() + "','" + hs["total"].ToString() + "')"; //Response.Write(sumSql + "<br>"); } fs.RunIUSql(sumSql); hs.MoveNext(); } #endregion mailprocess(titlesn, plantid[0].InnerXml, sno, ver.ToString()); if (System.IO.File.Exists(s.Replace("Download", "XML"))) //判斷在OUT資料夾裡, 檔案是否存在 { File.Delete(s.Replace("Download", "XML")); //存在的話先刪除該檔案再存入新檔案 File.Move(s, s.Replace("Download", "XML")); } else { File.Move(s, s.Replace("Download", "XML")); //不存在直接存入新檔案 } Upload("D:\\CBGI014_XML\\ERP_XML\\" + ftstr + ".xml", "ftp://192.168.0.250/" + ftstr + ".xml", "xmlback", "xmlback"); } //發mail--------------------------------------------------------------------------------------------------------------------------- fs.RunIUSql("insert into [EIPB].[dbo].[CBGI014_Base] " + " select tc_cbb06,tc_bgx02 from [EIPB].[dbo].[CBGI014_body] " + " left join [EIPB].[dbo].[CBGI014_Base] b on tc_cbb06=b.id " + " where tc_cbb06 is not null and b.id is null " + " group by tc_cbb06,tc_bgx02 "); fs.RunIUSql("insert into [EIPB].[dbo].[CBGI014_Base] " + "select tc_cbb07,tc_bgy02 from [EIPB].[dbo].[CBGI014_body] " + "left join [EIPB].[dbo].[CBGI014_Base] b on tc_cbb07=b.id " + " where tc_cbb07 is not null and b.id is null " + "group by tc_cbb07,tc_bgy02 "); //--------------------------------------------------------------------------------------------------------------------------- } //} // catch (Exception ex) //{ #region //herzog remark /* string s1 = s.Replace(".xml", ""); * s1 = s1.Replace("D:\\APMI610_XML\\ERP_Download\\", ""); * int sone = s1.IndexOf("_"); * int stwo = s1.LastIndexOf("_"); * stwo = stwo + 1; * FileStream fs = new FileStream(@"D:\APMI610_XML\4GL\" + s1 + ".txt", FileMode.Create, FileAccess.Write); * StreamWriter sw = new StreamWriter(fs); * sw.WriteLine("\"" + s1.Substring(0, sone) + "\",\"APMI610\",\"" + s1.Substring(stwo, 10) + "\",\"E\",\"\""); * sw.Close(); * fs.Close(); * Upload(fs.ToString(), "ftp://192.168.0.250/" + s1.ToString() + ".txt", "4gl", "4gl"); * * * //發mail--------------------------------------------------------------------------------------------------------------------------- * String ques; * * MailAddress from = new MailAddress("*****@*****.**", "ePortal(員工入口網站)"); * MailAddress to = new MailAddress("*****@*****.**"); * * MailAddress bcc = new MailAddress("*****@*****.**"); * * MailMessage message = new MailMessage(from, to); * message.Bcc.Add(bcc); * * ques = "有問題"; * * message.Subject = "ERP廠商代號有問題"; * message.IsBodyHtml = true; * message.Body = ques; * * SmtpClient client = new SmtpClient("192.168.0.12"); * * client.Send(message); * * Response.Write("ERP廠商代號有問題" + "<br>"); * */ #endregion //--------------------------------------------------------------------------------------------------------------------------- // } }
protected void FlowFeedback1_FlowStop(object sender, SmoothEnterprise.Flowwork.UI.WebControl.FlowStopEventArgs e) { if (e.ResultType == SmoothEnterprise.Flowwork.Control.ReviewResultType.Complete) { try { string sqlstr = ""; sqlstr = "SELECT * FROM EngineeringTest_head where id='" + Request.QueryString["id"] + "'"; SmoothEnterprise.Database.DataSet ds; ds = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); ds.Open(sqlstr); if (!ds.EOF) { ds["STATUS"] = "完成審核"; ds.Update(); SmoothEnterprise.Database.DataSet rss = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rss.Open("select add_user , email,mail,name from EngineeringTest_head a left join dguser b on a.add_user=b.id where a.id='" + Request.QueryString["id"] + "' "); if (!rss.EOF) { #region 寄給申請人完成的mail ArrayList email_list = new ArrayList(); //email list email_list.Add(rss["email"].ToString()); #endregion #region 寄給通知者 String[] s = rss["mail"].ToString().Split(';'); foreach (string bb in s) { email_list.Add(bb.ToString()); //Response.Write(bb.ToString()); } #endregion #region Send email String ques; MailAddress from = new MailAddress("*****@*****.**", "ePortal(員工入口網站)"); //MailAddress to = new MailAddress(i); MailAddress bcc = new MailAddress("*****@*****.**"); MailMessage message = new MailMessage("*****@*****.**", rss["email"].ToString()); foreach (string i in email_list) { if (!string.IsNullOrEmpty(i)) { message.To.Add(i); } } DateTime de = Convert.ToDateTime(this.FIELD_expect_date.Text); ques = "您好:" + "<br>" + "<br>" + "EIP工程試作單系統已完成審核, 詳細資料如下:" + "<br>" + "<br>" + "單號 : " + this.no.Text + "<br>" + "申請日期 : " + de.ToString("yyyy/MM/dd") + "<br>" + "申請內容 : " + "<a href=\"http://eip.minaik.com.tw/EngineeringTest/EngineeringTestView.aspx?id=" + Request.QueryString["id"] + "\" >至EIP工程試作單系統查看</a>" + "<br>" + "如您想了解更多有關員工入口網站的資訊請點選以下連結進入" + "<br>" + "<a href=\"http://eip.minaik.com.tw/\">員工入口網站</a>" + "<br>" + "感謝您對員工入口網站的支持與愛護,<font Color='red'>。因本信件為系統自動發送,請勿直接以此郵件回覆。</font>"; message.Subject = "EIP工程試作單號 - " + this.no.Text + " 成品料號-" + this.cima01.Text + "己完成審核"; message.IsBodyHtml = true; message.Body = ques; SmtpClient client = new SmtpClient("192.168.0.12"); client.Send(message); #endregion if (this.cima01.Text.Substring(1, 1) == "9") //料號的開頭如果是”9”的時候要寄出去信件並新增至模具試模試作系統中 { #region 寫入NPI_TryoutFeedback EIPSysSha eip = new EIPSysSha(); SmoothEnterprise.Database.DataSet rss2 = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); string NPI_TryoutFeedbackSN = eip.GetNewSn("N301", DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month.ToString("00"), "EIPB", "PAPDETAIL"); string Guidstring = Guid.NewGuid().ToString(); string sqlcommand = "INSERT INTO EIPB.dbo.NPI_TryoutFeedback " + " (rowno , " + " SN , " + " PNO , " + " PRODUCTION_NAME ," + " Drawing , " + " NPI , " + " VER , " + " QUARYTI ," + " samples," + " ORDERS," + " Explanation," + " NOTE, " + " Measured_datetime ," + " initdate ," + " inituid) " + " VALUES('" + Guidstring + "'," + " '" + NPI_TryoutFeedbackSN + "'," + " '" + this.cima01.Text + "'," + " '" + this.cima02.Text + "'," + " '" + this.cima03.Text + "'," + " '" + rss["add_user"].ToString() + "'," + " '" + this.rev.Text + "'," + " " + this.oduction_amount.Text + "," + " " + this.delivers_amount.Text + "," + " '" + this.order_no.Text + "'," + " '" + this.oduction_explain.Text + "'," + " '" + this.remark.Text + "'," + " '" + this.FIELD_expect_date.Text + "' , " + " SYSDATETIME()," + " '" + rss["add_user"].ToString() + "')"; //throw new Exception(sqlcommand); rss2.ExecuteNonQuery(sqlcommand); #endregion #region 寫入NPI的預設MailGrid InsertIntoMailGrid(Guidstring); #endregion #region 寄出模具試模計劃的EMail SendMail(email_list, Guidstring, NPI_TryoutFeedbackSN); #endregion } } } } catch (Exception ex) { Response.Write(ex.Message + ex.StackTrace); //showError(ex.Message); } } if (e.ResultType == SmoothEnterprise.Flowwork.Control.ReviewResultType.Terminate || e.ResultType == SmoothEnterprise.Flowwork.Control.ReviewResultType.Return) { //try //{ string sqlstr = ""; sqlstr = "SELECT * FROM EngineeringTest_head where id='" + Request.QueryString["id"] + "'"; SmoothEnterprise.Database.DataSet ds; ds = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); ds.Open(sqlstr); if (!ds.EOF) { ds["STATUS"] = "退回"; ds.Update(); SmoothEnterprise.Database.DataSet rss = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rss.Open("select add_user bid,email,name from EngineeringTest_head a left join dguser b on a.add_user=b.id where a.id='" + Request.QueryString["id"] + "' "); if (!rss.EOF) { #region 寄給申請人退回的mail ArrayList email_list = new ArrayList(); //email list email_list.Add(rss["email"].ToString()); #region 如資材單位已簽核過, 也給生管單位一份 SmoothEnterprise.Database.DataSet rsa = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rsa.Open("select * from dgflowqueue where text='資材單位' and qseq='1' and reviewresult is not null and requesturl like '%" + Request.QueryString["id"] + "'"); if (!rsa.EOF) { SmoothEnterprise.Database.DataSet rsb = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); rsb.Open("select email from dguser where id='" + this.FIELD_pmcsend.Text + "'"); if (!rsb.EOF) { email_list.Add(rsb["email"].ToString()); } } #endregion #endregion #region Send email foreach (string i in email_list) { String ques; MailAddress from = new MailAddress("*****@*****.**", "ePortal(員工入口網站)"); MailAddress to = new MailAddress(i); MailAddress bcc = new MailAddress("*****@*****.**"); MailMessage message = new MailMessage(from, to); DateTime de = Convert.ToDateTime(this.FIELD_expect_date.Text); ques = "您好:" + "<br>" + "<br>" + "EIP工程試作單系統已被退回, 詳細資料如下:" + "<br>" + "<br>" + "單號 : " + this.no.Text + "<br>" + "申請日期 : " + de.ToString("yyyy/MM/dd") + "<br>" + "申請內容 : " + "<a href=\"http://eip.minaik.com.tw/EngineeringTest/EngineeringTestView.aspx?id=" + Request.QueryString["id"] + "\" >至EIP工程試作單系統查看</a>" + "<br>" + "如您想了解更多有關員工入口網站的資訊請點選以下連結進入" + "<br>" + "<a href=\"http://eip.minaik.com.tw/\">員工入口網站</a>" + "<br>" + "感謝您對員工入口網站的支持與愛護,<font Color='red'>。因本信件為系統自動發送,請勿直接以此郵件回覆。</font>"; message.Subject = "EIP工程試作單號 - " + this.no.Text + " 成品料號-" + this.cima01.Text + "己被退回"; message.IsBodyHtml = true; message.Body = ques; SmtpClient client = new SmtpClient("192.168.0.12"); client.Send(message); } #endregion } } //} //catch //{ // Response.Write("有問題"); //} } }
protected void Page_Load(object sender, EventArgs e) { string db = "[EIPB].[dbo]."; /* ================= 抓 ERP 資料進 EIP ================= */ // FileRoute 設定..暫存的目錄位置 string InitDirectory = @"D:\APMI255_XML\ERP_Download\"; //string InitDirectory = @"D:\AnnSmooth\ERP_APMI255\APMI255_XML\ERP_Download\"; // 先抓 FTP 的資料 ArrayList FtpList = List("ftp://192.168.0.250/", "xmluser", "(XmlUser)"); foreach (string s in FtpList) { //Response.Write("AAA"); Response.Write(s.ToString()); //找到 自己要的檔名! if (s.IndexOf("apmi255") != -1) { //將目前FTP的XML抓下來 Download("ftp://192.168.0.250/" + s, InitDirectory, "xmluser", "(XmlUser)"); DeleteFileOnServer("ftp://192.168.0.250/" + s, "xmluser", "(XmlUser)"); } } //------------------------------------------------------------- string searchPattern = "*"; //可以指定目錄 或 //string InitDirectory = @"C:\"; // 取得目前工作目錄 //string InitDirectory = @"D:\XML"; //原始目錄 ArrayList MyFiles = new ArrayList(); DirectoryInfo di = new DirectoryInfo(InitDirectory); // 呼叫上面的函式 Get Files GetFiles(di, searchPattern, ref MyFiles); //Print it foreach (string s in MyFiles) { try { if (s.IndexOf("apmi255") != -1) { Response.Write("yes"); Response.Write("---------" + s.IndexOf("_") + "<br>"); System.Diagnostics.Debug.Write(s); Response.Write(s + "\n"); XmlDocument xDoc = new XmlDocument(); xDoc.Load((s)); XmlNodeList plantid = xDoc.GetElementsByTagName("PlantID"); XmlNodeList pmi01 = xDoc.GetElementsByTagName("pmi01"); XmlNodeList pmi02 = xDoc.GetElementsByTagName("pmi02"); XmlNodeList pmi03 = xDoc.GetElementsByTagName("pmi03"); XmlNodeList pmc03_0 = xDoc.GetElementsByTagName("pmc03-0"); XmlNodeList pmi04 = xDoc.GetElementsByTagName("pmi04"); XmlNodeList pmi05 = xDoc.GetElementsByTagName("pmi05"); XmlNodeList pmi06 = xDoc.GetElementsByTagName("pmi06"); XmlNodeList pmi07 = xDoc.GetElementsByTagName("pmi07"); XmlNodeList pmi08 = xDoc.GetElementsByTagName("pmi08"); XmlNodeList pmi081 = xDoc.GetElementsByTagName("pmi081"); XmlNodeList pmiuser = xDoc.GetElementsByTagName("pmiuser"); XmlNodeList gen02_1 = xDoc.GetElementsByTagName("gen02-1"); XmlNodeList pmigrup = xDoc.GetElementsByTagName("pmigrup"); XmlNodeList gem02_2 = xDoc.GetElementsByTagName("gem02-2"); XmlNodeList ta_pmi01 = xDoc.GetElementsByTagName("ta_pmi01"); XmlNodeList CompanyName = xDoc.GetElementsByTagName("CompanyName"); Response.Write("select * from " + db + "apmi255_in_head where pmi01 = '" + pmi01[0].InnerXml + "' and plantid='" + plantid[0].InnerXml + "' "); SmoothEnterprise.Database.DataSet hs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); hs.Open("select * from " + db + "apmi255_in_head where pmi01 = '" + pmi01[0].InnerXml + "' and plantid='" + plantid[0].InnerXml + "' ");//檢查單頭是否有重覆單據號碼 if (!hs.EOF) { Response.Write("相同"); #region 若有相同單號, 單頭UPDATE,單身刪除後新增 SmoothEnterprise.Database.DataSet rsb = new SmoothEnterprise.Database.DataSet(); rsb.ExecuteNonQuery("delete " + db + "apmi255_in_body where bno = '" + hs["no"].ToString() + "' and plantid='" + plantid[0].InnerXml + "'"); SmoothEnterprise.Database.DataSet rsc = new SmoothEnterprise.Database.DataSet(); rsc.ExecuteNonQuery("delete " + db + "apmi255_in_pmr where cno = '" + hs["no"].ToString() + "' and plantid='" + plantid[0].InnerXml + "'"); SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs.Open("SELECT * FROM " + db + "apmi255_IN_HEAD where pmi01 = '" + pmi01[0].InnerXml + "' and plantid='" + plantid[0].InnerXml + "' "); if (!rs.EOF) { //rs.Add(); if (plantid[0].InnerXml != "") { rs["plantID"] = plantid[0].InnerXml; } if (pmi01[0].InnerXml != "") { rs["pmi01"] = pmi01[0].InnerXml; } if (pmi02[0].InnerXml != "") { rs["pmi02"] = pmi02[0].InnerXml; } if (pmi03[0].InnerXml != "") { rs["pmi03"] = pmi03[0].InnerXml; } if (pmc03_0[0].InnerXml != "") { rs["pmc03_0"] = pmc03_0[0].InnerXml; } if (pmi04[0].InnerXml != "") { rs["pmi04"] = pmi04[0].InnerXml; } if (pmi05[0].InnerXml != "") { rs["pmi05"] = pmi05[0].InnerXml; } if (pmi06[0].InnerXml != "") { rs["pmi06"] = pmi06[0].InnerXml; } if (pmi07[0].InnerXml != "") { rs["pmi07"] = pmi07[0].InnerXml; } if (pmi08[0].InnerXml != "") { rs["pmi08"] = pmi08[0].InnerXml; } if (pmi081[0].InnerXml != "") { rs["pmi081"] = pmi081[0].InnerXml; } if (pmiuser[0].InnerXml != "") { rs["pmiuser"] = pmiuser[0].InnerXml; } if (gen02_1[0].InnerXml != "") { rs["gen02_1"] = gen02_1[0].InnerXml; } if (pmigrup[0].InnerXml != "") { rs["pmigrup"] = pmigrup[0].InnerXml; } if (gem02_2[0].InnerXml != "") { rs["gem02_2"] = gem02_2[0].InnerXml; } if (ta_pmi01[0].InnerXml != "") { rs["ta_pmi01"] = ta_pmi01[0].InnerXml; } if (plantid[0].InnerXml != "") { rs["plantid"] = plantid[0].InnerXml; } if (pmi06[0].InnerXml == "9:作廢") { rs["status"] = "V"; } else { rs["status"] = "N"; } rs.Update(); rs.Close(); } SmoothEnterprise.Database.DataSet aa = new SmoothEnterprise.Database.DataSet(); object objola = aa.ExecuteScalar("SELECT no FROM " + db + "apmi255_in_head where pmi01 = '" + pmi01[0].InnerXml + "' and plantid='" + plantid[0].InnerXml + "' "); string no = objola.ToString(); int cmicNodes = xDoc.GetElementsByTagName("record").Count; Response.Write("record共" + cmicNodes); for (int i = 0; i <= (cmicNodes - 1); i++) { XmlNodeList pmj02 = xDoc.GetElementsByTagName("pmj02"); XmlNodeList pmj03 = xDoc.GetElementsByTagName("pmj03"); XmlNodeList pmj031 = xDoc.GetElementsByTagName("pmj031"); XmlNodeList pmj032 = xDoc.GetElementsByTagName("pmj032"); XmlNodeList pmj04 = xDoc.GetElementsByTagName("pmj04"); XmlNodeList pmj05 = xDoc.GetElementsByTagName("pmj05"); XmlNodeList pmj06 = xDoc.GetElementsByTagName("pmj06"); XmlNodeList pmj06t = xDoc.GetElementsByTagName("pmj06t"); XmlNodeList pmj07 = xDoc.GetElementsByTagName("pmj07"); XmlNodeList pmj07t = xDoc.GetElementsByTagName("pmj07t"); XmlNodeList pmj08 = xDoc.GetElementsByTagName("pmj08"); XmlNodeList pmj09 = xDoc.GetElementsByTagName("pmj09"); XmlNodeList pmj10 = xDoc.GetElementsByTagName("pmj10"); XmlNodeList ta_pmj01 = xDoc.GetElementsByTagName("ta_pmj01"); XmlNodeList ima491 = xDoc.GetElementsByTagName("ima491"); XmlNodeList ima46 = xDoc.GetElementsByTagName("ima46"); SmoothEnterprise.Database.DataSet rs2 = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs2.Open("SELECT * FROM " + db + "apmi255_IN_BODY WHERE 1=0"); rs2.Add(); if (pmj02[0].InnerXml != "") { rs2["pmj02"] = pmj02[i].InnerXml; } if (pmj03[0].InnerXml != "") { rs2["pmj03"] = pmj03[i].InnerXml; } if (pmj031[0].InnerXml != "") { rs2["pmj031"] = pmj031[i].InnerXml; } if (pmj032[0].InnerXml != "") { rs2["pmj032"] = pmj032[i].InnerXml; } if (pmj04[0].InnerXml != "") { rs2["pmj04"] = pmj04[i].InnerXml; } if (pmj05[0].InnerXml != "") { rs2["pmj05"] = pmj05[i].InnerXml; } if (pmj06[0].InnerXml != "") { rs2["pmj06"] = pmj06[i].InnerXml; } if (pmj06t[0].InnerXml != "") { rs2["pmj06t"] = pmj06t[i].InnerXml; } if (pmj07[0].InnerXml != "") { rs2["pmj07"] = pmj07[i].InnerXml; } if (pmj07t[0].InnerXml != "") { rs2["pmj07t"] = pmj07t[i].InnerXml; } if (pmj08[i].InnerXml != "") { rs2["pmj08"] = pmj08[i].InnerXml; } if (pmj09[i].InnerXml != "") { rs2["pmj09"] = pmj09[i].InnerXml; } if (pmj10[0].InnerXml != "") { rs2["pmj10"] = pmj10[i].InnerXml; } if (ta_pmj01[i].InnerXml != "") { rs2["ta_pmj01"] = ta_pmj01[i].InnerXml; } if (ima491[0].InnerXml != "") { rs2["ima491"] = ima491[i].InnerXml; } if (ima46[0].InnerXml != "") { rs2["ima46"] = ima46[i].InnerXml; } if (plantid[0].InnerXml != "") { rs2["plantid"] = plantid[0].InnerXml; } rs2["bno"] = no; rs2.Update(); rs2.Close(); } #region 單身的單身(單身對應的核價資訊) if (pmi05[0].InnerXml == "Y") //分量計價才有這個 { int pmrNodes = xDoc.GetElementsByTagName("pmr").Count; for (int i2 = 0; i2 <= (pmrNodes - 1); i2++) { XmlNodeList pmr02 = xDoc.GetElementsByTagName("pmr02"); XmlNodeList pmr03 = xDoc.GetElementsByTagName("pmr03"); XmlNodeList pmr04 = xDoc.GetElementsByTagName("pmr04"); XmlNodeList pmr05 = xDoc.GetElementsByTagName("pmr05"); XmlNodeList pmr05t = xDoc.GetElementsByTagName("pmr05t"); SmoothEnterprise.Database.DataSet rspmr = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rspmr.Open("SELECT * FROM " + db + "apmi255_IN_PMR WHERE 1=0"); rspmr.Add(); if (pmr02[0].InnerXml != "") { rspmr["pmr02"] = pmr02[i2].InnerXml; } if (pmr03[0].InnerXml != "") { rspmr["pmr03"] = pmr03[i2].InnerXml; } if (pmr04[0].InnerXml != "") { rspmr["pmr04"] = pmr04[i2].InnerXml; } if (pmr05[0].InnerXml != "") { rspmr["pmr05"] = pmr05[i2].InnerXml; } if (pmr05t[0].InnerXml != "") { rspmr["pmr05t"] = pmr05t[i2].InnerXml; } if (plantid[0].InnerXml != "") { rspmr["plantid"] = plantid[0].InnerXml; } rspmr["cno"] = no; rspmr.Update(); rspmr.Close(); Response.Write("<br>hahahaha"); } } #endregion if (System.IO.File.Exists(s.Replace("Download", "XML"))) //判斷在OUT資料夾裡, 檔案是否存在 { File.Delete(s.Replace("Download", "XML")); //存在的話先刪除該檔案再存入新檔案 File.Move(s, s.Replace("Download", "XML")); } else { File.Move(s, s.Replace("Download", "XML")); //不存在直接存入新檔案 } #endregion } else { #region 單號不相同,將資料全數新增 //EIP單號----------------------------------------- EIPSysSha UseSha = new EIPSysSha(); string OK_NO; switch (plantid[0].InnerXml) { case "MAY": OK_NO = UseSha.GetNewSn("P101", DateTime.Now.ToString("yyMM")); break; case "MINAIK": OK_NO = UseSha.GetNewSn("P102", DateTime.Now.ToString("yyMM")); break; default: OK_NO = UseSha.GetNewSn("P102", DateTime.Now.ToString("yyMM")); break; } //------------------------------------------------- SmoothEnterprise.Database.DataSet rs = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs.Open("SELECT * FROM " + db + "apmi255_IN_HEAD WHERE 1=0"); rs.Add(); if (plantid[0].InnerXml != "") { rs["plantID"] = plantid[0].InnerXml; } if (pmi01[0].InnerXml != "") { rs["pmi01"] = pmi01[0].InnerXml; } if (pmi02[0].InnerXml != "") { rs["pmi02"] = pmi02[0].InnerXml; } if (pmi03[0].InnerXml != "") { rs["pmi03"] = pmi03[0].InnerXml; } if (pmc03_0[0].InnerXml != "") { rs["pmc03_0"] = pmc03_0[0].InnerXml; } if (pmi04[0].InnerXml != "") { rs["pmi04"] = pmi04[0].InnerXml; } if (pmi05[0].InnerXml != "") { rs["pmi05"] = pmi05[0].InnerXml; } if (pmi06[0].InnerXml != "") { rs["pmi06"] = pmi06[0].InnerXml; } if (pmi07[0].InnerXml != "") { rs["pmi07"] = pmi07[0].InnerXml; } if (pmi08[0].InnerXml != "") { rs["pmi08"] = pmi08[0].InnerXml; } if (pmi081[0].InnerXml != "") { rs["pmi081"] = pmi081[0].InnerXml; } if (pmiuser[0].InnerXml != "") { rs["pmiuser"] = pmiuser[0].InnerXml; } if (gen02_1[0].InnerXml != "") { rs["gen02_1"] = gen02_1[0].InnerXml; } if (pmigrup[0].InnerXml != "") { rs["pmigrup"] = pmigrup[0].InnerXml; } if (gem02_2[0].InnerXml != "") { rs["gem02_2"] = gem02_2[0].InnerXml; } if (ta_pmi01[0].InnerXml != "") { rs["ta_pmi01"] = ta_pmi01[0].InnerXml; } rs["CompanyName"] = CompanyName[0].InnerXml; rs["status"] = "N"; rs["no"] = OK_NO; rs.Update(); rs.Close(); int cmicNodes = xDoc.GetElementsByTagName("record").Count; Response.Write("record共" + cmicNodes); for (int i = 0; i <= (cmicNodes - 1); i++) { XmlNodeList pmj02 = xDoc.GetElementsByTagName("pmj02"); XmlNodeList pmj03 = xDoc.GetElementsByTagName("pmj03"); XmlNodeList pmj031 = xDoc.GetElementsByTagName("pmj031"); XmlNodeList pmj032 = xDoc.GetElementsByTagName("pmj032"); XmlNodeList pmj04 = xDoc.GetElementsByTagName("pmj04"); XmlNodeList pmj05 = xDoc.GetElementsByTagName("pmj05"); XmlNodeList pmj06 = xDoc.GetElementsByTagName("pmj06"); XmlNodeList pmj06t = xDoc.GetElementsByTagName("pmj06t"); XmlNodeList pmj07 = xDoc.GetElementsByTagName("pmj07"); XmlNodeList pmj07t = xDoc.GetElementsByTagName("pmj07t"); XmlNodeList pmj08 = xDoc.GetElementsByTagName("pmj08"); XmlNodeList pmj09 = xDoc.GetElementsByTagName("pmj09"); XmlNodeList pmj10 = xDoc.GetElementsByTagName("pmj10"); XmlNodeList ta_pmj01 = xDoc.GetElementsByTagName("ta_pmj01"); XmlNodeList ima491 = xDoc.GetElementsByTagName("ima491"); XmlNodeList ima46 = xDoc.GetElementsByTagName("ima46"); SmoothEnterprise.Database.DataSet rs2 = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rs2.Open("SELECT * FROM " + db + "apmi255_IN_BODY WHERE 1=0"); rs2.Add(); if (pmj02[0].InnerXml != "") { rs2["pmj02"] = pmj02[i].InnerXml; } if (pmj03[0].InnerXml != "") { rs2["pmj03"] = pmj03[i].InnerXml; } if (pmj031[0].InnerXml != "") { rs2["pmj031"] = pmj031[i].InnerXml; } if (pmj032[0].InnerXml != "") { rs2["pmj032"] = pmj032[i].InnerXml; } if (pmj04[0].InnerXml != "") { rs2["pmj04"] = pmj04[i].InnerXml; } if (pmj05[0].InnerXml != "") { rs2["pmj05"] = pmj05[i].InnerXml; } if (pmj06[0].InnerXml != "") { rs2["pmj06"] = pmj06[i].InnerXml; } if (pmj06t[0].InnerXml != "") { rs2["pmj06t"] = pmj06t[i].InnerXml; } if (pmj07[0].InnerXml != "") { rs2["pmj07"] = pmj07[i].InnerXml; } if (pmj07t[0].InnerXml != "") { rs2["pmj07t"] = pmj07t[i].InnerXml; } if (pmj08[i].InnerXml != "") { rs2["pmj08"] = pmj08[i].InnerXml; } if (pmj09[i].InnerXml != "") { rs2["pmj09"] = pmj09[i].InnerXml; } if (pmj10[0].InnerXml != "") { rs2["pmj10"] = pmj10[i].InnerXml; } if (ta_pmj01[i].InnerXml != "") { rs2["ta_pmj01"] = ta_pmj01[i].InnerXml; } if (ima491[0].InnerXml != "") { rs2["ima491"] = ima491[i].InnerXml; } if (ima46[0].InnerXml != "") { rs2["ima46"] = ima46[i].InnerXml; } if (plantid[0].InnerXml != "") { rs2["plantid"] = plantid[0].InnerXml; } rs2["bno"] = OK_NO; rs2.Update(); rs2.Close(); } #region 單身的單身(單身對應的核價資訊) if (pmi05[0].InnerXml == "Y") //分量計價才有這個 { int pmrNodes = xDoc.GetElementsByTagName("pmr").Count; for (int i2 = 0; i2 <= (pmrNodes - 1); i2++) { XmlNodeList pmr02 = xDoc.GetElementsByTagName("pmr02"); XmlNodeList pmr03 = xDoc.GetElementsByTagName("pmr03"); XmlNodeList pmr04 = xDoc.GetElementsByTagName("pmr04"); XmlNodeList pmr05 = xDoc.GetElementsByTagName("pmr05"); XmlNodeList pmr05t = xDoc.GetElementsByTagName("pmr05t"); SmoothEnterprise.Database.DataSet rspmr = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenUpdate); rspmr.Open("SELECT * FROM " + db + "apmi255_IN_PMR WHERE 1=0"); rspmr.Add(); if (pmr02[0].InnerXml != "") { rspmr["pmr02"] = pmr02[i2].InnerXml; } if (pmr03[0].InnerXml != "") { rspmr["pmr03"] = pmr03[i2].InnerXml; } if (pmr04[0].InnerXml != "") { rspmr["pmr04"] = pmr04[i2].InnerXml; } if (pmr05[0].InnerXml != "") { rspmr["pmr05"] = pmr05[i2].InnerXml; } if (pmr05t[0].InnerXml != "") { rspmr["pmr05t"] = pmr05t[i2].InnerXml; } if (plantid[0].InnerXml != "") { rspmr["plantid"] = plantid[0].InnerXml; } rspmr["cno"] = OK_NO; rspmr.Update(); rspmr.Close(); Response.Write("<br>hahahaha"); } } #endregion if (System.IO.File.Exists(s.Replace("Download", "XML"))) //判斷在OUT資料夾裡, 檔案是否存在 { File.Delete(s.Replace("Download", "XML")); //存在的話先刪除該檔案再存入新檔案 File.Move(s, s.Replace("Download", "XML")); } else { File.Move(s, s.Replace("Download", "XML")); //不存在直接存入新檔案 } #endregion } //發mail--------------------------------------------------------------------------------------------------------------------------- string pmi06_string = pmi06[0].InnerXml; if (pmi06_string.ToString() != "9:作廢" && pmi06_string.ToString() != "R:送簽退回") { Response.Write("<br>====" + pmi06[0].InnerXml); String ques; SmoothEnterprise.Database.DataSet es = new SmoothEnterprise.Database.DataSet(SmoothEnterprise.Database.DataSetType.OpenRead); es.Open("select email," + db + "apmi255_in_head.id id from " + db + "apmi255_in_head LEFT JOIN dguser ON pmiuser=erpid where pmi01 = '" + pmi01[0].InnerXml + "' and plantid='" + plantid[0].InnerXml + "' "); if (!es.EOF) { MailAddress from = new MailAddress("*****@*****.**", "ePortal(員工入口網站)"); MailAddress to = new MailAddress(es["email"].ToString()); MailAddress bcc = new MailAddress("*****@*****.**"); MailMessage message = new MailMessage(from, to); message.Bcc.Add(bcc); ques = "您好:" + "<br>" + "<br>" + "ERP採購核價電子簽核申請單現有一筆,正等待您的處理:" + "<br>" + "<br>" + "申請單號 : " + pmi01[0].InnerXml + "<br>" + "申請日期 : " + pmi02[0].InnerXml + "<br>" + "申請人員 : " + gen02_1[0].InnerXml + "<br>" + "申請內容 : " + "<a href=\"http://eip.minaik.com.tw/ERP_APMI255/ERP_APMI255Edit.aspx?id=" + es["id"].ToString() + "\" >至ERP採購核價電子簽核系統檢視並編輯內容</a>" + "<br>" + "<br>" + "如您想了解更多有關員工入口網站的資訊請點選以下連結進入" + "<br>" + "<a href=\"http://eip.minaik.com.tw/\">員工入口網站</a>" + "<br>" + "感謝您對員工入口網站的支持與愛護,<font Color='red'>。因本信件為系統自動發送,請勿直接以此郵件回覆。</font>"; message.Subject = "核價單號 - " + pmi01[0].InnerXml + " 等待您的處理"; message.IsBodyHtml = true; message.Body = ques; SmtpClient client = new SmtpClient("192.168.0.12"); client.Send(message); Response.Write("Mail傳送完畢" + "<br>"); } } Upload("D:\\APMI255_XML\\ERP_XML\\" + plantid[0].InnerXml + "_apmi255_" + pmi01[0].InnerXml + ".xml", "ftp://192.168.0.250/" + plantid[0].InnerXml + "_APMI255_" + pmi01[0].InnerXml + ".xml", "xmlback", "xmlback"); //--------------------------------------------------------------------------------------------------------------------------- } } catch (Exception ex) { string s1 = s.Replace(".xml", ""); s1 = s1.Replace("D:\\APMI255_XML\\ERP_Download\\", ""); int sone = s1.IndexOf("_"); int stwo = s1.LastIndexOf("_"); stwo = stwo + 1; FileStream fs = new FileStream(@"D:\APMI255_XML\4GL\" + s1 + ".txt", FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.WriteLine("\"" + s1.Substring(0, sone) + "\",\"apmi255\",\"" + s1.Substring(stwo, 10) + "\",\"E\",\"\""); sw.Close(); fs.Close(); Upload(fs.ToString(), "ftp://192.168.0.250/" + s1.ToString() + ".txt", "4gl", "4gl"); //發mail--------------------------------------------------------------------------------------------------------------------------- String ques; MailAddress from = new MailAddress("*****@*****.**", "ePortal(員工入口網站)"); MailAddress to = new MailAddress("*****@*****.**"); MailAddress bcc = new MailAddress("*****@*****.**"); MailMessage message = new MailMessage(from, to); message.Bcc.Add(bcc); ques = "有問題"; message.Subject = "ERP採購核價有問題"; message.IsBodyHtml = true; message.Body = ques; SmtpClient client = new SmtpClient("192.168.0.12"); client.Send(message); Response.Write("ERP採購核價有問題" + "<br>"); //--------------------------------------------------------------------------------------------------------------------------- } } }