/// <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;
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            });
        }
コード例 #4
0
        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;
        }
コード例 #6
0
        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);
            });
        }
コード例 #7
0
 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&lt;EntityMessageCount&gt;.</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);
     }
 }
コード例 #10
0
        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); });
        }
コード例 #11
0
        /// <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);
            }
        }
コード例 #12
0
        /// <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);
            }
        }
コード例 #13
0
        /// <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));
            }
        }
コード例 #14
0
 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);
     }
 }
コード例 #15
0
        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();
            }
        }
コード例 #16
0
        /// <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);
            }
        }
コード例 #17
0
        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")
            });
        }
コード例 #18
0
        /// <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));
            }
        }
コード例 #19
0
        /// <summary>
        /// Gets the sender message count.
        /// </summary>
        /// <returns>Task&lt;EntityMessageCount&gt;.</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));
            }
        }
コード例 #20
0
        /// <summary>
        /// Gets the sender entity usage percentage.
        /// </summary>
        /// <returns>Task&lt;System.Double&gt;.</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));
            }
        }
コード例 #21
0
        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); });
        }
コード例 #22
0
        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);
            });
        }
コード例 #23
0
        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); });
        }
コード例 #24
0
        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); }); });
        }
コード例 #25
0
        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);
        }
コード例 #26
0
        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);
            });
        }
コード例 #27
0
        /// <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();
            }
        }
コード例 #28
0
        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);
            });
        }
コード例 #29
0
        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);
            });
        }
コード例 #30
0
 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);
     });
 }