public static List<SystemGridRow> GetLastNSystems(Expedition currentExpedition, int numberToReturn = 20)
        {
            List<StarSystem> starSystems = null;
            List<SystemGridRow> result = new List<SystemGridRow>();
            using (var db = new EelContext()) {
                starSystems = (from p in db.StarSystems.Include("Expeditions")
                               where p.Expedition.Id == currentExpedition.Id
                               orderby p.CreatedAt descending
                               select p).Take(numberToReturn).ToList();

                foreach(var system in starSystems) {
                    int count = (from q in db.SystemObjects
                                 where q.StarSystem.Id == system.Id
                                 select q).Count();

                    var row = new SystemGridRow();
                    row.Date = system.CreatedAt;
                    row.Distance = system.DistToNext;
                    row.Name = system.Name;
                    row.HasSystemObjects = count > 0;
                    row.Id = system.Id;
                    result.Add(row);
                }
            }

            return result;
        }
 public static Expedition InsertExpedition(Expedition expedition)
 {
     if (null == expedition) throw new ArgumentNullException("expedition");
     using (var db = new EelContext()) {
         db.Expeditions.Add(expedition);
         db.SaveChanges();
     }
     return expedition;
 }
 public static double GetTotalDistance(Expedition expedition)
 {
     double sum = 0;
     using (var db = new EelContext()) {
         sum = (from p in db.StarSystems.Include("Expeditions")
                where p.Expedition.Id == expedition.Id
                select p.DistToNext).Sum();
     }
     return sum;
 }
 public LogFileHandler(Expedition expedition)
 {
     _netlogfiles = new Dictionary<string, NetLogFileInfo>();
     VisitedSystems = new List<SystemPosition>();
     _expedition = expedition;
 }
示例#5
0
 private void RefreshExpeditionDropDown()
 {
     _userSelectsExpedition = false;
     if (null == _expeditions) {
         _expeditions = ExpeditionServices.GetAll();
     }
     Expeditions.DataSource = _expeditions.ToList();
     Expeditions.DisplayMember = "Name";
     var currentExpedition = _expeditions.Where(a => a.Current).FirstOrDefault();
     int itemIndex = -1;
     for (int index = 0; index < Expeditions.Items.Count; index++) {
         var exp = (Expedition)Expeditions.Items[index];
         if (exp.Id == currentExpedition.Id) {
             itemIndex = index;
             _currentExpedition = exp;
             break;
         }
     }
     Expeditions.SelectedIndex = itemIndex;
     PopulateSystemGrid();
     _userSelectsExpedition = true;
 }
示例#6
0
 private void Expeditions_SelectedIndexChanged(object sender, EventArgs e)
 {
     _currentExpedition = (Expedition)Expeditions.SelectedItem;
     PopulateSystemGrid();
 }