public ActionResult DeleteConfirmed(int id) { LicenseFeature licenseFeature = db.LicenseFeatures.Find(id); db.LicenseFeatures.Remove(licenseFeature); db.SaveChanges(); return(RedirectToAction("Index")); }
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)); }
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)); }
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(); }
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)); }
// 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)); }
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)); }
/// <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); } }
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)); }
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(); }
public static bool HasLicensedFeature(LicenseFeature feature) { var licensedFeatures = ActivatedLicenseFeatures(); return((feature & licensedFeatures) == feature); }
internal AccessToken(LicenseFeature requested) { prevToken = AccessTokenScope; AccessTokenScope = this; tempFeatures = requested; }
public LicenseUseCase(LicenseFeature licenseFeature, QuotaType quotaType, int allowedLimit) { Feature = licenseFeature; QuotaType = quotaType; AllowedLimit = allowedLimit; }
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)); }
public static int GetLicenseFeature(int tmCid, LicenseFeature feature) { return(Native.TmcGetServerFeature(tmCid, (uint)feature)); }
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); }
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)); }
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)); }
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); }
public static bool HasLicensedFeature(LicenseFeature feature) { var licensedFeatures = ActivatedLicenseFeatures(); return (feature & licensedFeatures) == feature; }
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); }
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)); }
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); }