예제 #1
0
        // open a new file for watching, place it into the netlogreaders list

        private EDJournalReader OpenFileReader(FileInfo fi, Dictionary <string, TravelLogUnit> tlu_lookup = null)
        {
            EDJournalReader reader;
            TravelLogUnit   tlu;

            //System.Diagnostics.Trace.WriteLine(string.Format("File Read {0}", fi.FullName));

            if (netlogreaders.ContainsKey(fi.Name))
            {
                reader = netlogreaders[fi.Name];
            }
            else if (tlu_lookup != null && tlu_lookup.ContainsKey(fi.Name))
            {
                tlu      = tlu_lookup[fi.Name];
                tlu.Path = fi.DirectoryName;
                reader   = new EDJournalReader(tlu);
                netlogreaders[fi.Name] = reader;
            }
            else if (TravelLogUnit.TryGet(fi.Name, out tlu))
            {
                tlu.Path = fi.DirectoryName;
                reader   = new EDJournalReader(tlu);
                netlogreaders[fi.Name] = reader;
            }
            else
            {
                reader = new EDJournalReader(fi.FullName);

                netlogreaders[fi.Name] = reader;
            }

            return(reader);
        }
        // open a new file for watching, place it into the netlogreaders list. Always return a reader

        private EDJournalReader OpenFileReader(string filepath, bool delayadd = false)
        {
            EDJournalReader reader;

            //System.Diagnostics.Trace.WriteLine(string.Format("{0} Opening File {1}", Environment.TickCount % 10000, fi.FullName));

            if (netlogreaders.ContainsKey(filepath))        // cache
            {
                reader = netlogreaders[filepath];
            }
            else if (TravelLogUnit.TryGet(filepath, out TravelLogUnit tlu))   // from db
            {
                reader = new EDJournalReader(tlu);
                netlogreaders[filepath] = reader;
            }
            else
            {
                reader = new EDJournalReader(filepath);
                reader.TravelLogUnit.Type = TravelLogUnit.JournalType;
                if (!delayadd)
                {
                    reader.TravelLogUnit.Add();
                }
                netlogreaders[filepath] = reader;
            }

            return(reader);
        }
예제 #3
0
        // open a new file for watching, place it into the netlogreaders list. Always return a reader

        private EDJournalReader OpenFileReader(string filepath, bool delayadd = false)
        {
            EDJournalReader reader;

            //System.Diagnostics.Trace.WriteLine(string.Format("{0} Opening File {1}", Environment.TickCount % 10000, fi.FullName));

            if (netlogreaders.ContainsKey(filepath))        // cache
            {
                reader = netlogreaders[filepath];
            }
            else if (TravelLogUnit.TryGet(filepath, out TravelLogUnit tlu))   // from db
            {
                reader = new EDJournalReader(tlu);
                netlogreaders[filepath] = reader;
            }
            else
            {
                reader = new EDJournalReader(filepath);
                reader.TravelLogUnit.Type = TravelLogUnit.JournalType;
                var filename = Path.GetFileName(filepath);
                if (filename.StartsWith("JournalBeta.", StringComparison.InvariantCultureIgnoreCase) ||
                    filename.StartsWith("JournalAlpha.", StringComparison.InvariantCultureIgnoreCase))
                {
                    reader.TravelLogUnit.Type |= TravelLogUnit.BetaMarker;
                }

                if (!delayadd)
                {
                    reader.TravelLogUnit.Add();
                }
                netlogreaders[filepath] = reader;
            }

            return(reader);
        }
예제 #4
0
        private EDJournalReader OpenFileReader(FileInfo fi, Dictionary <string, TravelLogUnit> tlu_lookup = null)
        {
            EDJournalReader reader;
            TravelLogUnit   tlu;

            //System.Diagnostics.Trace.WriteLine(string.Format("File Read {0}", fi.FullName));

            if (netlogreaders.ContainsKey(fi.Name))
            {
                reader = netlogreaders[fi.Name];
            }
            else if (tlu_lookup != null && tlu_lookup.ContainsKey(fi.Name))
            {
                tlu      = tlu_lookup[fi.Name];
                tlu.Path = fi.DirectoryName;
                reader   = new EDJournalReader(tlu);
                netlogreaders[fi.Name] = reader;
            }
            else if (TravelLogUnit.TryGet(fi.Name, out tlu))
            {
                tlu.Path = fi.DirectoryName;
                reader   = new EDJournalReader(tlu);
                netlogreaders[fi.Name] = reader;
            }
            else
            {
                reader = new EDJournalReader(fi.FullName);

#if false
                // Bring over the commander from the previous log if possible
                Match match = journalNamePrefixRe.Match(fi.Name);
                if (match.Success)
                {
                    string prefix  = match.Groups["prefix"].Value;
                    string partstr = match.Groups["part"].Value;
                    int    part;
                    if (Int32.TryParse(partstr, NumberStyles.Integer, CultureInfo.InvariantCulture, out part) && part > 1)
                    {
                        //EDCommander lastcmdr = EDDConfig.Instance.CurrentCommander;
                        var lastreader = netlogreaders.Where(kvp => kvp.Key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
                                         .Select(k => k.Value)
                                         .FirstOrDefault();
                        //if (lastreader != null)
                        //{
                        //lastcmdr = lastreader.Commander;
                        //}

                        //reader.Commander = lastcmdr;
                    }
                }
#endif
                netlogreaders[fi.Name] = reader;
            }

            return(reader);
        }
예제 #5
0
        private static NetLogFileReader OpenFileReader(string filepath, int cmdrid)
        {
            NetLogFileReader reader;

            if (TravelLogUnit.TryGet(filepath, out TravelLogUnit tlu))
            {
                reader = new NetLogFileReader(tlu);
            }
            else
            {
                reader = new NetLogFileReader(filepath);
                reader.TravelLogUnit.Type        = TravelLogUnit.NetLogType;
                reader.TravelLogUnit.CommanderId = cmdrid;
            }

            return(reader);
        }
예제 #6
0
        private static NetLogFileReader OpenFileReader(FileInfo fi, Dictionary <string, TravelLogUnit> tlu_lookup = null, Dictionary <string, List <JournalLocOrJump> > vsc_lookup = null, Dictionary <string, NetLogFileReader> netlogreaders = null)
        {
            NetLogFileReader        reader;
            TravelLogUnit           tlu;
            List <JournalLocOrJump> vsclist = null;

            if (vsc_lookup != null && vsc_lookup.ContainsKey(fi.Name))
            {
                vsclist = vsc_lookup[fi.Name];
            }

            if (netlogreaders != null && netlogreaders.ContainsKey(fi.Name))
            {
                return(netlogreaders[fi.Name]);
            }
            else if (tlu_lookup != null && tlu_lookup.ContainsKey(fi.Name))
            {
                tlu      = tlu_lookup[fi.Name];
                tlu.Path = fi.DirectoryName;
                reader   = new NetLogFileReader(tlu, vsclist);
            }
            else if (TravelLogUnit.TryGet(fi.Name, out tlu))
            {
                tlu.Path = fi.DirectoryName;
                reader   = new NetLogFileReader(tlu, vsclist);
            }
            else
            {
                reader = new NetLogFileReader(fi.FullName);
            }

            if (netlogreaders != null)
            {
                netlogreaders[fi.Name] = reader;
            }

            return(reader);
        }