public JsonResult UpdateOrderQuestionActive() { string json = string.Empty; OrderQuestionQuery query = new OrderQuestionQuery(); _IOrderQuesMgr = new OrderQuestionMgr(mySqlConnectionString); try { if (!string.IsNullOrEmpty(Request.Params["id"])) { query.question_id = Convert.ToUInt32(Request.Params["id"]); } if (!string.IsNullOrEmpty(Request.Params["active"])) { query.question_status = Convert.ToUInt32(Request.Params["active"]); } if (query.question_id != 0) { _IOrderQuesMgr.UpdateQuestionStatus(query); return Json(new { success = "true", msg = "" }); } else { return Json(new { 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); return Json(new { success = "false", msg = "" }); } }
public HttpResponseBase ReplyQuestion() { string timestr = string.Empty; string path = Server.MapPath(xmlPath); SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path); SiteConfig Mail_From = _siteConfigMgr.GetConfigByName("Mail_From"); SiteConfig Mail_Host = _siteConfigMgr.GetConfigByName("Mail_Host"); SiteConfig Mail_Port = _siteConfigMgr.GetConfigByName("Mail_Port"); SiteConfig Mail_UserName = _siteConfigMgr.GetConfigByName("Mail_UserName"); SiteConfig Mail_UserPasswd = _siteConfigMgr.GetConfigByName("Mail_UserPasswd"); string EmailFrom = Mail_From.Value;//發件人郵箱 string SmtpHost = Mail_Host.Value;//smtp服务器 string SmtpPort = Mail_Port.Value;//smtp服务器端口 string EmailUserName = Mail_UserName.Value;//郵箱登陸名 string EmailPassWord = Mail_UserPasswd.Value;//郵箱登陸密碼 string json = string.Empty; _IOrderQuesMgr = new OrderQuestionMgr(mySqlConnectionString); _IOrderResponseMgr = new OrderResponseMgr(mySqlConnectionString); OrderQuestionQuery query = new OrderQuestionQuery(); OrderResponse ormodel = new OrderResponse(); SmsQuery smsquery = new SmsQuery(); //if (!string.IsNullOrEmpty(Request.Params["question_content"])) //{ // query.question_content = Request.Params["question_content"]; //} //string order_id = Request.Params["OrderId"].ToString(); //if (!string.IsNullOrEmpty(order_id)) //{ // query.order_id = Convert.ToUInt32(order_id); //} try { if (!string.IsNullOrEmpty(Request.Params["question_id"])) { query.question_id = Convert.ToUInt32(Request.Params["question_id"]); ormodel.question_id = query.question_id; } if (!string.IsNullOrEmpty(Request.Params["order_id"])) { smsquery.order_id = Convert.ToInt32(Request.Params["order_id"]); } //if (!string.IsNullOrEmpty(Request.Params["status"])) //{ // query.question_status = Convert.ToUInt32(Request.Params["status"]); //} if (!string.IsNullOrEmpty(Request.Params["response_content"])) { ormodel.response_content = Request.Params["response_content"].Replace("\\", "\\\\"); ; smsquery.content = ormodel.response_content.Replace("\\", "\\\\"); ; } if (!string.IsNullOrEmpty(Request.Params["question_createdate"])) { timestr = Request.Params["question_createdate"]; } if (!string.IsNullOrEmpty(Request.Params["question_username"])) { query.question_username = Request.Params["question_username"]; } if (!string.IsNullOrEmpty(Request.Params["this_question_email"])) { query.question_email = Request.Params["this_question_email"]; } if (!string.IsNullOrEmpty(Request.Params["question_phone"])) { smsquery.mobile = Request.Params["question_phone"].ToString(); } //回複方式 bool reply1 = false; bool reply2 = false; bool reply3 = false; if (!string.IsNullOrEmpty(Request.Params["reply_mail"])) { reply1 = Convert.ToBoolean(Request.Params["reply_mail"]); } if (!string.IsNullOrEmpty(Request.Params["reply_sms"])) { reply2 = Convert.ToBoolean(Request.Params["reply_sms"]); } if (!string.IsNullOrEmpty(Request.Params["reply_phone"])) { reply3 = Convert.ToBoolean(Request.Params["reply_phone"]); } //如果選擇結案就更新問題狀態 //更新order_question表狀態 query.question_status = 1; _IOrderQuesMgr.UpdateQuestionStatus(query); //獲取數據往回覆表添加數據 ormodel.user_id = uint.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); ormodel.response_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()); ; ormodel.response_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString())); //判斷選擇的回複方式 if (reply1 || !reply1 && !reply2 && !reply3) { ormodel.response_type = 1; _IOrderResponseMgr.insert(ormodel); FileStream fs = new FileStream(Server.MapPath("../ImportUserIOExcel/OrderQuestionResponse.html"), FileMode.OpenOrCreate, FileAccess.Read); StreamReader sr = new StreamReader(fs, Encoding.UTF8); string strTemp = sr.ReadToEnd(); sr.Close(); fs.Close(); strTemp = strTemp.Replace("{{$s_datetime$}}", timestr);//添加提問時間 strTemp = strTemp.Replace("{{$s_username$}}", query.question_username);//添加提問用戶名 strTemp = strTemp.Replace("{{$consultInfo$}}", query.question_content);//添加提問內容 strTemp = strTemp.Replace("{{$consultAnwser$}}", ormodel.response_content.Replace("\\\\", "\\")); sendmail(EmailFrom, FromName, query.question_email, query.question_username, EmailTile, strTemp, "", SmtpHost, Convert.ToInt32(SmtpPort), EmailUserName, EmailPassWord); } else if (reply2) { ormodel.response_type = 2; _IOrderResponseMgr.insert(ormodel); smsquery.type = 11;//10表示聯絡客服列表保存過去的 smsquery.send = 0; smsquery.trust_send = "9"; smsquery.created = DateTime.Now; smsquery.modified = DateTime.Now; _ISmsMgr = new SmsMgr(mySqlConnectionString); _ISmsMgr.InsertSms(smsquery); } else if (reply3) { ormodel.response_type = 3; _IOrderResponseMgr.insert(ormodel); } //if (!reply1 && !reply2 && !reply3) //{ // ormodel.response_type = 4; // _IOrderResponseMgr.insert(ormodel); //} json = "{success: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 = "{success:false,msg:0}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }