Generate() public static méthode

public static Generate ( int length ) : string
length int
Résultat string
Exemple #1
0
        public static void singleRace(int raceId, MySqlConnection connection, out string outPacket, out bool isGoodResponse)
        {
            string packetBody = File.ReadAllText(Program.serverPrefix + "/Engine.svc/matchmaking/launchevent/template.xml");

            string session = StringGen.Generate(20);

            string sql = String.Format("INSERT INTO EventSession (trackId, sessionType, challangeId) VALUES ({0},'{1}','{2}')", raceId, "singleplayer", session);

            using (MySqlCommand command = new MySqlCommand(sql, connection))
            {
                command.ExecuteNonQuery();
            }

            sql = String.Format("SELECT sessionId FROM EventSession WHERE challangeId = '{0}' ORDER BY sessionId DESC LIMIT 1", session);
            using (MySqlCommand command = new MySqlCommand(sql, connection))
                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        reader.Read();
                        string sessionId = reader["sessionId"].ToString();

                        outPacket      = string.Format(packetBody, session, raceId, sessionId);
                        isGoodResponse = true;
                    }
                    else
                    {
                        outPacket      = "";
                        isGoodResponse = false;
                    }
                }
        }
Exemple #2
0
        private static string sessionGen()
        {
            string        session    = StringGen.Generate(36);
            StringBuilder sessionArr = new StringBuilder(session);

            sessionArr[8]  = '-';
            sessionArr[13] = '-';
            sessionArr[18] = '-';
            sessionArr[23] = '-';

            return(sessionArr.ToString());
        }