Ejemplo n.º 1
0
        public override List <AdBrowseVO> GetModels(ref AdBrowsePara 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 <AdBrowseVO> list = new List <AdBrowseVO>();

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

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

            return(list);
        }
Ejemplo n.º 2
0
        private void Bind(int pageIndex = 1)
        {
            AdBrowsePara cip = new AdBrowsePara();

            cip.PageIndex  = pageIndex - 1;
            cip.PageSize   = 10;
            cip.FlowUserId = Account.UserId;
            cip.OrderBy    = " id desc ";
            cip.Time       = int.Parse(txtTime.Value.Replace("-", ""));

            if (!string.IsNullOrEmpty(ddlAdPage.SelectedValue))
            {
                cip.AdId = int.Parse(ddlAdPage.SelectedValue);
            }
            if (!string.IsNullOrEmpty(hidAdUserId.Value))
            {
                cip.AdUserId = int.Parse(hidAdUserId.Value);
            }

            var list = AdBrowseBLL.Instance.GetModels(ref cip);

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

            apPager.RecordCount = cip.Recount.Value;
        }
Ejemplo n.º 3
0
        public override string GetOrderByPara(AdBrowsePara mp)
        {
            if (!string.IsNullOrEmpty(mp.OrderBy))
            {
                return(string.Format(" order by {0}", mp.OrderBy));
            }

            return("");
        }
Ejemplo n.º 4
0
        public override AdBrowseVO GetSingle(AdBrowsePara mp)
        {
            var list = GetModels(mp);

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

            return(null);
        }
Ejemplo n.º 5
0
        public override int GetRecords(AdBrowsePara 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()));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 数据同步迁移
        /// </summary>
        /// <param name="time">默认是当前时间的前一天,格式:yyyyMMdd</param>
        public void Synchronization(int time = 0)
        {
            if (time == 0)
            {
                time = int.Parse(DateTime.Now.AddDays(-1).ToString("yyyyMMdd"));
            }

            AdBrowsePara ap = new AdBrowsePara();

            ap.IsNotDay  = true;
            ap.PageSize  = 1000;
            ap.PageIndex = 0;

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

            list = AdBrowseBLL.Instance.GetModels(ref ap);
            while (list.Count != 0)
            {
                List <int> ids = new List <int>();

                foreach (var item in list)
                {
                    AdBrowseHistoryVO info = new AdBrowseHistoryVO();
                    info.AdId       = item.AdId;
                    info.AdUrl      = item.AdUrl;
                    info.BrowseType = item.BrowseType;
                    info.ClientIp   = item.ClientIp;
                    info.CreateDate = item.CreateDate;
                    info.IsMoney    = item.IsMoney;
                    info.Money      = item.Money;
                    info.Time       = item.Time;
                    info.Url        = item.Url;
                    info.AdUserId   = item.AdUserId;


                    AdBrowseHistoryBLL.Instance.Add(info);
                    ids.Add(item.Id);
                    //删除数据
                    //AdBrowseBLL.Instance.Delete(new AdBrowsePara() { Id = item.Id });
                }

                AdBrowseBLL.Instance.Delete(new AdBrowsePara()
                {
                    Ids = ids
                });

                list = AdBrowseBLL.Instance.GetModels(ref ap);
            }
        }
Ejemplo n.º 7
0
        private void Bind(int pageIndex = 1)
        {
            AdBrowsePara cip = new AdBrowsePara();

            cip.PageIndex = pageIndex - 1;
            cip.PageSize  = 10;
            cip.OrderBy   = " id desc ";

            var list = AdBrowseBLL.Instance.GetModels(ref cip);

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

            apPager.RecordCount = cip.Recount.Value;
        }
Ejemplo n.º 8
0
        public override bool Delete(AdBrowsePara 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);
        }
Ejemplo n.º 9
0
        private void Bind(int pageIndex = 1)
        {
            AdBrowsePara cip = new AdBrowsePara();

            cip.PageIndex = pageIndex - 1;
            cip.PageSize  = 10;
            cip.Time      = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
            cip.OrderBy   = " id desc ";
            if (!string.IsNullOrEmpty(ddlAdPage.SelectedValue))
            {
                cip.AdId = int.Parse(ddlAdPage.SelectedValue);
            }

            var list = AdBrowseBLL.Instance.GetModels(ref cip);

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

            apPager.RecordCount = cip.Recount.Value;
        }
Ejemplo n.º 10
0
        public static string GetConditionByPara(AdBrowsePara mp)
        {
            StringBuilder sb = new StringBuilder();

            if (mp.IsNotDay.HasValue)
            {
                if (mp.IsNotDay.Value)
                {
                    sb.AppendFormat(" AND [Time] <> {0} ", DateTime.Now.ToString("yyyyMMdd"));
                }
                else
                {
                    sb.AppendFormat(" AND [Time] = {0} ", DateTime.Now.ToString("yyyyMMdd"));
                }
            }

            if (mp.Ids != null && mp.Ids.Count != 0)
            {
                sb.AppendFormat(" and  [Id] ({0}) ", string.Join(",", mp.Ids));
            }

            return(sb.ToString());
        }
Ejemplo n.º 11
0
        public override List <AdBrowseVO> GetModels(AdBrowsePara 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 <AdBrowseVO> list = new List <AdBrowseVO>();

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

            return(list);
        }
Ejemplo n.º 12
0
 public override string GetOtherConditionByPara(AdBrowsePara mp)
 {
     return("");
 }
Ejemplo n.º 13
0
        public override string GetConditionByPara(AdBrowsePara 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);
            }


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

            return(sb.ToString());
        }