コード例 #1
0
ファイル: UserForbidMgr.cs プロジェクト: lxh2014/gigade-net
        /// <summary>
        /// 判斷黑名單中是否已經存在IP
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public int GetUserForbidIp(UserForbidQuery query)
        {
            try
            {
                return _IuserForbidDao.GetUserForbidIp(query);
            }
            catch (Exception ex)
            {

                throw new Exception("UserForbidMgr-->GetUserForbidIp-->" + ex.Message, ex);
            }
        }
コード例 #2
0
ファイル: UserForbidMgr.cs プロジェクト: lxh2014/gigade-net
        /// <summary>
        /// 刪除黑名單
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public int UserForbidDelete(UserForbidQuery query)
        {
            try
            {
                return _IuserForbidDao.UserForbidDelete(query);
            }
            catch (Exception ex)
            {

                throw new Exception("UserForbidMgr-->UserForbidDelete-->" + ex.Message, ex);
            }
        }
コード例 #3
0
ファイル: UserForbidMgr.cs プロジェクト: lxh2014/gigade-net
        /// <summary>
        /// 黑名單列表頁
        /// </summary>
        /// <param name="store"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public List<UserForbidQuery> GetUserForbidList(UserForbidQuery store, out int totalCount)
        {
            try
            {
                return _IuserForbidDao.GetUserForbidList(store, out totalCount);
            }
            catch (Exception ex)
            {

                throw new Exception("UserForbidMgr-->GetUserForbidList-->" + ex.Message, ex);
            }
        }
コード例 #4
0
ファイル: UserForbidDao.cs プロジェクト: lxh2014/gigade-net
        /// <summary>
        /// 新增黑名單
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public int UserForbidInsert(UserForbidQuery query)
        {
            query.Replace4MySQL();
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@"insert into user_forbid(forbid_ip,forbid_createdate,forbid_createuser) values('{0}','{1}','{2}')", query.forbid_ip, query.forbid_createdate, query.forbid_createuser);
                return _access.execCommand(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("UserForbidDao-->UserForbidInsert-->" + ex.Message + sb.ToString(), ex);
            }

        }
コード例 #5
0
ファイル: UserForbidDao.cs プロジェクト: lxh2014/gigade-net
        /// <summary>
        /// 黑名單列表頁
        /// </summary>
        /// <param name="store"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public List<UserForbidQuery> GetUserForbidList(UserForbidQuery store, out int totalCount)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlfrom = new StringBuilder();
            try
            {
                sql.Append(@"SELECT  uf.forbid_id, uf.forbid_ip,uf.forbid_createdate,FROM_UNIXTIME(uf.forbid_createdate) create_time,uf.forbid_createuser,mu.user_username ");
                sqlfrom.AppendFormat(" from user_forbid uf left join manage_user mu on uf.forbid_createuser=mu.user_id  where 1=1 ");
                if (store.forbid_ip != "")
                {
                    sqlfrom.AppendFormat(" and uf.forbid_ip='{0}' ", store.forbid_ip);
                }
                if (!string.IsNullOrEmpty(store.timestart))
                {
                    sqlfrom.AppendFormat(" and uf.forbid_createdate>='{0}' ",CommonFunction.GetPHPTime(store.timestart));
                }
                if (!string.IsNullOrEmpty(store.timeend))
                {
                    sqlfrom.AppendFormat(" and uf.forbid_createdate<='{0}' ",CommonFunction.GetPHPTime(store.timeend));
                }
                string str = string.Format(" SELECT count(*) AS search_total  ");
                totalCount = 0;
                if (store.IsPage)
                {
                    System.Data.DataTable _dt = _access.getDataTable(str + sqlfrom.ToString());
                    if (_dt != null && _dt.Rows.Count > 0)
                    {

                        totalCount = Convert.ToInt32(_dt.Rows[0]["search_total"]);
                    }
                    sqlfrom.AppendFormat(" order by uf.forbid_id desc  ");
                    sqlfrom.AppendFormat(" limit {0},{1};", store.Start, store.Limit);

                }
                return _access.getDataTableForObj<UserForbidQuery>(sql.ToString() + sqlfrom.ToString());
            }
            catch (Exception ex)
            {

                throw new Exception("UserForbidDao-->GetUserForbidList-->" + sqlfrom.ToString() + ex.Message, ex);
            }


        }
コード例 #6
0
ファイル: UserForbidDao.cs プロジェクト: lxh2014/gigade-net
        /// <summary>
        /// 判斷黑名單中是否已經存在IP
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public int GetUserForbidIp(UserForbidQuery query)
        {
            query.Replace4MySQL();
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@"select forbid_id from user_forbid where forbid_ip = '{0}'", query.forbid_ip);
                UserForbidQuery temp = _access.getSinggleObj<UserForbidQuery>(sb.ToString());
                if (temp != null)
                {
                    return temp.forbid_id;
                }
                else
                {
                    return 0;
                }

            }
            catch (Exception ex)
            {
                throw new Exception("UserForbidDao-->GetUserForbidIp-->" + ex.Message + sb.ToString(), ex);
            }

        }
コード例 #7
0
ファイル: UserForbidDao.cs プロジェクト: lxh2014/gigade-net
        /// <summary>
        /// 刪除黑名單
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public int UserForbidDelete(UserForbidQuery query)
        {
            query.Replace4MySQL();
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@"delete from user_forbid where forbid_id in ({0})", query.rowIds);
                return _access.execCommand(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("UserForbidDao-->UserForbidDelete-->" + ex.Message + sb.ToString(), ex);
            }

        }
コード例 #8
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;
        }
コード例 #9
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;
        }
コード例 #10
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;

        }