public HttpResponseBase AddorEdit() { string json = string.Empty; _emailBlockListMgr = new EmailBlockListMgr(mySqlConnectionString); try { EmailBlockListQuery query = new EmailBlockListQuery(); query.block_update_userid = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); if (!string.IsNullOrEmpty(Request.Params["reason"])) { query.block_reason = Request.Params["reason"].ToString().Replace("\\", "\\\\"); ; query.block_create_userid = query.block_update_userid; if (!string.IsNullOrEmpty(Request.Params["email_address"])) { query.email_address = Request.Params["email_address"].ToString().Replace("\\", "\\\\"); ; } int i = _emailBlockListMgr.Add(query); if (i > 0) { json = "{success:true}"; } else if (i == -1) { json = "{success:false,msg:\'0\'}"; //郵箱已添加過 } } else { if (!string.IsNullOrEmpty(Request.Params["block_reason"])) { query.block_reason = Request.Params["block_reason"].ToString().Replace("\\", "\\\\"); ; } if (!string.IsNullOrEmpty(Request.Params["email_address"])) { query.email_address = Request.Params["email_address"].ToString(); } int i = _emailBlockListMgr.Update(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:false,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }