コード例 #1
0
        public void loadUserShipsInPort(long UserID, bool hideMessage = false)
        {
            LOG.Debug("loadUserShipsInPort()");
            PlayerShipImport Importer = WGAPI.GetPlayerShips(UserID);

            if (Importer.Status.ToLower().Equals("ok"))
            {
                List <PlayerShip> PersonalShips = new List <PlayerShip>();
                Dictionary <string, List <PlayerShip> > ImportedShips = Importer.Ships;

                foreach (KeyValuePair <string, List <PlayerShip> > ShipID in ImportedShips)
                {
                    foreach (PlayerShip PShip in ShipID.Value)
                    {
                        PersonalShips.Add(PShip);
                    }
                }

                string FileName = Commons.GetPersonalShipsFileName();
                BinarySerialize.WriteToBinaryFile <List <PlayerShip> >(FileName, PersonalShips);

                if (hideMessage == false)
                {
                    MessageBox.Show("Your ships have been imported.", "Load Personal Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                LOG.Debug("User ships downloaded ok");
            }
            else
            {
                LOG.Warning("Download of users ships failed!");
                MessageBox.Show("Some error occured during gathering of data. Try again later.", "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
        public static PlayerShipImport GetPlayerShips(long ID)
        {
            try { Setup(); } catch (Exception) { }
            string path           = $"ships/stats/?application_id={APP_ID}&account_id={ID}&in_garage=1&fields=ship_id";
            string responseString = "";
            var    response       = Client.GetAsync(path).Result;

            if (response.IsSuccessStatusCode)
            {
                var responseContent = response.Content;
                responseString = responseContent.ReadAsStringAsync().Result;
            }
            PlayerShipImport PlayerImport = JsonConvert.DeserializeObject <PlayerShipImport>(responseString);

            return(PlayerImport);
        }