Exemplo n.º 1
0
 public SystemClass(string Name)
 {
     name = Name;
     SearchName = Name.ToLower();
     status = SystemStatusEnum.Unknown;
     x = double.NaN;
     y = double.NaN;
     z = double.NaN;
 }
Exemplo n.º 2
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.º 3
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 [email protected]";
                    cmd.Parameters.AddWithValue("@Status", (int)source);

                    SQLiteDBClass.SqlNonQueryText(cn, cmd);

                }

                cn.Close();

            }
            return true;
        }
Exemplo n.º 4
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);

            }
        }