private void Lookup()
        {
            var sql = String.Format(SelectString, SelectArgValues);
            var results = Database.QueryHelper.RunQuery(_connection, sql);
            var v = _queries.SelectQueryFields.FirstOrDefault(x => x.Property == "ZoneId");
            string zoneIdField = null;
            if (v != null)
            {
                zoneIdField = v.Column;
            }

            if (results != null)
            {
                foreach (var row in results)
                {
                    Grid g = new Grid(_queryConfig);
                    if (row.ContainsKey(zoneIdField) && results.First() == row)
                    {
                        ZoneId = Int32.Parse(row[zoneIdField].ToString());
                    }

                    g.SetProperties(Queries, row);
                    Grids.Add(g);
                    g.Created();
                }

                foreach (var grid in Grids)
                {
                    sql = String.Format(grid.SelectString, grid.SelectArgValues);
                    results = Database.QueryHelper.RunQuery(_connection, sql);
                    foreach (var row in results)
                    {
                        var wp = new Waypoint(_queryConfig);

                        wp.SetProperties(grid.Queries, row);

                        wp.GridReference = grid;
                        grid.Waypoints.Add(wp);
                        wp.Created();
                    }
                }
            }
        }
Beispiel #2
0
        public Waypoint GetNewWaypoint()
        {
            int number = GetNextNewWaypointNumber();
            Waypoint wp = new Waypoint(Id, ZoneId, number, _queryConfig);
            wp.GridReference = this;
            wp.Created();

            return wp;
        }
Beispiel #3
0
        public void RemoveWaypoint(Waypoint wp)
        {
            if (!Waypoints.Contains(wp)) return;

            RemoveObject(wp);
            Waypoints.Remove(wp);
        }
Beispiel #4
0
        public void AddWaypoint(Waypoint wp)
        {
            if (Waypoints.Contains(wp)) return;

            if (wp.GridId != Id || wp.ZoneId != ZoneId || wp.Number < GetNextNewWaypointNumber())
            {
                throw new Exception("Attempted to add conflicting waypoint, request a waypoint before adding via GetNewWaypoint method");
            }

            wp.GridReference = this;
            AddObject(wp);
            Waypoints.Add(wp);
        }