コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            LicenseFeature licenseFeature = db.LicenseFeatures.Find(id);

            db.LicenseFeatures.Remove(licenseFeature);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "Id,Name,IsAllowed")] LicenseFeature licenseFeature)
 {
     if (ModelState.IsValid)
     {
         db.Entry(licenseFeature).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(licenseFeature));
 }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Id,Name,IsAllowed")] LicenseFeature licenseFeature)
        {
            if (ModelState.IsValid)
            {
                db.LicenseFeatures.Add(licenseFeature);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(licenseFeature));
        }
コード例 #4
0
ファイル: LicenseUtils.cs プロジェクト: 842549829/Redis
        public static void ApprovedUsage(LicenseFeature licenseFeature, LicenseFeature requestedFeature, int actualUsage, string message)
        {
            var hasFeature = (requestedFeature & licenseFeature) == requestedFeature;

            if (hasFeature)
            {
                return;
            }

            //if (actualUsage > allowedUsage)
            //    throw new LicenseException(message.Fmt(allowedUsage)).Trace();
        }
コード例 #5
0
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();

            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text ||
                accessToken == null || accessType.FullName != "ServiceStack.ServiceClientBase+AccessToken")
            {
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);
            }

            PclExport.Instance.VerifyInAssembly(accessType, "ServiceStack.Client.dll");

            return(new AccessToken(requestedAccess));
        }
コード例 #6
0
        // GET: LicenseFeatures/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LicenseFeature licenseFeature = db.LicenseFeatures.Find(id);

            if (licenseFeature == null)
            {
                return(HttpNotFound());
            }
            return(View(licenseFeature));
        }
コード例 #7
0
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();

            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text ||
                accessToken == null || !_approved.__tokens.Contains(accessType.FullName))
            {
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);
            }

            PclExport.Instance.VerifyInAssembly(accessType, _approved.__dlls);

            return(new AccessToken(requestedAccess));
        }
コード例 #8
0
        /// <summary>
        /// The AddFeatureInfo method.
        /// </summary>
        /// <param name="licenseFeature">The <paramref name="licenseFeature"/> to add the info for.</param>
        /// <param name="licenseNode">The node to add the info to.</param>
        private static void AddFeatureInfo(LicenseFeature licenseFeature, TreeNode licenseNode)
        {
            var featureNode = licenseNode.Nodes.Add("Feature");

            // Use reflection to get each available property from the license feature.
            foreach (var prop in licenseFeature.GetType().GetProperties())
            {
                if (prop.Name == "CapabilityRequestEndpoint")
                {
                    continue;
                }

                // Get the value from the property.
                var val = prop.GetValue(licenseFeature, null);

                // Skip if the value is a List type.
                if (val.GetType() == typeof(List <Device>))
                {
                    continue;
                }

                // Generate a string based on the value type.
                string valList;
                if (val is DateTime)
                {
                    var dt = (DateTime)val;
                    valList = dt == default(DateTime) ? "None" : dt.ToString("G");
                }
                else
                {
                    valList = val.ToString();
                }

                // Add the value to the current node.
                featureNode.Nodes.Add($"{prop.Name}: {valList}");
            }

            if (licenseFeature.CommissionedDevices.Count == 0)
            {
                return;
            }

            // Add a new node for commissioned devices if they are present and populate it.
            var deviceNode = featureNode.Nodes.Add("Commissioned Devices");

            foreach (var device in licenseFeature.CommissionedDevices)
            {
                AddDeviceInfo(device, deviceNode);
            }
        }
コード例 #9
0
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();

            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text ||
                accessToken == null || accessType.FullName != "ServiceStack.ServiceClientBase+AccessToken")
            {
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);
            }

#if !(IOS || ANDROID || SILVERLIGHT || NETFX_CORE || WP)
            if (accessType.Assembly.ManifestModule.Name != "ServiceStack.Client.dll") //might get merged/mangled on alt platforms
            {
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);
            }
#endif

            return(new AccessToken(requestedAccess));
        }
コード例 #10
0
        public static void AssertValidUsage(LicenseFeature feature, QuotaType quotaType, int count)
        {
            var licensedFeatures = ActivatedLicenseFeatures();

            if ((LicenseFeature.All & licensedFeatures) == LicenseFeature.All) //Standard Usage
            {
                return;
            }

            //Free Quotas
            switch (feature)
            {
            case LicenseFeature.Redis:
                switch (quotaType)
                {
                case QuotaType.Types:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.RedisTypes, count, ErrorMessages.ExceededRedisTypes);
                    return;

                case QuotaType.RequestsPerHour:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.RedisRequestPerHour, count, ErrorMessages.ExceededRedisRequests);
                    return;
                }
                break;

            case LicenseFeature.OrmLite:
                switch (quotaType)
                {
                case QuotaType.Tables:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.OrmLiteTables, count, ErrorMessages.ExceededOrmLiteTables);
                    return;
                }
                break;

            case LicenseFeature.Aws:
                switch (quotaType)
                {
                case QuotaType.Tables:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.AwsTables, count, ErrorMessages.ExceededAwsTables);
                    return;
                }
                break;

            case LicenseFeature.ServiceStack:
                switch (quotaType)
                {
                case QuotaType.Operations:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.ServiceStackOperations, count, ErrorMessages.ExceededServiceStackOperations);
                    return;
                }
                break;

            case LicenseFeature.Admin:
                switch (quotaType)
                {
                case QuotaType.PremiumFeature:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.PremiumFeature, count, ErrorMessages.ExceededAdminUi);
                    return;
                }
                break;

            case LicenseFeature.Premium:
                switch (quotaType)
                {
                case QuotaType.PremiumFeature:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.PremiumFeature, count, ErrorMessages.ExceededPremiumFeature);
                    return;
                }
                break;
            }

            throw new LicenseException("Unknown Quota Usage: {0}, {1}".Fmt(feature, quotaType)).Trace();
        }
コード例 #11
0
        public static bool HasLicensedFeature(LicenseFeature feature)
        {
            var licensedFeatures = ActivatedLicenseFeatures();

            return((feature & licensedFeatures) == feature);
        }
コード例 #12
0
 internal AccessToken(LicenseFeature requested)
 {
     prevToken        = AccessTokenScope;
     AccessTokenScope = this;
     tempFeatures     = requested;
 }
コード例 #13
0
 public LicenseUseCase(LicenseFeature licenseFeature, QuotaType quotaType, int allowedLimit)
 {
     Feature      = licenseFeature;
     QuotaType    = quotaType;
     AllowedLimit = allowedLimit;
 }
コード例 #14
0
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();

            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text || accessToken == null)
            {
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest).Trace();
            }

            if (accessType.Name == "AccessToken" && accessType.GetAssembly().ManifestModule.Name.StartsWith("<")) //Smart Assembly
            {
                return(new AccessToken(requestedAccess));
            }

            if (!_approved.__tokens.Contains(accessType.FullName))
            {
                var errorDetails = " __token: '{0}', Assembly: '{1}'".Fmt(
                    accessType.Name,
                    accessType.GetAssembly().ManifestModule.Name);

                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest + errorDetails).Trace();
            }

            PclExport.Instance.VerifyInAssembly(accessType, _approved.__dlls);

            return(new AccessToken(requestedAccess));
        }
コード例 #15
0
 public static int GetLicenseFeature(int tmCid, LicenseFeature feature)
 {
     return(Native.TmcGetServerFeature(tmCid, (uint)feature));
 }
コード例 #16
0
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();

            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text || accessToken == null)
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);

            if (accessType.Name == "AccessToken" && accessType.GetAssembly().ManifestModule.Name.StartsWith("<")) //Smart Assembly
                return new AccessToken(requestedAccess);

            if (!_approved.__tokens.Contains(accessType.FullName))
            {
                var errorDetails = " __token: '{0}', Assembly: '{1}'".Fmt(
                    accessType.Name,
                    accessType.GetAssembly().ManifestModule.Name);

                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest + errorDetails);
            }

            PclExport.Instance.VerifyInAssembly(accessType, _approved.__dlls);

            return new AccessToken(requestedAccess);
        }
コード例 #17
0
        public static void AssertValidUsage(LicenseFeature feature, QuotaType quotaType, int count)
        {
            var licensedFeatures = ActivatedLicenseFeatures();
            if ((LicenseFeature.All & licensedFeatures) == LicenseFeature.All) //Standard Usage
                return;

            if (AccessTokenScope != null)
            {
                if ((feature & AccessTokenScope.tempFeatures) == feature)
                    return;
            }

            //Free Quotas
            switch (feature)
            {
                case LicenseFeature.Text:
                    switch (quotaType)
                    {
                        case QuotaType.Types:
                            ApprovedUsage(licensedFeatures, feature, FreeQuotas.TextTypes, count, ErrorMessages.ExceededTextTypes);
                            return;
                    }
                    break;

                case LicenseFeature.Redis:
                    switch (quotaType)
                    {
                        case QuotaType.Types:
                            ApprovedUsage(licensedFeatures, feature, FreeQuotas.RedisTypes, count, ErrorMessages.ExceededRedisTypes);
                            return;
                        case QuotaType.RequestsPerHour:
                            ApprovedUsage(licensedFeatures, feature, FreeQuotas.RedisRequestPerHour, count, ErrorMessages.ExceededRedisRequests);
                            return;
                    }
                    break;

                case LicenseFeature.OrmLite:
                    switch (quotaType)
                    {
                        case QuotaType.Tables:
                            ApprovedUsage(licensedFeatures, feature, FreeQuotas.OrmLiteTables, count, ErrorMessages.ExceededOrmLiteTables);
                            return;
                    }
                    break;

                case LicenseFeature.ServiceStack:
                    switch (quotaType)
                    {
                        case QuotaType.Operations:
                            ApprovedUsage(licensedFeatures, feature, FreeQuotas.ServiceStackOperations, count, ErrorMessages.ExceededServiceStackOperations);
                            return;
                    }
                    break;

                case LicenseFeature.Admin:
                    switch (quotaType)
                    {
                        case QuotaType.PremiumFeature:
                            ApprovedUsage(licensedFeatures, feature, FreeQuotas.PremiumFeature, count, ErrorMessages.ExceededAdminUi);
                            return;
                    }
                    break;

                case LicenseFeature.Premium:
                    switch (quotaType)
                    {
                        case QuotaType.PremiumFeature:
                            ApprovedUsage(licensedFeatures, feature, FreeQuotas.PremiumFeature, count, ErrorMessages.ExceededPremiumFeature);
                            return;
                    }
                    break;
            }

            throw new LicenseException("Unknown Quota Usage: {0}, {1}".Fmt(feature, quotaType));
        }
コード例 #18
0
        public static void ApprovedUsage(LicenseFeature licenseFeature, LicenseFeature requestedFeature,
            int allowedUsage, int actualUsage, string message)
        {
            var hasFeature = (requestedFeature & licenseFeature) == requestedFeature;
            if (hasFeature)
                return;

            if (actualUsage > allowedUsage)
                throw new LicenseException(message.Fmt(allowedUsage));
        }
コード例 #19
0
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();
            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text
                || accessToken == null || accessType.FullName != "ServiceStack.ServiceClientBase+AccessToken")
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);

#if !(IOS || ANDROID || SILVERLIGHT || NETFX_CORE || WP)
            if (accessType.Assembly.ManifestModule.Name != "ServiceStack.Client.dll") //might get merged/mangled on alt platforms
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);
#endif

            return new AccessToken(requestedAccess);
        }
コード例 #20
0
 public static bool HasLicensedFeature(LicenseFeature feature)
 {
     var licensedFeatures = ActivatedLicenseFeatures();
     return (feature & licensedFeatures) == feature;
 }
コード例 #21
0
ファイル: LicenseUtils.cs プロジェクト: SeanmanX/opandroid
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();

            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text
                || accessToken == null || !_approved.__tokens.Contains(accessType.FullName))
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);

            PclExport.Instance.VerifyInAssembly(accessType, _approved.__dlls);

            return new AccessToken(requestedAccess);
        }
コード例 #22
0
 internal AccessToken(LicenseFeature requested)
 {
     prevToken = AccessTokenScope;
     AccessTokenScope = this;
     tempFeatures = requested;
 }
コード例 #23
0
ファイル: LicenseUtils.cs プロジェクト: fengmin0722/Mainline
        public static void AssertValidUsage(LicenseFeature feature, QuotaType quotaType, int count)
        {
            //去掉所有的License的限制https://servicestack.net/download
            //xupearl
            return;

            var licensedFeatures = ActivatedLicenseFeatures();

            if ((LicenseFeature.All & licensedFeatures) == LicenseFeature.All) //Standard Usage
            {
                return;
            }

            if (AccessTokenScope != null)
            {
                if ((feature & AccessTokenScope.tempFeatures) == feature)
                {
                    return;
                }
            }

            //Free Quotas
            switch (feature)
            {
            case LicenseFeature.Text:
                switch (quotaType)
                {
                case QuotaType.Types:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.TextTypes, count, ErrorMessages.ExceededTextTypes);
                    return;
                }
                break;

            case LicenseFeature.Redis:
                switch (quotaType)
                {
                case QuotaType.Types:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.RedisTypes, count, ErrorMessages.ExceededRedisTypes);
                    return;

                case QuotaType.RequestsPerHour:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.RedisRequestPerHour, count, ErrorMessages.ExceededRedisRequests);
                    return;
                }
                break;

            case LicenseFeature.OrmLite:
                switch (quotaType)
                {
                case QuotaType.Tables:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.OrmLiteTables, count, ErrorMessages.ExceededOrmLiteTables);
                    return;
                }
                break;

            case LicenseFeature.ServiceStack:
                switch (quotaType)
                {
                case QuotaType.Operations:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.ServiceStackOperations, count, ErrorMessages.ExceededServiceStackOperations);
                    return;
                }
                break;

            case LicenseFeature.Admin:
                switch (quotaType)
                {
                case QuotaType.PremiumFeature:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.PremiumFeature, count, ErrorMessages.ExceededAdminUi);
                    return;
                }
                break;

            case LicenseFeature.Premium:
                switch (quotaType)
                {
                case QuotaType.PremiumFeature:
                    ApprovedUsage(licensedFeatures, feature, FreeQuotas.PremiumFeature, count, ErrorMessages.ExceededPremiumFeature);
                    return;
                }
                break;
            }

            throw new LicenseException("Unknown Quota Usage: {0}, {1}".Fmt(feature, quotaType));
        }
コード例 #24
0
 public LicenseUseCase(LicenseFeature licenseFeature, QuotaType quotaType, int allowedLimit)
 {
     Feature = licenseFeature;
     QuotaType = quotaType;
     AllowedLimit = allowedLimit;
 }
コード例 #25
0
        public static IDisposable RequestAccess(object accessToken, LicenseFeature srcFeature, LicenseFeature requestedAccess)
        {
            var accessType = accessToken.GetType();
            if (srcFeature != LicenseFeature.Client || requestedAccess != LicenseFeature.Text
                || accessToken == null || accessType.FullName != "ServiceStack.ServiceClientBase+AccessToken")
                throw new LicenseException(ErrorMessages.UnauthorizedAccessRequest);

            PclExport.Instance.VerifyInAssembly(accessType, "ServiceStack.Client.dll");

            return new AccessToken(requestedAccess);
        }