Exemplo n.º 1
0
        public SystemClass(string Name, int xi, int yi, int zi, long edsmid,
                           long eddbid, int eddbupdateat, long population, string faction,
                           EDGovernment g, EDAllegiance a, EDState s, EDSecurity security,
                           EDEconomy eco, string power, string powerstate, int needspermit,
                           int gridid = -1, SystemStatusEnum statusv = SystemStatusEnum.Unknown)
        {
            base.Name = Name;
            Xi        = xi; Yi = yi; Zi = zi;
            EDSMID    = edsmid;
            GridID    = gridid == -1 ? EliteDangerousCore.DB.GridId.Id(xi, zi) : gridid;

            EDDBID         = eddbid;
            Population     = population;
            Faction        = faction;
            Government     = g;
            Allegiance     = a;
            State          = s;
            Security       = security;
            PrimaryEconomy = eco;
            Power          = power;
            PowerState     = powerstate;
            NeedsPermit    = needspermit;
            EDDBUpdatedAt  = eddbupdateat;
            status         = statusv;
        }
Exemplo n.º 2
0
 public SystemClass(SystemSource statusv, string name, int xi, int yi, int zi, long edsmid,
                    long population, string faction,
                    EDGovernment g, EDAllegiance a, EDState s, EDSecurity security,
                    EDEconomy eco, string power, string powerstate, int needspermit,
                    int gridid = -1) : base(name, xi, yi, zi, edsmid, gridid)
 {
     Population     = population;
     Faction        = faction;
     Government     = g;
     Allegiance     = a;
     State          = s;
     Security       = security;
     PrimaryEconomy = eco;
     Power          = power;
     PowerState     = powerstate;
     NeedsPermit    = needspermit;
     source         = statusv;
 }
Exemplo n.º 3
0
 public SystemClass(string name, int xi, int yi, int zi, long edsmid,
                    long eddbid, int eddbupdateat, long population, string faction,
                    EDGovernment g, EDAllegiance a, EDState s, EDSecurity security,
                    EDEconomy eco, string power, string powerstate, int needspermit,
                    int gridid = -1, SystemStatusEnum statusv = SystemStatusEnum.Unknown) : base(name, xi, yi, zi, edsmid, gridid)
 {
     EDDBID         = eddbid;
     Population     = population;
     Faction        = faction;
     Government     = g;
     Allegiance     = a;
     State          = s;
     Security       = security;
     PrimaryEconomy = eco;
     Power          = power;
     PowerState     = powerstate;
     NeedsPermit    = needspermit;
     EDDBUpdatedAt  = eddbupdateat;
     status         = statusv;
 }
Exemplo n.º 4
0
        public StationClass(JObject jo, SystemInfoSource source)
        {
            if (source == SystemInfoSource.EDDB)
            {
                name = jo["name"].Value<string>();
                SearchName = name.ToLower();

                eddb_id = jo["id"].Value<int>();
                system_id = jo["system_id"].Value<int>();

                if (jo["max_landing_pad_size"].Type == JTokenType.String)
                    max_landing_pad_size = jo["max_landing_pad_size"].Value<string>();

                if (jo["distance_to_star"].Type == JTokenType.Integer)
                    distance_to_star = jo["distance_to_star"].Value<int>();

                faction = jo["faction"].Value<string>();

                government = EliteDangerous.Government2ID(jo["government"]);
                allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]);

                state = EliteDangerous.EDState2ID(jo["state"]);

                stationtype = EliteDangerous.EDStationType2ID(jo["type"]);

                if (jo["has_blackmarket"].Type == JTokenType.Integer)
                    has_blackmarket = jo["has_blackmarket"].Value<int>();
                else
                    has_blackmarket = -1;

                if (jo["has_commodities"].Type == JTokenType.Integer)
                    has_commodities = jo["has_commodities"].Value<int>();
                else
                    has_commodities = -1;

                if (jo["has_refuel"].Type == JTokenType.Integer)
                    has_refuel = jo["has_refuel"].Value<int>();
                else
                    has_refuel = -1;

                if (jo["has_repair"].Type == JTokenType.Integer)
                    has_repair = jo["has_repair"].Value<int>();
                else
                    has_repair = -1;

                if (jo["has_rearm"].Type == JTokenType.Integer)
                    has_rearm = jo["has_rearm"].Value<int>();
                else
                    has_rearm = -1;

                if (jo["has_outfitting"].Type == JTokenType.Integer)
                    has_outfitting = jo["has_outfitting"].Value<int>();
                else
                    has_outfitting = -1;

                if (jo["has_shipyard"].Type == JTokenType.Integer)
                    has_shipyard = jo["has_shipyard"].Value<int>();
                else
                    has_shipyard = -1;

                economies = EliteDangerous.EDEconomies2ID((JArray)jo["economies"]);
                import_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["import_commodities"]);
                export_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["export_commodities"]);
                prohibited_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["prohibited_commodities"]);
                eddb_updated_at = jo["updated_at"].Value<int>();

            }
        }
Exemplo n.º 5
0
        private List <ISystem> GetSystemsByName(string systemName, bool uselike = false)     // Protect yourself against bad JSON
        {
            string query = String.Format("api-v1/systems?systemName={0}&showCoordinates=1&showId=1&showInformation=1&showPermit=1", Uri.EscapeDataString(systemName));

            var response = RequestGet(query, handleException: true);

            if (response.Error)
            {
                return(null);
            }

            var json = response.Body;

            if (json == null)
            {
                return(null);
            }

            JArray msg = JArray.Parse(json);

            List <ISystem> systems = new List <ISystem>();

            if (msg != null)
            {
                foreach (JObject sysname in msg)
                {
                    ISystem sys = new SystemClass();
                    sys.Name   = sysname["name"].Str("Unknown");
                    sys.EDSMID = sysname["id"].Long(0);
                    JObject co = (JObject)sysname["coords"];

                    if (co != null)
                    {
                        sys.X = co["x"].Double();
                        sys.Y = co["y"].Double();
                        sys.Z = co["z"].Double();
                    }

                    sys.NeedsPermit = sysname["requirePermit"].Bool(false) ? 1 : 0;

                    JObject info = sysname["information"] as JObject;

                    if (info != null)
                    {
                        sys.Population = info["population"].Long(0);
                        sys.Faction    = info["faction"].StrNull();
                        EDAllegiance allegiance = EDAllegiance.None;
                        EDGovernment government = EDGovernment.None;
                        EDState      state      = EDState.None;
                        EDEconomy    economy    = EDEconomy.None;
                        EDSecurity   security   = EDSecurity.Unknown;
                        sys.Allegiance     = Enum.TryParse(info["allegiance"].Str(), out allegiance) ? allegiance : EDAllegiance.None;
                        sys.Government     = Enum.TryParse(info["government"].Str(), out government) ? government : EDGovernment.None;
                        sys.State          = Enum.TryParse(info["factionState"].Str(), out state) ? state : EDState.None;
                        sys.PrimaryEconomy = Enum.TryParse(info["economy"].Str(), out economy) ? economy : EDEconomy.None;
                        sys.Security       = Enum.TryParse(info["security"].Str(), out security) ? security : EDSecurity.Unknown;
                    }

                    if (uselike ? sys.Name.StartsWith(systemName, StringComparison.InvariantCultureIgnoreCase) : sys.Name.Equals(systemName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        systems.Add(sys);
                    }
                }
            }

            return(systems);
        }
Exemplo n.º 6
0
        public StationClass(JObject jo, SystemInfoSource source)
        {
            if (source == SystemInfoSource.EDDB)
            {
                name       = jo["name"].Value <string>();
                SearchName = name.ToLower();

                eddb_id   = jo["id"].Value <int>();
                system_id = jo["system_id"].Value <int>();

                if (jo["max_landing_pad_size"].Type == JTokenType.String)
                {
                    max_landing_pad_size = jo["max_landing_pad_size"].Value <string>();
                }

                if (jo["distance_to_star"].Type == JTokenType.Integer)
                {
                    distance_to_star = jo["distance_to_star"].Value <int>();
                }

                faction = jo["faction"].Value <string>();

                government = EliteDangerous.Government2ID(jo["government"]);
                allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]);

                state = EliteDangerous.EDState2ID(jo["state"]);

                stationtype = EliteDangerous.EDStationType2ID(jo["type"]);

                if (jo["has_blackmarket"].Type == JTokenType.Integer)
                {
                    has_blackmarket = jo["has_blackmarket"].Value <int>();
                }
                else
                {
                    has_blackmarket = -1;
                }

                if (jo["has_commodities"].Type == JTokenType.Integer)
                {
                    has_commodities = jo["has_commodities"].Value <int>();
                }
                else
                {
                    has_commodities = -1;
                }

                if (jo["has_refuel"].Type == JTokenType.Integer)
                {
                    has_refuel = jo["has_refuel"].Value <int>();
                }
                else
                {
                    has_refuel = -1;
                }

                if (jo["has_repair"].Type == JTokenType.Integer)
                {
                    has_repair = jo["has_repair"].Value <int>();
                }
                else
                {
                    has_repair = -1;
                }

                if (jo["has_rearm"].Type == JTokenType.Integer)
                {
                    has_rearm = jo["has_rearm"].Value <int>();
                }
                else
                {
                    has_rearm = -1;
                }

                if (jo["has_outfitting"].Type == JTokenType.Integer)
                {
                    has_outfitting = jo["has_outfitting"].Value <int>();
                }
                else
                {
                    has_outfitting = -1;
                }

                if (jo["has_shipyard"].Type == JTokenType.Integer)
                {
                    has_shipyard = jo["has_shipyard"].Value <int>();
                }
                else
                {
                    has_shipyard = -1;
                }

                economies              = EliteDangerous.EDEconomies2ID((JArray)jo["economies"]);
                import_commodities     = EliteDangerous.EDCommodities2ID((JArray)jo["import_commodities"]);
                export_commodities     = EliteDangerous.EDCommodities2ID((JArray)jo["export_commodities"]);
                prohibited_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["prohibited_commodities"]);
                eddb_updated_at        = jo["updated_at"].Value <int>();
            }
        }
Exemplo n.º 7
0
        //public SystemClass(JObject jo, SystemInfoSource source)
        //{
        //    if (source == SystemInfoSource.RW)
        //    {
        //        try
        //        {
        //            x = jo["x"].Value<double>();
        //            y = jo["y"].Value<double>();
        //            z = jo["z"].Value<double>();

        //            name = jo["name"].Value<string>();
        //            SearchName = name.ToLower();


        //            cr = 1;
        //            status = SystemStatusEnum.RedWizzard;
        //        }
        //        catch
        //        {

        //        }


        //    }
        //    else if (source == SystemInfoSource.EDSC)
        //    {
        //        JArray ja = (JArray)jo["coord"];

        //        name = jo["name"].Value<string>();
        //        SearchName = name.ToLower();

        //        cr = jo["cr"].Value<int>();

        //        if (ja[0].Type == JTokenType.Float || ja[0].Type == JTokenType.Integer)
        //        {
        //            x = ja[0].Value<double>();
        //            y = ja[1].Value<double>();
        //            z = ja[2].Value<double>();
        //        }
        //        else
        //        {
        //            x = double.NaN;
        //            y = double.NaN;
        //            z = double.NaN;
        //        }


        //        CommanderCreate = jo["commandercreate"].Value<string>();
        //        CreateDate = jo["createdate"].Value<DateTime>();
        //        CommanderUpdate = jo["commanderupdate"].Value<string>();
        //        UpdateDate = jo["updatedate"].Value<DateTime>();
        //        status = SystemStatusEnum.EDSC;
        //    }
        //    else if (source == SystemInfoSource.EDSM)
        //    {
        //        JObject coords = (JObject)jo["coords"];

        //        name = jo["name"].Value<string>();
        //        SearchName = name.ToLower();

        //        //cr = jo["cr"].Value<int>();
        //        x = double.NaN;
        //        y = double.NaN;
        //        z = double.NaN;


        //        if (coords !=null &&  (coords["x"].Type == JTokenType.Float || coords["x"].Type == JTokenType.Integer))
        //        {
        //            x = coords["x"].Value<double>();
        //            y = coords["y"].Value<double>();
        //            z = coords["z"].Value<double>();
        //        }
        //        JArray submitted = (JArray)jo["submitted"];

        //        if (submitted.Count>0)
        //        {
        //            if (submitted[0]["cmdrname"]!=null)
        //                CommanderCreate = submitted[0]["cmdrname"].Value<string>();
        //            CreateDate = submitted[0]["date"].Value<DateTime>();

        //            if (submitted[submitted.Count - 1]["cmdrname"] != null)
        //                CommanderUpdate = submitted[submitted.Count-1]["cmdrname"].Value<string>();
        //            UpdateDate = submitted[submitted.Count-1]["date"].Value<DateTime>();

        //        }

        //        UpdateDate = jo["date"].Value<DateTime>();
        //        if (CreateDate.Year <= 1)
        //            CreateDate = UpdateDate;


        //        status = SystemStatusEnum.EDSC;
        //    }
        //    else if (source == SystemInfoSource.EDDB)
        //    {


        //        name = jo["name"].Value<string>();
        //        SearchName = name.ToLower();

        //        cr = 1;

        //        x = jo["x"].Value<double>();
        //        y = jo["y"].Value<double>();
        //        z = jo["z"].Value<double>();

        //        id_eddb = jo["id"].Value<int>();

        //        /*CommanderCreate = jo["commandercreate"].Value<string>();
        //        CreateDate = jo["createdate"].Value<DateTime>();
        //        CommanderUpdate = jo["commanderupdate"].Value<string>();
        //        UpdateDate = jo["updatedate"].Value<DateTime>();*/

        //        faction = jo["faction"].Value<string>();

        //        if (jo["population"].Type == JTokenType.Integer)
        //            population = jo["population"].Value<long>();


        //        government = EliteDangerous.Government2ID(jo["government"]);
        //        allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]);

        //        state = EliteDangerous.EDState2ID(jo["state"]);
        //        security = EliteDangerous.EDSecurity2ID(jo["security"]);



        //        primary_economy = EliteDangerous.EDEconomy2ID(jo["primary_economy"]);


        //        if (jo["needs_permit"].Type == JTokenType.Integer)
        //            needs_permit = jo["needs_permit"].Value<int>();

        //        eddb_updated_at = jo["updated_at"].Value<int>();

        //        status = SystemStatusEnum.EDDB;
        //    }



        //}



        public SystemClass(DataRow dr)
        {
            try
            {
                Object o;

                id   = (int)(long)dr["id"];
                name = (string)dr["name"];



                SearchName = name.ToLower();


                cr = (int)(long)dr["cr"];

                if (System.DBNull.Value == dr["x"])
                {
                    x = double.NaN;
                    y = double.NaN;
                    z = double.NaN;
                }
                else
                {
                    x = (double)dr["x"];
                    y = (double)dr["y"];
                    z = (double)dr["z"];
                    CommanderCreate = dr["commandercreate"].ToString();
                    if (CommanderCreate.Length > 0)
                    {
                        CreateDate = (DateTime)dr["createdate"];
                    }
                    else
                    {
                        CreateDate = new DateTime(1980, 1, 1);
                    }

                    CommanderUpdate = (string)dr["commanderupdate"].ToString();
                    if (CommanderUpdate.Length > 0)
                    {
                        UpdateDate = (DateTime)dr["updatedate"];
                    }
                    else
                    {
                        UpdateDate = new DateTime(1980, 1, 1);
                    }
                }

                status = (SystemStatusEnum)((long)dr["status"]);
                Note   = dr["Note"].ToString();

                o       = dr["id_eddb"];
                id_eddb = o == DBNull.Value ? 0 : (int)((long)o);

                o       = dr["faction"];
                faction = o == DBNull.Value ? null : (string)o;

                o          = dr["government_id"];
                government = o == DBNull.Value ? EDGovernment.Unknown : (EDGovernment)((long)o);

                o          = dr["allegiance_id"];
                allegiance = o == DBNull.Value ? EDAllegiance.Unknown : (EDAllegiance)((long)o);

                o = dr["primary_economy_id"];
                primary_economy = o == DBNull.Value ? EDEconomy.Unknown : (EDEconomy)((long)o);

                o        = dr["security"];
                security = o == DBNull.Value ? EDSecurity.Unknown : (EDSecurity)((long)o);

                o = dr["eddb_updated_at"];
                eddb_updated_at = o == DBNull.Value ? 0 : (int)((long)o);

                o     = dr["state"];
                state = o == DBNull.Value ? EDState.Unknown : (EDState)((long)o);

                o            = dr["needs_permit"];
                needs_permit = o == DBNull.Value ? 0 : (int)((long)o);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception SystemClass: " + ex.Message);
                System.Diagnostics.Trace.WriteLine("Trace: " + ex.StackTrace);
            }
        }
Exemplo n.º 8
0
        public SystemClass(JObject jo, SystemInfoSource source)
        {
            if (source == SystemInfoSource.RW)
            {
                try
                {
                    x = jo["x"].Value<double>();
                    y = jo["y"].Value<double>();
                    z = jo["z"].Value<double>();

                    name = jo["name"].Value<string>();
                    SearchName = name.ToLower();

                    cr = 1;
                    status = SystemStatusEnum.RedWizzard;
                }
                catch
                {

                }

            }
            else if (source == SystemInfoSource.EDSC)
            {
                JArray ja = (JArray)jo["coord"];

                name = jo["name"].Value<string>();
                SearchName = name.ToLower();

                cr = jo["cr"].Value<int>();

                if (ja[0].Type == JTokenType.Float || ja[0].Type == JTokenType.Integer)
                {
                    x = ja[0].Value<double>();
                    y = ja[1].Value<double>();
                    z = ja[2].Value<double>();
                }
                else
                {
                    x = double.NaN;
                    y = double.NaN;
                    z = double.NaN;
                }

                CommanderCreate = jo["commandercreate"].Value<string>();
                CreateDate = jo["createdate"].Value<DateTime>();
                CommanderUpdate = jo["commanderupdate"].Value<string>();
                UpdateDate = jo["updatedate"].Value<DateTime>();
                status = SystemStatusEnum.EDSC;
            }
            else if (source == SystemInfoSource.EDSM)
            {
                JObject coords = (JObject)jo["coords"];

                name = jo["name"].Value<string>();
                SearchName = name.ToLower();

                //cr = jo["cr"].Value<int>();
                x = double.NaN;
                y = double.NaN;
                z = double.NaN;

                if (coords !=null &&  (coords["x"].Type == JTokenType.Float || coords["x"].Type == JTokenType.Integer))
                {
                    x = coords["x"].Value<double>();
                    y = coords["y"].Value<double>();
                    z = coords["z"].Value<double>();
                }
                JArray submitted = (JArray)jo["submitted"];

                if (submitted.Count>0)
                {
                    if (submitted[0]["cmdrname"]!=null)
                        CommanderCreate = submitted[0]["cmdrname"].Value<string>();
                    CreateDate = submitted[0]["date"].Value<DateTime>();

                    if (submitted[submitted.Count - 1]["cmdrname"] != null)
                        CommanderUpdate = submitted[submitted.Count-1]["cmdrname"].Value<string>();
                    UpdateDate = submitted[submitted.Count-1]["date"].Value<DateTime>();

                }
                status = SystemStatusEnum.EDSC;
            }
            else if (source == SystemInfoSource.EDDB)
            {

                name = jo["name"].Value<string>();
                SearchName = name.ToLower();

                cr = 1;

                x = jo["x"].Value<double>();
                y = jo["y"].Value<double>();
                z = jo["z"].Value<double>();

                id_eddb = jo["id"].Value<int>();

                /*CommanderCreate = jo["commandercreate"].Value<string>();
                CreateDate = jo["createdate"].Value<DateTime>();
                CommanderUpdate = jo["commanderupdate"].Value<string>();
                UpdateDate = jo["updatedate"].Value<DateTime>();*/

                faction = jo["faction"].Value<string>();

                if (jo["population"].Type == JTokenType.Integer)
                    population = jo["population"].Value<long>();

                government = EliteDangerous.Government2ID(jo["government"]);
                allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]);

                state = EliteDangerous.EDState2ID(jo["state"]);
                security = EliteDangerous.EDSecurity2ID(jo["security"]);

                primary_economy = EliteDangerous.EDEconomy2ID(jo["primary_economy"]);

                if (jo["needs_permit"].Type == JTokenType.Integer)
                    needs_permit = jo["needs_permit"].Value<int>();

                eddb_updated_at = jo["updated_at"].Value<int>();

                status = SystemStatusEnum.EDDB;
            }
        }
Exemplo n.º 9
0
        public SystemClass(DataRow dr)
        {
            try
            {
                Object o;

                id = (int)(long)dr["id"];
                name = (string)dr["name"];

                SearchName = name.ToLower();

                cr = (int)(long)dr["cr"];

                if (System.DBNull.Value == dr["x"])
                {
                    x = double.NaN;
                    y = double.NaN;
                    z = double.NaN;

                }
                else
                {
                    x = (double)dr["x"];
                    y = (double)dr["y"];
                    z = (double)dr["z"];
                    CommanderCreate = dr["commandercreate"].ToString();
                    if (CommanderCreate.Length > 0)
                        CreateDate = (DateTime)dr["createdate"];
                    else
                        CreateDate = new DateTime(1980, 1, 1);

                    CommanderUpdate = (string)dr["commanderupdate"].ToString();
                    if (CommanderUpdate.Length > 0)
                        UpdateDate = (DateTime)dr["updatedate"];
                    else
                        UpdateDate = new DateTime(1980, 1, 1);

                }

                status = (SystemStatusEnum)((long)dr["status"]);
                Note = dr["Note"].ToString();

                o = dr["id_eddb"];
                id_eddb = o == DBNull.Value ? 0 : (int)((long)o);

                o = dr["faction"];
                faction = o == DBNull.Value ? null : (string)o;

                o = dr["government_id"];
                government = o == DBNull.Value ? EDGovernment.Unknown : (EDGovernment)((long)o);

                o = dr["allegiance_id"];
                allegiance = o == DBNull.Value ? EDAllegiance.Unknown : (EDAllegiance)((long)o);

                o = dr["primary_economy_id"];
                primary_economy = o == DBNull.Value ? EDEconomy.Unknown : (EDEconomy)((long)o);

                o = dr["security"];
                security = o == DBNull.Value ? EDSecurity.Unknown : (EDSecurity)((long)o);

                o = dr["eddb_updated_at"];
                eddb_updated_at = o == DBNull.Value ? 0 : (int)((long)o);

                o = dr["state"];
                state = o == DBNull.Value ? EDState.Unknown : (EDState)((long)o);

                o = dr["needs_permit"];
                needs_permit = o == DBNull.Value ? 0 : (int)((long)o);

            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Exception SystemClass: " + ex.Message);
                System.Diagnostics.Trace.WriteLine("Trace: " + ex.StackTrace);

            }
        }
Exemplo n.º 10
0
        public SystemClass(JObject jo, SystemInfoSource source)
        {
            if (source == SystemInfoSource.RW)
            {
                try
                {
                    x = jo["x"].Value <double>();
                    y = jo["y"].Value <double>();
                    z = jo["z"].Value <double>();

                    name       = jo["name"].Value <string>();
                    SearchName = name.ToLower();


                    cr     = 1;
                    status = SystemStatusEnum.RedWizzard;
                }
                catch
                {
                }
            }
            else if (source == SystemInfoSource.EDSC)
            {
                JArray ja = (JArray)jo["coord"];

                name       = jo["name"].Value <string>();
                SearchName = name.ToLower();

                cr = jo["cr"].Value <int>();

                if (ja[0].Type == JTokenType.Float || ja[0].Type == JTokenType.Integer)
                {
                    x = ja[0].Value <double>();
                    y = ja[1].Value <double>();
                    z = ja[2].Value <double>();
                }
                else
                {
                    x = double.NaN;
                    y = double.NaN;
                    z = double.NaN;
                }


                CommanderCreate = jo["commandercreate"].Value <string>();
                CreateDate      = jo["createdate"].Value <DateTime>();
                CommanderUpdate = jo["commanderupdate"].Value <string>();
                UpdateDate      = jo["updatedate"].Value <DateTime>();
                status          = SystemStatusEnum.EDSC;
            }
            else if (source == SystemInfoSource.EDSM)
            {
                JObject coords = (JObject)jo["coords"];

                name       = jo["name"].Value <string>();
                SearchName = name.ToLower();

                //cr = jo["cr"].Value<int>();
                x = double.NaN;
                y = double.NaN;
                z = double.NaN;


                if (coords != null && (coords["x"].Type == JTokenType.Float || coords["x"].Type == JTokenType.Integer))
                {
                    x = coords["x"].Value <double>();
                    y = coords["y"].Value <double>();
                    z = coords["z"].Value <double>();
                }
                JArray submitted = (JArray)jo["submitted"];

                if (submitted.Count > 0)
                {
                    if (submitted[0]["cmdrname"] != null)
                    {
                        CommanderCreate = submitted[0]["cmdrname"].Value <string>();
                    }
                    CreateDate = submitted[0]["date"].Value <DateTime>();

                    if (submitted[submitted.Count - 1]["cmdrname"] != null)
                    {
                        CommanderUpdate = submitted[submitted.Count - 1]["cmdrname"].Value <string>();
                    }
                    UpdateDate = submitted[submitted.Count - 1]["date"].Value <DateTime>();
                }
                status = SystemStatusEnum.EDSC;
            }
            else if (source == SystemInfoSource.EDDB)
            {
                name       = jo["name"].Value <string>();
                SearchName = name.ToLower();

                cr = 1;

                x = jo["x"].Value <double>();
                y = jo["y"].Value <double>();
                z = jo["z"].Value <double>();

                id_eddb = jo["id"].Value <int>();

                /*CommanderCreate = jo["commandercreate"].Value<string>();
                 * CreateDate = jo["createdate"].Value<DateTime>();
                 * CommanderUpdate = jo["commanderupdate"].Value<string>();
                 * UpdateDate = jo["updatedate"].Value<DateTime>();*/

                faction = jo["faction"].Value <string>();

                if (jo["population"].Type == JTokenType.Integer)
                {
                    population = jo["population"].Value <long>();
                }


                government = EliteDangerous.Government2ID(jo["government"]);
                allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]);

                state    = EliteDangerous.EDState2ID(jo["state"]);
                security = EliteDangerous.EDSecurity2ID(jo["security"]);



                primary_economy = EliteDangerous.EDEconomy2ID(jo["primary_economy"]);


                if (jo["needs_permit"].Type == JTokenType.Integer)
                {
                    needs_permit = jo["needs_permit"].Value <int>();
                }

                eddb_updated_at = jo["updated_at"].Value <int>();

                status = SystemStatusEnum.EDDB;
            }
        }