示例#1
0
 public int Add(EmailBlockListQuery query)
 {
     query.Replace4MySQL();
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@"INSERT INTO email_block_list(email_address,block_reason,block_create_userid,block_update_userid,block_createdate,block_updatedate) VALUES('{0}','{1}','{2}','{3}',NOW(),NOW());", query.email_address, query.block_reason, query.block_create_userid, query.block_update_userid);
         return _access.execCommand(sql.ToString());
     }
     catch (MySqlException ex)
     {
         throw new Exception(ex.Number.ToString() + ":EmailBlockListDao-->Add" + ex.Message, ex);
     }
     catch (Exception ex)
     {
         throw new Exception("EmailBlockListDao-->Add-->" + ex.Message, ex);
     }
 }
示例#2
0
        public DataTable GetEmailBlockList(EmailBlockListQuery query)
        {
            query.Replace4MySQL();
            StringBuilder sql = new StringBuilder();
            StringBuilder count = new StringBuilder();
            int totalCount = 0;
           DataTable store = new DataTable();
            try
            {
                sql.AppendFormat(@"SELECT email_address,block_reason,block_createdate,(SELECT user_username FROM manage_user WHERE manage_user.user_id=email_block_list.block_create_userid ) as user_name from email_block_list where 1=1 ");
                count.AppendFormat(@"SELECT count(email_address) as totalCount from email_block_list where 1=1 ");
                if (query.email_address != string.Empty)
                {
                    sql.AppendFormat(" AND email_address LIKE N'%{0}%'", query.email_address);
                    count.AppendFormat(" AND email_address LIKE N'%{0}%'", query.email_address);
                }
                if (query.IsPage)
                {
                    DataTable _dt = _access.getDataTable(count.ToString());
                    if (_dt != null && _dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]);
                    }
                    sql.AppendFormat("  limit {0},{1} ;", query.Start, query.Limit);
                }

                store = _access.getDataTable(sql.ToString());
                return store;
            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Number.ToString() + ":EmailBlockListDao-->GetEmailBlockList" + ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception("EmailBlockListDao-->GetEmailBlockList-->" + ex.Message, ex);
            }
        }
示例#3
0
 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;
 }
示例#4
0
 public HttpResponseBase GetEmailBlockList()
 {
     string json = string.Empty;
     try
     {
         _emailBlockListMgr = new EmailBlockListMgr(mySqlConnectionString);
         DataTable store = new DataTable();
         EmailBlockListQuery query = new EmailBlockListQuery();
         if (!string.IsNullOrEmpty(Request.Params["email"]))
         {
             query.email_address = Request.Params["email"];
         }
         store = _emailBlockListMgr.GetEmailBlockList(query);
         if (store != null)
         {
             IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
             timeConverter.DateTimeFormat = "yyyy-MM-dd";
             json = "{success:true" + ",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,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
示例#5
0
 public int Update(EmailBlockListQuery query)
 {
     query.Replace4MySQL();
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@"UPDATE email_block_list SET block_reason='{0}' ,block_update_userid={1},block_updatedate=NOW() WHERE email_address='{2}'", query.block_reason, query.block_update_userid, query.email_address);
         return _access.execCommand(sql.ToString());
     }
     catch (MySqlException ex)
     {
         throw new Exception(ex.Number.ToString() + ":EmailBlockListDao-->Update" + ex.Message, ex);
     }
     catch (Exception ex)
     {
         throw new Exception("EmailBlockListDao-->Update-->" + ex.Message, ex);
     }
 }