Ejemplo n.º 1
0
        public WN8ExpValues()
        {
            XmlDocument xmlDoc      = new XmlDocument();
            XmlNodeList nodes       = null;
            XmlNodeList headerNodes = null;

            try
            {
                xmlDoc.Load(WOTHelper.GetWN8ExpectedTankValuesFile());
                XmlElement root = xmlDoc.DocumentElement;
                nodes       = root.SelectSingleNode("WN8").ChildNodes;
                headerNodes = root.SelectSingleNode("Header").ChildNodes;
            }
            catch (Exception ex)
            {
                WOTHelper.AddToLog(ex.Message);
            }
            WN8Version   = 0;
            WN8DateEpoch = 0;
            WN8Date      = new DateTime(1970, 1, 1, 0, 0, 0);
            if (headerNodes != null)
            {
                foreach (XmlNode headerNode in headerNodes)
                {
                    if (headerNode.Name == "Version")
                    {
                        WN8Version = Convert.ToInt16(headerNode.InnerText);
                    }

                    if (headerNode.Name == "Date")
                    {
                        WN8DateEpoch = Convert.ToInt32(headerNode.InnerText);
                        WN8Date      = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(WN8DateEpoch);
                    }
                }
            }

            if (nodes != null)
            {
                MessageQueue     _messages       = null;
                TankDescriptions tankDescription = new TankDescriptions(_messages);
                foreach (XmlNode node in nodes)
                {
                    WN8ExpValue expVal = new WN8ExpValue();

                    expVal.Tank       = tankDescription.Description(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value));
                    expVal.Country    = Translations.TranslationGet(Convert.ToString(node.Attributes["countryid"].Value), "DE", Convert.ToString(node.Attributes["countryid"].Value));
                    expVal.Tier       = tankDescription.Tier(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value));
                    expVal.tankID     = Convert.ToInt32(node.Attributes["tankid"].Value);
                    expVal.countryID  = Convert.ToInt32(node.Attributes["countryid"].Value);
                    expVal.expFrag    = double.Parse(node.Attributes["expFrag"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expDamage  = double.Parse(node.Attributes["expDamage"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expSpot    = double.Parse(node.Attributes["expSpot"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expDefense = double.Parse(node.Attributes["expDef"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expWin     = double.Parse(node.Attributes["expWinRate"].Value, System.Globalization.CultureInfo.InvariantCulture);

                    Add(expVal);
                }
            }
        }
Ejemplo n.º 2
0
        private bool IsNewestFile(string fileName, MemoryTables mt)
        {
            using (DataTable tankDetail = mt.GetTable("File_TankDetails"))
            {
                using (DataTable battles = mt.GetTable("File_Battles"))
                {
                    int       file = GetCurrentPlayerFile();
                    DataTable dt;
                    if (file == 0)
                    {
                        return(true);
                    }
                    else
                    {
                        string sql = String.Format(@"select T1.cmCountryID, T1.cmTankID, sum(T2.bpBattleCount) bpBattleCount from File_TankDetails T1 inner join File_Battles T2 on T1.cmID = T2.bpParentID  where cmFileID = {0} group by T1.cmCountryID, T1.cmTankID --and bpBattleMode in (15, 0)", file);
                        using (IDBHelpers db = new DBHelpers(WOTHelper.GetDBPath(_playerName)))
                        {
                            if (!UserSettings.ClearRecentBattlesFragList.Split(';').Contains(_playerName))
                            {
                                //trying to clean up the mess need to remove this sometime in the future
                                using (DataTable recordDelete = db.GetDataTable("select cmFileID, cmID from File_Battles inner join File_TankDetails on bpParentID = cmID where bpWins > bpBattleCount  group by cmFileID"))
                                {
                                    foreach (DataRow delRows in recordDelete.Rows)
                                    {
                                        db.ExecuteNonQuery(@"delete from File_Achievements where faParentID = " + delRows.GetSafeInt("cmID"));
                                        db.ExecuteNonQuery(@"delete from File_Battles where bpParentID = " + delRows.GetSafeInt("cmID"));

                                        db.ExecuteNonQuery(@"delete from File_Clan where clParentID = " + delRows.GetSafeInt("cmID"));
                                        db.ExecuteNonQuery(@"delete from File_Company where fcParentID = " + delRows.GetSafeInt("cmID"));
                                        db.ExecuteNonQuery(@"delete from File_Historical where hsParentID = " + delRows.GetSafeInt("cmID"));
                                        db.ExecuteNonQuery(@"delete from File_FragList where fgParentID = " + delRows.GetSafeInt("cmID"));
                                        db.ExecuteNonQuery(@"delete from File_Total where foParentID = " + delRows.GetSafeInt("cmID"));
                                        db.ExecuteNonQuery(@"delete from File_TankDetails where cmFileID = " + delRows.GetSafeInt("cmFileID"));
                                        db.ExecuteNonQuery(@"delete from Files where fiID  = " + delRows.GetSafeInt("cmFileID"));
                                        db.ExecuteNonQuery(@"delete from recentbattles  where rbBattles > 100");
                                    }
                                    LoadDossierFiles();
                                }

                                db.ExecuteNonQuery(@"delete from File_Battles where bpFrags8P >  bpFrags");
                                db.ExecuteNonQuery(@"delete from File_Battles where bpMaxFrags >  15");


                                db.ExecuteNonQuery(@"update RecentBattles set rbFragList=''");
                                UserSettings.ClearRecentBattlesFragList = UserSettings.ConvertFlatFilesToDB + _playerName + ";";
                            }



                            dt = db.GetDataTable(sql);
                        }
                    }
                    int obj_Sum          = 0;
                    int obj_TestFile_Sum = 0;
                    using (TankDescriptions tankDescription = new TankDescriptions(_messages))
                    {
                        foreach (DataRow tank in dt.Rows)
                        {
                            if (tankDescription.Active(tank.GetSafeInt("cmCountryID"), tank.GetSafeInt("cmTankID")))
                            {
                                obj_Sum += tank.GetSafeInt("bpBattleCount");
                            }
                        }
                        foreach (DataRow tank in tankDetail.Rows)
                        {
                            if (tankDescription.Active(tank.GetSafeInt("cmCountryID"), tank.GetSafeInt("cmTankID")))
                            {
                                obj_TestFile_Sum += (from x in battles.AsEnumerable()
                                                     where x.GetSafeInt("bpParentID") == tank.GetSafeInt("cmID") //&& (x.GetSafeInt("bpBattleMode") == 15 || x.GetSafeInt("bpBattleMode") == 0)
                                                     select x.GetSafeInt("bpBattleCount")).Sum();
                            }
                        }
                    }
                    if (obj_Sum <= obj_TestFile_Sum)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }