コード例 #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;
        }
コード例 #2
0
 public SystemClass(string Name)
 {
     name       = Name;
     SearchName = Name.ToLower();
     status     = SystemStatusEnum.Unknown;
     x          = double.NaN;
     y          = double.NaN;
     z          = double.NaN;
 }
コード例 #3
0
 public SystemClass(string Name)
 {
     name = Name;
     SearchName = Name.ToLower();
     status = SystemStatusEnum.Unknown;
     x = double.NaN;
     y = double.NaN;
     z = double.NaN;
 }
コード例 #4
0
ファイル: SystemClass.cs プロジェクト: taemtha/EDDiscovery
 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;
 }
コード例 #5
0
ファイル: SystemClass.cs プロジェクト: itguy327/EDDiscovery
        public static bool Delete(SystemStatusEnum source)
        {
            using (SQLiteConnection cn = new SQLiteConnection(SQLiteDBClass.ConnectionString))
            {
                cn.Open();

                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection     = cn;
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 30;
                    cmd.CommandText    = "Delete from Systems where Status=@Status";
                    cmd.Parameters.AddWithValue("@Status", (int)source);

                    SQLiteDBClass.SqlNonQueryText(cn, cmd);
                }


                cn.Close();
            }
            return(true);
        }
コード例 #6
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);
            }
        }
コード例 #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>();

                }
                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;
            }
        }
コード例 #8
0
        public static bool Delete(SystemStatusEnum source)
        {
            using (SQLiteConnection cn = new SQLiteConnection(SQLiteDBClass.ConnectionString))
            {
                cn.Open();

                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = cn;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandTimeout = 30;
                    cmd.CommandText = "Delete from Systems where Status=@Status";
                    cmd.Parameters.AddWithValue("@Status", (int)source);

                    SQLiteDBClass.SqlNonQueryText(cn, cmd);

                }

                cn.Close();

            }
            return true;
        }
コード例 #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);

            }
        }
コード例 #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;
            }
        }