public ListUserResponse ListByUserTypes(string UserType) { ListUserResponse response = new ListUserResponse(); try { using (IDbConnection conn = GetConnection()) { response.users = conn.GetList <User>("Where UserType = ?UserType", new { UserType }).ToList(); if (response.users.Count > 0) { response.Status = true; response.Description = "Successful"; } else { response.Status = false; response.Description = "No data"; } } } catch (Exception ex) { response.Status = false; response.Description = ex.Message; } return(response); }
public async Task <ListUserResponse> GetUsers(ListUserRequest o) { var result = new ListUserResponse(o.RequestId); result.Application = o.Application; result.Users.AddRange(await Server.GetUsers(o.Application)); return(result); }
private void HandleListUser(ListUserResponse r) { Debug.Print("handling list user"); readyEvent.WaitOne(); if (onListUserResponse != null) { onListUserResponse(r); } }
private void OnListUserResponse(ListUserResponse r) { try { Invoke(new Action(() => { lstUsers.Items.Clear(); foreach (ListUserResponse.Types.User u in r.Users) { Program.usernameMap[u.Uid] = u.Username; if (Program.chatFormMap.ContainsKey(u.Uid)) { Program.chatFormMap[u.Uid].UpdateUsername(); } lstUsers.Items.Add(new UserWrapper(u)); Debug.Print(u.Username); } })); } catch (Exception) { } }
private void Handle() { while (connected) { byte type; byte[] buffer = Packet.Read(stream, out type); if (buffer == null) { Debug.Print("broken"); break; } Debug.Print("Type: {0}", type); lastReset = null; // dispatch switch (type) { case Packet.PACKET_LOGIN: { LoginResponse r = LoginResponse.Parser.ParseFrom(buffer); HandleLogin(r); break; } case Packet.PACKET_REGISTER: { RegisterResponse r = RegisterResponse.Parser.ParseFrom(buffer); HandleRegister(r); break; } case Packet.PACKET_LIST_USER: { ListUserResponse r = ListUserResponse.Parser.ParseFrom(buffer); HandleListUser(r); break; } case Packet.PACKET_LIST_BUDDY: { ListBuddyResponse r = ListBuddyResponse.Parser.ParseFrom(buffer); HandleListBuddy(r); break; } case Packet.PACKET_ADD_BUDDY: { AddBuddyResponse r = AddBuddyResponse.Parser.ParseFrom(buffer); HandleAddBuddy(r); break; } case Packet.PACKET_REMOVE_BUDDY: { RemoveBuddyResponse r = RemoveBuddyResponse.Parser.ParseFrom(buffer); HandleRemoveBuddy(r); break; } case Packet.PACKET_MESSAGE: { Message r = Message.Parser.ParseFrom(buffer); HandleMessage(r); break; } case Packet.PACKET_RESET: { Reset r = Reset.Parser.ParseFrom(buffer); HandleReset(r); break; } case Packet.PACKET_RAW: { Debug.Print(Encoding.UTF8.GetString(buffer)); break; } default: { LoginResponse r = LoginResponse.Parser.ParseFrom(buffer); break; } } } Close(); }