/// <summary> /// Sets the additional receiver information. /// </summary> /// <returns>Task.</returns> private async Task SetAdditionalReceiverInfo() { // Get information about the topic/queue for the receiver. if (ReceiverInfo.EntityType == EntityType.Topic) { if (ReceiverInfo.CreateEntityIfNotExists) { await Task.Run(() => ManagerClient.CreateTopicIfNotExists(ReceiverInfo.EntityName, ReceiverInfo.EntitySubscriptionName, ReceiverInfo.EntityFilter)); } var topic = await ManagerClient.GetTopicAsync(ReceiverInfo.EntityName); var subscription = await ManagerClient.GetSubscriptionAsync(ReceiverInfo.EntityName, ReceiverInfo.EntitySubscriptionName); ReceiverInfo.MaxEntitySizeMb = topic.MaxSizeInMB; ReceiverInfo.MaxLockDuration = subscription.LockDuration; } else { if (ReceiverInfo.CreateEntityIfNotExists) { await Task.Run(() => ManagerClient.CreateQueueIfNotExists(ReceiverInfo.EntityName)); } var queue = await ManagerClient.GetQueueAsync(ReceiverInfo.EntityName); ReceiverInfo.MaxLockDuration = queue.LockDuration; ReceiverInfo.MaxEntitySizeMb = queue.MaxSizeInMB; } }
public static string SaveLogindata(string account, string platformCode, string extraData = "", string kgext = "") { string returnCode = ""; try { ManagerClient reader = new ManagerClient(); var user = reader.GetUserByAccount(account, GetRealIP()); if (user != null) { var sessionId = ShareUtil.GenerateComb().ToString(); SetFormsAuthentication(account, Guid.Empty, "", 1, sessionId); //转页 returnCode = UAErrorCode.ErrOK; } else { returnCode = UAErrorCode.ErrNoUser; } } catch (Exception ex) { SystemlogMgr.Error("UAHelper SaveLogindata", ex); returnCode = UAErrorCode.ErrOther; } return(returnCode); }
public void RejectUpdateResourceOwnerClaims() { Option.Error response = null !; "When updating resource owner password".x( async() => { response = await ManagerClient.UpdateResourceOwnerClaims( new UpdateResourceOwnerClaimsRequest { Claims = new[] { new ClaimData { Type = "something", Value = "else" } }, Subject = "administrator" }, GrantedToken.AccessToken) .ConfigureAwait(false) as Option.Error; }); "Then response has error.".x( () => { Assert.Equal(HttpStatusCode.Forbidden, response.Details.Status); }); }
public void SuccessUpdateResourceOwnerPassword() { "When adding resource owner".x( async() => { var response = await ManagerClient.AddResourceOwner( new AddResourceOwnerRequest { Password = "******", Subject = "test" }, GrantedToken.AccessToken) .ConfigureAwait(false) as Option <AddResourceOwnerResponse> .Result; Assert.NotNull(response); }); "Then can update resource owner password".x( async() => { var response = await ManagerClient.UpdateResourceOwnerPassword( new UpdateResourceOwnerPasswordRequest { Subject = "test", Password = "******" }, GrantedToken.AccessToken) .ConfigureAwait(false); Assert.IsType <Option.Success>(response); }); }
/// <summary> /// Sets the additional sender information. /// </summary> /// <returns>Task.</returns> private async Task SetAdditionalSenderInfo() { // Get information about the topic/queue for the sender. if (SenderInfo.EntityType == EntityType.Topic) { if (SenderInfo.CreateEntityIfNotExists) { await Task.Run(() => ManagerClient.CreateTopicIfNotExists(SenderInfo.EntityName)); } var queue = await ManagerClient.GetTopicAsync(SenderInfo.EntityName); SenderInfo.MaxEntitySizeMb = queue.MaxSizeInMB; } else { if (SenderInfo.CreateEntityIfNotExists) { await Task.Run(() => ManagerClient.CreateQueueIfNotExists(SenderInfo.EntityName)); } var queue = await ManagerClient.GetQueueAsync(SenderInfo.EntityName); SenderInfo.MaxEntitySizeMb = queue.MaxSizeInMB; } SenderInfo.MaxMessageBatchSizeBytes = IsPremiumTier ? 1024000 : 256000; }
public void SuccessAddResourceOwner() { string subject = null !; "When adding resource owner".x( async() => { var response = await ManagerClient.AddResourceOwner( new AddResourceOwnerRequest { Password = "******", Subject = "test" }, GrantedToken.AccessToken) .ConfigureAwait(false) as Option <AddResourceOwnerResponse> .Result; Assert.NotNull(response); subject = response.Item.Subject; }); "Then resource owner is local account".x( async() => { var response = await ManagerClient.GetResourceOwner("test", GrantedToken.AccessToken) .ConfigureAwait(false) as Option <ResourceOwner> .Result; Assert.NotNull(response); Assert.True(response.Item.IsLocalAccount); }); }
public BattleHostService(ILogger <BattleHostService> logger, ManagerClient client, IManagerConnection connection, IHostApplicationLifetime appLifetime) { this.logger = logger; this.client = client; this.connection = connection; this.appLifetime = appLifetime; }
/// <summary> /// Gets a count for the specified queue/topic. /// </summary> /// <param name="entityName">Name of the entity to count on.</param> /// <returns>Task<EntityMessageCount>.</returns> public async Task <EntityMessageCount> EntityCount(string entityName) { var isTopic = await ManagerClient.IsTopic(entityName); return(isTopic ? await ManagerClient.GetTopicMessageCount(entityName) : await ManagerClient.GetQueueMessageCount(entityName)); }
/// <summary> /// Deletes a topic/queue entity. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="entityName">Name of the entity to delete.</param> /// <returns>Task.</returns> public async Task DeleteEntity(EntityType entityType, string entityName) { if (entityType == EntityType.Topic) { await ManagerClient.DeleteTopicIfExists(entityName); } else { await ManagerClient.DeleteQueueIfExists(entityName); } }
public void RejectedScopeLoad() { Option <Scope> .Error scope = null !; "When requesting existing scope".x( async() => { scope = await ManagerClient.GetScope("test", GrantedToken.AccessToken) .ConfigureAwait(false) as Option <Scope> .Error; }); "then error is returned".x(() => { Assert.Equal(HttpStatusCode.Forbidden, scope.Details.Status); }); }
/// <summary> /// Purges the entity of all messages (very crude - will purge all queues). /// </summary> /// <param name="entityName">Name of the entity to purge.</param> /// <param name="preserveState">if set to <c>true</c> [preserve state while purging] - ONLY RELEVANT FOR TOPICS.</param> /// <returns>Task.</returns> public async Task EntityFullPurge(string entityName, bool preserveState = true) { var isTopic = await ManagerClient.IsTopic(entityName); if (isTopic) { await ManagerClient.PurgeTopic(entityName, preserveState); } else { await ManagerClient.PurgeQueue(entityName); } }
/// <summary> /// Deletes a topic subscription entity. /// </summary> /// <param name="entityName">Name of the topic entity.</param> /// <returns>Task.</returns> public async Task DeleteEntity(string entityName) { var isTopic = await ManagerClient.IsTopic(entityName); if (isTopic) { await ManagerClient.DeleteTopicIfExists(entityName); } else { await ManagerClient.DeleteQueueIfExists(entityName); } }
/// <summary> /// Check the queue entity exists. /// </summary> /// <param name="entityName">The entity name to check exists.</param> /// <returns>Boolean true if exists and false if not.</returns> public async Task <bool> EntityExists(string entityName) { var isTopic = await ManagerClient.IsTopic(entityName); if (isTopic) { return(await ManagerClient.TopicExistsAsync(entityName)); } else { return(await ManagerClient.QueueExistsAsync(entityName)); } }
public void NotifyManagerStarted(string managerAddress, string exchangeCode) { try { if (this.StateServer.IsUseManager) { ManagerClient.Start(managerAddress, exchangeCode); } } catch (Exception ex) { AppDebug.LogEvent("StateServer.Service2.NotifyManagerStarted", ex.ToString(), EventLogEntryType.Error); } }
public static void Main(string[] args) { database.Populate(); //enter if terminal should be provider if (PROVIDER_TERMINAL) { ProviderClient client = new ProviderClient(); } //enter if terminal should be provider if (MANAGER_TERMINAL) { ManagerClient client = new ManagerClient(); } }
/// <summary>Scotches the namespace by deleting all topics and queues.</summary> public async Task ScotchNamespace() { var topics = await ManagerClient.GetTopicsAsync(); var queues = await ManagerClient.GetQueuesAsync(); foreach (var topic in topics) { await ManagerClient.DeleteTopicIfExists(topic.Path); } foreach (var queue in queues) { await ManagerClient.DeleteQueueIfExists(queue.Path); } }
static void Main(string[] args) { var managerClient = new ManagerClient(); managerClient.Start(); var vmManager = new VirtualMachineManager(); vmManager.AddVirtualMachine("test"); managerClient.QueueCommand(new ManagerClientCommand() { IPAddress = IPAddress.Parse("127.0.0.1"), Command = new KeyValuePair <string, string>("PrimaryUser", "bestincode") }); }
/// <summary> /// Creates a new Queue, Topic and or Subscription. /// </summary> /// <param name="config">The config with the creation details, <see cref="ServiceBusEntityConfig"/>.</param> /// <exception cref="NullReferenceException"></exception> public async Task CreateEntity(IEntityConfig config) { if (!(config is ServiceBusEntityConfig sbConfig)) { throw new InvalidOperationException("ServiceBusCreateEntityConfig is required "); } if (sbConfig.EntityType == EntityType.Topic) { await Task.Run(() => ManagerClient.CreateTopicIfNotExists(sbConfig.EntityName, sbConfig.EntitySubscriptionName, sbConfig.SqlFilter)); } else { await Task.Run(() => ManagerClient.CreateQueueIfNotExists(sbConfig.EntityName)); } }
/// <summary> /// Gets the sender message count. /// </summary> /// <returns>Task<EntityMessageCount>.</returns> /// <exception cref="InvalidOperationException">Sender entity has not been configured</exception> /// <exception cref="System.InvalidOperationException">Sender entity has not been configured</exception> public async Task <EntityMessageCount> GetSenderMessageCount() { if (SenderInfo == null) { throw new InvalidOperationException("Sender entity has not been configured"); } if (SenderInfo.EntityType == EntityType.Queue) { return(await ManagerClient.GetQueueMessageCount(SenderInfo.EntityName)); } else { return(await ManagerClient.GetTopicMessageCount(SenderInfo.EntityName)); } }
/// <summary> /// Gets the sender entity usage percentage. /// </summary> /// <returns>Task<System.Double>.</returns> /// <exception cref="InvalidOperationException">Sender entity has not been configured</exception> /// <exception cref="System.InvalidOperationException">Sender entity has not been configured</exception> public async Task <decimal> GetSenderEntityUsagePercentage() { if (SenderInfo == null) { throw new InvalidOperationException("Sender entity has not been configured"); } if (SenderInfo.EntityType == EntityType.Queue) { return(await ManagerClient.GetQueueUsagePercentage(SenderInfo.EntityName, SenderInfo.MaxEntitySizeBytes)); } else { return(await ManagerClient.GetTopicUsagePercentage(SenderInfo.EntityName, SenderInfo.MaxEntitySizeBytes)); } }
public void SuccessScopeLoad() { Scope scope = null !; "When requesting existing scope".x( async() => { var response = await ManagerClient.GetScope("test", GrantedToken.AccessToken) .ConfigureAwait(false) as Option <Scope> .Result; scope = response !.Item; Assert.NotNull(scope); }); "then scope information is returned".x(() => { Assert.Equal("test", scope.Name); }); }
public void RejectedListResourceOwners() { Option <ResourceOwner[]> .Error response = null !; "When listing resource owners".x( async() => { response = await ManagerClient.GetAllResourceOwners(GrantedToken.AccessToken) .ConfigureAwait(false) as Option <ResourceOwner[]> .Error; }); "Then response has error.".x( () => { Assert.Equal(HttpStatusCode.Forbidden, response.Details.Status); }); }
public void RejectedAddScope() { Option <Scope> .Error scope = null !; "When adding new scope".x( async() => { scope = await ManagerClient.AddScope( new Scope { Name = "test", Claims = new[] { "openid" } }, GrantedToken.AccessToken) .ConfigureAwait(false) as Option <Scope> .Error; }); "then error is returned".x(() => { Assert.Equal(HttpStatusCode.Forbidden, scope.Details.Status); }); }
public void SuccessfulClientListing() { Client[] clients = null !; "When getting all clients".x( async() => { var response = await ManagerClient.GetAllClients(GrantedToken.AccessToken).ConfigureAwait(false) as Option <Client[]> .Result; Assert.NotNull(response); clients = response !.Item; }); "Then contains list of clients".x(() => { Assert.All(clients, x => { Assert.NotNull(x.ClientId); }); }); }
static void Main(string[] args) { ManagerRol ctx = new ManagerRol(); ManagerClient client = new ManagerClient(); ManagerUsuario user = new ManagerUsuario(); ManagerPedidos pedidosM = new ManagerPedidos(); ManagerPlatos managerPlatos = new ManagerPlatos(); var rol = new Roles() { NombreRol = "Cajero" }; ctx.Create(rol); var usuario = new Usuario() { Nombre = "gumu", Password = "******", Roles = rol }; user.Create(usuario); var clientes = new Cliente() { Nit = 1233, Nombre = "pepe" }; client.Create(clientes); var platos = new Platos() { Nombre = "tranca", Precio = 10 }; managerPlatos.Create(platos); var pedidos = new Pedidos() { Usuario = usuario, cliente = clientes, Estados = Estados.INICIO, FechaPedido = DateTime.Now }; pedidosM.Create(pedidos); }
public void RejectDeleteResourceOwner() { Option.Error response = null !; "When deleting resource owner".x( async() => { response = (await ManagerClient.DeleteResourceOwner( "administrator", GrantedToken.AccessToken) .ConfigureAwait(false) as Option.Error) !; }); "Then response has error.".x( () => { Assert.Equal(HttpStatusCode.Forbidden, response.Details.Status); }); }
/// <summary> /// Initialises this instance. /// </summary> /// <returns>Task.</returns> internal async Task Initialise() { var instanceInfo = await ManagerClient.GetNamespaceInfoAsync(); InstanceName = instanceInfo.Name; IsPremiumTier = instanceInfo.MessagingSku == MessagingSku.Premium; EnableAutoBackOff = _entityConfig.EnableAutobackOff; if (_entityConfig.Receiver != null) { ReceiverInfo = _entityConfig.Receiver.GetBase(); await SetAdditionalReceiverInfo(); } if (_entityConfig.Sender != null) { SenderInfo = _entityConfig.Sender.GetBase(); await SetAdditionalSenderInfo(); } }
public void RejectAddResourceOwner() { Option <AddResourceOwnerResponse> .Error response = null !; "When adding resource owner".x( async() => { response = await ManagerClient.AddResourceOwner( new AddResourceOwnerRequest { Password = "******", Subject = "test" }, GrantedToken.AccessToken) .ConfigureAwait(false) as Option <AddResourceOwnerResponse> .Error; }); "Then response has error.".x( () => { Assert.Equal(HttpStatusCode.Forbidden, response.Details.Status); }); }
public void RejectUpdateResourceOwnerPassword() { Option.Error response = null !; "When updating resource owner password".x( async() => { response = await ManagerClient.UpdateResourceOwnerPassword( new UpdateResourceOwnerPasswordRequest { Password = "******", Subject = "administrator" }, GrantedToken.AccessToken) .ConfigureAwait(false) as Option.Error; }); "Then response has error.".x( () => { Assert.Equal(HttpStatusCode.Forbidden, response.Details.Status); }); }
public void SuccessfulAddClient() { "When adding client".x( async() => { var client = new Client { ClientId = "test_client", ClientName = "Test Client", Secrets = new[] { new ClientSecret { Type = ClientSecretTypes.SharedSecret, Value = "secret" } }, AllowedScopes = new[] { "api" }, RedirectionUrls = new[] { new Uri("http://localhost/callback"), }, ApplicationType = ApplicationTypes.Native, GrantTypes = new[] { GrantTypes.ClientCredentials }, JsonWebKeys = TestKeys.SuperSecretKey.CreateSignatureJwk().ToSet() }; var response = await ManagerClient.AddClient(client, GrantedToken.AccessToken) .ConfigureAwait(false); }); }