Esempio n. 1
0
        private void LoadLogDatabase()
        {
            foreach (var e in Enum.GetValues(typeof(LogType)).Cast <LogType>())
            {
                logDatabase[e] = new Dictionary <string, List <LogExtract> >();
            }

            Assembly _assembly = Assembly.GetExecutingAssembly();

            string[] names = _assembly.GetManifestResourceNames();

            var logEntries = names.Where(str => str.Contains("RogueBasin.bin.Debug.logentries"));

            foreach (var filename in logEntries)
            {
                try
                {
                    Stream _fileStream = _assembly.GetManifestResourceStream(filename);
                    var    logFilenameWithoutSuffix   = filename.Substring(0, filename.LastIndexOf('.'));
                    var    logShortfilename           = logFilenameWithoutSuffix.Substring(logFilenameWithoutSuffix.LastIndexOf('.') + 1);
                    var    logShortfilenamewithsuffix = logShortfilename;

                    int logNo        = 0;
                    var numberSuffix = int.TryParse(logShortfilename.Substring(logShortfilename.Count() - 1), out logNo);

                    if (numberSuffix)
                    {
                        logShortfilename = logShortfilename.Substring(0, logShortfilename.Count() - 1);
                    }

                    var logPrefix = logShortfilename.Substring(0, logShortfilename.IndexOf('_'));
                    var logType   = logPrefixMapping[logPrefix];

                    var logExtract = new LogExtract();

                    using (StreamReader reader = new StreamReader(_fileStream))
                    {
                        string thisLine;
                        while ((thisLine = reader.ReadLine()) != null)
                        {
                            logExtract.lines.Add(thisLine);
                        }
                    }

                    logExtract.logType = logType;

                    if (!logDatabase[logType].ContainsKey(logShortfilename))
                    {
                        logDatabase[logType][logShortfilename] = new List <LogExtract>();
                    }
                    logDatabase[logType][logShortfilename].Add(logExtract);
                    logDatabaseByFilename.Add(logShortfilenamewithsuffix, logExtract);
                }
                catch (Exception)
                {
                    //Ignore it
                    continue;
                }
            }
        }
Esempio n. 2
0
        private void LoadLogDatabase()
        {
            foreach (var e in Enum.GetValues(typeof(LogType)).Cast<LogType>())
            {
                logDatabase[e] = new Dictionary<string, List<LogExtract>>();
            }

            Assembly _assembly = Assembly.GetExecutingAssembly();

            string[] names = _assembly.GetManifestResourceNames();

            var logEntries = names.Where(str => str.Contains("RogueBasin.bin.Debug.logentries"));

            foreach (var filename in logEntries)
            {

                try
                {
                    Stream _fileStream = _assembly.GetManifestResourceStream(filename);
                    var logFilenameWithoutSuffix = filename.Substring(0, filename.LastIndexOf('.'));
                    var logShortfilename = logFilenameWithoutSuffix.Substring(logFilenameWithoutSuffix.LastIndexOf('.') + 1);
                    var logShortfilenamewithsuffix = logShortfilename;

                    int logNo = 0;
                    var numberSuffix = int.TryParse(logShortfilename.Substring(logShortfilename.Count() - 1), out logNo);

                    if (numberSuffix)
                        logShortfilename = logShortfilename.Substring(0, logShortfilename.Count() - 1);

                    var logPrefix = logShortfilename.Substring(0, logShortfilename.IndexOf('_'));
                    var logType = logPrefixMapping[logPrefix];

                    var logExtract = new LogExtract();

                    using (StreamReader reader = new StreamReader(_fileStream))
                    {

                        string thisLine;
                        while ((thisLine = reader.ReadLine()) != null)
                        {
                            logExtract.lines.Add(thisLine);
                        }
                    }

                    logExtract.logType = logType;

                    if (!logDatabase[logType].ContainsKey(logShortfilename))
                        logDatabase[logType][logShortfilename] = new List<LogExtract>();
                    logDatabase[logType][logShortfilename].Add(logExtract);
                    logDatabaseByFilename.Add(logShortfilenamewithsuffix, logExtract);
                }
                catch (Exception)
                {
                    //Ignore it
                    continue;
                }
            }
        }