public void GetContactUsQuestionExcelList() { string json = string.Empty; DataTable _dt = new DataTable(); DataTable dtHZ = new DataTable(); ContactUsQuestionQuery cuQuery = new ContactUsQuestionQuery(); try { string newExcelName = string.Empty; dtHZ.Columns.Add("問題流水號", typeof(String)); dtHZ.Columns.Add("公司", typeof(String)); dtHZ.Columns.Add("姓名", typeof(String)); //dtHZ.Columns.Add("電話", typeof(String)); // dtHZ.Columns.Add("電子信箱", typeof(String)); dtHZ.Columns.Add("問題類型", typeof(String)); dtHZ.Columns.Add("問題分類", typeof(String)); dtHZ.Columns.Add("狀態", typeof(String)); dtHZ.Columns.Add("問題內容", typeof(String)); dtHZ.Columns.Add("回覆內容", typeof(String)); dtHZ.Columns.Add("建立日期", typeof(String)); dtHZ.Columns.Add("回覆日期", typeof(String)); _ctactMgr = new ContactUsQuestionMgr(mySqlConnectionString); cuQuery.search_type = Convert.ToInt32(Request.Params["search_type"]); cuQuery.searchcontent = Request.Params["searchcontent"]; // cuQuery.date_type = Convert.ToInt32(Request.Params["date_type"]); if (!string.IsNullOrEmpty(Request.Params["dateStart"]) && Request.Params["dateStart"]!="0") { cuQuery.datestart = Convert.ToDateTime(Request.Params["dateStart"]);//建立時間 } if (!string.IsNullOrEmpty(Request.Params["dateEnd"]) && Request.Params["dateEnd"] != "0") { cuQuery.dateend = Convert.ToDateTime(Request.Params["dateEnd"]); } cuQuery.question_type = Convert.ToUInt32(Request.Params["qusetion_type"]); if (Convert.ToBoolean(Request.Params["radio2"]) == true)//待回覆 { cuQuery.question_status = 3; } else if (Convert.ToBoolean(Request.Params["radio3"]) == true)//已回覆 { cuQuery.question_status = 4; } else if (Convert.ToBoolean(Request.Params["radio4"]) == true) { cuQuery.question_status = 2; } _dt = _ctactMgr.GetContactUsQuestionExcelList(cuQuery); if (!System.IO.Directory.Exists(Server.MapPath(excelPath))) { System.IO.Directory.CreateDirectory(Server.MapPath(excelPath)); } for (int i = 0; i < _dt.Rows.Count; i++) { DataRow dr = dtHZ.NewRow(); dr[0] = _dt.Rows[i]["question_id"]; dr[1] = _dt.Rows[i]["question_company"]; dr[2] = _dt.Rows[i]["question_username"]; //dr[3] = _dt.Rows[i]["question_phone"]; //dr[4] = _dt.Rows[i]["question_email"]; dr[3] = _dt.Rows[i]["question_type_name"]; dr[4] = _dt.Rows[i]["question_problem_name"]; dr[5] = _dt.Rows[i]["question_status_name"]; dr[6] = _dt.Rows[i]["question_content"]; dr[8] = _dt.Rows[i]["question_createdate"]; if (_dt.Rows[i]["question_status"].ToString() == "0") { dr[9] = "~"; dr[7] = ""; } else { dr[9] = _dt.Rows[i]["response_createdate"]; dr[7] = _dt.Rows[i]["response_content"]; } dtHZ.Rows.Add(dr); } if (dtHZ.Rows.Count > 0) { string fileName = DateTime.Now.ToString("聯絡客服列表_yyyyMMddHHmmss") + ".xls"; MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "聯絡客服列表_" + DateTime.Now.ToString("yyyyMMddHHmmss")); Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.BinaryWrite(ms.ToArray()); } else { Response.Write("匯出數據不存在"); } } 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,totalCount:0,data:[]}"; } }
public HttpResponseBase GetContactUsQuestionList() { string json = string.Empty; DataTable _dt = new DataTable(); ContactUsQuestionQuery cuQuery = new ContactUsQuestionQuery(); cuQuery.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 cuQuery.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 try { cuQuery.search_type = Convert.ToInt32(Request.Params["search_type"]); cuQuery.searchcontent = Request.Params["searchcontent"]; if (!string.IsNullOrEmpty(Request.Params["dateStart"])) { cuQuery.datestart = Convert.ToDateTime(Request.Params["dateStart"]);//建立時間 } if (!string.IsNullOrEmpty(Request.Params["dateEnd"])) { cuQuery.dateend = Convert.ToDateTime(Request.Params["dateEnd"]); } cuQuery.question_type = Convert.ToUInt32(Request.Params["qusetion_type"]); if (Convert.ToBoolean(Request.Params["radio2"]) == true)//待回覆 { cuQuery.question_status = 3; } else if (Convert.ToBoolean(Request.Params["radio3"]) == true)//已回覆 { cuQuery.question_status = 4; } else if (Convert.ToBoolean(Request.Params["radio4"]) == true)//已處理 { cuQuery.question_status = 2; } if (!string.IsNullOrEmpty(Request.Params["relation_id"])) { cuQuery.question_id = Convert.ToUInt32(Request.Params["relation_id"]); } if (Convert.ToBoolean(Request.Params["isSecret"])) { cuQuery.isSecret = true; } int totalCount = 0; _ctactMgr = new ContactUsQuestionMgr(mySqlConnectionString); _dt = _ctactMgr.GetContactUsQuestionList(cuQuery, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd"; json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dt, Formatting.Indented, timeConverter) + "}";//返回json數據 } 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,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase update() { 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 jsonStr = String.Empty; int result = 0; ContactUsQuestion cusTion = new ContactUsQuestion(); ContactUsResponse cusponse = new ContactUsResponse(); SmsQuery smsquery = new SmsQuery(); try { _ctactMgr = new ContactUsQuestionMgr(mySqlConnectionString); _ctactrsponseMgr = new ContactUsResponseMgr(mySqlConnectionString); if (!string.IsNullOrEmpty(Request.Params["question_id"])) { cusTion.question_id = Convert.ToUInt32(Request.Params["question_id"]); smsquery.serial_id = Convert.ToInt32(cusTion.question_id); } if (Convert.ToBoolean(Request.Params["state1"]) == true) { cusTion.question_status = 1;//1表示已經回覆 } else if (Convert.ToBoolean(Request.Params["state2"]) == true) { cusTion.question_status = 1;//1表示已經回覆 } else if (Convert.ToBoolean(Request.Params["state3"]) == true) { cusTion.question_status = 2;//2表示已經回覆 } string updatesql = _ctactMgr.UpdateSql(cusTion); string questiontime = string.Empty; if (!string.IsNullOrEmpty(Request.Params["question_createdate"])) { questiontime = Request.Params["question_createdate"];//提問問題時間 } if (!string.IsNullOrEmpty(Request.Params["question_phone"])) { smsquery.mobile = Request.Params["question_phone"];//提問者電話 } if (!string.IsNullOrEmpty(Request.Params["question_content"])) { cusTion.question_content = Request.Params["question_content"];//咨詢問題內容 } if (!string.IsNullOrEmpty(Request.Params["question_username"])) { cusTion.question_username = Request.Params["question_username"];//提問問題用戶名 } cusponse.response_id = Convert.ToUInt32(_ctactrsponseMgr.GetMaxResponseId()); if (!string.IsNullOrEmpty(Request.Params["question_id"])) { cusponse.question_id = Convert.ToUInt32(Request.Params["question_id"]);//咨詢問題id } cusponse.user_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id); if (!string.IsNullOrEmpty(Request.Params["content_reply"])) { cusponse.response_content = Request.Params["content_reply"].Replace("\\", "\\\\"); smsquery.content = Request.Params["content_reply"].ToString().Replace("\\", "\\\\");//保存sms表的數據 } bool reply1 = false; bool reply2 = false; bool reply3 = false; if (!string.IsNullOrEmpty(Request.Params["reply1"])) { reply1 = Convert.ToBoolean(Request.Params["reply1"]); } if (!string.IsNullOrEmpty(Request.Params["reply2"])) { reply2 = Convert.ToBoolean(Request.Params["reply2"]); } if (!string.IsNullOrEmpty(Request.Params["reply3"])) { reply3 = Convert.ToBoolean(Request.Params["reply3"]); } if (!string.IsNullOrEmpty(Request.Params["question_email"])) { cusTion.question_email = Request.Params["question_email"].ToString().Trim(); } cusponse.response_createdate = Convert.ToInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); cusponse.response_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()); if (cusTion.question_status != 2) { //mh.SendToUser(Convert.ToInt32(cusponse.user_id),"郵箱標題","郵箱內容");//發送郵件 if (reply1 || !reply3 && !reply2 && !reply1) {//當email被勾選 cusponse.response_type = 1; _ctactrsponseMgr.Insert(updatesql, cusponse); FileStream fs = new FileStream(Server.MapPath("../ImportUserIOExcel/ContactUsQuestionResponse.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$}}", questiontime); strTemp = strTemp.Replace("{{$s_username$}}", cusTion.question_username); strTemp = strTemp.Replace("{{$consultInfo$}}", cusTion.question_content); strTemp = strTemp.Replace("{{$consultAnwser$}}", cusponse.response_content.Replace("\\\\", "\\")); sendmail(EmailFrom, FromName, cusTion.question_email, cusTion.question_username, EmailTile, strTemp, "", SmtpHost, Convert.ToInt32(SmtpPort), EmailUserName, EmailPassWord); } else if (reply2) {//當簡訊被勾選 cusponse.response_id = Convert.ToUInt32(_ctactrsponseMgr.GetMaxResponseId()); smsquery.type = 10;//10表示聯絡客服列表保存過去的 smsquery.send = 0; smsquery.trust_send = "8"; smsquery.created = DateTime.Now; smsquery.modified = DateTime.Now; cusponse.response_type = 2; _ctactrsponseMgr.Insert(updatesql, cusponse); _ISmsMgr = new SmsMgr(mySqlConnectionString); _ISmsMgr.InsertSms(smsquery); } else if (reply3) {//當電話被勾選 cusponse.response_id = Convert.ToUInt32(_ctactrsponseMgr.GetMaxResponseId()); cusponse.response_type = 3; _ctactrsponseMgr.Insert(updatesql, cusponse); } //if (!reply3 && !reply2 && !reply1) //{ // cusponse.response_id = Convert.ToUInt32(_ctactrsponseMgr.GetMaxResponseId()); // cusponse.response_type = 4; // _ctactrsponseMgr.Insert(updatesql, cusponse); //} jsonStr = "{success:true}"; } else//等於2時,已處理,不操作其它 { cusponse.response_id = 4; result = _ctactrsponseMgr.Insert(updatesql, cusponse); if (result > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false}"; } DateTime today = DateTime.Now; DateTime a = DateTime.Now.AddDays(-5); } } 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); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
public JsonResult UpdateActive() { string json = string.Empty; ContactUsQuestionQuery query = new ContactUsQuestionQuery(); _ctactMgr = new ContactUsQuestionMgr(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) { string sql = _ctactMgr.UpdateSql(query); _ctactMgr.UpdateActive(sql); 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 Save() { string jsonStr = String.Empty; int result = 0; ContactUsQuestion cusTion = new ContactUsQuestion(); try { _ctactMgr = new ContactUsQuestionMgr(mySqlConnectionString); cusTion.question_id = Convert.ToUInt32(_ctactMgr.GetMaxQuestionId()); cusTion.question_language = 1; if (Convert.ToUInt32(Request.Params["type_id"]) == 0) { cusTion.question_type = 1; } else { cusTion.question_type = Convert.ToUInt32(Request.Params["type_id"]); } cusTion.question_company = Request.Params["company_id"]; // cusTion.question_username = Request.Params["linkpeople"]; cusTion.question_email = Request.Params["email_id"]; cusTion.question_phone = Request.Params["linkphone"]; cusTion.question_problem = 9; cusTion.question_status = 0; cusTion.question_content = Request.Params["content"]; //電話回復方式 bool phone1 = false; bool phone2 = false; bool phone3 = false; if (!string.IsNullOrEmpty(Request.Params["phone1"])) { phone1 = Convert.ToBoolean(Request.Params["phone1"]); } if (!string.IsNullOrEmpty(Request.Params["phone2"])) { phone2 = Convert.ToBoolean(Request.Params["phone2"]); } if (!string.IsNullOrEmpty(Request.Params["phone3"])) { phone3 = Convert.ToBoolean(Request.Params["phone3"]); } //回複方式 bool reply1 = false; bool reply2 = false; bool reply3 = false; if (!string.IsNullOrEmpty(Request.Params["reply1"])) { reply1 = Convert.ToBoolean(Request.Params["reply1"]); } if (!string.IsNullOrEmpty(Request.Params["reply2"])) { reply2 = Convert.ToBoolean(Request.Params["reply2"]); } if (!string.IsNullOrEmpty(Request.Params["reply3"])) { reply3 = Convert.ToBoolean(Request.Params["reply3"]); } if (reply1) { cusTion.question_reply = cusTion.question_reply + "1|"; if (reply2) { cusTion.question_reply = cusTion.question_reply + "1|"; if (reply3) { if (phone1) { cusTion.question_reply_time = 1; } else if (phone2) { cusTion.question_reply_time = 2; } else if (phone3) { cusTion.question_reply_time = 3; } else { cusTion.question_reply_time = 4; } cusTion.question_reply = cusTion.question_reply + "1"; } else { cusTion.question_reply_time = 0; cusTion.question_reply = cusTion.question_reply + "0"; } } else { cusTion.question_reply = cusTion.question_reply + "0|"; if (reply3) { if (phone1) { cusTion.question_reply_time = 1; } else if (phone2) { cusTion.question_reply_time = 2; } else if (phone3) { cusTion.question_reply_time = 3; } else { cusTion.question_reply_time = 4; } cusTion.question_reply = cusTion.question_reply + "1"; } else { cusTion.question_reply_time = 0; cusTion.question_reply = cusTion.question_reply + "0"; } } } else { cusTion.question_reply = cusTion.question_reply + "0|"; if (reply2) { cusTion.question_reply = cusTion.question_reply + "1|"; if (reply3) { if (phone1) { cusTion.question_reply_time = 1; } else if (phone2) { cusTion.question_reply_time = 2; } else if (phone3) { cusTion.question_reply_time = 3; } else { cusTion.question_reply_time = 4; } cusTion.question_reply = cusTion.question_reply + "1"; } else { cusTion.question_reply_time = 0; cusTion.question_reply = cusTion.question_reply + "0"; } } else { cusTion.question_reply = cusTion.question_reply + "0|"; if (reply3) {//當電話被選擇時在判斷在什麼時間段 if (phone1) { cusTion.question_reply_time = 1; } else if (phone2) { cusTion.question_reply_time = 2; } else if (phone3) { cusTion.question_reply_time = 3; } else { cusTion.question_reply_time = 4; } cusTion.question_reply = cusTion.question_reply + "1"; } else { cusTion.question_reply_time = 0; cusTion.question_reply = cusTion.question_reply + "0"; } } } //if (!reply1 && !reply2 && !reply3) //{ // cusTion.question_reply_time = 4; //} if (!string.IsNullOrEmpty(Request.Params["linkpeople"])) { string info = Request.Params["linkpeople"].ToString(); if (info.Contains(cusTion.question_email)) { cusTion.question_username = info.Substring(0, info.Length - cusTion.question_email.Length - 2); } else { cusTion.question_username = Request.Params["linkpeople"]; } } cusTion.question_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); // cusTion.question_ipfrom = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList.FirstOrDefault().ToString(); cusTion.question_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()); result = _ctactMgr.Save(cusTion); if (result > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false}"; } } 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); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }