Ejemplo n.º 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();
 }
Ejemplo n.º 2
0
        private void butApply_Click(object sender, EventArgs e)
        {
            string prevF = "0";
            string currF = "0";

            prevF = (string)OldDossier.EditValue;

            if (prevF == "4")
            {
                if (oldSelection.Text != "")
                {
                    prevF = oldSelection.Text.Replace("-", "");
                }
                else
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Please select date.");
                    return;
                }
            }

            currF = (string)NewDossier.EditValue;
            if (currF == "4")
            {
                if (newSelection.Text != "")
                {
                    currF = newSelection.Text.Replace("-", "");
                }
                else
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Please select date.");
                    return;
                }
            }

            _players.SetPlayer(_dm.GetPlayerID, prevF, currF);
            _players.Save();
            Close();
        }
Ejemplo n.º 3
0
        public frmMain()
        {
            _message.Add("frmMain loaded");

            SetTextOnSplashScreen("Initializing Components");

            WOTHelper.SetInternetZone();
            InitializeComponent();
            repositoryItemRadioGroup2.SelectedIndexChanged += new EventHandler(repositoryItemRadioGroup2_SelectedIndexChanged);
            repositoryItemRecentBattlesDisplayList.SelectedIndexChanged += new EventHandler(repositoryItemRecentBattlesDisplayList_SelectedIndexChanged);

            _chart.ObjectHotTracked += new HotTrackEventHandler(_chart_ObjectHotTracked);
            _browser.ObjectForScripting = this;

            _message = new MessageQueue();
            _message.ItemAdded += new MessageQueue_OnAdd(NewMessage);

            #if DEBUG
            _browser.IsWebBrowserContextMenuEnabled = true;
            #else
            _browser.IsWebBrowserContextMenuEnabled = false;
            #endif

            //dockPanel3.Visibility = DockVisibility.Hidden;
            //dockPanel4.Visibility = DockVisibility.Hidden;
            //dockPanelGraph.Visibility = DockVisibility.Hidden;
            //dockPanel2.Visibility = DockVisibility.Hidden;

            bar6.Visible = false;
            bar6.Offset = 0;
            barLastPlayedGames.Visible = false;
            barLastPlayedGames.Offset = 0;
            helpProvider1.HelpNamespace = Path.Combine(WOTHelper.GetEXEPath(), "Help", "WoT_Stats.chm");
            //ScriptWrapper.Initialise(WOTHelper.GetCustomScript());
            using (PlayerListing players = new PlayerListing(_message))
            {
                if (players.Count() > 0)
                {

                    string errorMessage = "";
                    foreach (KeyValuePair<string, Player> player in players)
                    {
                        SetTextOnSplashScreen("Initializing Dossier of " + player.Value.PlayerID);
                        if (!File.Exists(player.Value.WatchFile))
                        {
                            string dir = player.Value.WatchFile.Remove(player.Value.WatchFile.LastIndexOf('\\'));
                            if (Directory.Exists(dir))
                            {
                                foreach (FileInfo item in new DirectoryInfo(dir).GetFiles().Where(x => x.Extension.ToLower() == ".dat"))
                                {
                                    if (WOTHelper.PlayerIdFromDatFile(item.Name) == player.Value.PlayerID)
                                    {
                                        player.Value.WatchFile = item.FullName;
                                        players.SetPlayerWatchFile(player.Value.PlayerID, item.FullName);
                                        players.Save();
                                        break;
                                    }
                                }
                            }
                        }

                        if (File.Exists(player.Value.WatchFile))
                        {
                            DossierManager dm = new DossierManager(player.Value.PlayerID, player.Value.WatchFile, player.Value.Monitor, _message, this);
                            dm.CurrentFileChange += DossierFileChanged;
                            dictPlayers.Add(player.Value.PlayerID.Replace("_", "*"), dm);

                            //try
                            //{
                                _currentStatsFile.Add(player.Value.PlayerID.Replace("_", "*"), new WOTCompare(new Dossier(dm.GetFileB(), dm.GetPlayerName, _message).GetStats(), new Dossier(dm.GetFileA(), dm.GetPlayerName, _message).GetStats()));
                                dm.RefreshDossier();
                            //}
                            //catch (Exception ex)
                            //{

                            //    _message.Add("Error: cannot refresh dossier file. - " + ex.Message);
                            //}

                            //BarButtonItem buttonOpen = new BarButtonItem(barManager1, player.Value.PlayerID);
                            //buttonOpen.ItemClick += new ItemClickEventHandler(buttonOpen_ItemClick);
                            //buttonOpen.Name = player.Value.PlayerID;
                            //barCompare.AddItem(buttonOpen);

                            CreatePlayerMenu(player.Value.PlayerID);

                            SetTextOnSplashScreen("Initializing Monitor");

                            if (UserSettings.StartMonOnStartUp == true)
                            {
                                dm.StartDossierWatch();
                                barStaticItem1.Glyph = WOTStatistics.Stats.Properties.Resources.bullet_square_green;
                                barStaticItem1.Caption = "Monitor Status : Running";
                            }
                            else
                            {
                                barStaticItem1.Glyph = WOTStatistics.Stats.Properties.Resources.bullet_square_red;
                                barStaticItem1.Caption = "Monitor Status : Stopped";
                            }
                        }
                        else
                        {

                           // _HasPlayerError = true;
                            if (errorMessage.Length > 1)
                                errorMessage += Environment.NewLine + Environment.NewLine;

                            errorMessage += Translations.TranslationGet("STR_PLAYERERROR", "DE", "Dossier file not found for player : " + player.Value.PlayerID + Environment.NewLine + "Please check the dossier file location on the edit player screen in setup." + Environment.NewLine + "Player not loaded.").Replace("{playerid}", player.Value.PlayerID);
                        }

                        if (errorMessage.Length > 1)
                            DevExpress.XtraEditors.XtraMessageBox.Show(errorMessage, "WOT Statistics", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }

            try
            {
                if (splashScreenManagerWaitForm.IsSplashFormVisible)
                {
                    splashScreenManagerWaitForm.CloseWaitForm();
                }
            }
            catch {}

               // if (splashScreenManagerWaitForm.IsSplashFormVisible)
                //splashScreenManagerWaitForm.CloseWaitForm();
             _message.Add("frmMain DONE");

             try
             {
                 DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
             }
             catch { }
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        public void UploadToVBAddict(string filePath, string playerID, MessageQueue message)
        {
            try
            {
                FileInfo toUpload = new FileInfo(filePath);
                byte[] data = File.ReadAllBytes(filePath);

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.vbaddict.net/xxx.php");
                request.Proxy.Credentials = CredentialCache.DefaultCredentials;
                request.Method = "PUT";
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = data.Length;
                request.Headers.Clear();
                request.Referer = toUpload.Name;
                request.UserAgent = "WOTStatistics 2.1.0.0";
                request.ServicePoint.Expect100Continue = false;

                using (Stream stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }

                var response = request.GetResponse();
                Stream outStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(outStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();

                if (responseFromServer.Contains("SUCCESS"))
                {
                    using (PlayerListing pl = new PlayerListing(new MessageQueue()))
                    {
                        if (pl.GetPlayer(playerID).OnlineURL == "#")
                        {
                            pl.SetPlayerOnlineURL(playerID, responseFromServer.Substring(responseFromServer.IndexOf("Link: ") + 6).Replace("SUCCESS", ""));
                            try
                            {
                                pl.Save();
                            }
                            catch
                            {
                            }
                        }
                    }
                }

                response.Close();
            }
            catch (Exception ex)
            {
                message.Add(ex.Message);
            }
        }