Ejemplo n.º 1
0
 public ActionResult BannerNewsList()
 {
     ViewBag.sid = Request.Params["sid"];
     List<BannerNewsSite> store = new List<BannerNewsSite>();
     BannerNewsSite bns = new BannerNewsSite();
     _bnsMgr = new BannerNewsSiteMgr(mySqlConnectionString);
     if (!string.IsNullOrEmpty(Request.Params["sid"]))
     {
         bns.news_site_id = uint.Parse(Request.Params["sid"]);
     }
     store = _bnsMgr.GetBannerNewsSiteName(bns);
     if (store.Count > 0)
     {
         ViewBag.sname = store[0].news_site_name;
     }
     else
     {
         ViewBag.sname = "";
     }
     if (!string.IsNullOrEmpty(Request.Params["history"]))
     {
         ViewBag.history = Request.Params["history"];
     }
     else
     {
         ViewBag.history = "0";
     }
     return View();
 }
Ejemplo n.º 2
0
        public HttpResponseBase GetBannerNewsSiteList()
        {
            string json = string.Empty;
            List<BannerNewsSiteQuery> store = new List<BannerNewsSiteQuery>();
            BannerNewsSiteQuery bs = new BannerNewsSiteQuery();
            try
            {
                bs.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                bs.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                _bnsMgr = new BannerNewsSiteMgr(mySqlConnectionString);
                int totalCount = 0;
                store = _bnsMgr.GetList(bs, out totalCount);
                foreach (var item in store)
                {
                    item.creattime = CommonFunction.GetNetTime(item.news_site_createdate);
                    item.updtime = CommonFunction.GetNetTime(item.news_site_updatedate);
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss ";

                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, 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;
        }