示例#1
0
 private void ResetData()
 {
     FrametimeGraphDataContext.FrametimeModel.Series.Clear();
     FrametimeGraphDataContext.FrametimeModel.InvalidatePlot(true);
     FpsGraphDataContext.FpsModel.Series.Clear();
     FpsGraphDataContext.FpsModel.InvalidatePlot(true);
     _localRecordDataServer.CurrentSession = null;
     LShapeCollection?.Clear();
     StatisticCollection?.Clear();
     StutteringStatisticCollection?.Clear();
     SystemInfos?.Clear();
 }
示例#2
0
 private bool canDeleteWeightRow()
 {
     try
     {
         if (StatisticCollection.Count() > 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка");
         return(false);
     }
 }
示例#3
0
        private void deleteWeightRow()
        {
            try
            {
                if (LastSelected != null)
                {
                    using (UnitOfWork unit = new UnitOfWork())
                    {
                        UsersParam toDelete = unit.UserParamRepository.Get(x => x.ParamsDate == lastSelected.ParamsDate && x.IdParams == DeserializedUser.deserializedUser.Id).First();
                        unit.UserParamRepository.Remove(toDelete);
                        unit.Save();

                        StatisticCollection = unit.UserParamRepository.Get(x => x.IdParams == DeserializedUser.deserializedUser.Id);
                    }

                    SeriesCollection.Clear();

                    ChartValues <decimal> weights = new ChartValues <decimal>(StatisticCollection.Select(x => x.UserWeight));
                    List <string>         labels  = new List <string>();

                    foreach (DateTime x in StatisticCollection.Select(x => x.ParamsDate))
                    {
                        labels.Add(x.ToString("d"));
                    }

                    Labels = labels.ToArray();
                    SeriesCollection.Add(new LineSeries
                    {
                        Title             = "Вес",
                        Values            = weights,
                        LineSmoothness    = 0,
                        PointGeometrySize = 15,
                        PointForeground   = Brushes.Coral,
                        Stroke            = Brushes.Coral,
                        Fill = Brushes.Transparent
                    });
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка");
            }
        }
        /// <summary>
        /// This is the new Regex based parser
        /// </summary>
        /// <param name="logline"></param>
        /// <returns></returns>
        public StatisticCollection RegexForDeathStats(string logline)
        {
            // Initialise this struct
            StatisticCollection statistic = new StatisticCollection();

            //Player Name
            Match PlayerNameMatch = Regex.Match(logline.Substring(33,40), "^(\\w|\\W)+\\<[0-9]+\\>(<ST|<BO|<><)");
            PlayerNameMatch = Regex.Match(PlayerNameMatch.ToString(), "^(\\w|\\W)+\\<[0-9]");
            if (PlayerNameMatch.Success)
            {
                statistic.GamerName = System.Security.SecurityElement.Escape(this.FormatBotNames(PlayerNameMatch.ToString().Substring(0, (PlayerNameMatch.ToString().Length - 2))));
            }

            //SteamID
            Match SteamIDMatch = Regex.Match(logline, "STEAM_[0-9]:[0-9]:[0-9]+");
            if (SteamIDMatch.Success == false ||
                statistic.GamerName == "Tank" ||
                statistic.GamerName == "Smoker" ||
                statistic.GamerName == "witch" ||
                statistic.GamerName == "Boomer" ||
                statistic.GamerName == "Hunter" ||
                statistic.GamerName == "Louis" ||
                statistic.GamerName == "Zoey" ||
                statistic.GamerName == "Bill" ||
                statistic.GamerName == "Francis" ||
                statistic.GamerName == "infected" ||
                statistic.GamerName == "Infected")
            {
                statistic.SteamID = "BOT-" + statistic.GamerName;
            }
            else
            {
                statistic.SteamID = SteamIDMatch.ToString();
            }

            //Area
            Match AreaIDMatch = Regex.Match(logline, "\\<Area\\s\\d+");
            if (AreaIDMatch.Success)
            {
                statistic.AreaID = AreaIDMatch.ToString().Substring(6);
            }

            //Killed entity
            Match KilledEntityMatch = Regex.Match(logline, "(killed\\s\\\"\\w+|e\\swith\\s\\\"\\w+)");
            if (KilledEntityMatch.Success)
            {
                statistic.KilledEntity = System.Security.SecurityElement.Escape(KilledEntityMatch.ToString().Substring(8));
            }
            else
            {
                KilledEntityMatch = Regex.Match(logline, "killed\\s\\\"(\\w|\\W)+\\<\\d+\\>");
                if (KilledEntityMatch.Success)
                {
                    KilledEntityMatch = Regex.Match(KilledEntityMatch.ToString().Substring(8), "(\\w|\\W)+\\<");

                    statistic.KilledEntity = System.Security.SecurityElement.Escape(KilledEntityMatch.ToString().Substring(0,KilledEntityMatch.ToString().Length -1));
                }

            }

            //Weapon
            Match WeaponMatch = Regex.Match(logline, "with\\s\\\"\\w+");
            if (WeaponMatch.Success)
            {
                statistic.Weapon = WeaponMatch.ToString().Substring(6);
            }

            // Did someone score a headshot?
            if (logline.Contains("headshot") == true)
            {
                statistic.HeadShot = "1";
            }
            else
            {
                statistic.HeadShot = "0";
            }

            return statistic;
        }
        /// <summary>
        /// Given a log directory, the prefix of the setup log and the mapname this function
        /// chews through the log counting up the stats and creating a big ol' array of
        /// arrays ready for further processing
        /// </summary>
        /// <param name="logDirectory">The log directory.</param>
        /// <param name="logFile">The log file.</param>
        /// <param name="mapName">Name of the map.</param>
        /// <returns>
        /// an array that can be sent for further processing
        /// </returns>
        public IndivGame ProcessLogs(string logDirectory, string logFile, string mapName)
        {
            ArrayList thisGame = new ArrayList();
            IndivGame returnArray = new IndivGame();
            bool isLogClosed = false;
            int kills = 0;

            string[] logFileParts = logFile.Split(new char[] { '_' });
            string logFilePrefix = logFileParts[0] + "_" + logFileParts[1] + "_" + logFileParts[2] + "_" + logFileParts[3] + "_" + logFileParts[4] + "_" + logFileParts[5];
            string fullFilePath = string.Empty;
            string fullFileName = string.Empty;

            //Check if the file passed (which we already know has setup elements in it) is also a stats log
            if (this.Check_sv_log_onefile(logDirectory + logFile) == true)
            {
                Console.WriteLine("Found a log file written as sv_log_onefile 1. Processing...");
                fullFilePath = logDirectory + logFile;
                fullFileName = logFile;
                validFiles.SetupLog = logFile;
                validFiles.StatsLog = "false";
                validFiles.LogDirectory = logDirectory;
                returnArray.MapName = mapName + "_movie";
            }
            else
            {
                Console.WriteLine("Log file was only a setup file, attempting to find a matching stats log...");
                validFiles.SetupLog = logFile;
                validFiles.LogDirectory = logDirectory;
                // Setup logs should be either 000.log (first log in this minute) or 002.log (previous game failed and a new one started in the same minute)
                if (logFileParts[6] == "000.log")
                {
                    fullFilePath = logDirectory + logFilePrefix + "_001.log";
                    fullFileName = logFilePrefix + "_001.log";
                }
                else
                {
                    fullFilePath = logDirectory + logFilePrefix + "_003.log";
                    fullFileName = logFilePrefix + "_003.log";
                }

                returnArray.MapName = mapName;
            }
            returnArray.LogPrefix = logFilePrefix;

            StreamReader re;

            Console.WriteLine("Opening File: " + fullFilePath);

            //Try and open the file
            try
            {
                if (File.Exists(fullFilePath))
                {
                    re = File.OpenText(fullFilePath);
                }
                else
                {
                    Console.WriteLine("Usual statistics log X_001.log not found - trying known alternatives");

                    fullFileName = this.FindAlternativeLogFile(logDirectory, validFiles.SetupLog);

                    if (fullFileName == "FAILED")
                    {
                        Console.WriteLine("Alternative Files not found or some other such nasty error\r\n");
                        returnArray.Closed = false;
                        return returnArray;
                    }
                    else
                    {
                        fullFilePath = logDirectory + fullFileName;
                        re = File.OpenText(fullFilePath);
                    }
                }

                //No point repeating ourselves [Will cause MoveFiles() to crash
                if (fullFileName != validFiles.SetupLog)
                {
                    validFiles.StatsLog = fullFileName; // logFilePrefix + "_001.log";
                }
                else
                {
                    validFiles.StatsLog = "false";
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                Console.WriteLine("Despite a call to FindAlternativeLogFile() no alternative logs were found");

                returnArray.Closed = false;
                return returnArray;
            }
            catch
            {
                Console.WriteLine("An exception unrelated to I/O Operations occured\r\n");

                returnArray.Closed = false;
                return returnArray;
            }

            // Check this is a valid log file
            if (re.ReadToEnd().Contains("Log file closed"))
            {
                isLogClosed = true;
                Console.WriteLine("Log File has been closed by server - continuing to process\r\n");
            }
            else
            {
                Console.WriteLine("Log File is still in use or crashed - aborting processing\r\n");
                returnArray.Closed = false;
                return returnArray;
            }

            // Its valid so loop through each line
            string logLine = string.Empty;
            string StatType = string.Empty;
            re.Close();
            re = File.OpenText(fullFilePath);

            while ((logLine = re.ReadLine()) != null)
            {
                //Experimental Regular Expression matching

                if (logLine.Length > 30)
                {
                    StatType = logLine.Substring(26, 4);
                }
                else
                {
                    continue;
                }

            switch(StatType)
            {
                //This is a line where something killed something
                case "DEAT":
                {
                     // Initialise this struct
                    StatisticCollection statistic = new StatisticCollection();

                    statistic = this.RegexForDeathStats(logLine);

                    // If all is OK assign the struct values
                    if (statistic.Weapon == "player" ||
                        statistic.Weapon == "prop_physics" ||
                        statistic.Weapon == "trigger_hurt" ||
                        statistic.Weapon == "env_fire" ||
                        statistic.Weapon == "trigger_hurt_ghost" ||
                        statistic.Weapon == "Reset" ||
                        statistic.Weapon == "prop_door_rotating_checkpoint" ||
                        statistic.Weapon == "entityflame" ||
                        statistic.Weapon == "world" ||
                        statistic.Weapon == "worldspawn" ||
                        String.IsNullOrEmpty(statistic.AreaID) ||
                        String.IsNullOrEmpty(statistic.GamerName) ||
                        String.IsNullOrEmpty(statistic.HeadShot) ||
                        String.IsNullOrEmpty(statistic.KilledEntity) ||
                        String.IsNullOrEmpty(statistic.SteamID) ||
                        String.IsNullOrEmpty(statistic.Weapon))
                    {
                        // do nothing
                    }
                    else
                    {
                        kills++;
                        thisGame.Add(statistic);
                    }
                }
                break;

                //Something got incapped
                case "INCA":
                {
                    //print("INCAP Event  -  ");
                    //RegexIncapParser($Data);
                }
                break;
            }

                /////////////////////////// OLD PARSER ///////////////////////////////////////////
                /*
                // Do all the parsing
                // Explode the line into componant parts
                string[] line = logLine.Split(new char[] { ':' });

                // Make sure this isn't a funky line
                if (line.Length >= 6)
                {
                    string gamerName = string.Empty;
                    string headShot = "false";
                    string steamID = string.Empty;
                    string areaID = string.Empty;
                    string killedEntity = string.Empty;
                    string weapon = string.Empty;
                    string testLine = line[3];

                    // This is a lazy hack to fix people who have :'s in their name
                    // This *REALLY* needs to be fixed
                    if (testLine.Length < 6)
                    {
                        testLine = "123456";
                    }

                    // Evaluate the first 6 characters of the chopped line and work out what sort of stat record this is
                    switch (testLine.Substring(0, 6))
                    {
                        case " (1)Ta":
                            {
                                // Console.WriteLine("TANK Event");
                            }

                            break;

                        case " (2)Ta":
                            {
                                // Console.WriteLine("TANK Event");
                            }

                            break;

                        case " (RESC":
                            {
                                // Console.WriteLine("Rescue Event");
                            }

                            break;

                        case " (INCA":
                            {
                                // Console.WriteLine("Player Incap'd");
                            }

                            break;

                        case " (PHYS":
                            {
                                // Console.WriteLine("The physics engine did something");
                            }

                            break;

                        case " (TONG":
                            {
                                // Console.WriteLine("A smoker did something");
                            }

                            break;

                        case " (MOB)":
                            {
                                // Console.WriteLine("MOB Event");
                            }

                            break;

                        case " (SKIN":
                            {
                                // Console.WriteLine("(SKIN) Event");
                            }

                            break;

                        case " (DEAT":
                            {
                                string[] ltgtdelimter = { "><" };
                                string[] steamIDArray;
                                try
                                {
                                    int startPlayerName = logLine.IndexOf('"') + 1;
                                    int endPlayerName = logLine.IndexOf('<') - startPlayerName;
                                    gamerName = logLine.Substring(startPlayerName, endPlayerName);
                                }
                                catch // (Exception GamerNameException)
                                {
                                    Console.WriteLine("Ascertaining the players name failed - this record will be scrubbed");
                                    continue;
                                }

                                try
                                {
                                    // Get the Steam ID (we do this first then do the check for bots later)
                                    steamIDArray = logLine.Split(ltgtdelimter, System.StringSplitOptions.None);
                                    steamID = steamIDArray[1];
                                }
                                catch // (Exception SteamIDException)
                                {
                                    Console.WriteLine("Ascertaining the players Steam ID failed - this record will be scrubbed");
                                    continue;
                                }

                                // If they have a valid SteamID it won't be changed *if* however they are
                                // a bot we need to record that
                                switch (gamerName)
                                {
                                    case "(1)Tank":
                                    case "(2)Tank":
                                    case "(3)Tank":
                                    case "(4)Tank":
                                        {
                                            gamerName = "Tank";
                                            steamID = "BOT-TANK";
                                        }

                                        break;

                                    case "Hunter":
                                        {
                                            steamID = "BOT-Hunter";
                                        }

                                        break;

                                    case "infected":
                                        {
                                            steamID = "BOT-infected";
                                        }

                                        break;

                                    case "witch":
                                        {
                                            steamID = "BOT-witch";
                                        }

                                        break;

                                    case "Smoker":
                                        {
                                            steamID = "BOT-Smoker";
                                        }

                                        break;

                                    case "Boomer":
                                        {
                                            steamID = "BOT-Boomer";
                                        }

                                        break;

                                    case "Bill":
                                        {
                                            steamID = "BOT-Bill";
                                        }

                                        break;

                                    case "Louis":
                                        {
                                            steamID = "BOT-Louis";
                                        }

                                        break;

                                    case "Zoey":
                                        {
                                            steamID = "BOT-Zoey";
                                        }

                                        break;

                                    case "Francis":
                                        {
                                            steamID = "BOT-Francis";
                                        }

                                        break;
                                }

                                // Get the AREAID
                                try
                                {
                                    areaID = steamIDArray[7].Substring(5, (steamIDArray[7].IndexOf('>') - 5));
                                }
                                catch // (Exception AreaIDException)
                                {
                                    Console.WriteLine("Ascertaining the Area ID failed - this record will be scrubbed");
                                    continue;
                                }

                                try
                                {
                                    // Get what was killed
                                    string[] killedDelimiter = { "\" killed \"" };
                                    string[] killedEntityArray = logLine.Split(killedDelimiter, System.StringSplitOptions.None);

                                    // This is to prevent the OOB error due to someone dying 'weirdly'
                                    if (killedEntityArray.Length < 2)
                                    {
                                        killedEntity = "Unknown";
                                    }
                                    else
                                    {
                                        killedEntity = killedEntityArray[1];
                                        killedEntity = killedEntity.Substring(0, killedEntity.IndexOf('<'));
                                    }
                                }
                                catch
                                {
                                    Console.WriteLine("Ascertaining what was killed failed - this record will be scrubbed");
                                    continue;
                                }

                                try
                                {
                                    // Get What Weapon Was used
                                    string[] weaponDelimiter = { "\" with \"" };
                                    string[] weaponArray = logLine.Split(weaponDelimiter, System.StringSplitOptions.None);
                                    if (weaponArray.Length < 2)
                                    {
                                        weapon = "world";
                                    }
                                    else
                                    {
                                        weapon = weaponArray[1].Substring(0, weaponArray[1].IndexOf('"'));
                                    }
                                }
                                catch // (Exception WeaponException)
                                {
                                    Console.WriteLine("Ascertaining what weapon was used failed - this record will be scrubbed");
                                    continue;
                                }

                                // Did someone score a headshot?
                                if (logLine.Contains("headshot") == true)
                                {
                                    headShot = "1";
                                }
                                else
                                {
                                    headShot = "0";
                                }
                            }

                            break;

                        default:
                            {
                                // This is not an error its output to help for matching!
                                // Console.WriteLine("Match error:" + Line[3].Substring(0, 6));
                            }

                            break;
                    }

                    // Initialise this struct
                    StatisticCollection statistic = new StatisticCollection();

                    // If all is OK assign the struct values
                    if (weapon == "player" ||
                        weapon == "prop_physics" ||
                        weapon == "trigger_hurt" ||
                        weapon == "env_fire" ||
                        weapon == "trigger_hurt_ghost" ||
                        weapon == "Reset" ||
                        weapon == "prop_door_rotating_checkpoint" ||
                        weapon == "entityflame" ||
                        weapon == "world" ||
                        weapon == "worldspawn" ||
                        weapon == "" ||
                        steamID == "")
                    {
                        // do nothing
                    }
                    else
                    {
                        kills++;
                        statistic.GamerName = gamerName;
                        statistic.SteamID = steamID;
                        statistic.AreaID = areaID;
                        statistic.KilledEntity = killedEntity;
                        statistic.Weapon = weapon;
                        statistic.HeadShot = headShot;

                        thisGame.Add(statistic);
                    }
                }*/
            }

            // Close the file so we can move it
            re.Close();

            // Move the files we know were valid - moved to the calling function to check if the XMLRPC post worked 28/01/09
            //this.MoveFiles(validFiles, logDirectory);

            // Pass all these stats back for further processing
            returnArray.Kills = kills;
            returnArray.Closed = isLogClosed;
            returnArray.Stats = thisGame;
            return returnArray;
        }
示例#6
0
        public StatisticViewModel()
        {
            try
            {
                using (UnitOfWork unit = new UnitOfWork())
                {
                    LastSelected = default;

                    StatisticCollection = unit.UserParamRepository.Get(x => x.IdParams == DeserializedUser.deserializedUser.Id);
                    IEnumerable <Report> report             = unit.ReportRepository.Get(x => x.IdReport == DeserializedUser.deserializedUser.Id);
                    List <Report>        mostReportCategory = (List <Report>)unit.ReportRepository.Get(x => x.IdReport == DeserializedUser.deserializedUser.Id && DateTime.Today.Date.Date.Equals(x.ReportDate.Date));

                    if (mostReportCategory.Capacity != 0)
                    {
                        MostCategory = mostReportCategory.GroupBy(i => i.MostCategory).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First();
                    }
                    else
                    {
                        MostCategory = "---";
                    }

                    if (report.Count() != 0)
                    {
                        LastReportDate = report.Last().ReportDate.ToString();
                    }
                    else
                    {
                        LastReportDate = "---";
                    }

                    if (StatisticCollection.Count() != 0)
                    {
                        Height = StatisticCollection.Last().UserHeight;
                        Weight = StatisticCollection.Last().UserWeight;


                        ChartValues <decimal> weights = new ChartValues <decimal>(StatisticCollection.Select(x => x.UserWeight));
                        List <string>         labels  = new List <string>();

                        foreach (DateTime x in StatisticCollection.Select(x => x.ParamsDate))
                        {
                            labels.Add(x.ToString("d"));
                        }

                        Labels     = labels.ToArray();
                        YFormatter = value => value.ToString("0.00");

                        SeriesCollection = new SeriesCollection();

                        SeriesCollection.Add(new LineSeries
                        {
                            Title             = "Вес",
                            Values            = weights,
                            LineSmoothness    = 0,
                            PointGeometrySize = 15,
                            PointForeground   = Brushes.Coral,
                            Stroke            = Brushes.Coral,
                            Fill = Brushes.Transparent
                        });
                    }
                    else
                    {
                        Height = 0;
                        Weight = 0;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка");
            }
        }
 public SaleIncomeQueryResultVM()
 {
     ResultList = new List <SaleIncomeVM>();
     Statistic  = new StatisticCollection <SaleIncomeQueryStatisticVM>();
 }
示例#8
0
 public InvoiceQueryResultVM()
 {
     ResultList = new List <InvoiceVM>();
     Statistic  = new StatisticCollection <InvoiceQueryStatisticVM>();
 }