public DataTable GetBannerNewsContentList(BannerNewsContent bnc, out int totalCount)
 {
     try
     {
         return _bannerNewsContent.GetBannerNewsContentList(bnc, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("BannerNewsContentMgr-->GetBannerNewsContentList" + ex.Message, ex);
     }
 }
        /// <summary>
        /// 列表頁
        /// </summary>
        /// <param name="bnc"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public DataTable GetBannerNewsContentList(BannerNewsContent bnc, out int totalCount)
        {
            totalCount = 0;
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlwhere = new StringBuilder();
            sql.AppendLine(@"SELECT news_id,news_site_id,news_title,news_content,news_link_url,news_link_mode,news_sort,news_status,");
            sql.AppendLine(@"FROM_UNIXTIME(news_start) AS news_start ,FROM_UNIXTIME(news_end) AS news_end,");
            sql.AppendLine(@"FROM_UNIXTIME(news_createdate) AS news_createdate,FROM_UNIXTIME(news_updatedate) AS news_updatedate,news_ipfrom");
            sqlwhere.AppendLine(@" FROM banner_news_content WHERE 1=1 ");
            if (bnc.news_site_id != 0)
            {
                sqlwhere.AppendFormat(@" AND news_site_id='{0}' ", bnc.news_site_id);
            }
            if (bnc.news_status == 3)
            {
                sqlwhere.AppendFormat(@" AND news_status=3 ");
            }
            else
            {
                sqlwhere.AppendFormat(@" AND news_status <>3 ");
            }
            sql.Append(sqlwhere.ToString());
            if (bnc.news_status == 3)
            {
                sql.AppendFormat(@" ORDER BY news_id DESC ");
            }
            else
            {
                sql.AppendFormat(@" ORDER BY news_sort DESC, news_id DESC ");
            }
            try
            {
                if (bnc.IsPage)
                {
                    sql.AppendFormat(@" LIMIT {0},{1} ", bnc.Start, bnc.Limit);
                    DataTable dt = _access.getDataTable(" SELECT news_id " + sqlwhere.ToString());
                    totalCount = dt.Rows.Count;
                }
                return _access.getDataTable(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("BannerNewsContentDao-->GetBannerNewsContentList" + ex.Message + sql.ToString(), ex);
            }

        }
示例#3
0
 /// <summary>
 ///內容和歷史跳轉鏈接頁面  文字廣告列表
 /// </summary>
 /// <returns></returns>
 public HttpResponseBase GetBannerNewsList()
 {
     string json = string.Empty;
     BannerNewsContent query = new BannerNewsContent();
     try
     {
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
         if (!string.IsNullOrEmpty(Request.Params["sid"]))
         {
             query.news_site_id = uint.Parse(Request.Params["sid"]);
         }
         if (Request.Params["history"] == "1")
         {
             query.news_status = 3;
         }
         bncMgr = new BannerNewsContentMgr(mySqlConnectionString);
         int totalCount = 0;
         DataTable dt = bncMgr.GetBannerNewsContentList(query, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss ";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(dt, 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:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }