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 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 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 = "" }); } }