public static SystemPosition Parse(DateTime lasttime, string line) { SystemPosition sp = new SystemPosition(); try { if (line.Length < 15) return null; if (line.StartsWith("<data>")) return null; string str = line.Substring(1, 2); int hour = int.Parse(str); int min = int.Parse(line.Substring(4, 2)); int sec = int.Parse(line.Substring(7, 2)); sp.Time = new DateTime(lasttime.Year, lasttime.Month, lasttime.Day, hour, min, sec); if (sp.Time.Subtract(lasttime).TotalHours < -12) sp.Time = sp.Time.AddDays(1); str = line.Substring(18, line.IndexOf(" Body:") - 19); sp.Nr = int.Parse(str.Substring(0, str.IndexOf("("))); sp.Name = str.Substring(str.IndexOf("(") + 1); return sp; } catch { return null; } }
public async Task<StarSystem> AddNewStarSystem(SystemPosition ps) { if (null == CurrentExpedition) throw new Exception("CurrentExpedition is null"); if (null == ps) throw new ArgumentNullException("ps"); var ss = new StarSystem(); ss.Name = ps.Name; ss.Expedition = CurrentExpedition; var sys = await _starSystemRepository.Insert(ss); if (null != sys) { StarSystems.ToList().Add(sys); } return sys; }
static public SystemPosition Parse(DateTime lasttime, string line) { SystemPosition sp = new SystemPosition(); try { if (line.Length < 15) { return(null); } if (line.StartsWith("<data>")) { return(null); } string str = line.Substring(1, 2); int hour = int.Parse(str); int min = int.Parse(line.Substring(4, 2)); int sec = int.Parse(line.Substring(7, 2)); sp.Time = new DateTime(lasttime.Year, lasttime.Month, lasttime.Day, hour, min, sec); if (sp.Time.Subtract(lasttime).TotalHours < -12) { sp.Time = sp.Time.AddDays(1); } str = line.Substring(18, line.IndexOf(" Body:") - 19); sp.Nr = int.Parse(str.Substring(0, str.IndexOf("("))); sp.Name = str.Substring(str.IndexOf("(") + 1); return(sp); } catch { return(null); } }
private async Task AddNewSystem(SystemPosition ps) { if (ps == null) throw new ArgumentNullException("ps"); var starSystem = await _persistentStore.AddNewStarSystem(ps); NetLogWatcherEventArgs args = new NetLogWatcherEventArgs(); args.CurrentSystem = starSystem; OnNewPosition(this, args); //ss.Name = ps.Name; //var sys = await _starSystemRepository.Save(ss); //LogText(string.Format("{0}: Adding system: {1}", DateTime.Now, ps.Name)); //var current = _systemPointer.Get<string>("currentObjectId"); ; //_systemPointer["lastObjectId"] = current; //_systemPointer["currentObjectId"] = sys.ObjectId; //_systemPointer = await _systemPointerRepository.Save(_systemPointer); }