Beispiel #1
0
        private int ReadData(FileInfo fi, List <SystemPosition> visitedSystems, int count, StreamReader sr)
        {
            DateTime gammastart = new DateTime(2014, 11, 22, 13, 00, 00);

            DateTime       filetime = DateTime.Now.AddDays(-500);
            string         FirstLine = sr.ReadLine();
            string         line, str;
            NetLogFileInfo nfi = null;

            str = "20" + FirstLine.Substring(0, 8) + " " + FirstLine.Substring(9, 5);

            filetime = DateTime.Parse(str);

            if (netlogfiles.ContainsKey(fi.FullName))
            {
                nfi = netlogfiles[fi.FullName];
                sr.BaseStream.Position = nfi.filePos;
                sr.DiscardBufferedData();
            }

            while ((line = sr.ReadLine()) != null)
            {
                if (line.Contains(" System:"))
                {
                    SystemPosition ps = SystemPosition.Parse(filetime, line);
                    if (ps != null)
                    {
                        if (ps.Name.Equals("Training"))
                        {
                            continue;
                        }
                        if (ps.Name.Equals("Destination"))
                        {
                            continue;
                        }


                        if (visitedSystems.Count > 0)
                        {
                            if (visitedSystems[visitedSystems.Count - 1].Name.Equals(ps.Name))
                            {
                                continue;
                            }
                        }

                        if (ps.time.Subtract(gammastart).TotalMinutes > 0)  // Ta bara med efter gamma.
                        {
                            visitedSystems.Add(ps);
                            count++;

                            //System.Diagnostics.Trace.WriteLine("Added system: " + ps.Name);
                        }

                        //Console.WriteLine(line);
                    }
                }
            }


            if (nfi == null)
            {
                nfi = new NetLogFileInfo();
            }

            nfi.FileName    = fi.FullName;
            nfi.lastchanged = File.GetLastWriteTimeUtc(nfi.FileName);
            nfi.filePos     = sr.BaseStream.Position;
            nfi.fileSize    = fi.Length;

            netlogfiles[nfi.FileName] = nfi;
            lastnfi = nfi;

            return(count);
        }
Beispiel #2
0
        private int ReadData(FileInfo fi, List <SystemPosition> visitedSystems, int count, StreamReader sr)
        {
            DateTime gammastart = new DateTime(2014, 11, 22, 13, 00, 00);

            DateTime       filetime = DateTime.Now.AddDays(-500);
            string         FirstLine = sr.ReadLine();
            string         line, str;
            NetLogFileInfo nfi = null;
            bool           CQC = false;

            str = "20" + FirstLine.Substring(0, 8) + " " + FirstLine.Substring(9, 5);

            filetime = DateTime.Parse(str);

            if (netlogfiles.ContainsKey(fi.FullName))
            {
                nfi = netlogfiles[fi.FullName];
                sr.BaseStream.Position = nfi.filePos;
                sr.DiscardBufferedData();
                CQC = nfi.CQC;
            }

            while ((line = sr.ReadLine()) != null)
            {
                if (line.Contains("[PG] [Notification] Left a playlist lobby"))
                {
                    CQC = false;
                }

                if (line.Contains("[PG] Destroying playlist lobby."))
                {
                    CQC = false;
                }

                if (line.Contains("[PG] [Notification] Joined a playlist lobby"))
                {
                    CQC = true;
                }
                if (line.Contains("[PG] Created playlist lobby"))
                {
                    CQC = true;
                }
                if (line.Contains("[PG] Found matchmaking lobby object"))
                {
                    CQC = true;
                }

                if (line.Contains(" System:") && CQC == false)
                {
                    if (line.Contains("ProvingGround"))
                    {
                        continue;
                    }

                    SystemPosition ps = SystemPosition.Parse(filetime, line);
                    if (ps != null)
                    {   // Remove some training systems
                        if (ps.Name.Equals("Training"))
                        {
                            continue;
                        }
                        if (ps.Name.Equals("Destination"))
                        {
                            continue;
                        }
                        if (ps.Name.Equals("Altiris"))
                        {
                            continue;
                        }
                        filetime = ps.time;

                        if (visitedSystems.Count > 0)
                        {
                            if (visitedSystems[visitedSystems.Count - 1].Name.Equals(ps.Name))
                            {
                                continue;
                            }
                        }

                        if (ps.time.Subtract(gammastart).TotalMinutes > 0)  // Ta bara med efter gamma.
                        {
                            visitedSystems.Add(ps);
                            count++;

                            //System.Diagnostics.Trace.WriteLine("Added system: " + ps.Name);
                        }

                        //Console.WriteLine(line);
                    }
                }
            }


            if (nfi == null)
            {
                nfi = new NetLogFileInfo();
            }

            nfi.FileName    = fi.FullName;
            nfi.lastchanged = File.GetLastWriteTimeUtc(nfi.FileName);
            nfi.filePos     = sr.BaseStream.Position;
            nfi.fileSize    = fi.Length;
            nfi.CQC         = CQC;

            netlogfiles[nfi.FileName] = nfi;
            lastnfi = nfi;

            return(count);
        }