public PerformanceAggregate DeleteManyAccounts(ClientConnectionInfo adminConnectionInfo, int countAccounts, string accounLoginPrefix, bool useParallel)
 {
     return(DoParallelTasks(0, countAccounts, ParallelismFactor, async i1 => await FindAndDeleteAccount(adminConnectionInfo, string.Format("{0}{1}", accounLoginPrefix, i1)), counter =>
     {
         if (counter % ParallelismFactor == 0)
         {
             Console.WriteLine("Deleted {0} accounts", counter);
         }
     }).Item1);
 }
        public Task <Tuple <PerformanceCounter, bool> > FindAndDeleteAccount(ClientConnectionInfo adminConnectionInfo, string login)
        {
            var accountApi = new AccountApiClient(adminConnectionInfo.Context);

            return(DoPerformanceMeasureAction(async() =>
            {
                var acount = accountApi.GetByLoginAsync(login).Result;
                var delResult = await accountApi.DeleteAsync(acount.UserId);
                return delResult;
            }, adminConnectionInfo.Context.BaseUri.ToString()));
        }
        public ClientConnectionInfo[] GetServerConnections(int countRequests)
        {
            var result = new ClientConnectionInfo[countRequests];

            for (int r = 0, s = 0; r < countRequests; r++)
            {
                result[r] = GetConnection(s);
                s         = s == _serviceUriList.Length - 1 ? 0 : s + 1;
            }
            return(result);
        }
        public async Task <Tuple <PerformanceCounter, string> > Echo(ClientConnectionInfo client, string text)
        {
            Random r = new Random(54657);

            return(await DoPerformanceMeasureAction(() =>
            {
                var gameClient = new ServerInfoClient(client.Context);
                //return Task.Delay(r.Next(5,500)).ContinueWith<string>(_ =>  "ok");
                return Task.Run(() =>
                {
                    return gameClient.Echo(text);
                });
            }, client.Context.BaseUri.ToString()));
        }
 public void StopAllGames(ClientConnectionInfo adminConnectionInfo)
 {
     Task.WhenAll(DoAuthServersWithAdmin(_serviceUriList, "admin").Where(_ => _ != null).Select(_ => Task.Factory.StartNew(
                                                                                                    () =>
     {
         try
         {
             new AdminApiClient(_).StopAllGames();
         }
         catch (Exception)
         {
         }
     }))).Wait();
 }
        public Task <string> Echo1(ClientConnectionInfo client, string text)
        {
            /* var gameClient = new ServerInfoClient(client.Context);
             * return Task.Run(() =>
             * {
             *   var performanceCounter = new PerformanceCounter()
             *   {
             *       ServerUri = client.Context.BaseUri.ToString(), ErrorMessage = null
             *   };
             *   var res = gameClient.Echo(text);
             *   //Thread.Sleep(500);
             *   return new Tuple<PerformanceCounter, string>(performanceCounter, "dfgd");
             * });*/
            return(Task.Run(() =>
            {
                var gameClient = new ServerInfoClient(client.Context);
                return gameClient.Echo(text);
            })

                   );
        }
        public string Echo2(ClientConnectionInfo client, string text)
        {
            var gameClient = new ServerInfoClient(client.Context);

            return(gameClient.Echo(text));
        }
        public Task <Tuple <PerformanceCounter, ManualStepResultModel> > PerformStep(ClientConnectionInfo client)
        {
            var gameClient = new GameApiClient(client.Context);

            return(DoPerformanceMeasureAction(async() => await gameClient.PerformManualStepAsync(), client.Context.BaseUri.ToString()));
        }
        public Task <Tuple <PerformanceCounter, GameDataModel> > GetGameData(ClientConnectionInfo client)
        {
            var gameClient = new GameApiClient(client.Context);

            return(DoPerformanceMeasureAction(async() => await gameClient.GetGameDataAsync(), client.Context.BaseUri.ToString()));
        }
        public Task <Tuple <PerformanceCounter, object> > Logout(ClientConnectionInfo client)
        {
            var authApi = new AuthApiClient(client.Context);

            return(DoPerformanceMeasureAction(async() => await authApi.Logout(), client.Context.BaseUri.ToString()));
        }