public bool send_cancel_mail_for_vendor(Dictionary<uint, string> SendMail) { MailHelper mail = new MailHelper(); bool result = false; try { DataTable _dtVendor = new DataTable(); StringBuilder sb = new StringBuilder(); sb.Append(" select parameterCode from t_parametersrc where parameterType ='develop';"); DataTable _dtDEV = _accessMySql.getDataTable(sb.ToString()); sb.Clear(); DataTable _dtTest = new DataTable(); sb.Append(" select remark from t_parametersrc where parameterType ='TestMail';"); _dtTest = _accessMySql.getDataTable(sb.ToString()); sb.Clear(); string TestMail = ""; if (_dtTest.Rows.Count > 0) { TestMail = _dtTest.Rows[0]["remark"].ToString(); } string DEV = "false"; if (_dtDEV.Rows.Count > 0) { DEV = _dtDEV.Rows[0]["parameterCode"].ToString(); } foreach (uint item in SendMail.Keys) { sb.AppendFormat(" select os.order_id,v.vendor_email,v.vendor_name_full from order_slave os left join vendor v on v.vendor_id=os.vendor_id where slave_id='{0}';", item); _dtVendor = _accessMySql.getDataTable(sb.ToString()); sb.Clear(); if (_dtVendor.Rows.Count > 0) { string MailTitle = "取消出貨通知"; string MailBody = _dtVendor.Rows[0]["vendor_name_full"].ToString() + "公司您好,<br/>吉甲地市集平台訂單, 付款單號 :" + _dtVendor.Rows[0]["order_id"].ToString(); MailBody += "客戶因故取消部分商品, 請協助再次確認出貨品項無誤,以免衍生後續不便,<br/>感謝您。吉甲地在地好物市集敬上 "; if (DEV == "true") { result = mail.SendMailAction(TestMail, MailTitle, MailBody); } else { result = mail.SendMailAction(_dtVendor.Rows[0]["vendor_email"].ToString(), MailTitle, MailBody); } } } return result; } catch (Exception ex) { throw new Exception("OrderCancelMasterDao-->send_cancel_mail_for_vendor" + ex.Message, ex); } }
public HttpResponseBase Reply() { string json = string.Empty; string response_content = string.Empty; OrderCancelResponse ocr = new OrderCancelResponse(); _ptersrc = new ParameterMgr(mySqlConnectionString); int i = 0; string cancel_id = string.Empty; ; if (!string.IsNullOrEmpty(Request.Params["cancel_id"])) { cancel_id = Request.Params["cancel_id"]; ocr.cancel_id = uint.Parse(cancel_id); } string question_email = string.Empty; if (!string.IsNullOrEmpty(Request.Params["question_email"])) { question_email = Request.Params["question_email"]; } //獲取登錄用戶的user_email string user_email = (Session["caller"] as Caller).user_email; //獲取登錄用戶的user_id string user_id = (Session["caller"] as Caller).user_id.ToString(); string res; try { res = Request.Params["response"].ToString().Trim(); res = res.Replace("\n", ""); if (res.Length > 0) { response_content = Request.Params["response"] + " "; ocr.user_id = uint.Parse(user_id); ocr.response_content = response_content; System.Net.IPAddress[] addlist = Dns.GetHostEntry(Dns.GetHostName()).AddressList; if (addlist.Length > 0) { ocr.response_ipfrom = addlist[0].ToString(); } _orderCancelMsgMgr = new OrderCancelMsgMgr(mySqlConnectionString); i = _orderCancelMsgMgr.Reply(ocr); bool issend = false; if (i == 2) { MailHelper mail = new MailHelper(); string mail1 = _ptersrc.Getmail("TestMail"); if (mail1 == "*****@*****.**") {//測試使用上正式機后可變更為gigademail則是讀取會員mail mail1 = question_email; } issend = mail.SendMailAction(mail1, "取消訂單通知信", response_content); } json = "{success:true,msg:\"" + " 發送郵件成功!" + "\"}"; } else { json = "{success:false,msg:\"" + "请填写回覆内容!" + "\"}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = ex.InnerException.Message; json = ex.InnerException.Source; json = "{success:false,msg:\"" + " 發送郵件失敗!" + "\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase NoOrComing() { List<ArrivalNoticeQuery> list = new List<ArrivalNoticeQuery>(); ArrivalNoticeQuery query = null; string json = string.Empty; string mailBody; MailHelper mailHelper = new MailHelper(); try { if (!string.IsNullOrEmpty(Request.Params["rowID"])) { string select_id = Request.Params["rowID"]; if (select_id.IndexOf("∑") != -1) { foreach (string id in select_id.Split('∑')) { if (!string.IsNullOrEmpty(id)) { query = new ArrivalNoticeQuery(); string[] data = id.Split(','); query.status = Convert.ToInt32(Request.Params["type"]); query.id = Convert.ToUInt32(data[0]); query.user_email = _usmgr.getModel(Convert.ToInt32(data[1].ToString())).user_email; query.product_name = data[2]; if (!string.IsNullOrEmpty(Request.Params["coming_time"])) { query.coming_time = Convert.ToInt32(CommonFunction.GetPHPTime(Request.Params["coming_time"].ToString())); } if (!string.IsNullOrEmpty(Request.Params["recommend"])) { query.recommend = Request.Params["recommend"].ToString(); } list.Add(query); } } } } _IArrivalNoticeMgr = new ArrivalNoticeMgr(mySqlConnectionString); if (_IArrivalNoticeMgr.IgnoreNotice(list)) { FileStream fs = new FileStream(Server.MapPath("../ImportUserIOExcel/ArrivalNotice.html"), FileMode.OpenOrCreate, FileAccess.Read); StreamReader sr = new StreamReader(fs, Encoding.UTF8); string strTemp = sr.ReadToEnd(); for (int i = 0; i < list.Count; i++) { #region 不再補貨 if (list[i].status == 2) { if (!string.IsNullOrEmpty(list[i].recommend)) { mailBody = "您關注補貨的商品" + "【" + list[i].product_name + "】" + "已不再進貨/販售,建議您購買我們推薦的類似商品:" + list[i].recommend; } else { mailBody = "您關注補貨的商品" + "【" + list[i].product_name + "】" + "已不再進貨/販售。 "; } strTemp = strTemp.Replace("{{$serviceAnwser$}}", mailBody); } #endregion #region 預計補貨 if (list[i].status == 3) { mailBody = "您關注補貨的商品" + "【" + list[i].product_name + "】" + "將預計在" + CommonFunction.DateTimeToString(CommonFunction.GetNetTime(list[i].coming_time)) + "補貨,敬請及早購買,以免向隅。 "; strTemp = strTemp.Replace("{{$serviceAnwser$}}", mailBody); } #endregion try { mailHelper.SendMailAction(list[i].user_email, "吉甲地市集補貨通知信", strTemp); } catch (Exception ex) { json = "{success:true,msg:1}"; } } json = "{success:true,msg:0}"; } else { json = "{failure:true}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{failure:true}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/*public HttpResponseBase GetContentUrl() { string json = string.Empty; string template_data = string.Empty; string contentJson = string.Empty; string replaceStr = string.Empty; string editStr = string.Empty; try { _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString); if (!string.IsNullOrEmpty(Request.Params["content_url"])) { #region 獲取網頁內容方法 string url = Request.Params["content_url"].ToString(); HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); httpRequest.Timeout = 9000; httpRequest.Method = "GET"; HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); StreamReader sr = new StreamReader(httpResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8")); contentJson = sr.ReadToEnd(); #endregion } else { int template_id = Convert.ToInt32(Request.Params["template_id"]); string url = _edmContentNewMgr.GetContentUrl(template_id); HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); httpRequest.Timeout = 9000; httpRequest.Method = "GET"; HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); StreamReader sr = new StreamReader(httpResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8")); contentJson = sr.ReadToEnd(); } if (!string.IsNullOrEmpty(Request.Params["template_data"])) { template_data = Request.Params["template_data"]; } DataTable _dt = _edmContentNewMgr.GetPraraData(1); if (_dt != null && _dt.Rows.Count > 0) { replaceStr = _dt.Rows[0][0].ToString(); } else { replaceStr = " "; } DataTable _dtEdit = _edmContentNewMgr.GetPraraData(3); if (_dtEdit != null && _dtEdit.Rows.Count > 0) { editStr = _dtEdit.Rows[0][0].ToString(); } else { editStr = " "; } template_data = template_data.Replace(editStr,""); contentJson=contentJson.Replace(replaceStr,template_data); json = contentJson; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "獲取網頁出現異常!"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }*/ #endregion #region 發送電子報 (測試發送/正式發送) public HttpResponseBase SendEdm() { string json = string.Empty; EdmSendLog eslQuery = new EdmSendLog(); MailRequest mQuery = new MailRequest(); try { _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString); if (!string.IsNullOrEmpty(Request.Params["content_id"])) { eslQuery.content_id = mQuery.content_id = Convert.ToInt32(Request.Params["content_id"]); } if (!string.IsNullOrEmpty(Request.Params["group_id"])) { mQuery.group_id = Convert.ToInt32(Request.Params["group_id"]); } if (!string.IsNullOrEmpty(Request.Params["sender_email"])) { mQuery.sender_address = Request.Params["sender_email"]; } if (!string.IsNullOrEmpty(Request.Params["sender_name"])) { mQuery.sender_name = Request.Params["sender_name"]; } if (!string.IsNullOrEmpty(Request.Params["subject"])) { mQuery.subject = Request.Params["subject"]; } if (!string.IsNullOrEmpty(Request.Params["template_id"])) { mQuery.template_id = Convert.ToInt32(Request.Params["template_id"]); } if (!string.IsNullOrEmpty(Request.Params["static_template"])) { mQuery.static_template = Convert.ToUInt64(Request.Params["static_template"]); } eslQuery.create_userid = (Session["caller"] as Caller).user_id; mQuery.user_id = 0; if (!string.IsNullOrEmpty(Request.Params["testSend"])) { if (Request.Params["testSend"] == "true")// { eslQuery.test_send_end = true; #region 字段賦值 eslQuery.test_send = 1; eslQuery.receiver_count = 1; eslQuery.schedule_date = DateTime.Now; eslQuery.expire_date = eslQuery.schedule_date.AddHours(1); eslQuery.createdate = eslQuery.schedule_date; mQuery.schedule_date = eslQuery.schedule_date; mQuery.valid_until_date = eslQuery.expire_date; mQuery.retry_count = 0; mQuery.next_send = eslQuery.schedule_date; mQuery.max_retry = 1; if (!string.IsNullOrEmpty(Request.Params["test_send_list"])) { string[] test_send_arr = Request.Params["test_send_list"].ToString().TrimEnd('\n').Split('\n'); for (int i = 0; i < test_send_arr.Length; i++) { if (test_send_arr[i] != "") { mQuery.receiver_address = test_send_arr[i]; eslQuery.receiver_count = test_send_arr.Length; if (!string.IsNullOrEmpty(Request.Params["body"])) { if (mQuery.static_template == 0)//非靜態範本,需動態生成推薦 { mQuery.bodyData = Request.Params["body"] + _edmContentNewMgr.GetRecommendHtml(0); } else//靜態範本 { mQuery.bodyData = Request.Params["body"]; } #region 得到電子報整體內容 string replaceStr = string.Empty; string editStr = string.Empty; string content_url = _edmContentNewMgr.GetContentUrlByContentId(eslQuery.content_id); if (!string.IsNullOrEmpty(content_url)) { #region 獲取網頁內容 HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(content_url); httpRequest.Timeout = 9000; httpRequest.Method = "GET"; HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); StreamReader sr = new StreamReader(httpResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8")); string contentStr = sr.ReadToEnd(); DataTable _dt = _edmContentNewMgr.GetPraraData(1); if (_dt != null && _dt.Rows.Count > 0) { replaceStr = _dt.Rows[0][0].ToString(); } else { replaceStr = " "; } DataTable _dtEdit = _edmContentNewMgr.GetPraraData(3); if (_dtEdit != null && _dtEdit.Rows.Count > 0) { editStr = _dtEdit.Rows[0][0].ToString(); } else { editStr = " "; } if (mQuery.bodyData.IndexOf(subscribe) > 0)//找到了埋的那個code,證明是點擊了訂閱電子報 { mQuery.bodyData = contentStr.Replace(replaceStr, mQuery.bodyData.Replace(subscribe, "\n").Replace(editStr,"") ) + subscribe_url; ; } else { mQuery.bodyData = contentStr.Replace(replaceStr, mQuery.bodyData.Replace(editStr, "")); } #endregion } #endregion } MailHelper mail = new MailHelper(); mail.SendMailAction(test_send_arr[i], mQuery.subject, mQuery.bodyData + " "); json = _edmContentNewMgr.MailAndRequest(eslQuery, mQuery); } } } else { MailHelper mail = new MailHelper(); mQuery.bodyData = Request.Params["body"]; if (mQuery.bodyData.IndexOf(subscribe) > 0)//找到了埋的那個code,證明是點擊了訂閱電子報 { mQuery.bodyData = mQuery.bodyData.Replace(subscribe, "\n") + _edmContentNewMgr.GetRecommendHtml(Convert.ToUInt32((Session["caller"] as Caller).user_id)) + subscribe_url; } mail.SendMailAction((Session["caller"] as Caller).user_email, mQuery.subject, mQuery.bodyData + " "); json = _edmContentNewMgr.MailAndRequest(eslQuery, mQuery); } #endregion } else//正式發送,寫入排程所用表 { if (!string.IsNullOrEmpty(Request.Params["body"])) { mQuery.body = Request.Params["body"]; } eslQuery.test_send_end = false; eslQuery.test_send = 0; //eslQuery.receiver_count=""; 經計算後寫入 if (!string.IsNullOrEmpty(Request.Params["schedule_date"])) { eslQuery.schedule_date = Convert.ToDateTime(Request.Params["schedule_date"]); mQuery.schedule_date = eslQuery.schedule_date; } if (!string.IsNullOrEmpty(Request.Params["email_group_id"])) { eslQuery.email_group_id = Convert.ToInt32(Request.Params["email_group_id"]); } if (!string.IsNullOrEmpty(Request.Params["expire_date"])) { eslQuery.expire_date = Convert.ToDateTime(Convert.ToDateTime(Request.Params["expire_date"]).ToString("yyyy-MM-dd 23:59:59")); mQuery.valid_until_date = eslQuery.expire_date; } eslQuery.createdate = DateTime.Now; if (!string.IsNullOrEmpty(Request.Params["elcm_id"])) { eslQuery.elcm_id = Convert.ToInt32(Request.Params["elcm_id"]); } if (!string.IsNullOrEmpty(Request.Params["extra_send"])) { mQuery.extra_send = Request.Params["extra_send"]; } if (!string.IsNullOrEmpty(Request.Params["extra_no_send"])) { mQuery.extra_no_send = Request.Params["extra_no_send"]; } if (!string.IsNullOrEmpty(Request.Params["is_outer"])) { if (Request.Params["is_outer"] == "true") { mQuery.is_outer = true; } else { mQuery.is_outer = false; } } json = _edmContentNewMgr.MailAndRequest(eslQuery, mQuery); } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
// public bool SendEMail(MailHelper mail) { DataTable dt = new DataTable(); StringBuilder sql = new StringBuilder(); StringBuilder sql1 = new StringBuilder(); StringBuilder sql2 = new StringBuilder(); List<MailRequest> MR = new List<MailRequest>(); //MailHelper mail = new MailHelper(); try { sql1.AppendFormat("SELECT request_id,priority,user_id,sender_address,sender_name,receiver_address,receiver_name,`subject`,importance,schedule_date,valid_until_date,retry_count,last_sent,sent_log,request_createdate,request_updatedate,body,success_action,fail_action from mail_request where schedule_date<'{0}' order by next_send,priority,valid_until_date;", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); MR = _access.getDataTableForObj<MailRequest>(sql1.ToString()); int next_time = int.Parse(_access.getDataTable("SELECT parameterName from t_parametersrc where parameterType='edm_type' AND parameterCode='4';").Rows[0][0].ToString()); sql2.Append("SELECT email_address from email_block_list;"); dt = _access.getDataTable(sql2.ToString()); foreach (var item in MR) { bool black = true; //擋信名單排除 for (int i = 0; i < dt.Rows.Count; i++) { if (item.receiver_address.ToString() == dt.Rows[i][0].ToString()) { //刪除擋信名單的數據 sql.Append(InsertLog(item, "4")); black = false; if (sql.Length > 0) { _access.execCommand(sql.ToString()); sql.Clear(); } } } if (black) {//是不是擋信名單的email try { if (mail.SendMailAction(item.receiver_address.ToString(), item.subject.ToString(), item.body.ToString(), item.sender_address, item.sender_name)) { sql.Append(item.success_action); //發送成功刪除原數據新增log sql.Append(InsertLog(item, "1")); } else { //發送失敗更新數據 sql.Append(item.fail_action); sql.AppendFormat("update mail_request set retry_count ='{1}',next_send='{2}',sent_log='{3}' where request_id='{0}' ;", item.request_id, item.retry_count + 1, DateTime.Now.AddMinutes(next_time), "not errow massage"); //sql.Append(item.fail_action + ";"); } if (sql.Length > 0) { _access.execCommand(sql.ToString()); sql.Clear(); } } catch (Exception ex) { item.sent_log = ex.ToString(); item.Replace4MySQL(); sql.Append(item.fail_action); //發送失敗更新數據 sql.AppendFormat("update mail_request set retry_count ='{1}',next_send='{2}',sent_log='{3}' where request_id='{0}' ;", item.request_id, item.retry_count + 1, DateTime.Now.AddMinutes(next_time).ToString("yyyy-MM-dd HH:mm:ss"), item.sent_log); _access.execCommand(sql.ToString()); } } } return true; } catch (Exception ex) { throw new Exception("ScheduleServiceDao-->SchedulePeriodDelete-->" + sql.ToString() + ex.Message); } }
public bool Start(string schedule_code) { BLL.gigade.Common.MailModel mailModel = new Common.MailModel (); mailModel.MysqlConnectionString = mySqlConnectionString; string GroupCode = string.Empty; string MailTitle = string.Empty; string MailBody = string.Empty; string hourNum = string.Empty; //bool IsSeparate = false; //bool IsDisplyName = true; string isSendMailToGroup = string.Empty; try { //獲取該排程參數 List<ScheduleConfigQuery> store_config = new List<ScheduleConfigQuery>(); ScheduleConfigQuery query_config = new ScheduleConfigQuery(); query_config.schedule_code = schedule_code; ScheduleServiceMgr _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); store_config = _secheduleServiceMgr.GetScheduleConfig(query_config); #region mailhelp賦值 foreach (ScheduleConfigQuery item in store_config) { if (item.parameterCode.Equals("MailFromAddress")) { mailModel.MailFromAddress = item.value; } else if (item.parameterCode.Equals("MailHost")) { mailModel.MailHost = item.value; } else if (item.parameterCode.Equals("MailPort")) { mailModel.MailPort = item.value; } else if (item.parameterCode.Equals("MailFromUser")) { mailModel.MailFromUser = item.value; } else if (item.parameterCode.Equals("EmailPassWord")) { mailModel.MailFormPwd = item.value; } else if (item.parameterCode.Equals("GroupCode")) { GroupCode = item.value; } else if (item.parameterCode.Equals("MailTitle")) { MailTitle = item.value; } else if (item.parameterCode.Equals("HourNum")) { if (item.value.Trim() == "0") { hourNum = "1"; } else { hourNum = item.value; } } else if (item.parameterCode.Equals("isSendMailToGroup")) { isSendMailToGroup = item.value; } } if (hourNum.Trim() == string.Empty) { hourNum = "1"; } #endregion //獲取期望到貨日調整記錄(邮件内容) #region 獲取期望到貨日調整記錄表格 DeliverChangeLogQuery aclQuery = new DeliverChangeLogQuery(); aclQuery.time_start = DateTime.Now.AddHours(-Convert.ToDouble(hourNum)); aclQuery.time_end = DateTime.Now; System.Data.DataTable dclTable = _IDeliverChangeLogDao.GetDeliverChangeLogDataTable(aclQuery); System.Data.DataTable dmTable = _IDeliverChangeLogDao.GetDataTable(aclQuery); DataTable _dt = new DataTable(); DataRow dr; _dt.Columns.Add("訂單編號", typeof(string)); _dt.Columns.Add("出貨單號", typeof(string)); _dt.Columns.Add("供應商名稱", typeof(string)); _dt.Columns.Add("出貨方式", typeof(string)); _dt.Columns.Add("異動人", typeof(string)); _dt.Columns.Add("異動類型", typeof(string));// _dt.Columns.Add("異動時間", typeof(string)); //_dt.Columns.Add("原期望到貨日", typeof(string)); _dt.Columns.Add("期望到貨日", typeof(string)); _dt.Columns.Add("期望到貨時段", typeof(string)); _dt.Columns.Add("備註", typeof(string)); _dt.Columns.Add("來源IP", typeof(string)); _dt.Columns.Add("異動時段", typeof(string)); _dt.Columns.Add("時間", typeof(string));//difftime //自行出貨的供應商 DataTable deliverDt = new DataTable(); DataRow deliverDr; deliverDt.Columns.Add("訂單編號", typeof(string)); deliverDt.Columns.Add("出貨單號", typeof(string)); deliverDt.Columns.Add("付款完成時間", typeof(string)); deliverDt.Columns.Add("供應商編號", typeof(string)); deliverDt.Columns.Add("供應商郵箱", typeof(string)); deliverDt.Columns.Add("供應商名稱", typeof(string)); deliverDt.Columns.Add("期望到貨日", typeof(string)); deliverDt.Columns.Add("期望到貨時段", typeof(string)); deliverDt.Columns.Add("預計到貨日", typeof(string)); deliverDt.Columns.Add("備註", typeof(string)); if (dclTable.Rows.Count > 0) { #region 循環賦值 for (int i = 0; i < dmTable.Rows.Count; i++) { #region 自行出貨的供應商的table賦值 deliverDr = deliverDt.NewRow(); deliverDr["訂單編號"] = dmTable.Rows[i]["order_id"].ToString(); deliverDr["出貨單號"] = dmTable.Rows[i]["deliver_id"].ToString(); if (Convert.ToInt32(dmTable.Rows[i]["order_date_pay"]) == 0) { deliverDr["付款完成時間"] = ""; } else { deliverDr["付款完成時間"] = CommonFunction.GetNetTime(Convert.ToInt32(dmTable.Rows[i]["order_date_pay"])).ToString("yyyy-MM-dd HH:mm:ss"); } deliverDr["供應商編號"] = dmTable.Rows[i]["vendor_id"].ToString(); deliverDr["供應商郵箱"] = dmTable.Rows[i]["vendor_email"].ToString(); deliverDr["供應商名稱"] = dmTable.Rows[i]["vendor_name_full"].ToString(); if (Convert.ToDateTime(dmTable.Rows[i]["expect_arrive_date_dm"]).ToString("yyyy-MM-dd") == "0001-01-01") { deliverDr["期望到貨日"] = ""; } else { deliverDr["期望到貨日"] = Convert.ToDateTime(dmTable.Rows[i]["expect_arrive_date_dm"]).ToString("yyyy-MM-dd"); } //期望到貨時段 StringBuilder expectArrivePeriodSb = new StringBuilder(); if (dmTable.Rows[i]["expect_arrive_period_dm"].ToString() == "1") { expectArrivePeriodSb.Append("12:00以前"); } if (dmTable.Rows[i]["expect_arrive_period_dm"].ToString() == "2") { expectArrivePeriodSb.Append("12:00-17:00"); } if (dmTable.Rows[i]["expect_arrive_period_dm"].ToString() == "3") { expectArrivePeriodSb.Append("17:00-20:00"); } if (dmTable.Rows[i]["expect_arrive_period_dm"].ToString() == "0") { expectArrivePeriodSb.Append("不限制"); } deliverDr["期望到貨時段"] = expectArrivePeriodSb.ToString(); if (Convert.ToInt32(dmTable.Rows[i]["deliver_org_days"]) == 0) { deliverDr["預計到貨日"] = ""; } else { deliverDr["預計到貨日"] = Convert.ToDateTime(CommonFunction.GetNetTime(Convert.ToInt32(dmTable.Rows[i]["deliver_org_days"]))).ToString("yyyy-MM-dd"); } deliverDr["備註"] = dmTable.Rows[i]["dcl_note"].ToString(); deliverDt.Rows.Add(deliverDr); #endregion } #region MyRegion for (int i = 0; i < dclTable.Rows.Count; i++) { dr = _dt.NewRow(); StringBuilder sb = new StringBuilder(); dr["訂單編號"] = dclTable.Rows[i]["order_id"].ToString(); dr["出貨單號"] = dclTable.Rows[i]["deliver_id"].ToString(); dr["供應商名稱"] = dclTable.Rows[i]["vendor_name_full"].ToString(); if (dclTable.Rows[i]["type"].ToString() == "1") { dr["出貨方式"] = "統倉出貨"; } else if (dclTable.Rows[i]["type"].ToString() == "2") { dr["出貨方式"] = "供應商自行出貨"; } else //if (dclTable.Rows[i]["type"].ToString() == "101") { dr["出貨方式"] = "其他"; } if (dclTable.Rows[i]["dcl_create_type"].ToString() == "1") { dr["異動人"] = dclTable.Rows[i]["dcl_create_username"].ToString(); dr["異動類型"] = "前台"; } else if (dclTable.Rows[i]["dcl_create_type"].ToString() == "2") { dr["異動人"] = dclTable.Rows[i]["dcl_create_musername"].ToString(); dr["異動類型"] = "後台"; } dr["異動時間"] = Convert.ToDateTime(dclTable.Rows[i]["dcl_create_datetime"]).ToString("yyyy-MM-dd HH:mm:ss"); #region 獲取該出貨單的上一個小時之前的期望到貨日 ////aclQuery.time_start = dcl_create_datetime_start.AddHours(-1); //aclQuery.time_end = dcl_create_datetime_end.AddHours(-1); //aclQuery.deliver_id = Convert.ToInt32(dclTable.Rows[i]["deliver_id"]); //System.Data.DataTable Table = _IDeliverChangeLogDao.GetExpectArriveDateByCreatetime(aclQuery); //if (Table.Rows.Count > 0) //{ // if (Convert.ToDateTime(Table.Rows[0]["expect_arrive_date"]).ToString("yyyy-MM-dd") == "0001-01-01") // { // dr["原期望到貨日"] = ""; // } // else // { // dr["原期望到貨日"] = Convert.ToDateTime(Table.Rows[0]["expect_arrive_date"]).ToString("yyyy-MM-dd"); // } //} //else //{ // dr["原期望到貨日"] = ""; //} #endregion if (Convert.ToDateTime(dclTable.Rows[i]["expect_arrive_date_dcl"]).ToString("yyyy-MM-dd") == "0001-01-01") { dr["期望到貨日"] = ""; } else { dr["期望到貨日"] = Convert.ToDateTime(dclTable.Rows[i]["expect_arrive_date_dcl"]).ToString("yyyy-MM-dd"); } if (dclTable.Rows[i]["expect_arrive_period_dcl"].ToString() == "1") { sb.Append("12:00以前"); } if (dclTable.Rows[i]["expect_arrive_period_dcl"].ToString() == "2") { sb.Append("12:00-17:00"); } if (dclTable.Rows[i]["expect_arrive_period_dcl"].ToString() == "3") { sb.Append("17:00-20:00"); } if (dclTable.Rows[i]["expect_arrive_period_dcl"].ToString() == "0") { sb.Append("不限制"); } dr["期望到貨時段"] = sb.ToString(); dr["備註"] = dclTable.Rows[i]["dcl_note"].ToString(); dr["來源IP"] = dclTable.Rows[i]["dcl_ipfrom"].ToString(); TimeSpan ti = aclQuery.time_end-Convert.ToDateTime(dclTable.Rows[i]["dcl_create_datetime"]); dr["異動時段"] = hourNum + "小時以外"; dr["時間"] = "0"; if (ti.TotalHours < int.Parse(hourNum)) { dr["異動時段"] = Convert.ToInt32(ti.TotalHours) + "小時"; dr["時間"] = "1"; } _dt.Rows.Add(dr); sb.Clear(); } #endregion #endregion #region 出貨方式為“供應商自行出貨”的出貨單整理后,發郵件給對應的供應商 Dictionary<string, string> vendorDictionary = new Dictionary<string, string>(); for (int i = 0; i < deliverDt.Rows.Count; i++) { if (!vendorDictionary.ContainsKey(deliverDt.Rows[i]["出貨單號"].ToString())) { vendorDictionary.Add(deliverDt.Rows[i]["出貨單號"].ToString(), deliverDt.Rows[i]["供應商編號"].ToString()); } } List<string> SendEmailVendorIdList = new List<string>(); foreach (KeyValuePair<string, string> kvp in vendorDictionary) { DataTable deliverDt_1 = deliverDt.Clone(); string MailToAddress_1 = string.Empty; string vendor_name_full = string.Empty; if (!SendEmailVendorIdList.Contains(kvp.Value)) { for (int i = 0; i < deliverDt.Rows.Count; i++) { DataRow deliverDr_1 = deliverDt_1.NewRow(); if (kvp.Value == deliverDt.Rows[i]["供應商編號"].ToString()) { MailToAddress_1 = deliverDt.Rows[i]["供應商郵箱"].ToString(); vendor_name_full = deliverDt.Rows[i]["供應商名稱"].ToString(); deliverDr_1["訂單編號"] = deliverDt.Rows[i]["訂單編號"].ToString(); deliverDr_1["出貨單號"] = deliverDt.Rows[i]["出貨單號"].ToString(); deliverDr_1["付款完成時間"] = deliverDt.Rows[i]["付款完成時間"].ToString(); //deliverDr_1["供應商編號"] = deliverDt.Rows[i]["供應商編號"].ToString(); //deliverDr_1["供應商郵箱"] = deliverDt.Rows[i]["供應商郵箱"].ToString(); //deliverDr_1["供應商名稱"] = deliverDt.Rows[i]["供應商名稱"].ToString(); deliverDr_1["期望到貨日"] = deliverDt.Rows[i]["期望到貨日"].ToString(); deliverDr_1["期望到貨時段"] = deliverDt.Rows[i]["期望到貨時段"].ToString(); deliverDr_1["預計到貨日"] = deliverDt.Rows[i]["預計到貨日"].ToString(); deliverDr_1["備註"] = deliverDt.Rows[i]["備註"].ToString(); deliverDt_1.Rows.Add(deliverDr_1); } } SendEmailVendorIdList.Add(kvp.Value); BLL.gigade.Common.MailModel mailModel_1 = new Common.MailModel(); mailModel_1.MysqlConnectionString = mySqlConnectionString; mailModel_1.MailFromAddress = mailModel.MailFromAddress; mailModel_1.MailHost = mailModel.MailHost; mailModel_1.MailPort = mailModel.MailPort; mailModel_1.MailFromUser = mailModel.MailFromUser; mailModel_1.MailFormPwd = mailModel.MailFormPwd; //string MailBody_1 = "<br/><font size=\"4\">" + "<font color=\"#00BB00\" >" + vendor_name_full + "</font>" + " 您好,在前 " + "<font color=\"#FF0000\" >" + Convert.ToDouble(hourNum) // + "</font>" + " 個小時之內,貴公司自行出貨的商品出貨單期望到貨日調整記錄如下:</font><br/><p/>" + GetHtmlByDataTable(deliverDt_1); deliverDt_1.Columns.Remove("供應商編號"); deliverDt_1.Columns.Remove("供應商郵箱"); deliverDt_1.Columns.Remove("供應商名稱"); string MailBody_1 = "<p>吉甲地市集【期望到貨日改變】通知信</p><p><font color=\"#00BB00\" >" + vendor_name_full + "</font> 您好:</p>" + "<p>以下訂單已改變出貨單期望到貨日,訂單資訊如下。</p>" + //"<p>============================================================</p>"+ GetHtmlByDataTable(deliverDt_1) + //"<p>============================================================</p>"+ "<p>訂單的相關資訊,請至<a href='http://vendor.gigade100.com' style='color:#3399ff;text-decoration: none;'>【後台管理】</a>中查詢。</p>"+ "<p>※本信由系統寄出,請勿直接回覆!</p>"+ "有任何問題與建議,歡迎聯絡我們<a href='http://www.gigade100.com/contact_service.php' target='_blank'> <img src='http://www.gigade100.com/images/send_mail.jpg'></a>" + "<p>吉甲地市集<a href='http://www.gigade100.com/'>http://www.gigade100.com/</a></p>"; string MailTitle_1 = MailTitle; //MailToAddress_1 = "*****@*****.**"; BLL.gigade.Common.MailHelper mailHelper = new MailHelper(mailModel_1); //public Boolean SendMailAction(string MailToAddress, string MailTitle, string MailBody) try { mailHelper.SendMailAction(MailToAddress_1, MailTitle_1, MailBody_1 + " ");//給單個供應商發送郵件 } catch (Exception) { continue; } } } #endregion } #endregion if (_dt.Rows.Count == 0) { //MailBody = "<br/><p><font size=\"4\"> 出貨單期望日在前 <font color=\"#FF0000\" >" + Convert.ToDouble(hourNum) + "</font> 個小時之內沒有調整記錄!</font><p/>"; } else { if (isSendMailToGroup.Trim() == "true") { MailBody = "<br/><font size=\"4\">出貨單期望到貨日在前 " + "<font color=\"#FF0000\" >" + Convert.ToDouble(hourNum) + "</font>" + " 個小時之內的調整記錄如下:</font><br/><p/>" + GetHtmlByDataTable(_dt, "時間","0"); BLL.gigade.Common.MailHelper mail = new Common.MailHelper(mailModel); mail.SendToGroup(GroupCode, MailTitle, MailBody + " ", false, true); } } return true; } catch (Exception ex) { throw new Exception("DeliverChangeLogMgr-->Start-->" + ex.Message, ex); } }
public string ChangeDeliverData(OrderShowMasterQuery oms, OrderShowMasterQuery newOms, OrderMasterQuery om) { string json = string.Empty; ArrayList arrList = new ArrayList(); Serial serial = new Serial(); oms.status_description = "Writer:" + "(" + om.user_id + ")" + om.user_name + "," + "\r\n" + "異動收貨資訊"; oms.status_ipfrom = om.Order_Ipfrom; oms.StatusCreateDate = DateTime.Now; oms.order_id = om.Order_Id; om.mdd = true; newOms = _orderMasterDao.GetData(om.Order_Id); string note_order = newOms.note_order; if (note_order == "") { om.note_order = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "更改收件人資訊"; } else { om.note_order = note_order + '/' + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "更改收件人資訊"; } oms.order_status = newOms.order_status; arrList.Add(_orderMasterDao.UpOrderMaster(om));//更新order_master arrList.Add(_orderMasterDao.UpdateDM(om));//更新deliver_master serial = _serialDao.GetSerialById(29); oms.serial_id = Convert.ToInt32(serial.Serial_Value) + 1; serial.Serial_Value = Convert.ToUInt64(oms.serial_id); arrList.Add(_serialDao.UpdateAutoIncreament(serial));//更新serial表 arrList.Add(_orderMasterDao.InsertOrderMasterStatus(oms));//插入order_master_status表 if (_mysqlDao.ExcuteSqlsThrowException(arrList)) { json = "{success:true}"; #region 發送郵件 MailHelper mail = new MailHelper(); string body = "付款單號 : " + om.Order_Id + " 已更改收貨人資訊,請重新檢視出貨單<br/>更改時間:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "<br/><br/>以上為系統通知信請勿直接回覆,謝謝! "; mail.SendMailAction("*****@*****.**", "收貨人資訊變更", body); #endregion } else { json = "{success:false}"; } return json; }