示例#1
0
 public IEnumerable<City> getCitysByProvinceId(int ProvinceId)
 {
     MyContext db = new MyContext();
     var q = db.Cities.Where(c => c.ProvinceId == ProvinceId).ToArray();
     db.Dispose();
     return q;
 }
示例#2
0
 public IEnumerable<Province> getAllProvinces()
 {
     MyContext db = new MyContext();
     var q = db.Provinces.ToArray();
     db.Dispose();
     return q;
 }
示例#3
0
 public IEnumerable<City> getAllCitys()
 {
     MyContext db = new MyContext();
     var q = db.Cities.ToArray();
     db.Dispose();
     return q;
 }
示例#4
0
        public CityAQIPublishLive getCityAir(int cityid)
        {
            CityAQIPublishLive r = null;
            MyContext db = new MyContext();
            r = db.CityAQIPublishLives.FirstOrDefault(a => a.CityCode == cityid);

            db.Dispose();
            return r;
        }
示例#5
0
 public IEnumerable<AQIDataPublishLive> getCityStationAir(int cityid)
 {
     IEnumerable<AQIDataPublishLive> r = new AQIDataPublishLive[0];
     MyContext db = new MyContext();
     var q = db.Cities.Where(c => c.CityCode == cityid).FirstOrDefault();
     if (null != q)
     {
         string cityname = q.CityName;
         r = db.AQIDataPublishLives.Where(a => a.Area.Equals(cityname)).ToArray();
     }
     db.Dispose();
     return r;
 }
        // OnActionExecuted 在执行操作方法后由 ASP.NET MVC 框架调用。
        // OnActionExecuting 在执行操作方法之前由 ASP.NET MVC 框架调用。
        // OnResultExecuted 在执行操作结果后由 ASP.NET MVC 框架调用。
        // OnResultExecuting 在执行操作结果之前由 ASP.NET MVC 框架调用。
        /// <summary>
        /// 在执行操作方法之前由 ASP.NET MVC 框架调用。
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(HttpActionContext filterContext)
        {
            string token = System.Web.HttpContext.Current.Request.QueryString["token"];

            if (!System.Web.HttpContext.Current.Request.IsSecureConnection)
            {
                throw new WebApiHandleException(ResponseModelCode.SSLRequired, "请使用https协议请求");
            }
            else if (string.IsNullOrEmpty(token))
            {
                throw new WebApiHandleException(ResponseModelCode.NoTokenArgument, "却少参数token");
            }
            else
            {
                MyContext db = new MyContext();
                var q = db.users.FirstOrDefault(u => u.token.Equals(token));
                db.Dispose();
                if (null == q)
                    throw new WebApiHandleException(ResponseModelCode.Unauthorized, "token错误");
                else if (!q.isok.Value)
                    throw new WebApiHandleException(ResponseModelCode.Unauthorized, "token已被停用");
            }
            base.OnActionExecuting(filterContext);

            //var fcinfo = new filterContextInfo(filterContext);
            //fcinfo.actionName;//获取域名
            //fcinfo.controllerName;获取 controllerName 名称

            bool isstate = true;
            //islogin = false;
            if (isstate)//如果满足
            {
                //逻辑代码
                // filterContext.Result = new HttpUnauthorizedResult();//直接URL输入的页面地址跳转到登陆页
                // filterContext.Result = new RedirectResult("http://www.baidu.com");//也可以跳到别的站点
                //filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { Controller = "product", action = "Default" }));
            }
            else
            {
                // filterContext
            }
        }