public HttpResponseBase UpdateStats()
        {
            string json = string.Empty;
            try
            {
                _dkMgr = new DisableKeywordsMgr(mySqlConnectionString);
                DisableKeywordsQuery query = new DisableKeywordsQuery();

                if (!string.IsNullOrEmpty(Request.Params["id"]))
                {
                    query.dk_id = Convert.ToInt32(Request.Params["id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["active"]))
                {
                    query.dk_active = Convert.ToInt32(Request.Params["active"]);
                }
                json = _dkMgr.UpdateStatus(query);
            }
            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 GetCount()
        {
            string json = string.Empty;
            int result = 0;
            _dkMgr = new DisableKeywordsMgr(mySqlConnectionString);
            try
            {
                string dk_string = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["dk_string"]))
                {
                 dk_string = Request.Params["dk_string"].ToString();
                }
                result = _dkMgr.GetCount(dk_string);
                if (result > 0)//如果大於0表示已存在
                {
                    json = "{success:true,msg:"+result+"}";
                }
                else
                {
                    json = "{success:true,msg:" + 0 + "}";
                }

            }
            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}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
 public HttpResponseBase AddOrEdit()
 {
     string json = string.Empty;
     int result = 0;
     _dkMgr = new DisableKeywordsMgr(mySqlConnectionString);
     try
     {
         DisableKeywordsQuery query = new DisableKeywordsQuery();
         #region 編輯
         if (!string.IsNullOrEmpty(Request.Params["dk_id"]))
         {
             query.dk_string = Request.Params["dk_string"].ToString().Replace("\\", "\\\\");
             query.dk_id = Convert.ToInt32(Request.Params["dk_id"]);
             result = _dkMgr.UpdateKeyWords(query);
             if (result > 0)
             {
                 json = "{success:true,msg:\'1\'}";
             }
             else
             {
                 json = "{success:false}";
             }
         }
         #endregion
         #region 新增
         else
         {
             query.dk_string = Request.Params["dk_string"].ToString().Replace("\\", "\\\\");
             query.user_id = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
             query.dk_created = DateTime.Now;
             result = _dkMgr.AddKeyWords(query);
             if (result > 0)
             {
                 json = "{success:true,msg:\'0\'}";
             }
             else
             {
                 json = "{success:false}";
             }
         }
         #endregion
     }
     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}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 } 
        public HttpResponseBase DeleteKeyWords()
        {
            string json = string.Empty;
            int result = 0;
            _dkMgr = new DisableKeywordsMgr(mySqlConnectionString);
            try
            {
                DisableKeywordsQuery query = new DisableKeywordsQuery();
                if (!string.IsNullOrEmpty(Request.Params["ids"]))
                {
                    query.ids = Request.Params["ids"].ToString();
                }
                result = _dkMgr.DeleteKeyWords(query);
                if (result > 0)
                {
                    json = "{success:true,msg:\'1\'}";
                }
                else
                {
                    json = "{success:false}";
                }

            }
            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}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
 public HttpResponseBase GetKeyWordsList()
 {
     string json = string.Empty;
     int totalCount = 0;
     DisableKeywordsQuery query = new DisableKeywordsQuery();
     query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
     query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["starttime"]) && !string.IsNullOrEmpty(Request.Params["endtime"]))
         {
             query.start = Convert.ToDateTime(Request.Params["starttime"]);
             query.end = Convert.ToDateTime(Request.Params["endtime"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["text"]))
         {
             query.search_text = Request.Params["text"].ToString().Replace("\\", "\\\\");
         }
         _dkMgr = new DisableKeywordsMgr(mySqlConnectionString);
         DataTable store = _dkMgr.GetKeyWordsList(query, out totalCount);
         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;
 }