コード例 #1
0
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     using (PlayerListing pl = new PlayerListing(new MessageQueue()))
     {
         pl.SetPlayer(txtPlayerID.Text, txtPlayerID.Text, txtPlayerRealm.Text, txtWatchFile.Text, checkFTPFile.Checked);
         pl.Save();
         if (!File.Exists(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + txtPlayerID.Text, "LastBattle", "WOTSStore.db")))
         {
             Directory.CreateDirectory(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + txtPlayerID.Text, "LastBattle"));
             DatabaseSanityChecker.Create(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + txtPlayerID.Text, "LastBattle", "WOTSStore.db"));
         }
     }
     Close();
 }
コード例 #2
0
        public VersionChecker(string productVersion)
        {
            MemoryStream versionMS  = GetWebVersion;
            StreamReader sr         = new StreamReader(versionMS);
            string       versions   = sr.ReadToEnd();
            string       webVersion = versions.Split('|')[0];
            Version      v1         = new Version(webVersion);
            Version      v2         = new Version(productVersion);

            switch (v1.CompareTo(v2))
            {
            case 0:
                UpdateAvailable = false;
                break;

            case 1:
                UpdateAvailable = true;
                break;

            case -1:
                UpdateAvailable = false;
                break;

            default:
                UpdateAvailable = false;
                break;
            }

            SiteVersion = webVersion;

            try
            {
                string settingFileVersion = versions.Split('|')[1];
                if (settingFileVersion != UserSettings.SettingsFileVersion)
                {
                    DownloadFile("wotstatistics/sync/", WOTHelper.GetApplicationData(), "settings.xml");
                    Task.Factory.StartNew(() => VerifyImages());
                    UserSettings.SettingsFileVersion = settingFileVersion;
                }
            }
            catch { }

            try
            {
                string translationFileVersion = versions.Split('|')[2];
                if (translationFileVersion != UserSettings.TranslationFileVersion)
                {
                    DownloadFile("wotstatistics/sync/", WOTHelper.GetApplicationData(), "translations.xml");
                    UserSettings.TranslationFileVersion = translationFileVersion;
                    Translations.Reload();
                }
            }
            catch { }

            try
            {
                string WN8ExpectedVersion = versions.Split('|')[5];
                if (WN8ExpectedVersion != UserSettings.WN8ExpectedVersion)
                {
                    DownloadFile("wotstatistics/sync/", WOTHelper.GetApplicationData(), "expected_wn8.xml");
                    UserSettings.WN8ExpectedVersion = WN8ExpectedVersion;
                }
            }
            catch { }

            try
            {
                string scriptFileVersion = versions.Split('|')[3];
                if (scriptFileVersion != UserSettings.ScriptFileVersion)
                {
                    try
                    {
                        DownloadFile("wotstatistics/sync/", WOTHelper.GetApplicationData() + @"\Scripts", "CustomScript.wss");
                    }
                    catch {}
                    try
                    {
                        DownloadFile("wotstatistics/sync/", WOTHelper.GetApplicationData() + @"\Scripts", "tooltips.js");
                    }
                    catch {}
                    try
                    {
                        DownloadFile("wotstatistics/sync/", WOTHelper.GetApplicationData() + @"\Scripts", "sorttable.js");
                    }
                    catch {}
                    UserSettings.ScriptFileVersion = scriptFileVersion;
                    ScriptWrapper.Initialise(WOTHelper.GetCustomScript());
                }
            }
            catch { ScriptWrapper.Initialise(WOTHelper.GetCustomScript()); }
        }
コード例 #3
0
        // Public MemoryStream property containing PDF Data

        private void VerifyImages()
        {
            string      tanksWebPath = "wotstatistics/sync/images/tanks/";
            XmlDocument xmlDoc       = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetSettingsFile());
            XmlElement  root  = xmlDoc.DocumentElement;
            XmlNodeList nodes = root.SelectSingleNode(@"Tanks").ChildNodes;

            foreach (XmlNode node in nodes)
            {
                string tankID        = String.Format("{0}_{1}", node.Attributes["Country"].Value, node.Attributes["Code"].Value);
                bool   updatePicture = false;
                try
                {
                    updatePicture = node.Attributes["Update"] == null ? false : bool.Parse(node.Attributes["Update"].Value);
                }
                catch
                {
                    //silently handle the error
                    updatePicture = false;
                }

                //first check if we should update
                if (updatePicture)
                {
                    DownloadFile(tanksWebPath, Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks"), tankID + ".png");
                    DownloadFile(tanksWebPath, Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks"), tankID + "_Large.png");
                }
                else
                {
                    //only check the small in appdata it is not there we download both'
                    if (!File.Exists(Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks", tankID + ".png")))
                    {
                        //ok now check if it exists in the exe path
                        if (!File.Exists(Path.Combine(WOTHelper.GetEXEPath(), "Images", "Tanks", tankID + ".png")))
                        {
                            //Download both the normal and large file
                            DownloadFile(tanksWebPath, Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks"), tankID + ".png");
                            DownloadFile(tanksWebPath, Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks"), tankID + "_Large.png");
                        }

                        //ok now check if the large file exists in the appdata path
                        if (!File.Exists(Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks", tankID + "_Large.png")))
                        {
                            //ok now check if the large file exists in the exe path
                            if (!File.Exists(Path.Combine(WOTHelper.GetEXEPath(), "Images", "Tanks", tankID + "_Large.png")))
                            {
                                //Download both the large file
                                DownloadFile(tanksWebPath, Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks"), tankID + "_Large.png");
                            }
                        }
                    }
                    else
                    {
                        //Okay we found the small one in appdata now check for big one
                        if (!File.Exists(Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks", tankID + "_Large.png")))
                        {
                            //download Large file
                            DownloadFile(tanksWebPath, Path.Combine(WOTHelper.GetApplicationData(), "Images", "Tanks"), tankID + "_Large.png");
                        }
                    }
                }
            }
        }