public override IEnumerator Initialize()
        {
            ConnectionString = System.String.Format("Server={0};Port={1};Database={2};Uid={3};password={4}",
                                                    server,
                                                    portNum,
                                                    database,
                                                    userID,
                                                    password);
            conn = new MySqlConnection(ConnectionString);

            MySqlCommand command = conn.CreateCommand();

            command.CommandText    = CommandString;
            command.CommandTimeout = 999999;

            try {
                conn.Open();
            }
            catch (System.Exception ex) {
                Debug.LogException(ex);
                ReplayGUI.ErrorMessage(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }

            reader = command.ExecuteReader();
            loaded = true;
            RequestNextAction();
            yield break;
        }
예제 #2
0
        private void CacheUserList()
        {
            MySqlCommand command = conn.CreateCommand();

            if (string.IsNullOrEmpty(db_where_clause))
            {
                command.CommandText = String.Format("SELECT DISTINCT(userID) FROM {0};", db_table);
            }
            else
            {
                command.CommandText = String.Format("SELECT DISTINCT(userID) FROM {0} WHERE {1};", db_table, db_where_clause);
            }

            try {
                conn.Open();
            }
            catch (Exception ex) {
                Debug.LogException(ex);
                ReplayGUI.ErrorMessage(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            Debug.LogFormat("<color=purple>MySQL Query:</color> {0}", command.CommandText);
            MySqlDataReader reader = command.ExecuteReader();

            cached_users = new List <string>();
            while (reader.Read())
            {
                cached_users.Add(reader.GetString(0));
            }

            conn.Close();

            current_user_dex = 0;
        }
예제 #3
0
 void OnGUI()
 {
     if (!string.IsNullOrEmpty(errorMessage))
     {
         if (ReplayGUI.ErrorMessage(errorMessage))
         {
             errorMessage = string.Empty;
         }
     }
 }
예제 #4
0
        private void CacheUserLogs()
        {
            MySqlCommand command = conn.CreateCommand();

            if (string.IsNullOrEmpty(db_where_clause))
            {
                command.CommandText = String.Format("SELECT selection, action, input, state, eventTime, userID, levelName, attemptNumber, sessionID, transactionID, attemptID FROM {0} WHERE userID=\"{1}\" ORDER BY eventTime;", db_table, cached_users[current_user_dex]);
            }
            else
            {
                string where        = string.Format("userID = \"{0}\" AND {1}", cached_users[current_user_dex], db_where_clause);
                command.CommandText = String.Format("SELECT selection, action, input, state, eventTime, userID, levelName, attemptNumber, sessionID, transactionID, attemptID FROM {0} WHERE {1} ORDER BY eventTime;", db_table, where);
            }

            try {
                conn.Open();
            }
            catch (Exception ex) {
                Debug.LogException(ex);
                ReplayGUI.ErrorMessage(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            Debug.LogFormat("<color=purple>MySQL Query:</color> {0}", command.CommandText);
            MySqlDataReader reader = command.ExecuteReader();

            cached_actions = new List <AgentAction>();
            while (reader.Read())
            {
                AgentAction act = new AgentAction(
                    reader["selection"].ToString(),
                    reader["action"].ToString(),
                    reader["input"].ToString(),
                    reader["state"].ToString(),
                    reader["eventTime"].ToString(),
                    reader["userID"].ToString(),
                    reader["levelName"].ToString(),
                    reader["attemptNumber"].ToString(),
                    reader["sessionID"].ToString(),
                    reader["transactionID"].ToString(),
                    reader["attemptID"].ToString());
                cached_actions.Add(act);
            }

            conn.Close();

            Debug.LogFormat("Cached {0} actions for user {1}", cached_actions.Count, cached_users[current_user_dex]);

            cached_actions_by_level = new Dictionary <string, List <int> >();
            for (int i = 0; i < cached_actions.Count; i++)
            {
                AgentAction act = cached_actions[i];
                if (act.Action == "Level_Start")
                {
                    continue;
                }
                if (!cached_actions_by_level.ContainsKey(act.LevelName))
                {
                    cached_actions_by_level.Add(act.LevelName, new List <int>());
                }
                cached_actions_by_level[act.LevelName].Add(i);
            }
            current_action_dex = -1;
            FireEvent(EventTypes.User_Changed);
        }