private static string TypeEquals(BundleTypes type) { return(TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, type.ToString()), TableOperators.Or, TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, BundleTypes.ALL.ToString()) )); }
public WebhookRegistrationEntity(BundleTypes type, string webhook, bool shouldRecieveUpdates) { PartitionKey = type.ToString(); RowKey = System.Guid.NewGuid().ToString(); EncryptedWebhook = MachineKey.Protect(Encoding.UTF8.GetBytes(webhook)); ShouldRecieveUpdates = shouldRecieveUpdates; BundleType = (int)type; }
/// <summary> /// Restarts effect running after deserialization. Does not execute a MagicRound() tick. /// </summary> public virtual void Resume(EntityEffectManager.EffectSaveData_v1 effectData, EntityEffectManager manager, DaggerfallEntityBehaviour caster = null) { this.manager = manager; this.caster = caster; roundsRemaining = effectData.roundsRemaining; chanceSuccess = effectData.chanceSuccess; statMods = effectData.statMods; skillMods = effectData.skillMods; bundleGroup = effectData.bundleGroup; }
/// <summary> /// Generate EffectBundleSettings from classic SpellRecordData. /// </summary> /// <param name="spellRecordData">Classic spell record data.</param> /// <param name="bundleType">Type of bundle to create.</param> /// <param name="effectBundleSettingsOut">Effect bundle created by conversion.</param> /// <returns>True if successful, otherwise false.</returns> public bool ClassicSpellRecordDataToEffectBundleSettings(SpellRecord.SpellRecordData spellRecordData, BundleTypes bundleType, out EffectBundleSettings effectBundleSettingsOut) { // Spell record data must have effect records if (spellRecordData.effects == null || spellRecordData.effects.Length == 0) { effectBundleSettingsOut = new EffectBundleSettings(); return(false); } // Create bundle effectBundleSettingsOut = new EffectBundleSettings() { Version = EntityEffectBroker.CurrentSpellVersion, BundleType = bundleType, TargetType = ClassicTargetIndexToTargetType(spellRecordData.rangeType), ElementType = ClassicElementIndexToElementType(spellRecordData.element), Name = spellRecordData.spellName, IconIndex = spellRecordData.icon, Icon = new SpellIcon(), }; effectBundleSettingsOut.Icon.index = effectBundleSettingsOut.IconIndex; // Assign effects List <EffectEntry> foundEffects = new List <EffectEntry>(); for (int i = 0; i < spellRecordData.effects.Length; i++) { // Skip unused effect slots if (spellRecordData.effects[i].type == -1) { continue; } // Get entry from effect EffectEntry entry; if (!ClassicEffectRecordToEffectEntry(spellRecordData.effects[i], out entry)) { continue; } // Assign to valid effects foundEffects.Add(entry); } // Must have assigned at least one valid effect if (foundEffects.Count == 0) { return(false); } // Assign effects to bundle effectBundleSettingsOut.Effects = foundEffects.ToArray(); return(true); }
private static List <WebhookRegistrationEntity> GetAllWebhooksForBundleType(IQueryable <WebhookRegistrationEntity> existingWebhooks, BundleTypes type, bool isUpdate) { var webhooksForType = existingWebhooks.Where(x => x.PartitionKey == type.ToString()).ToList(); var discordHooks = webhooksForType.Where(x => x.WebhookType == (int)WebhookType.RawJson); if (isUpdate) { discordHooks = discordHooks.Where(x => x.ShouldRecieveUpdates); } return(discordHooks.ToList()); }
public static string pluralOf(BundleTypes type) => Enum.GetName(typeof(BundleTypes), type) + "s";
public static string singularOf(BundleTypes type) => Enum.GetName(typeof(BundleTypes), type);
public static IEnumerable <WebhookRegistrationEntity> GetAllWebhooksForBundleType(this CloudTable existingWebhooks, BundleTypes type, bool isUpdate) { var filter = TableQuery.CombineFilters( TypeEquals(type), TableOperators.And, TableQuery.GenerateFilterConditionForInt("WebhookType", QueryComparisons.Equal, (int)WebhookType.Discord) ); if (isUpdate) { filter = TableQuery.CombineFilters( filter, TableOperators.And, TableQuery.GenerateFilterConditionForBool("ShouldRecieveUpdates", QueryComparisons.Equal, true)); } var query = new TableQuery <WebhookRegistrationEntity>().Where(filter); TableContinuationToken token = null; do { // TODO: When we upgrade to C# 8.0, use await var queryResult = existingWebhooks.ExecuteQuerySegmentedAsync(query, token).GetAwaiter().GetResult(); foreach (var item in queryResult.Results) { yield return(item); } token = queryResult.ContinuationToken; } while (token != null); }
private static List <String> GetAllWebhooksForBundleType(IQueryable <WebhookRegistrationEntity> existingWebhooks, BundleTypes type, bool isUpdate) { var webhooksForType = existingWebhooks.Where(x => x.PartitionKey == type.ToString()); if (isUpdate) { webhooksForType = webhooksForType.Where(x => x.ShouldRecieveUpdates == true); } return(webhooksForType.ToList().Select(x => x.GetDecryptedWebhook()).ToList()); }