Ejemplo n.º 1
0
        protected override void OnAuthentication(System.Web.Mvc.Filters.AuthenticationContext filterContext)
        {
            filterContext.CheckNull("AuthorizationContext is not null");
            base.OnAuthentication(filterContext);
            IPrincipal user = filterContext.HttpContext.User;

            var lstAttCtr = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(UGAuthorizeAttribute), false);
            var lstAttAcction = filterContext.ActionDescriptor.GetCustomAttributes(typeof(UGAuthorizeAttribute), false);
            var lstAttAjaxAcction = filterContext.ActionDescriptor.GetCustomAttributes(typeof(UGFollowAuthorizeAttribute), false);
            
            if (user.Identity.IsAuthenticated)
            {
                WorkContext = new WorkContext(user.GetUserName(), filterContext);
                if (!WorkContext.IsInited(user.Identity.Name))
                {
                    WorkContext.Init();
                    if(WorkContext.CurrentUser==null)
                    {
                        OwinContext.Authentication.SignOut();
                        WorkContext = null;
                        //redirect to Loginform
                        filterContext.Result = new RedirectToRouteResult(RouteLogin(filterContext.HttpContext.Request.RawUrl));
                    }
                }
                var attCtrKey = lstAttCtr.Length > 0 ? (lstAttCtr.First() as UGAuthorizeAttribute).Key : "";
                var attCtrName = lstAttCtr.Length > 0 ? (lstAttCtr.First() as UGAuthorizeAttribute).Name : "";
                if (lstAttAcction.Length > 0)
                {
                    UGAuthorizeAttribute att = lstAttAcction.First() as UGAuthorizeAttribute;
                    //Check permission
                    if (!WorkContext.CurrentUser.HasPermission(att.Key))
                    {
                        //redirect to Accecc Diney
                        filterContext.Result = new RedirectToRouteResult(RouteAccessDenied(attCtrName+"|"+att.Name));
                    }
                }
                else if (lstAttAjaxAcction.Length > 0)
                {
                    UGFollowAuthorizeAttribute att = lstAttAjaxAcction.First() as UGFollowAuthorizeAttribute;
                    //Check permission
                    if (!WorkContext.CurrentUser.HasPermission(att.FollowKey))
                    {
                        //redirect to Accecc Diney
                        filterContext.Result = new RedirectToRouteResult(RouteAccessDenied(string.Format("Bạn không có quyền vào chức năng: 'Controller|{0}-Acction|{1}'", attCtrKey, att.FollowKey)));
                    }
                }
            }
            else
            {
                if (lstAttAcction.Length > 0)
                {
                    //redirect to Loginform
                    filterContext.Result = new RedirectToRouteResult(RouteLogin(filterContext.HttpContext.Request.RawUrl));
                }
            }

        }
 public override System.Data.Spatial.DbGeometry Buffer(System.Data.Spatial.DbGeometry geometryValue, double distance)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STBuffer.Value.Invoke(sqlGeometryValue, new object[] { distance });
     return this.GeometryFromProviderValue(result);
 }
 public override bool Relate(System.Data.Spatial.DbGeometry geometryValue1, System.Data.Spatial.DbGeometry geometryValue2, string matrix)
 {
     geometryValue1.CheckNull("geometryValue1");
     object sqlGeometryValue1 = ConvertToSqlValue(geometryValue1, "geometryValue1");
     object sqlGeometryValue2 = ConvertToSqlValue(geometryValue2, "geometryValue2");
     object result = imi_SqlGeometry_STRelate.Value.Invoke(sqlGeometryValue1, new object[] { sqlGeometryValue2, matrix });
     return ConvertSqlBooleanToBoolean(result);
 }
 public override bool Overlaps(System.Data.Spatial.DbGeometry geometryValue1, System.Data.Spatial.DbGeometry geometryValue2)
 {
     geometryValue1.CheckNull("geometryValue1");
     object sqlGeometryValue1 = ConvertToSqlValue(geometryValue1, "geometryValue1");
     object sqlGeometryValue2 = ConvertToSqlValue(geometryValue2, "geometryValue2");
     object result = imi_SqlGeometry_STOverlaps.Value.Invoke(sqlGeometryValue1, new object[] { sqlGeometryValue2 });
     return ConvertSqlBooleanToBoolean(result);
 }
 public override string AsGml(System.Data.Spatial.DbGeography geographyValue)
 {
     geographyValue.CheckNull("geographyValue");
     object sqlGeographyValue = ConvertToSqlValue(geographyValue, "geographyValue");
     object result = imi_SqlGeography_AsGml.Value.Invoke(sqlGeographyValue, new object[] {  });
     return ConvertSqlXmlToString(result);
 }
 public override int? GetInteriorRingCount(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STNumInteriorRing.Value.Invoke(sqlGeometryValue, new object[] {  });
     return ConvertSqlInt32ToNullableInt(result);
 }
 public override double? GetArea(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STArea.Value.Invoke(sqlGeometryValue, new object[] {  });
     return ConvertSqlDoubleToNullableDouble(result);
 }
 public override double? GetMeasure(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = ipi_SqlGeometry_M.Value.GetValue(sqlGeometryValue, null);
     return ConvertSqlDoubleToNullableDouble(result);
 }
 public override int GetCoordinateSystemId(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = ipi_SqlGeometry_STSrid.Value.GetValue(sqlGeometryValue, null);
     return ConvertSqlInt32ToInt(result);
 }
 public override System.Data.Spatial.DbGeography PointAt(System.Data.Spatial.DbGeography geographyValue, int nValue)
 {
     geographyValue.CheckNull("geographyValue");
     object sqlGeographyValue = ConvertToSqlValue(geographyValue, "geographyValue");
     object result = imi_SqlGeography_STPointN.Value.Invoke(sqlGeographyValue, new object[] { nValue });
     return this.GeographyFromProviderValue(result);
 }
 public override int? GetPointCount(System.Data.Spatial.DbGeography geographyValue)
 {
     geographyValue.CheckNull("geographyValue");
     object sqlGeographyValue = ConvertToSqlValue(geographyValue, "geographyValue");
     object result = imi_SqlGeography_STNumPoints.Value.Invoke(sqlGeographyValue, new object[] {  });
     return ConvertSqlInt32ToNullableInt(result);
 }
 public override double? GetElevation(System.Data.Spatial.DbGeography geographyValue)
 {
     geographyValue.CheckNull("geographyValue");
     object sqlGeographyValue = ConvertToSqlValue(geographyValue, "geographyValue");
     object result = ipi_SqlGeography_Z.Value.GetValue(sqlGeographyValue, null);
     return ConvertSqlDoubleToNullableDouble(result);
 }
 public override System.Data.Spatial.DbGeography Union(System.Data.Spatial.DbGeography geographyValue1, System.Data.Spatial.DbGeography geographyValue2)
 {
     geographyValue1.CheckNull("geographyValue1");
     object sqlGeographyValue1 = ConvertToSqlValue(geographyValue1, "geographyValue1");
     object sqlGeographyValue2 = ConvertToSqlValue(geographyValue2, "geographyValue2");
     object result = imi_SqlGeography_STUnion.Value.Invoke(sqlGeographyValue1, new object[] { sqlGeographyValue2 });
     return this.GeographyFromProviderValue(result);
 }
 public override bool Disjoint(System.Data.Spatial.DbGeography geographyValue1, System.Data.Spatial.DbGeography geographyValue2)
 {
     geographyValue1.CheckNull("geographyValue1");
     object sqlGeographyValue1 = ConvertToSqlValue(geographyValue1, "geographyValue1");
     object sqlGeographyValue2 = ConvertToSqlValue(geographyValue2, "geographyValue2");
     object result = imi_SqlGeography_STDisjoint.Value.Invoke(sqlGeographyValue1, new object[] { sqlGeographyValue2 });
     return ConvertSqlBooleanToBoolean(result);
 }
 public override bool GetIsEmpty(System.Data.Spatial.DbGeography geographyValue)
 {
     geographyValue.CheckNull("geographyValue");
     object sqlGeographyValue = ConvertToSqlValue(geographyValue, "geographyValue");
     object result = imi_SqlGeography_STIsEmpty.Value.Invoke(sqlGeographyValue, new object[] {  });
     return ConvertSqlBooleanToBoolean(result);
 }
 public override double Distance(System.Data.Spatial.DbGeometry geometryValue1, System.Data.Spatial.DbGeometry geometryValue2)
 {
     geometryValue1.CheckNull("geometryValue1");
     object sqlGeometryValue1 = ConvertToSqlValue(geometryValue1, "geometryValue1");
     object sqlGeometryValue2 = ConvertToSqlValue(geometryValue2, "geometryValue2");
     object result = imi_SqlGeometry_STDistance.Value.Invoke(sqlGeometryValue1, new object[] { sqlGeometryValue2 });
     return ConvertSqlDoubleToDouble(result);
 }
 public override System.Data.Spatial.DbGeometry SymmetricDifference(System.Data.Spatial.DbGeometry geometryValue1, System.Data.Spatial.DbGeometry geometryValue2)
 {
     geometryValue1.CheckNull("geometryValue1");
     object sqlGeometryValue1 = ConvertToSqlValue(geometryValue1, "geometryValue1");
     object sqlGeometryValue2 = ConvertToSqlValue(geometryValue2, "geometryValue2");
     object result = imi_SqlGeometry_STSymDifference.Value.Invoke(sqlGeometryValue1, new object[] { sqlGeometryValue2 });
     return this.GeometryFromProviderValue(result);
 }
 public override string GetSpatialTypeName(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STGeometryType.Value.Invoke(sqlGeometryValue, new object[] {  });
     return ConvertSqlStringToString(result);
 }
 public override bool? GetIsRing(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STIsRing.Value.Invoke(sqlGeometryValue, new object[] {  });
     return ConvertSqlBooleanToNullableBoolean(result);
 }
 public override int GetDimension(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STDimension.Value.Invoke(sqlGeometryValue, new object[] {  });
     return ConvertSqlInt32ToInt(result);
 }
 public override System.Data.Spatial.DbGeometry GetPointOnSurface(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STPointOnSurface.Value.Invoke(sqlGeometryValue, new object[] {  });
     return this.GeometryFromProviderValue(result);
 }
 public override byte[] AsBinary(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STAsBinary.Value.Invoke(sqlGeometryValue, new object[] {  });
     return ConvertSqlBytesToBinary(result);
 }
 public override System.Data.Spatial.DbGeometry InteriorRingAt(System.Data.Spatial.DbGeometry geometryValue, int nValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STInteriorRingN.Value.Invoke(sqlGeometryValue, new object[] { nValue });
     return this.GeometryFromProviderValue(result);
 }
 public override string AsText(System.Data.Spatial.DbGeometry geometryValue)
 {
     geometryValue.CheckNull("geometryValue");
     object sqlGeometryValue = ConvertToSqlValue(geometryValue, "geometryValue");
     object result = imi_SqlGeometry_STAsText.Value.Invoke(sqlGeometryValue, new object[] {  });
     return ConvertSqlCharsToString(result);
 }