public HttpResponseBase GetEpaperContentById() { string json = string.Empty; EdmContentQuery store = new EdmContentQuery(); EdmContentQuery query = new EdmContentQuery(); try { if (!string.IsNullOrEmpty(Request.Params["rowid"])) { _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); store.content_id = Convert.ToUInt32(Request.Params["rowid"]); _epaperMgr = new EpaperContentMgr(mySqlConnectionString); store = _IEdmContentMgr.GetEdmContentById(store); store.content_body = Server.HtmlDecode(store.content_body); store.s_content_start = CommonFunction.GetNetTime(store.content_start); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true" + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}"; } else { json = "{success:false,data:[]}"; } } 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); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 新增編輯電子報信息 /// </summary> /// <returns></returns> public HttpResponseBase EdmContentSave() { string json = string.Empty; string jsonStr = string.Empty; EdmContentQuery cq = new EdmContentQuery(); _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); try { if (string.IsNullOrEmpty(Request.Params["content_id"])) { //cq.content_id = Convert.ToUInt32(Request.Params["content_id"].ToString()); if (!string.IsNullOrEmpty(Request.Params["content_title"])) { cq.content_title = Request.Params["content_title"].ToString().Replace("\\", "\\\\"); } if (!string.IsNullOrEmpty(Request.Params["kendoEditor"])) { cq.content_body = Request.Params["kendoEditor"].ToString().Replace("\\", "\\\\"); } if (!string.IsNullOrEmpty(Request.Params["startdate"])) { DateTime dt = Convert.ToDateTime(Request.Params["startdate"]); cq.content_start = Convert.ToUInt32(CommonFunction.GetPHPTime(dt.ToString("yyyy-MM-dd HH:mm:ss"))); } if (!string.IsNullOrEmpty(Request.Params["content_from_name"])) { cq.content_from_name = Request.Params["content_from_name"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["content_from_email"])) { cq.content_from_email = Request.Params["content_from_email"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["content_reply_email"])) { cq.content_reply_email = Request.Params["content_reply_email"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["group_id"])) { cq.group_id = Convert.ToUInt32(Request.Params["group_id"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["edm_dis"])) { cq.content_priority = Convert.ToUInt32(Request.Params["edm_dis"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["epaper_id"])) { int s = 0; if (Int32.TryParse(Request.Params["epaper_id"], out s)) { cq.info_epaper_id = s; } } cq.content_email_id = 0; cq.content_range = 300; cq.content_single_count = 100; cq.content_click = 0; cq.content_person = 0; cq.content_status = 1; int i = _IEdmContentMgr.EdmContentSave(cq); if (i > 0) { json = "{success:true}"; } } else { cq.content_id = Convert.ToUInt32(Request.Params["content_id"].ToString()); EdmContentQuery oldQuery = _IEdmContentMgr.GetEdmContentById(cq); if (!string.IsNullOrEmpty(Request.Params["content_title"])) { cq.content_title = Request.Params["content_title"].ToString().Replace("\\", "\\\\"); ; } else { cq.content_title = oldQuery.content_title; } if (!string.IsNullOrEmpty(Request.Params["kendoEditor"])) { cq.content_body = Request.Params["kendoEditor"].ToString().Replace("\\", "\\\\"); ; } if (!string.IsNullOrEmpty(Request.Params["startdate"])) { DateTime dt = Convert.ToDateTime(Request.Params["startdate"]); cq.content_start = Convert.ToUInt32(CommonFunction.GetPHPTime(dt.ToString("yyyy-MM-dd HH:mm:ss"))); } else { cq.content_start = oldQuery.content_start; } if (!string.IsNullOrEmpty(Request.Params["content_from_name"])) { cq.content_from_name = Request.Params["content_from_name"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["content_from_email"])) { cq.content_from_email = Request.Params["content_from_email"].ToString(); } else { cq.content_from_email = oldQuery.content_from_email; } if (!string.IsNullOrEmpty(Request.Params["content_reply_email"])) { cq.content_reply_email = Request.Params["content_reply_email"].ToString(); } else { cq.content_reply_email = oldQuery.content_reply_email; } if (!string.IsNullOrEmpty(Request.Params["group_id"])) { cq.group_id = Convert.ToUInt32(Request.Params["group_id"].ToString()); } else { cq.group_id = oldQuery.group_id; } if (!string.IsNullOrEmpty(Request.Params["edm_dis"])) { cq.content_priority = Convert.ToUInt32(Request.Params["edm_dis"].ToString()); } else { cq.content_priority = oldQuery.content_priority; } if (!string.IsNullOrEmpty(Request.Params["epaper_id"])) { int i = 0; if (Int32.TryParse(Request.Params["epaper_id"], out i)) { cq.info_epaper_id = i; } } int j = _IEdmContentMgr.EdmContentSave(cq); if (j > 0) { 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:true,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }