Esempio n. 1
0
        /// <summary>
        /// 新增黑名單
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SaveUserFoid()
        {
            string json = string.Empty;
            UserForbidQuery query = new UserForbidQuery();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["forbid_id"]))//修改
                {
                    query.forbid_id = Convert.ToInt32(Request.Params["forbid_id"]);
                    query.forbid_ip = Request.Params["forbid_ip"];
                    //_siteMgr = new SiteMgr(mySqlConnectionString);
                    //_siteMgr.UpSite(query);
                }
                else//新增
                {
                    query.forbid_ip = Request.Params["forbid_ip"];
                    query.forbid_createuser = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    query.forbid_createdate = Convert.ToInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                    _IuserForbidMgr = new UserForbidMgr(mySqlConnectionString);
                    int j = _IuserForbidMgr.GetUserForbidIp(query);
                    if (j > 0)
                    {
                        json = "{success:true,msg:\"" + "1" + "\"}";
                    }
                    else
                    {
                        _IuserForbidMgr.UserForbidInsert(query);
                        json = "{success:true,msg:\"" + "" + "\"}";
                    }
                }


            }
            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,msg:\"" + ex.Message + "\"}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Esempio n. 2
0
        /// <summary>
        /// 刪除黑名單
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase DeleteUserFoid()
        {
            string json = string.Empty;
            UserForbidQuery query = new UserForbidQuery();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["rowID"]))//修改
                {
                    string str = Request.Params["rowID"].ToString();
                    str = str.Remove(str.LastIndexOf(','));
                    query.rowIds = str;

                    _IuserForbidMgr = new UserForbidMgr(mySqlConnectionString);
                    _IuserForbidMgr.UserForbidDelete(query);
                }
                json = "{success:true}";
                //返回json數據

            }
            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,msg:\"" + ex.Message + "\"}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Esempio n. 3
0
        /// <summary>
        /// 黑名單列表
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetUserForbidList()
        {
            UserForbidQuery query = new UserForbidQuery();
            List<UserForbidQuery> stores = new List<UserForbidQuery>();
            string json = string.Empty;
            try
            {

                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                if (!string.IsNullOrEmpty(Request.Params["serchcontent"]))
                {
                    query.forbid_ip = Request.Params["serchcontent"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["timestart"]))
                {
                    query.timestart = Convert.ToDateTime(Request.Params["timestart"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                }
                if (!string.IsNullOrEmpty(Request.Params["timeend"]))
                {
                    query.timeend = Convert.ToDateTime(Request.Params["timeend"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                }
                _IuserForbidMgr = new UserForbidMgr(mySqlConnectionString);
                int totalCount = 0;
                stores = _IuserForbidMgr.GetUserForbidList(query, out totalCount);
                //foreach (var item in stores)
                //{
                //    item.screatedate = CommonFunction.GetNetTime(item.createdate);

                //}
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                //listUser是准备转换的对象
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據

            }
            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,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }