/// <summary> /// 取消電子報 /// </summary> /// <returns></returns> public HttpResponseBase CancelEdm() { string json = "{success:false}"; uint update_id = 0; uint vid = 0; try { string mail = string.Empty; if (!string.IsNullOrEmpty(Request.Params["mail"])) { mail = Request.Params["mail"].ToString().Trim(); } _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); update_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); int i = _IEdmContentMgr.CancelEdm(mail, update_id, out vid); if (i > 0) { json = "{success:true}"; } else if (i == -1) { json = "{success:false,msg:\'0\'}"; //郵箱不存在,不可取消電子報 } else if (i == -2) { json = "{success:false,msg:\'1\'}";//郵箱沒有對應的用戶 } else if (i == -3) { //DataTable dt = new DataTable(); //dt.Columns.Add("vid"); //DataRow dr = new DataRow(); //dr[0] = vid.ToString(); //dt.Rows.Add(dr); json = "{success:false,msg:\'2\',vid:\'" + vid + "\'}";//郵箱已加入黑名單且狀態為解除 } else if (i == -4) { json = "{success:false,msg:\'3\'}";//郵箱已加入黑名單且狀態為鎖定 } else if (i == -5) { json = "{success:false,msg:\'4\'}";//郵箱無法取消電子報 } } 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; }
public HttpResponseBase GetEdmContent() { string json = string.Empty; try { _edmContentMgr = new EdmContentMgr(mySqlConnectionString); json = _edmContentMgr.GetEdmContent(); } 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,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
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 GetEdmGroup() { string json = string.Empty; List<EdmContentQuery> store = new List<EdmContentQuery>(); EdmContentQuery query = new EdmContentQuery(); try { _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); store = _IEdmContentMgr.GetEdmGroup(); json = "{success:true" + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented) + "}"; } 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 LoadEpaperContent() { string json = string.Empty; EpaperContentQuery query = new EpaperContentQuery(); EpaperContentQuery model = new EpaperContentQuery(); try { if (!string.IsNullOrEmpty(Request.Params["content_id"])) { _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); query.epaper_id = Convert.ToUInt32(Request.Params["content_id"]); _epaperMgr = new EpaperContentMgr(mySqlConnectionString); model = _epaperMgr.GetEpaperContentById(query); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; if (model != null) { model.epaper_id = query.epaper_id; switch (model.epaper_status) { case 0: json = "{success:false" + ",data:" + JsonConvert.SerializeObject(model, Formatting.Indented, timeConverter) + ",msg:0}"; break; case 1: json = "{success:true" + ",data:" + JsonConvert.SerializeObject(model, Formatting.Indented, timeConverter) + "}"; break; case 2: json = "{success:false" + ",data:" + JsonConvert.SerializeObject(model, Formatting.Indented, timeConverter) + ",msg:1}"; break; case 3: json = "{success:false" + ",data:" + JsonConvert.SerializeObject(model, Formatting.Indented, timeConverter) + ",msg:2}"; break; } } else { json = "{success:false,msg:3}"; } } 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; }
public HttpResponseBase EditStatus() { 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; EdmContentQuery query = new EdmContentQuery(); int i = 0; try { if (!string.IsNullOrEmpty(Request.Params["content_id"])) { query.content_id = Convert.ToUInt32(Request.Params["content_id"]); } if (!string.IsNullOrEmpty(Request.Params["status"])) { query.content_status = Convert.ToUInt32(Request.Params["status"]); } _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); _edmContentMgr = new EdmContentMgr(mySqlConnectionString); //////////// string FromName = string.Empty; string EmailTile = string.Empty; string strTemp = string.Empty; string userEmail = string.Empty; string userName = string.Empty; DataTable _emaildt = _edmContentMgr.GetTestEmailById(query.content_id); if (_emaildt.Rows.Count > 0) { EmailFrom = _emaildt.Rows[0]["content_from_email"].ToString(); FromName = _emaildt.Rows[0]["content_from_name"].ToString(); EmailTile = _emaildt.Rows[0]["content_title"].ToString(); strTemp = _emaildt.Rows[0]["content_body"].ToString(); } if (query.content_status == 1) { //發送郵件 DataTable _dt = _edmContentMgr.GetAllTestEmail(); for (int index = 0; index < _dt.Rows.Count; index++) { userEmail = _dt.Rows[index]["email_address"].ToString(); userName = _dt.Rows[index]["test_username"].ToString(); bool result = sendmail(EmailFrom, FromName, userEmail, userName, EmailTile, strTemp, "", SmtpHost, Convert.ToInt32(SmtpPort), EmailUserName, EmailPassWord); if (result) json = "{success:true}"; } } if (query.content_status == 3) { //修改狀態 i = _IEdmContentMgr.EditStatus(query); if (i > 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; }
/// <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; }
public HttpResponseBase DeleteEdm() { string json = string.Empty; _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); if (!string.IsNullOrEmpty(Request.Params["rowID"])) { try { foreach (string item in Request.Params["rowID"].Split('|')) { if (!string.IsNullOrEmpty(item)) { _IEdmContentMgr.DeleteEdm(Convert.ToInt32(item)); } } 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}"; } } else { json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetEdmContentList() { string json = string.Empty; List<EdmContentQuery> store = new List<EdmContentQuery>(); EdmContentQuery query = new EdmContentQuery(); try { query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25"); if (!string.IsNullOrEmpty(Request.Params["searchStatus"])) { query.searchStatus = Request.Params["searchStatus"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["search_text"])) { query.search_text = Request.Params["search_text"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["tstart"])) { query.s_content_start = Convert.ToDateTime(Request.Params["tstart"]); } if (!string.IsNullOrEmpty(Request.Params["tend"])) { query.s_content_end = Convert.ToDateTime(Request.Params["tend"]); } _IEdmContentMgr = new EdmContentMgr(mySqlConnectionString); int totalCount = 0; store = _IEdmContentMgr.GetEdmContentList(query, out totalCount); foreach (var item in store) { item.content_send_count = item.content_send_success + item.content_send_failed; item.content_body = Server.HtmlDecode(Server.HtmlDecode(item.content_body)); item.s_content_start = CommonFunction.GetNetTime(item.content_start); } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}"; } 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; }