示例#1
0
        public static ICollection <SolarSystemConnection> GetConnectionsBetweenSystems(IList <SolarSystemViewModel> allSystemsIn)
        {
            var allDistinctSystems = allSystemsIn.Distinct()
                                     .ToArray();
            var ids = string.Join(",", allDistinctSystems.Select(x => x.ID.ToString(CultureInfo.InvariantCulture)));

            var modelById = allDistinctSystems.ToDictionary(x => x.ID, x => x);

            var command = DB_CONNECTION.CreateCommand();

            command.CommandText =
                string.Format(
                    "SELECT FromSystem, ToSystem FROM SystemConnection WHERE ToSystem IN ({0}) AND FromSystem IN ({0}) AND ToSystem < FromSystem",
                    ids);           // ToSystem < FromSystem to not get duplicates like A->B and B->A

            IList <SolarSystemConnection> connections = new List <SolarSystemConnection>();

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    var curConnection = new SolarSystemConnection(modelById[reader.GetInt32(0)], modelById[reader.GetInt32(1)]);
                    connections.Add(curConnection);
                }
            }

            var whConnectionList = GetWormholeConnections(allDistinctSystems);
            var theraList        = GetEveScoutWormholeConnections(allDistinctSystems);

            return(connections.Concat(whConnectionList)
                   .Concat(theraList)
                   .ToList());

            // return connections;
        }
示例#2
0
        private double GetGateCampIndex(SolarSystemConnection solarSystemConnection, IEnumerable <GateCampMessageModel> gateCamps)
        {
            var locations = new[] { new StargateLocation
                                    {
                                        SolarSystemID1 = solarSystemConnection.Source.ID,
                                        SolarSystemID2 = solarSystemConnection.Target.ID
                                    } };
            var gateCamp = gateCamps.FirstOrDefault(x => x.StargateLocations.HasIntersection(locations));

            return(gateCamp != null ? gateCamp.GateCampIndex : 0);
        }