protected override void OnRequest() { base.OnRequest(); try { uint?pageLevel = getParameterUint("pagelevel"); AdListModel adList = null; using (Controller.Ad controllerAd = new Controller.Ad()) { adList = controllerAd.GetAdList(pageLevel); } DatagridModel <AdModel> data = new DatagridModel <AdModel>(); data.total = (uint)adList.Count; data.rows = adList; WriteJson(data); } catch (UnfulfilException ex) { WriteUnfulfil(ex.DisplayMessage); } catch (Database.Exception ex) { WriteException(ex); } catch (Exception ex) { WriteException(ex); } }
// protected override void OnRequest() { try { uint?pageLevel = getParameterUint("pagelevel"); AdListModel adList = null; using (Controller.Ad controllerAd = new Controller.Ad()) { adList = controllerAd.GetAdList(pageLevel); } //List<Dictionary<string, string>> adList = Controller.Ad.Instance.GetAdList(null); WriteSuccess <AdListModel>(adList); }catch (Exception ex) { WriteException(ex); } WriteEnd(); }
/// <summary> /// 获取广告列表 /// </summary> /// <param name="PageLevel"></param> /// <returns></returns> public AdListModel GetAdList(uint?PageLevel) { //List<Dictionary<string, string>> list=new List<Dictionary<string, string>>(); List <AdModel> list = null; if (PageLevel != null) { string where = String.Format(" ad.PageLevel={0}", PageLevel); list = db.SelectData <AdModel>("ad", where); } else { list = db.SelectData <AdModel>("ad"); } AdListModel adList = new AdListModel(); foreach (AdModel ad in list) { ad.imgsrc = SystemConfig.WebappURL + SystemConfig.AdUploadPath + ad.imgsrc; adList.Add(ad); //dictionary<string, string> map = new dictionary<string, string>(); //map.add("link", ad.imglink); //string imgsrc =systemconfig.webappurl + systemconfig.aduploadpath+ ad.imgsrc; //map.add("source", imgsrc); //list.add(map); } return(adList); }