Esempio n. 1
0
        private string GetJoke()
        {
            RandomName name = GetRandomName();
            string     joke = GetRandomJoke(name);

            return(joke);
        }
Esempio n. 2
0
        private void GenerateProfile()
        {
            Size          = GenerateSize();
            Atmosphere    = GenerateAtmosphere(Size);
            Hydrographics = GenerateHydrographics(Size, Atmosphere);
            Population    = GeneratePopulation();
            Government    = GenerateGovernment(Population);
            LawLevel      = GenerateLawLevel(Population, Government);
            StarPort      = GenerateStarport(Population);
            TechLevel     = GenerateTechLevel(StarPort, Size, Atmosphere, Hydrographics, Population, Government);
            Temperature   = GenerateTemperature();
            GenerateBases();
            Name = RandomName.GetName(r);
            var i = r.Next(2, 12);

            if (i > 9)
            {
                HasGasGiant = false;
            }
            else
            {
                HasGasGiant = true;
            }
            GenerateTradeCodes();
        }
Esempio n. 3
0
 private void Awake()
 {
     uname       = GetInput("NameInput");
     uname.value = RandomName.GetRandName();
     SetCallback("createChar", OnEnter);
     SetCallback("randomName", OnName);
 }
Esempio n. 4
0
        public static NPC NewNPC(int level, string profession, string race)
        {
            string[] availableRaces = { "Human" };
            if (profession == null)
            {
                profession = "Child";
            }
            if (race == null)
            {
                race = availableRaces[Program.rng.Next(availableRaces.Length)];
            }
            NPC npc = GenerateNPC(Verify.Min(level, 0), $"{race} {profession}");

            if (npc != null)
            {
                npc.faction = Reputation.Faction.Factions.Civil;

                switch (npc.displayName.Split(' ')[0].ToLower())
                {
                case "stranger":
                case "human":
                    npc.name = RandomName.ARandomName() + " " + RandomName.ARandomName();
                    break;
                }
                return(npc);
            }
            return(null);
        }
Esempio n. 5
0
        //---------------------------------------------------------------------
        public Game(params Player[] players)
        {
            if (players.Length == 0)
            {
                _players = new List <Player>()
                {
                    new Player(RandomName.Boy(true)), new Player(RandomName.Boy(true))
                }
            }
            ;
            else if (players.Length == 1)
            {
                _players = new List <Player>()
                {
                    players.First(), new Player(RandomName.Boy(true))
                }
            }
            ;
            else
            {
                _players = new List <Player>(players);
            }

            _cardDeck = new CardDeck();
            _cardDeck.Full();
        }
Esempio n. 6
0
            protected async override Task <AuthenticateResult> HandleAuthenticateAsync()
            {
                // This is where you plumb in your actual custom authentication logic.
                // you have access to the full Request and Response so you can spin it however you want:

                // some ideas:

                // To access headers you can use: Request.Headers.TryGetValue(...)
                // To access cookies you can use: Request.Cookies.TryGetValue(...)
                // You also have access to request bodies, querystrings, you name it.

                // To set cookies you can Response.Cookies.Append(...)
                // recommend not mixing cookie and header auth in the same handler (tight coupling).

                // To grant access you can return AuthenticateResult.Success(ticket))
                // To deny access you can return AuthenticateResult.Fail(message)

                // Super-simple example below will validate a header Authorization (key is in startup).

                Request.Headers.TryGetValue(HeaderNames.Authorization, out var authheaders);

                if (authheaders.Count == 0)
                {
                    return(await Task.Run(() =>
                                          AuthenticateResult.Fail(Messages.EInvalidHeader)
                                          ));
                }

                // The auth key from Authorization header check against the configured one
                if (authheaders != Options.CustomSimpleAuthorizationToken)
                {
                    return(await Task.Run(() =>
                                          AuthenticateResult.Fail(Messages.EInvalidCredentials)
                                          ));
                }

                // If we've got this far, we're considered to be authenticated.

                // Generate an on-the-fly claims based identity for use in controllers, actions, views et..
                // bear in mind we don't have a user-store in this context it's only used during the scope.
                var identity = new ClaimsIdentity(SchemeName);

                // set some randomly generated claim values to prove we can read them in the controller.
                identity.AddClaim(new Claim("FirstName", RandomName.GetFirstName()));
                identity.AddClaim(new Claim("LastName", RandomName.GetLastName()));

                List <ClaimsIdentity> identities =
                    new List <ClaimsIdentity> {
                    identity
                };

                AuthenticationTicket ticket =
                    new AuthenticationTicket(new ClaimsPrincipal(identities), SchemeName);

                // return a success state.
                return(await Task.Run(() =>
                                      AuthenticateResult.Success(ticket)
                                      ));
            }
Esempio n. 7
0
 void Start()
 {
     RandomName.init("Assets/xml/names.xml", "names");
     for (int i = 0; i < 200; ++i)
     {
         print(RandomName.getRandomName());
     }
 }
Esempio n. 8
0
    IEnumerator SpawnNPC()
    {
        yield return(new WaitForSeconds(Random.Range(minSecondsBetweenSpawn, maxSecondsBetweenSpawn)));

        var npc = Instantiate(NPC);

        npc.GetComponent <NPC>().PlayerName = RandomName.Generate();

        StartCoroutine(SpawnNPC());
    }
Esempio n. 9
0
        private RandomName GetRandomName()
        {
            using (WebClient client = new WebClient())
            {
                string     nameJson   = client.DownloadString(RANDOM_NAME_URL);
                RandomName randomName = JsonConvert.DeserializeObject <RandomName>(nameJson);

                return(randomName);
            }
        }
Esempio n. 10
0
 public Player(BotUser bUser, string newChar = null)
 {
     userid = bUser._id;
     if (newChar == null)
     {
         newChar = RandomName.ARandomName();
     }
     CreateSave(newChar);
     bUser.loaded = newChar;
     bUser.Save();
 }
Esempio n. 11
0
        void DisplayRandomName(RandomName name)
        {
            this.selectedCategory.Text  = name.Category.ToString();
            this.selectedGender.Text    = name.Gender.ToString();
            this.selectedGivenName.Text = name.GivenName;
            this.selectedSurname.Text   = name.Surname;

            this.selectedCategoryBar.Text  = name.Category.ToString();
            this.selectedGenderBar.Text    = name.Gender.ToString();
            this.selectedGivenNameBar.Text = name.GivenName;
            this.selectedSurnameBar.Text   = name.Surname;
        }
Esempio n. 12
0
        private string GetRandomJoke(RandomName name)
        {
            string     url     = String.Format("{0}?firstName={1}&lastName={2}&limitTo=[nerdy]", RANDOM_JOKE_URL, name.name, name.surname);
            WebRequest request = WebRequest.Create(url);

            request.Method      = "POST";
            request.ContentType = "text/html";

            HttpWebResponse response = TryGetResponse(request);

            return(TryParseJoke(response));
        }
Esempio n. 13
0
    public Ghost GenerateGhost(Board board)
    {
        Ghost ghost = Object.Instantiate(PrefabRegistry.I.ghost).GetComponent <Ghost>();

        ghost.Init(0);
        ghost.nameSet = RandomName.Generate();

        ghost.summonRoom     = RandomRoom(board);
        ghost.summonPosition = FindSummonPosition(ghost.summonRoom);

        InstallRandomPersonality(ghost);

        return(ghost);
    }
Esempio n. 14
0
        public Entity(GameScreen screen, Sprite s, int x, int y, int hp, float ap = 1, int xp = 0) : base(screen, s, x, y)
        {
            XPValue = xp;
            facing  = Direction.Right;
            State   = EntityState.Standing;

            Name       = RandomName.newName();
            Properties = new Dictionary <string, bool>();
            Bounds     = new EntityBounds(this, x, y, (int)TileMap.SPRITE_SIZE, 12, 14, 6, 24);

            // Stats
            Equipment = new Equipment(this);
            Stats     = new EntityStats(this, hp, ap);

            commonEntityInit();
        }
    void Awake()// Start is called before the first frame update
    {
        if (!isSummon && !Monster && !Guard && !Worker && !Merchent)
        {
            //   CharName= RandomName.NPCName(gender); //generate npc name
            //  CharName = randomName(gender);
            RandomName r = new RandomName();
            //  RandomName r = GetComponent<RandomName>();
            CharName = r.NPCName(gender);

            //  CharName = "Bugass";
            analytics = FindObjectOfType <Analytics>();
            analytics.addNPC(this.gameObject);
            // Gold = 1300;
        }
    }
Esempio n. 16
0
    void OnRandomNameBtn(GameObject go)
    {
        GameObject userName = gameObject.transform.FindChild
                                  ("CreateCharWnd2/sp_link2/sp_username/ip_username").gameObject;

        int size = sdConfDataMgr.Instance().m_randomNameDB.Count;
        int idx  = Random.Range(0, size);

        RandomName randomName = sdConfDataMgr.Instance().m_randomNameDB[idx + 1] as RandomName;
        string     firstName  = randomName.FirstName;

        idx        = Random.Range(0, size);
        randomName = sdConfDataMgr.Instance().m_randomNameDB[idx + 1] as RandomName;
        string lastName = randomName.LastName;

        userName.GetComponent <UIInput>().value = lastName + firstName;
    }
Esempio n. 17
0
    protected override void InitUiOnAwake()
    {
        randomName = new RandomName();
        randomName.LoadRandomNameData();

        Btn_RandomName = GameTool.GetTheChildComponent <Button>(this.gameObject, "Btn_RandomName");
        Btn_RandomName.onClick.AddListener(SetPlayerName);

        Btn_Login = GameTool.GetTheChildComponent <Button>(this.gameObject, "Btn_Login");
        Btn_Login.onClick.AddListener(StartGame);


        inputField      = GameTool.GetTheChildComponent <InputField>(this.gameObject, "InputField");
        inputField.text = randomName.GetRandomName();

        clientConf = MeaninglessJson.LoadJsonFromFile <ClientConf>(MeaninglessJson.Path_StreamingAssets + "ClientConf.json");
    }
Esempio n. 18
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Unicode;

            int size = 18;

            Player[] players = new Player[size];
            for (var i = 0; i < players.Length; i++)
            {
                players[i] = new Player(RandomName.Boy(true));
            }

            Game game = new Game(players);

            game.Play();

            Console.Read();
        }
Esempio n. 19
0
        //从datarow得到Player的信息
        public bool getPlayerInfo(DataRow player)
        {
            try {
                //传给玩家用户名(做主键)
                username = player["username"].ToString();

                //如果服务器中姓名为空,则随机给他一个姓名
                if (player["name"] == null || player["name"].ToString() == "")
                {
                    RandomName randomName = new RandomName();
                    name = randomName.getRandomName();

                    //将随机的名字写入数据库
                    int result = SqlDbHelper.ExecuteNonQuery("UPDATE USER_TABLE SET NAME = '" + name
                                                             + "' WHERE username = '******'");

                    if (result == 0)
                    {
                        MessageBox.Show("修改玩家姓名失败!");
                    }
                }
                else
                {
                    name = player["name"].ToString();
                }

                //传给玩家性别
                sex = (bool)player["sex"];
                //传给玩家积分
                score = (int)player["score"];
                //传给玩家图片
                image = (int)player["image"];
                //设置准备状态为false
                isReady = false;
                //设置玩家的状态为在线状态
                playerEnum = PlayerEnum.ONLINE;

                return(true);
            } catch (Exception e) {
                MessageBox.Show(e.ToString());
                return(false);
            }
        }
Esempio n. 20
0
        public static Worker GenerateRandomWorker()
        {
            Random     rand    = new Random();
            RandomName nameGen = new RandomName(rand);
            var        worker  = new Worker()
            {
                Name = nameGen.Generate((Sex)rand.Next(0, 2), rand.Next(0, 2)), Cost = 2000
            };
            var weights = new Dictionary <int, int>()
            {
                { 1, 40 },
                { 2, 40 },
                { 3, 15 },
                { 4, 4 },
                { 5, 1 },
            };

            worker.Efficiency = WeightedRandomizer.From(weights).TakeOne();
            return(worker);
        }
Esempio n. 21
0
        public PlayerState()
        {
            this.MoneyPercentageSkillLevel      = 1;
            this.EfficiencyPercentageSkillLevel = 1;
            Random     rand    = new Random();
            RandomName nameGen = new RandomName(rand);

            Workers = new List <Worker.Worker>
            {
                new Worker.Worker()
                {
                    Efficiency = 2, Name = nameGen.Generate((Sex)rand.Next(0, 2), rand.Next(0, 2)), Cost = 2000
                },
            };

            Customers = new List <Customer>();

            UnlockedDrinks = new List <Drink>
            {
                new Drink()
                {
                    name = "Cappuccino", price = 7
                },
                new Drink()
                {
                    name = "coffee", price = 3
                },
                new Drink()
                {
                    name = "flat white", price = 2
                }
            };

            for (var i = 0; i < 100; i++)
            {
                Customers.Add(new Customer()
                {
                    FavoriteDrink = UnlockedDrinks[0], Name = $"Customer{i}", Satisfaction = 20
                });
            }
        }
Esempio n. 22
0
    //TODO: update for 1.62
    private void SetMetaData(string mid)
    {
        sPaintStrokes.OnAddToScene();

        bool         useLocation  = Input.location.status == LocationServiceStatus.Running;
        LocationInfo locationInfo = Input.location.lastData;

        // Update for PN 1.62
        LibPlacenote.MapMetadataSettable metadata = new LibPlacenote.MapMetadataSettable();
        metadata.name   = RandomName.Get();
        mLabelText.text = "Saved Map Name: " + metadata.name;
        JObject userdata = new JObject();

        metadata.userdata = userdata;

        //JObject shapeList = Shapes2JSON();
        //userdata["shapeList"] = shapeList;

        userdata[sModels.jsonKey]       = sModels.ToJSON();
        userdata[sPaintStrokes.jsonKey] = sPaintStrokes.ToJSON();
        userdata[sPeople.jsonKey]       = sPeople.ToJSON();


        if (useLocation)
        {
            metadata.location           = new LibPlacenote.MapLocation();
            metadata.location.latitude  = locationInfo.latitude;
            metadata.location.longitude = locationInfo.longitude;
            metadata.location.altitude  = locationInfo.altitude;
        }
        else
        { // default location so that JSON object is not invalid due to missing location data
            metadata.location           = new LibPlacenote.MapLocation();
            metadata.location.latitude  = 50f;
            metadata.location.longitude = 100f;
            metadata.location.altitude  = 10f;
        }

        LibPlacenote.Instance.SetMetadata(mid, metadata);
    }
Esempio n. 23
0
        //获取一个电脑版的Player
        public static Player getRobotPlayer(GameLobby lobby, int lobbyIndex)
        {
            Player player = new Player();
            //随机生成玩家的姓名,图片,分数和性别
            RandomName randomName = new RandomName();

            player.name = randomName.getRandomName();
            Random rand = new Random();

            player.image = rand.Next(6);
            player.sex   = (player.image != 1);
            player.score = 0;

            //设置玩家所在的大厅及其编号
            player.lobby      = lobby;
            player.lobbyIndex = lobbyIndex;

            //设置当前玩家为机器人
            player.playerEnum = PlayerEnum.ROBOT;

            return(player);
        }
    void DoChecks()
    {
        WorldMultiplier = worldMultiplier;

        initCiySize   = MinCitySpreadreq;
        secondCiySize = MaxCitySpreadreq;

        //if (FindObjectOfType<MapMagic.Core.MapMagicObject>() == null)
        //{
        //    return;
        //}

        ProduceOverlay = options.Overlay;
        //  if (TownGlobalObject.bundles == null || TownGlobalObject.townsData == null)
        //  {
        //   TownGlobalObject.bundles = new Dictionary<Coord, AOTABundle>();
        //   TownGlobalObject.townsData = new Dictionary<Coord, Town.Town>();
        //
        //  Debug.LogFormat("INITITALISED TownGlobalObject.bundles and .townsdata");
        //   }



        // setup district name
        CurrentDistricts = new List <string>();

        // assign statics
        if (PatchCap != MaxCitySpreadreq)
        {
            PatchCap = MaxCitySpreadreq;
        }

        if (PatchFloor != MinCitySpreadreq)
        {
            PatchFloor = MinCitySpreadreq;
        }

        districtNameText.text = "";

        if (TownGlobalObjectService.namegenref != namegen)
        {
            TownGlobalObjectService.namegenref = namegen;
        }

        int allnames = 200;

        if (NamesQueue == null)
        {
            NamesQueue = new Queue <string>(allnames);
        }

        TownGlobalObjectService.NamesQueue.Enqueue("Hometon");

        if (NamesQueue.Count < 200)
        {
            for (int i = 0; i < allnames; i++)
            {
                var tempname = "Hometon";
                while (TownGlobalObjectService.NamesQueue.Contains(tempname))
                {
                    tempname = namegen.GeneratePlace();
                }
                TownGlobalObjectService.NamesQueue.Enqueue(tempname);
            }
        }

        //    Debug.Log(NamesQueue.Peek());

        if (MapMagicObjectRef != MapMagicObjectReference)
        {
            MapMagicObjectRef = MapMagicObjectReference;
        }

        if (LiveRendererOptions != rendererOptions)
        {
            rendererOptions = LiveRendererOptions;
        }
    }
Esempio n. 25
0
        public void StandardTest()
        {
            #region Description and count getting
            while (Console.KeyAvailable)
            {
                Console.ReadKey(true);
            }
            Console.WriteLine("The standard test runs two sets of tests. The first runs through valid data");
            Console.WriteLine("and tests each method in turn with both valid and invalid data. The second");
            Console.WriteLine("runs invalid data only, attempting to create an account with no password,");
            Console.WriteLine("an account with no name, and finally creating a legitimate account to fail");
            Console.WriteLine("to create characters against.");
            Console.WriteLine();
            int accts = GetNumber("Please enter number of accounts to create per test: ", 1, 200);
            int chars = GetNumber("Please enter number of characters to create per account: ", 1, 12);
            Console.WriteLine("Press Q at any point to cancel the test, or V to toggle verbose mode.");
            Console.WriteLine("Press any key when you're ready...");
            Console.ReadKey();
            #endregion
            WriteResultHeader();
            var  tokenSource = new CancellationTokenSource();
            var  token       = tokenSource.Token;
            Task task        = Task.Factory.StartNew(() => {
                RandomName acctName = new RandomName("acct", 1000);
                RandomName charName = new RandomName("chr", 10000);
                int failures        = 0;
                int badSuccesses    = 0;
                int counter         = 0;
                while (counter < accts && !token.IsCancellationRequested)
                {
                    Console.WriteLine("NEXT ACCOUNT:");
                    var acct          = new TestData.Account(acctName.GetName());
                    TestResult result = acct.Create(_verbose);
                    Console.WriteLine(result.Output);
                    if (!result.Success)
                    {
                        failures++;
                    }
                    else
                    {
                        if (result.Success)
                        {
                            WoW.Enums.Faction faction;

                            if (counter % 2 == 0)
                            {
                                faction = Enums.Faction.Alliance;
                            }
                            else
                            {
                                faction = Enums.Faction.Horde;
                            }
                            int charcounter = 0;
                            while (charcounter < chars && !token.IsCancellationRequested)
                            {
                                Console.WriteLine("SUCCESSFUL TESTS:");
                                //Create Character
                                var character = new TestData.Character(acct, charName.GetName(), faction, true);
                                result        = character.Create(_verbose);
                                Console.WriteLine(result.Output);
                                if (!result.Success)
                                {
                                    failures++;
                                }
                                else
                                {
                                    #region Success testing
                                    result = character.ChangeLevel(56, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (!result.Success)
                                    {
                                        failures++;
                                    }
                                    result = character.Update(true, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (!result.Success)
                                    {
                                        failures++;
                                    }
                                    result = character.ChangeName(character.Name + "n", _verbose);
                                    Console.WriteLine(result.Output);
                                    if (!result.Success)
                                    {
                                        failures++;
                                    }
                                    result = character.Delete(_verbose);
                                    Console.WriteLine(result.Output);
                                    if (!result.Success)
                                    {
                                        failures++;
                                    }
                                    result = character.Update(true, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                    result = character.Restore(_verbose);
                                    Console.WriteLine(result.Output);
                                    if (!result.Success)
                                    {
                                        failures++;
                                    }
                                    result = character.Update(true, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (!result.Success)
                                    {
                                        failures++;
                                    }
                                    #endregion
                                    #region Failure Testing
                                    Console.WriteLine("EXPECTED FAILURES:");
                                    result = character.Update(false, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                    result = character.ChangeLevel(0, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                    result = character.ChangeLevel(55, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                    result = character.ChangeLevel(90, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                    result = character.ChangeName("\"{dude}", _verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                    if (charcounter > 0)
                                    {
                                        result = character.ChangeName(charName.GetName(true, 1) + "n", _verbose);
                                        Console.WriteLine(result.Output);
                                        if (result.Success)
                                        {
                                            badSuccesses++;
                                        }
                                    }
                                    charcounter++;
                                    #endregion
                                }
                            }
                        }
                    }
                    counter++;
                }
                counter = 0;
                Console.WriteLine("Valid data test completed!");
                Console.WriteLine(accts.ToString() + " accounts created, each with " + chars.ToString() + " characters, for a total of " + ((int)(accts * chars)).ToString() + " requests.");
                Console.WriteLine("Unexpected Failures: " + failures.ToString() + ".");
                Console.WriteLine("Unexpected Successes: " + badSuccesses.ToString() + ".");
                badSuccesses = 0;
                if (!token.IsCancellationRequested)
                {
                    Console.WriteLine("Press any key (other than Enter) to move on to failure testing...");
                    Console.ReadKey();
                    Console.WriteLine();
                    TestData.Account account;
                    TestResult result;

                    if (!token.IsCancellationRequested)
                    {
                        Console.WriteLine("Creating account with no password...");
                        account = new TestData.Account("failure", string.Empty);
                        result  = account.Create(_verbose);
                        Console.WriteLine(result.Output);
                        if (result.Success)
                        {
                            badSuccesses++;
                        }
                    }
                    if (!token.IsCancellationRequested)
                    {
                        Console.WriteLine("Creating 'good' account: ");
                        account = new TestData.Account(acctName.GetName());
                        result  = account.Create(_verbose);
                        if (result.Success && !token.IsCancellationRequested)
                        {
                            Console.WriteLine("Creating character with bad password...");
                            TestData.Character character = new TestData.Character(account, "badChar", Enums.Faction.Alliance, true, string.Empty);
                            result = character.Create(_verbose);
                            Console.WriteLine(result.Output);
                            if (result.Success)
                            {
                                badSuccesses++;
                            }
                            if (!token.IsCancellationRequested)
                            {
                                Console.WriteLine("Creating character with bad name...");
                                character = new TestData.Character(account, "!\"{}", Enums.Faction.Horde, true);
                                result    = character.Create(_verbose);
                                Console.WriteLine(result.Output);
                                if (result.Success)
                                {
                                    badSuccesses++;
                                }
                            }
                            if (!token.IsCancellationRequested)
                            {
                                Console.WriteLine("Creating character successfully...");
                                character = new TestData.Character(account, charName.GetName(), Enums.Faction.Horde, true);
                                result    = character.Create(_verbose);
                                if (result.Success && !token.IsCancellationRequested)
                                {
                                    Console.WriteLine("Attempting to access good character with diff account...");
                                    TestData.Account badacct = new TestData.Account(acctName.GetName());
                                    badacct.Create(false);
                                    character.AccountName = badacct.Name;
                                    result = character.Update(true, _verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                    Console.WriteLine("Creating character with same name...");
                                    character = new TestData.Character(account, charName.GetName(true), Enums.Faction.Horde, true);
                                    result    = character.Create(_verbose);
                                    Console.WriteLine(result.Output);
                                    if (result.Success)
                                    {
                                        badSuccesses++;
                                    }
                                }
                            }
                        }
                    }
                }

                Console.WriteLine("Press any key to return to main test menu...");
            }, token);
            ConsoleKey key = ConsoleKey.F17;
            do
            {
                key = Console.ReadKey().Key;
                if (task.Status != TaskStatus.RanToCompletion)
                {
                    if (key == ConsoleKey.V)
                    {
                        _verbose = !_verbose;
                    }
                    else if (key == ConsoleKey.Q)
                    {
                        tokenSource.Cancel();
                        task.Wait();
                    }
                }
                else
                {
                    key = ConsoleKey.Q;
                }
            } while (key != ConsoleKey.Q);
        }
Esempio n. 26
0
        public void StressTest()
        {
            //Console.WriteLine("1234578901234567890123456789012345678901234567890123456789012345679801234567980");
            Console.WriteLine("This test will generate ten threads, each making forty new accounts and 120 new");
            Console.WriteLine("characters. Press Q at any point to quit this test.");
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            List <Task>             tasks  = new List <Task>();
            CancellationTokenSource source = new CancellationTokenSource();
            CancellationToken       token  = source.Token;
            RandomName acctName            = new RandomName("acct", 1000);
            RandomName charName            = new RandomName("chr", 10000);
            int        failures            = 0;

            for (int i = 0; i < 10; i++)
            {
                tasks.Add(new Task(() => {
                    int counter = 0;
                    while (counter < 40 && !token.IsCancellationRequested)
                    {
                        string acct = string.Empty;
                        lock (acctName)
                        {
                            acct = acctName.GetName();
                        }
                        TestData.Account account = new TestData.Account(acct);
                        TestResult result        = account.Create(false);
                        Console.WriteLine(result.Output);
                        if (!result.Success)
                        {
                            Interlocked.Increment(ref failures);
                        }
                        else
                        {
                            int charcounter = 0;
                            while (charcounter < 3 && !token.IsCancellationRequested)
                            {
                                string charname = string.Empty;
                                lock (charName)
                                {
                                    charname = charName.GetName();
                                }
                                TestData.Character character = new TestData.Character(account, charname, Enums.Faction.Alliance, true);
                                TestResult charResult        = character.Create(false);
                                if (!charResult.Success)
                                {
                                    Interlocked.Increment(ref failures);
                                }
                                Console.WriteLine(charResult.Output);
                                charcounter++;
                            }
                        }
                        counter++;
                    }
                    Console.WriteLine("Thread complete!");
                }, token));
            }
            foreach (Task task in tasks)
            {
                task.Start();
            }
            bool halt = false;

            while (!halt)
            {
                if (!Console.KeyAvailable)
                {
                    Thread.Sleep(200);
                    if (tasks.Count(t => t.IsCompleted == false) == 0)
                    {
                        Console.WriteLine("Stress test complete! Total failed requests: " + failures.ToString());
                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();
                        halt = true;
                    }
                }
                else
                {
                    ConsoleKey key = Console.ReadKey().Key;
                    if (key == ConsoleKey.Q)
                    {
                        source.Cancel();
                        while (tasks.Count(t => t.Status == TaskStatus.RanToCompletion) < 10)
                        {
                            Thread.Sleep(500);
                        }
                        halt = true;
                    }
                }
            }
        }
Esempio n. 27
0
 void OnName()
 {
     uname.value = RandomName.GetRandName();
 }
Esempio n. 28
0
    public void OnSaveMapClick()
    {
        if (!LibPlacenote.Instance.Initialized())
        {
            Debug.Log("SDK not yet initialized");
//            ToastManager.ShowToast("SDK not yet initialized", 2f);
            return;
        }

        OnDropPaintStrokeClick();

        bool         useLocation  = Input.location.status == LocationServiceStatus.Running;
        LocationInfo locationInfo = Input.location.lastData;

        // If there is a loaded map, then saving just updates the metadata
        if (!currentMapId.Equals(""))
        {
            mLabelText.text = "Setting MetaData...";
            SetMetaData(currentMapId);
        }
        else
        {
            mLabelText.text = "Saving...";
            LibPlacenote.Instance.SaveMap(
                (mapId) =>  // savedCb   upon saving the map locally
            {
                LibPlacenote.Instance.StopSession();
                mLabelText.text = "Saved Map ID: " + mapId;

                //clear all existing planes
                mPNPlaneManager.ClearPlanes();
                mPlaneDetectionToggle.GetComponent <Toggle>().isOn = false;

                // Updated for 1.62
                LibPlacenote.MapMetadataSettable metadata = new LibPlacenote.MapMetadataSettable();
                metadata.name     = RandomName.Get();
                mLabelText.text   = "Saved Map Name: " + metadata.name;
                JObject userdata  = new JObject();
                metadata.userdata = userdata;

                userdata[sModels.jsonKey] = sModels.ToJSON();     // replaces shapeList

                userdata[sPaintStrokes.jsonKey] = sPaintStrokes.ToJSON();

                //userdata["person"] = name;
                userdata[sPeople.jsonKey] = sPeople.ToJSON();

                if (useLocation)
                {
                    metadata.location           = new LibPlacenote.MapLocation();
                    metadata.location.latitude  = locationInfo.latitude;
                    metadata.location.longitude = locationInfo.longitude;
                    metadata.location.altitude  = locationInfo.altitude;
                }
                else
                {     // default location so that JSON object is not invalid due to missing location data
                    metadata.location           = new LibPlacenote.MapLocation();
                    metadata.location.latitude  = 50f;
                    metadata.location.longitude = 100f;
                    metadata.location.altitude  = 10f;
                }
                LibPlacenote.Instance.SetMetadata(mapId, metadata);
                currentMapId    = mCurrMapDetails.name;  //mapId;  // from prev. PN version, still needed?
                mCurrMapDetails = metadata;
            },
                (completed, faulted, percentage) =>
            {     // progressCb  upon transfer to cloud
                String percentText = (percentage * 100f).ToString();
                uploadText.text    = "Map upload status– Completed: " + completed + "    Faulted: " + faulted + "   " + "\n" + percentText + "% uploaded";

                ActivateMapButton(false);
            }
                );
        }
    }
Esempio n. 29
0
    public void OnSaveMapClick()
    {
        if (!LibPlacenote.Instance.Initialized())
        {
            Debug.Log("SDK not yet initialized");
            return;
        }

        bool         useLocation  = Input.location.status == LocationServiceStatus.Running;
        LocationInfo locationInfo = Input.location.lastData;

        mLabelText.text = "Saving...";
        LibPlacenote.Instance.SaveMap(
            (mapId) => {
            LibPlacenote.Instance.StopSession();
            mSaveMapId = mapId;
            mInitButtonPanel.SetActive(true);
            mMappingButtonPanel.SetActive(false);
            mExitButton.SetActive(false);
            //mPlaneDetectionToggle.SetActive (false);

            //clear all existing planes
            mPNPlaneManager.ClearPlanes();
            mPlaneDetectionToggle.GetComponent <Toggle>().isOn = false;

            LibPlacenote.MapMetadataSettable metadata = new LibPlacenote.MapMetadataSettable();
            metadata.name   = RandomName.Get();
            mLabelText.text = "Saved Map Name: " + metadata.name;

            JObject userdata  = new JObject();
            metadata.userdata = userdata;

            JObject shapeList = GetComponent <ShapeManager>().Shapes2JSON();

            userdata["shapeList"] = shapeList;

            if (useLocation)
            {
                metadata.location           = new LibPlacenote.MapLocation();
                metadata.location.latitude  = locationInfo.latitude;
                metadata.location.longitude = locationInfo.longitude;
                metadata.location.altitude  = locationInfo.altitude;
            }
            LibPlacenote.Instance.SetMetadata(mapId, metadata, (success) => {
                if (success)
                {
                    Debug.Log("Meta data successfully saved");
                }
                else
                {
                    Debug.Log("Meta data failed to save");
                }
            });
            mCurrMapDetails = metadata;
        },
            (completed, faulted, percentage) => {
            if (completed)
            {
                mLabelText.text = "Upload Complete:" + mCurrMapDetails.name;
            }
            else if (faulted)
            {
                mLabelText.text = "Upload of Map Named: " + mCurrMapDetails.name + "faulted";
            }
            else
            {
                mLabelText.text = "Uploading Map Named: " + mCurrMapDetails.name + "(" + percentage.ToString("F2") + "/1.0)";
            }
        }
            );
    }
Esempio n. 30
0
        public IHttpActionResult PostStudentProfile(int num, string type)
        {
            string   result    = "";
            DateTime timeStart = DateTime.Now;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var studentProfileList = new List <StudentProfile>();

            var           randomId  = new RandomID();
            List <string> randomIDs = randomId.getRandomIDs(num);

            DateTime timeIdDone = DateTime.Now;

            result += "generate ID costs " + Util.getSecond(timeStart, timeIdDone) + " sec, ";

            var           randomName  = new RandomName(new Random());
            List <string> randomNames = randomName.RandomNames(num, 2);

            DateTime timeNameDone = DateTime.Now;

            result += "generate Name costs " + Util.getSecond(timeIdDone, timeNameDone) + " sec, ";

            List <string>  randomGenders = Util.getRandomList(Const.Gender, num);
            List <string>  randomBloods  = Util.getRandomList(Const.Blood, num);
            List <decimal> randomHeights = Util.getRandomDecimalList(150, 200, 1, num);
            List <decimal> randomWeights = Util.getRandomDecimalList(40, 100, 1, num);

            DateTime timeOtherDone = DateTime.Now;

            result += "generate other columns costs " + Util.getSecond(timeNameDone, timeOtherDone) + " sec, ";

            for (int i = 0; i < num; i++)
            {
                var item = new StudentProfile
                {
                    guid       = Guid.NewGuid(),
                    Id         = randomIDs[i],
                    Name       = randomNames[i],
                    Gender     = randomGenders[i],
                    Blood      = randomBloods[i],
                    Height     = randomHeights[i],
                    Weight     = randomWeights[i],
                    CreateDate = DateTime.Now
                };
                studentProfileList.Add(item);
            }

            randomIDs.Clear();
            randomIDs.TrimExcess();
            randomNames.Clear();
            randomNames.TrimExcess();
            randomGenders.Clear();
            randomGenders.TrimExcess();
            randomBloods.Clear();
            randomBloods.TrimExcess();
            randomHeights.Clear();
            randomHeights.TrimExcess();
            randomWeights.Clear();
            randomWeights.TrimExcess();
            GC.Collect();

            DateTime timeListDone = DateTime.Now;

            result += "put into List costs " + Util.getSecond(timeOtherDone, timeListDone) + " sec, ";

            bool dbResult;

            switch (type)
            {
            case "ADO_For":
                dbResult = MassInsert_ADO_For(studentProfileList);
                break;

            case "EF_AddRange":
                dbResult = MassInsert_EF_AddRange(studentProfileList);
                break;

            case "SqlBulkCopy":
                dbResult = MassInsert_SqlBulkCopy(studentProfileList);
                break;

            case "TVP":
                dbResult = MassInsert_TVP(studentProfileList);
                break;

            default:
                return(BadRequest("invalid type: " + type));
            }

            studentProfileList.Clear();
            studentProfileList.TrimExcess();
            GC.Collect();

            if (!dbResult)
            {
                result += "save DB has error, see detail in EventLog";
                return(Ok(new { result }));
            }

            DateTime timeDbDone = DateTime.Now;

            result += "save to DB costs " + Util.getSecond(timeListDone, timeDbDone) + " sec, ";

            DateTime timeEnd = DateTime.Now;

            result += "total costs " + Util.getSecond(timeStart, timeEnd) + " sec.";

            return(Ok(new { result }));
        }