public override List <LogBrowseVO> GetModels(ref LogBrowsePara mp)
        {
            string where = GetConditionByPara(mp);

            int    pStart = mp.PageIndex.Value * mp.PageSize.Value;
            int    pEnd   = mp.PageSize.Value;
            string cmd    = QUERYPAGE
                            .Replace("@PAGESIZE", pEnd.ToString())
                            .Replace("@PTOP", pStart.ToString())
                            .Replace("@WHERE", where)
                            .Replace("@ORDER", GetOrderByPara(mp));

            CodeCommand command = new CodeCommand();

            command.CommandText = cmd;

            var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command);

            List <LogBrowseVO> list = new List <LogBrowseVO>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(new LogBrowseVO(table.Rows[i]));
            }

            if (!mp.Recount.HasValue)
            {
                mp.Recount = GetRecords(mp);
            }

            return(list);
        }
        public override string GetOrderByPara(LogBrowsePara mp)
        {
            if (!string.IsNullOrEmpty(mp.OrderBy))
            {
                return(string.Format(" order by {0}", mp.OrderBy));
            }

            return("");
        }
        public override LogBrowseVO GetSingle(LogBrowsePara mp)
        {
            var list = GetModels(mp);

            if (list.Count == 1)
            {
                return(list[0]);
            }

            return(null);
        }
        public override int GetRecords(LogBrowsePara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            command.CommandText = QUERYCOUNT + where;

            var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command);

            return(int.Parse(result.ToString()));
        }
        public override bool Delete(LogBrowsePara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            command.CommandText = DELETE + where;

            int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command);

            if (result >= 1)
            {
                return(true);
            }

            return(false);
        }
        private void Bind(int pageIndex = 1)
        {
            LogBrowsePara lp = new LogBrowsePara();

            lp.PageIndex = pageIndex - 1;
            lp.PageSize  = 10;
            lp.OrderBy   = " id desc ";
            lp.Time      = int.Parse(txtTime.Value.Replace("-", ""));
            if (!string.IsNullOrEmpty(ddlAdPage.SelectedValue))
            {
                lp.AdId = int.Parse(ddlAdPage.SelectedValue);
            }

            var list = LogBrowseBLL.Instance.GetModels(ref lp);

            rptTable.DataSource = list;
            rptTable.DataBind();

            apPager.RecordCount = lp.Recount.Value;
        }
        public override List <LogBrowseVO> GetModels(LogBrowsePara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            string cmd = LOAD
                         .Replace("@WHERE", where)
                         .Replace("@ORDER", GetOrderByPara(mp));

            command.CommandText = cmd;

            var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command);

            List <LogBrowseVO> list = new List <LogBrowseVO>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(new LogBrowseVO(table.Rows[i]));
            }

            return(list);
        }
 public override string GetOtherConditionByPara(LogBrowsePara mp)
 {
     return("");
 }
        public override string GetConditionByPara(LogBrowsePara mp)
        {
            StringBuilder sb = new StringBuilder();

            if (mp.Id.HasValue)
            {
                sb.AppendFormat(" AND [Id]='{0}' ", mp.Id);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Url)))
            {
                sb.AppendFormat(" AND [Url]='{0}' ", mp.Url);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ClientIp)))
            {
                sb.AppendFormat(" AND [ClientIp]='{0}' ", mp.ClientIp);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.BrowseType)))
            {
                sb.AppendFormat(" AND [BrowseType]='{0}' ", mp.BrowseType);
            }
            if (mp.CreateDate.HasValue)
            {
                sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate);
            }
            if (mp.AdId.HasValue)
            {
                sb.AppendFormat(" AND [AdId]='{0}' ", mp.AdId);
            }
            if (mp.AdUserId.HasValue)
            {
                sb.AppendFormat(" AND [AdUserId]='{0}' ", mp.AdUserId);
            }
            if (mp.FlowUserId.HasValue)
            {
                sb.AppendFormat(" AND [FlowUserId]='{0}' ", mp.FlowUserId);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.AdUrl)))
            {
                sb.AppendFormat(" AND [AdUrl]='{0}' ", mp.AdUrl);
            }
            if (mp.Money.HasValue)
            {
                sb.AppendFormat(" AND [Money]='{0}' ", mp.Money);
            }
            if (mp.IsMoney.HasValue)
            {
                sb.AppendFormat(" AND [IsMoney]='{0}' ", mp.IsMoney);
            }
            if (mp.Time.HasValue)
            {
                sb.AppendFormat(" AND [Time]='{0}' ", mp.Time);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ClientId)))
            {
                sb.AppendFormat(" AND [ClientId]='{0}' ", mp.ClientId);
            }
            if (mp.IsMobile.HasValue)
            {
                sb.AppendFormat(" AND [IsMobile]='{0}' ", mp.IsMobile);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ReferrerUrl)))
            {
                sb.AppendFormat(" AND [ReferrerUrl]='{0}' ", mp.ReferrerUrl);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.BrowseName)))
            {
                sb.AppendFormat(" AND [BrowseName]='{0}' ", mp.BrowseName);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.BrowseVersion)))
            {
                sb.AppendFormat(" AND [BrowseVersion]='{0}' ", mp.BrowseVersion);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.OsName)))
            {
                sb.AppendFormat(" AND [OsName]='{0}' ", mp.OsName);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Country)))
            {
                sb.AppendFormat(" AND [Country]='{0}' ", mp.Country);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Area)))
            {
                sb.AppendFormat(" AND [Area]='{0}' ", mp.Area);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Region)))
            {
                sb.AppendFormat(" AND [Region]='{0}' ", mp.Region);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.City)))
            {
                sb.AppendFormat(" AND [City]='{0}' ", mp.City);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.County)))
            {
                sb.AppendFormat(" AND [County]='{0}' ", mp.County);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Isp)))
            {
                sb.AppendFormat(" AND [Isp]='{0}' ", mp.Isp);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.IpSource)))
            {
                sb.AppendFormat(" AND [IpSource]='{0}' ", mp.IpSource);
            }


            sb.Insert(0, " WHERE 1=1 ");

            return(sb.ToString());
        }