Exemple #1
0
        private void btnGetData_Click(object sender, EventArgs e)
        {
            string token =
                "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImtpZCI6IjI4YTMxOGY3LTAwMDAtYTFlYi03ZmExLTJjNzQzM2M2Y2NhNSJ9.eyJpc3MiOiJzdXBlcmNlbGwiLCJhdWQiOiJzdXBlcmNlbGw6Z2FtZWFwaSIsImp0aSI6IjMwMzc4M2ViLWIyNWYtNDU5MC05M2NmLTFhNmZjMzQ5Yjk1OSIsImlhdCI6MTU5MTMxNTIyMCwic3ViIjoiZGV2ZWxvcGVyLzcyODgzMmI1LTI4NzgtYTJlZi01MTQ0LTUyNTM5N2U3YzI4NiIsInNjb3BlcyI6WyJjbGFzaCJdLCJsaW1pdHMiOlt7InRpZXIiOiJkZXZlbG9wZXIvc2lsdmVyIiwidHlwZSI6InRocm90dGxpbmcifSx7ImNpZHJzIjpbIjk0LjIxLjM0LjEwOSJdLCJ0eXBlIjoiY2xpZW50In1dfQ.OgBZEinxO9LZ51E8mgPZKT_UiWsNt6IvZgr-1wNfZZINkv-vQvtN6vNFaTHXIecCao5RwAh3QHOAWjQS_fhulg";

            Funq.Container container = CocCore.Instance(token).Container;
            ICocCoreClans  clansCore = container.Resolve <ICocCoreClans>();

            var clan = clansCore.GetClans(txtTag.Text);

            txtName.Text       = clan.Name;
            txtLocation.Text   = clan.Location.Name;
            txtType.Text       = clan.Type;
            txtClanLevel.Text  = clan.ClanLevel.ToString();
            txtClanPoints.Text = clan.ClanPoints.ToString();
            txtWarWins.Text    = clan.WarWins.ToString();
        }
 public void InitializeCore()
 {
     ClansCore = CocCore.Instance(TOKEN).Container.Resolve <ICocCoreClans>();
 }
        public void GetLootRecords()
        {
            SqlConnection con;                      // connection variables
            SqlCommand    com;
            DateTime      localDate = DateTime.Now; // date now for loot logging date

            try                                     // connect to clash API
            {
                Console.Write("Connecting to Clash API...");
                // set clash api connection token
                string          token       = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImtpZCI6IjI4YTMxOGY3LTAwMDAtYTFlYi03ZmExLTJjNzQzM2M2Y2NhNSJ9.eyJpc3MiOiJzdXBlcmNlbGwiLCJhdWQiOiJzdXBlcmNlbGw6Z2FtZWFwaSIsImp0aSI6ImFlNjY2YzJmLWUyNGQtNGUwZS1hNzU5LTcyZjU4NjRjODY5NSIsImlhdCI6MTUzMDMxMTE3Niwic3ViIjoiZGV2ZWxvcGVyLzA5MGJlMzBlLWFhNjEtN2Y0YS1iMjY1LTk3Mjg1NmEzZDVhOSIsInNjb3BlcyI6WyJjbGFzaCJdLCJsaW1pdHMiOlt7InRpZXIiOiJkZXZlbG9wZXIvc2lsdmVyIiwidHlwZSI6InRocm90dGxpbmcifSx7ImNpZHJzIjpbIjE4LjE5MS4xMjcuODgiLCI3NS4xMzQuOTYuNDciXSwidHlwZSI6ImNsaWVudCJ9XX0.3-S8KOl2DjyO9dhPq4aNjfpyc3Mfei6a_YevQXV0btVU_-d6bJO1pBfuM-7LEtYN5ypXrjAyY5nDjtrHdbJBuQ";
                Funq.Container  container   = CocCore.Instance(token).Container;     // build new container with api token
                ICocCorePlayers playersCore = container.Resolve <ICocCorePlayers>(); // CoCNET interface config to players core
                Console.WriteLine(" Connection Established!");

                try  // fetch loot data
                {
                    Console.Write("Fetching loot data...");
                    var player = playersCore.GetPlayer("#98QGLCJCR");                               //get JSON data for player tag
                    totalGold   = player.Achievements.Find(x => x.Name == "Gold Grab").Value;       // fetch gold grab achievement
                    totalElixer = player.Achievements.Find(x => x.Name == "Elixir Escapade").Value; // fetch elixer escapade achievement
                    totalDark   = player.Achievements.Find(x => x.Name == "Heroic Heist").Value;    // fetch elixer escapade achievement
                    trophies    = player.Trophies;                                                  // fetch player trophies
                    Console.WriteLine(" Loot data fetched!");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Failed to fetch data");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Failed to connect to API");
            }


            Console.WriteLine();
            Console.WriteLine("Fetched Loot Data to be logged - " + localDate.ToString());
            Console.WriteLine("Total gold value: " + totalGold.ToString());
            Console.WriteLine("Total elixer value: " + totalElixer.ToString());
            Console.WriteLine("Total dark value: " + totalDark.ToString());
            Console.WriteLine("Total trophies value: " + trophies.ToString());
            Console.WriteLine();

            try
            {
                using (con = new SqlConnection(Properties.Settings.Default.newLootConStr)) // new sql connection using the db connection string
                {
                    Console.Write("Establishing db connection...");
                    con.Open();     // open db for use
                    Console.WriteLine(" Connected to db!");

                    Console.Write("Creating sql command...");
                    // build sql insert command with loot values
                    using (com = new SqlCommand("INSERT INTO LootRecords(dateNow, gold, elixer, dark, trophies) VALUES(" +
                                                "@dateNow, @gold, @elixer, @dark, @trophies)", con))
                    {
                        com.Parameters.AddWithValue("dateNow", localDate);  // add values to sql command
                        com.Parameters.AddWithValue("gold", totalGold);
                        com.Parameters.AddWithValue("elixer", totalElixer);
                        com.Parameters.AddWithValue("dark", totalDark);
                        com.Parameters.AddWithValue("trophies", trophies);
                        Console.WriteLine("Values added to sql command!");
                        try
                        {
                            Console.Write("Inserting data into db...");
                            com.ExecuteNonQuery();  // execute INSERT command
                            Console.WriteLine(" Loot data successfully inserted to db!");
                            con.Close();
                        }
                        catch (SqlException e)
                        {
                            Console.WriteLine(e.Message);
                            Console.WriteLine("Failed to insert data to db");
                        }
                    }
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Failed to connect to db");
            }

            Console.WriteLine();
            Console.WriteLine("Operation Complete");
        }
Exemple #4
0
        public void GetMemberList()
        {
            SqlConnection con;                      // connection variables
            SqlCommand    com;
            DateTime      localDate = DateTime.Now; // date now for loot logging date


            try   // connect to clash API
            {
                Console.WriteLine();
                Console.Write("Connecting to Clash API...");
                // set clash api connection token
                string         token     = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImtpZCI6IjI4YTMxOGY3LTAwMDAtYTFlYi03ZmExLTJjNzQzM2M2Y2NhNSJ9.eyJpc3MiOiJzdXBlcmNlbGwiLCJhdWQiOiJzdXBlcmNlbGw6Z2FtZWFwaSIsImp0aSI6ImFlNjY2YzJmLWUyNGQtNGUwZS1hNzU5LTcyZjU4NjRjODY5NSIsImlhdCI6MTUzMDMxMTE3Niwic3ViIjoiZGV2ZWxvcGVyLzA5MGJlMzBlLWFhNjEtN2Y0YS1iMjY1LTk3Mjg1NmEzZDVhOSIsInNjb3BlcyI6WyJjbGFzaCJdLCJsaW1pdHMiOlt7InRpZXIiOiJkZXZlbG9wZXIvc2lsdmVyIiwidHlwZSI6InRocm90dGxpbmcifSx7ImNpZHJzIjpbIjE4LjE5MS4xMjcuODgiLCI3NS4xMzQuOTYuNDciXSwidHlwZSI6ImNsaWVudCJ9XX0.3-S8KOl2DjyO9dhPq4aNjfpyc3Mfei6a_YevQXV0btVU_-d6bJO1pBfuM-7LEtYN5ypXrjAyY5nDjtrHdbJBuQ";
                Funq.Container container = CocCore.Instance(token).Container;  // build new container with api token

                ICocCoreClans clansCore = container.Resolve <ICocCoreClans>(); // CoCNET interface config to clans

                Console.WriteLine("     Connection Established!");

                try  // fetch loot data
                {
                    Console.WriteLine();
                    Console.Write("Fetching member details...");

                    var clan = clansCore.GetClans("#99L9R088"); //get JSON data for clan tag

                    foreach (var obj in clan.MemberList)        // loop through each members details
                    {
                        Member member = new Member();
                        member.Tag               = obj.Tag;
                        member.Name              = obj.Name;
                        member.ExpLevel          = obj.ExpLevel;
                        member.LeagueID          = obj.League.Id;
                        member.LeagueName        = obj.League.Name;
                        member.LeagueIcon        = obj.League.IconUrls["small"];
                        member.Trophies          = obj.Trophies;
                        member.Role              = obj.Role;
                        member.ClanRank          = obj.ClanRank;
                        member.Donations         = obj.Donations;
                        member.DonationsReceived = obj.DonationsReceived;
                        member.LocalDate         = localDate;
                        myMemberList.Add(member);
                    }
                    //Console.WriteLine();
                    Console.WriteLine("     Member details fetched!");
                }
                catch (Exception e)
                {
                    Console.WriteLine();
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Failed to fetch data");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Failed to connect to API");
            }

            Console.WriteLine();
            //Console.WriteLine();

            /*
             * foreach (var member in myMemberList)
             * {
             *  Console.WriteLine(member.Name);
             * }
             */

            try
            {
                using (con = new SqlConnection(Properties.Settings.Default.newLootConStr)) // new sql connection using the db connection string
                {
                    Console.Write("Establishing db connection...");
                    con.Open();     // open db for use
                    Console.WriteLine("     Connected to db!");

                    foreach (var member in myMemberList)
                    {
                        //Console.WriteLine();
                        Console.Write("Creating sql command...");
                        // build sql insert command with loot values

                        using (com = new SqlCommand("AddMemberDetails", con))
                        {
                            com.CommandType = CommandType.StoredProcedure;

                            com.Parameters.AddWithValue("@tag", member.Tag);                             // add values to sql command
                            com.Parameters.AddWithValue("@name", member.Name);                           // add values to sql command
                            com.Parameters.AddWithValue("@expLevel", member.ExpLevel);                   // add values to sql command
                            com.Parameters.AddWithValue("@leagueID", member.LeagueID);                   // add values to sql command
                            com.Parameters.AddWithValue("@leagueName", member.LeagueName);               // add values to sql command
                            com.Parameters.AddWithValue("@leagueIcon", member.LeagueIcon);               // add values to sql command
                            com.Parameters.AddWithValue("@trophies", member.Trophies);                   // add values to sql command
                            com.Parameters.AddWithValue("@role", member.Role);                           // add values to sql command
                            com.Parameters.AddWithValue("@clanRank", member.ClanRank);                   // add values to sql command
                            com.Parameters.AddWithValue("@donations", member.Donations);                 // add values to sql command
                            com.Parameters.AddWithValue("@donationsReceived", member.DonationsReceived); // add values to sql command
                            com.Parameters.AddWithValue("@dateNow", member.LocalDate);                   // add values to sql command

                            Console.WriteLine("     Values added to sql command!");
                            try
                            {
                                //Console.WriteLine();
                                Console.Write("Inserting " + member.Name + " member into db...");
                                com.ExecuteNonQuery();  // execute INSERT command
                                Console.WriteLine("     " + member.Name + " successfully inserted to db!");
                            }
                            catch (SqlException e)
                            {
                                Console.WriteLine();
                                Console.WriteLine(e.Message);
                                Console.WriteLine("Failed to insert data to db");
                            }
                        }
                    }
                    con.Close();
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Failed to connect to db");
            }


            Console.WriteLine();
            Console.WriteLine("Operation Complete");
        }
 public void InitializeCore()
 {
     LeaguesCore = CocCore.Instance(TOKEN).Container.Resolve <ICocCoreLeagues>();
 }
Exemple #6
0
 public void InitializeCore()
 {
     PlayersCore = CocCore.Instance(TOKEN).Container.Resolve <ICocCorePlayers>();
 }
        public void GetClanDetails()
        {
            SqlConnection con;                      // connection variables
            SqlCommand    com;
            DateTime      localDate = DateTime.Now; // date now for loot logging date


            try   // connect to clash API
            {
                Console.Write("Connecting to Clash API...");
                // set clash api connection token
                string         token     = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImtpZCI6IjI4YTMxOGY3LTAwMDAtYTFlYi03ZmExLTJjNzQzM2M2Y2NhNSJ9.eyJpc3MiOiJzdXBlcmNlbGwiLCJhdWQiOiJzdXBlcmNlbGw6Z2FtZWFwaSIsImp0aSI6ImFlNjY2YzJmLWUyNGQtNGUwZS1hNzU5LTcyZjU4NjRjODY5NSIsImlhdCI6MTUzMDMxMTE3Niwic3ViIjoiZGV2ZWxvcGVyLzA5MGJlMzBlLWFhNjEtN2Y0YS1iMjY1LTk3Mjg1NmEzZDVhOSIsInNjb3BlcyI6WyJjbGFzaCJdLCJsaW1pdHMiOlt7InRpZXIiOiJkZXZlbG9wZXIvc2lsdmVyIiwidHlwZSI6InRocm90dGxpbmcifSx7ImNpZHJzIjpbIjE4LjE5MS4xMjcuODgiLCI3NS4xMzQuOTYuNDciXSwidHlwZSI6ImNsaWVudCJ9XX0.3-S8KOl2DjyO9dhPq4aNjfpyc3Mfei6a_YevQXV0btVU_-d6bJO1pBfuM-7LEtYN5ypXrjAyY5nDjtrHdbJBuQ";
                Funq.Container container = CocCore.Instance(token).Container;  // build new container with api token

                ICocCoreClans clansCore = container.Resolve <ICocCoreClans>(); // CoCNET interface config to clans

                Console.WriteLine(" Connection Established!");

                try  // fetch loot data
                {
                    Console.Write("Fetching clan details...");

                    var clan = clansCore.GetClans("#99L9R088");   //get JSON data for clan tag

                    tag              = clan.Tag;
                    name             = clan.Name;
                    badgeUrls        = clan.BadgeUrls["large"];
                    clanLevel        = clan.ClanLevel;
                    clanPoints       = clan.ClanPoints;
                    members          = clan.Members;
                    warWinStreak     = clan.WarWinStreak;
                    warWins          = clan.WarWins;
                    description      = clan.Decsription;
                    type             = clan.Type;
                    requiredTrophies = clan.RequiredTrophies;
                    warFrequency     = clan.WarFrequency;


                    Console.WriteLine("Clan details fetched!");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Failed to fetch data");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Failed to connect to API");
            }


            try
            {
                using (con = new SqlConnection(Properties.Settings.Default.newLootConStr)) // new sql connection using the db connection string
                {
                    Console.Write("Establishing db connection...");
                    con.Open();     // open db for use
                    Console.WriteLine(" Connected to db!");

                    Console.Write("Creating sql command...");
                    // build sql insert command with loot values
                    using (com = new SqlCommand("AddClanDetails", con))
                    {
                        com.CommandType = CommandType.StoredProcedure;

                        com.Parameters.AddWithValue("@tag", tag);  // add values to sql command
                        com.Parameters.AddWithValue("@name", name);
                        com.Parameters.AddWithValue("@badgeUrls", badgeUrls);
                        com.Parameters.AddWithValue("@clanLevel", clanLevel);
                        com.Parameters.AddWithValue("@clanPoints", clanPoints);
                        com.Parameters.AddWithValue("@members", members);
                        com.Parameters.AddWithValue("@warWinStreak", warWinStreak);
                        com.Parameters.AddWithValue("@warWins", warWins);
                        com.Parameters.AddWithValue("@description", description);
                        com.Parameters.AddWithValue("@type", type);
                        com.Parameters.AddWithValue("@requiredTrophies", requiredTrophies);
                        com.Parameters.AddWithValue("@warFrequency", warFrequency);
                        com.Parameters.AddWithValue("@dateNow", localDate);

                        Console.WriteLine("Values added to sql command!");
                        try
                        {
                            Console.Write("Inserting data into db...");
                            com.ExecuteNonQuery();  // execute INSERT command
                            Console.WriteLine(" Loot data successfully inserted to db!");
                            con.Close();
                        }
                        catch (SqlException e)
                        {
                            Console.WriteLine(e.Message);
                            Console.WriteLine("Failed to insert data to db");
                        }
                    }
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Failed to connect to db");
            }

            Console.WriteLine();
            Console.WriteLine("Operation Complete");
        }