Ejemplo n.º 1
0
        public static string PostTransmog(string _url, TransmogSet _transmog)
        {
            string result = "";
            string json   = JsonConvert.SerializeObject(_transmog);

            using (var client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/json";
                try
                {
                    result = client.UploadString(_url, "POST", json);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"{DateTime.Now}: [!] An error has occurred posting data to the web API.");
                    Console.WriteLine($"{DateTime.Now}: [!] {ex.Message}");
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            while (true)
            {
                //// Get a random realm
                Realm realm = GetRandomRealm();
                Console.WriteLine($"{DateTime.Now}: [+] Selected: {realm.Name}");

                // Select a random auction owner
                string auctionOwner = GetRandomAuctionOwner(realm.Name);
                Console.WriteLine($"{DateTime.Now}: [+] Selected: {auctionOwner}");

                // Get guild information
                string guild = GetGuild(realm.Name, auctionOwner);
                Console.WriteLine($"{DateTime.Now}: [+] Guild is: {guild}");

                //DEBUG
                //IEnumerable<Realm> _realms = explorer.GetRealms();
                //Realm realm = _realms.Where(i => i.Name == "Caelestrasz").FirstOrDefault();
                //string name = "Katora";
                //string guild = "Affinity";

                IEnumerable <GuildMember> lvl100Members = new List <GuildMember>();

                try
                {
                    // IEnumerable<GuildMember> lvl100Members = GetLevel100GuildMembers(realm, guild);
                    lvl100Members = GetLevel100GuildMembers(realm, guild);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"{DateTime.Now}: [!] Unable to look up guild information for {guild}");
                    Console.WriteLine($"{DateTime.Now}: [!] {ex.Message}");
                    //throw;
                    continue;
                }



                foreach (GuildMember member in lvl100Members)
                {
                    Console.WriteLine($"{DateTime.Now}: [*] {member.Character.Name} is level {member.Character.Level} and has guild rank {member.Rank}");

                    // See if the character exists already
                    HttpStatusCode result = LookupCharacter(member.Character.Realm, member.Character.Name).StatusCode;
                    switch (result)
                    {
                    case HttpStatusCode.Found:
                        Console.WriteLine($"{DateTime.Now}: [!] Character already exists. Skiping ...");
                        continue;

                    case HttpStatusCode.NotFound:
                        //Console.WriteLine($"{DateTime.Now}: [+] Character not found.");
                        break;

                    default:
                        Console.WriteLine($"{DateTime.Now}: [!] An error has occurred checking this character in the database.");
                        Console.WriteLine($"{DateTime.Now}: {result.ToString()}");
                        continue;
                    }

                    // Get the character info for assessment
                    Character character = explorer.GetCharacter(member.Character.Realm, member.Character.Name, CharacterOptions.GetEverything);

                    // Validate the image url
                    string imgUrl = ValidateCharacterImageURL(realm, character);
                    if (imgUrl == null)
                    {
                        // failed to lookup the image url
                        continue;
                    }

                    // Enumerate Transmogged Items
                    List <TransmogItem> TransmogrifiedItems = new List <TransmogItem>();
                    try
                    {
                        TransmogrifiedItems = GetTransmogrifiedItems(realm, member.Character.Name);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"{DateTime.Now}: [!] Unable to lookup character info for {member.Character.Name}");
                        Console.WriteLine($"{DateTime.Now}: [!] {ex.Message}");
                        continue;
                    }


                    Console.WriteLine($"{DateTime.Now}: [+] {member.Character.Name} has {TransmogrifiedItems.Where(i => i.Transmogrified == true).Count()} transmogrified items");



                    // if (TransmogrifiedItems.Count() > 3)
                    if (TransmogrifiedItems.Where(i => i.Transmogrified == true).Count() > 3)
                    {
                        // Create Transmog Object
                        // Character character = explorer.GetCharacter(member.Character.Realm, member.Character.Name, CharacterOptions.GetEverything);

                        TransmogSet Appearance = new TransmogSet(character, TransmogrifiedItems);
                        // TransmogSet Appearance = new TransmogSet(character);

                        // Post the transmog to the API
                        string url = "http://localhost:50392/api/REST/Add";
                        Console.WriteLine($"{DateTime.Now}: [*] Posting JSON to {url}");
                        Console.WriteLine(PostTransmog(url, Appearance));

                        // Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine($"{DateTime.Now}: [-] {member.Character.Name} has < 3 transmogged items. Skipping ...");
                    }
                }

                Console.WriteLine("");
                // Console.ReadKey(); // DEBUG
            }
        }