public IEnumerator AddAccountCoroutine(uLobby.AccountRecord account, uLobby.Request <uLobby.AccountRecord> request) { MySqlParameter[] paramsArray = new MySqlParameter[4]; paramsArray[0] = new MySqlParameter("name", account.name); paramsArray[1] = new MySqlParameter("password", account.passwordHash.passwordHash); paramsArray[2] = new MySqlParameter("salt", account.passwordHash.salt); paramsArray[3] = new MySqlParameter("data", account.data); var operation = ExecuteNonQueryAsync.BeginInvoke(storageManager.connectionString, "INSERT INTO accounts (name,password,salt,data)VALUES(@name,@password,@salt,@data)", paramsArray, null, null); while (!operation.IsCompleted) { yield return(null); } ExecuteNonQueryAsync.EndInvoke(operation); operation = ExecuteDataReaderAsync.BeginInvoke(storageManager.connectionString, "SELECT id FROM accounts where name = @name and password = @password and salt = @salt LIMIT 1;", paramsArray, null, null); while (!operation.IsCompleted) { yield return(null); } var dr = ExecuteDataReaderAsync.EndInvoke(operation); dr.Read(); account.id = new AccountID(dr.GetInt32("id").ToString()); dr.Close(); StorageLayerUtility.RequestUtility.SetResult(request, account); }
public IEnumerator SetFriendListRecordCoroutine(uLobby.AccountID accountID, uLobby.FriendListRecord record, uLobby.Request request) { var operation = ExecuteNonQueryAsync.BeginInvoke(storageManager.connectionString, "DELETE FROM friends WHERE owner = @id", new MySqlParameter[] { new MySqlParameter("id", int.Parse(accountID.value)) }, null, null); while (!operation.IsCompleted) { yield return(null); } ExecuteNonQueryAsync.EndInvoke(operation); operation = ExecuteNonQueryAsync.BeginInvoke(storageManager.connectionString, "DELETE FROM invitations WHERE sender = @id", new MySqlParameter[] { new MySqlParameter("id", int.Parse(accountID.value)) }, null, null); while (!operation.IsCompleted) { yield return(null); } ExecuteNonQueryAsync.EndInvoke(operation); foreach (AccountID friend in StorageLayerUtility.FriendListRecordUtility.GetFriendIDs(record)) { MySqlParameter[] paramsArray = new MySqlParameter[2]; paramsArray[0] = new MySqlParameter("owner", int.Parse(accountID.value)); paramsArray[1] = new MySqlParameter("friend", int.Parse(friend.value)); operation = ExecuteNonQueryAsync.BeginInvoke(storageManager.connectionString, "INSERT INTO friends (owner,friend) VALUES(@owner,@friend)", paramsArray, null, null); while (!operation.IsCompleted) { yield return(null); } ExecuteNonQueryAsync.EndInvoke(operation); } foreach (var inviter in StorageLayerUtility.FriendListRecordUtility.GetInviterIDs(record)) { MySqlParameter[] paramsArray = new MySqlParameter[2]; paramsArray[0] = new MySqlParameter("sender", int.Parse(inviter.value)); paramsArray[1] = new MySqlParameter("receiver", int.Parse(accountID.value)); operation = ExecuteNonQueryAsync.BeginInvoke(storageManager.connectionString, "INSERT INTO invitations (sender,receiver) VALUES(@sender,@receiver)", paramsArray, null, null); while (!operation.IsCompleted) { yield return(null); } ExecuteNonQueryAsync.EndInvoke(operation); } yield break; }