コード例 #1
0
        public string GetTopScores(int Number, DateTime sinceDateTime)
        {
            string Returner = "";

            string TheLine = ("SELECT * FROM " + VDataTab);

            TheLine += " WHERE AggScore > 0 AND SysDate >= '" + sinceDateTime.ToString("yyyyMMdd") + "' AND SysTime >= '" + sinceDateTime.ToString("HH:mm:ss");
            TheLine += "' ORDER BY AggScore ASC LIMIT " + Convert.ToString(Number) + ";";

            MySqlCommand GetScores = new MySqlCommand((TheLine), DBconnect);

            GetScores.Connection.Open();


            MySqlDataReader RecordData;

            RecordData = GetScores.ExecuteReader();

            while (RecordData.Read())
            {
                if (RecordData.HasRows)
                {
                    Returner += RecordData.GetString(3) + ",";
                    Returner += Convert.ToString(RecordData.GetDouble(4)) + ",";
                    Returner += Convert.ToString(RecordData.GetDouble(5)) + ",";
                    Returner += Convert.ToString(RecordData.GetDouble(6)) + ";";
                }
            }

            RecordData.Close();
            GetScores.Connection.Close();

            return(Returner);
        }
コード例 #2
0
        public void getCountAndSpeed(string Name, string EndTime, ref int vcount, ref double AvSp, ref TimeSpan StartTime)
        {
            string QueryLine = ("SELECT VCount, AvSpeed, StartTime FROM " + VDataTab + " WHERE ");

            QueryLine += "(LoopName LIKE '%" + Name + "%') AND ";
            QueryLine += "EndTime = '" + EndTime + "';";

            MySqlCommand LookUpData = new MySqlCommand(QueryLine, DBconnect);

            LookUpData.Connection.Open();

            MySqlDataReader RecordData;

            RecordData = LookUpData.ExecuteReader();



            while (RecordData.Read())
            {
                //TODO come back to this
                vcount = RecordData.GetInt32("VCount");
                AvSp   = RecordData.GetDouble("AvSpeed");
                string TimeString = RecordData.GetString("StartTime");
                StartTime = Convert.ToDateTime(TimeString).TimeOfDay;
            }

            RecordData.Close();
            LookUpData.Connection.Close();
        }
コード例 #3
0
        public int GetGameID()
        {
            int    GameID  = -2;
            string TheLine = "SELECT MAX(GameID) from PlayerScoreSchema." + VDataTab + ";";

            MySqlCommand GetGameID = new MySqlCommand((TheLine), DBconnect);

            GetGameID.Connection.Open();


            MySqlDataReader RecordData;

            RecordData = GetGameID.ExecuteReader();

            try
            {
                while (RecordData.Read())
                {
                    if (RecordData.HasRows)
                    {
                        GameID = RecordData.GetInt32(0);
                    }
                }
            }
            catch
            {
                //do nothing for now. - means there's nothing in the database
            }


            RecordData.Close();
            GetGameID.Connection.Close();

            return(GameID);
        }
コード例 #4
0
        public void GetVLifeTime(string Condition, ref double LifeTime, ref int NumV)
        {
            string QueryLine = ("SELECT SUM(TIME_TO_SEC(SUBTIME(AtTime,BornTime))),COUNT(*) FROM " + VDataTab + " WHERE ");

            QueryLine += (Condition + ";");

            MySqlCommand LookUpData = new MySqlCommand(QueryLine, DBconnect);

            LookUpData.Connection.Open();

            MySqlDataReader RecordData;

            RecordData = LookUpData.ExecuteReader();


            LifeTime = 0;
            NumV     = 0;

            try
            {
                while (RecordData.Read())
                {
                    LifeTime = RecordData.GetDouble(0);
                    NumV     = RecordData.GetInt32(1);
                }
            }
            catch (Exception e)
            {
                //let this fail quietly and log zero's because it is probably because there are no vehicles in the sim.
            }

            RecordData.Close();
            LookUpData.Connection.Close();
        }
コード例 #5
0
        public List <string[]> GetTurningDirections(string Condition) //AH Function - same as above but strings instead of doubles, returns string[2] where [0] = NextTurn and [1] = NextNextTurn
        {
            string QueryLine = ("SELECT NextTurn, NextNextTurn FROM " + VDataTab + " WHERE ");

            QueryLine += (Condition + ";");

            MySqlCommand LookUpData = new MySqlCommand(QueryLine, DBconnect);

            LookUpData.Connection.Open();

            MySqlDataReader RecordData;

            RecordData = LookUpData.ExecuteReader();


            List <string[]> NextAndNextNextTurn = new List <string[]>();

            while (RecordData.Read())
            {
                string[] SpD = new string[2];
                SpD[0] = RecordData.GetString(0);
                SpD[1] = RecordData.GetString(1);
                NextAndNextNextTurn.Add(SpD);
            }

            RecordData.Close();
            LookUpData.Connection.Close();

            return(NextAndNextNextTurn);
        }
コード例 #6
0
        public List <double[]> GetSpeedAndDistane(string Condition)
        {
            string QueryLine = ("SELECT Speed, AlongLink FROM " + VDataTab + " WHERE ");

            QueryLine += (Condition + ";");

            MySqlCommand LookUpData = new MySqlCommand(QueryLine, DBconnect);

            LookUpData.Connection.Open();

            MySqlDataReader RecordData;

            RecordData = LookUpData.ExecuteReader();


            List <double[]> SpeedsDist = new List <double[]>();

            while (RecordData.Read())
            {
                double[] SpD = new double[2];
                SpD[0] = RecordData.GetDouble(0);
                SpD[1] = RecordData.GetDouble(1);
                SpeedsDist.Add(SpD);
            }

            RecordData.Close();
            LookUpData.Connection.Close();

            return(SpeedsDist);
        }
コード例 #7
0
        public int CountInVDataTab(string Condition)
        {
            string QueryLine = ("SELECT COUNT(*) FROM " + VDataTab + " WHERE ");

            QueryLine += (Condition + ";");

            MySqlCommand LookUpData = new MySqlCommand(QueryLine, DBconnect);

            LookUpData.Connection.Open();

            MySqlDataReader RecordData;

            RecordData = LookUpData.ExecuteReader();

            int Count = 0;

            while (RecordData.Read())
            {
                Count = RecordData.GetInt32(0);
            }

            RecordData.Close();
            LookUpData.Connection.Close();

            return(Count);
        }
コード例 #8
0
        public List <VehicleIdentity> VidGrabLine(string Condition)
        {
            string QueryLine = ("SELECT * FROM " + ViDTab + " WHERE ");

            QueryLine += (Condition + ";");

            MySqlCommand LookUpData = new MySqlCommand(QueryLine, DBconnect);

            List <VehicleIdentity> TempIDL = new List <VehicleIdentity>();

            LookUpData.Connection.Open();

            MySqlDataReader RecordData;

            RecordData = LookUpData.ExecuteReader();

            while (RecordData.Read())
            {
                VehicleIdentity TempID = new VehicleIdentity();
                TempID.ViD      = RecordData.GetString(0);
                TempID.Vtype    = RecordData.GetInt32(1);
                TempID.BornAt   = DateTime.Parse(RecordData.GetString(2));
                TempID.BornLink = new LinkID(RecordData.GetString(3));
                if (!RecordData.IsDBNull(4))
                {
                    TempID.Routename = RecordData.GetString(4);
                }
                if (!RecordData.IsDBNull(5))
                {
                    TempID.Origin = RecordData.GetInt32(5);
                }
                if (!RecordData.IsDBNull(6))
                {
                    TempID.Destination = RecordData.GetInt32(6);
                }
                TempID.Tag          = RecordData.GetInt32(7);
                TempID.BornStage    = RecordData.GetInt32(8);
                TempID.BornScenario = RecordData.GetInt32(9);
                TempID.Obsolete     = RecordData.GetBoolean(10);

                if (!RecordData.IsDBNull(11))
                {
                    TempID.MagicNumbers = RecordData.GetString(11);
                }

                TempIDL.Add(TempID);
            }

            RecordData.Close();
            LookUpData.Connection.Close();

            return(TempIDL);
        }