public List <QQBuddy> GetOnlineBuddyList() { return((from buddy in _buddyMap where QQStatus.IsGeneralOnline(buddy.Value.Status) select buddy.Value).ToList()); }
public IEnumerable <QQBuddy> GetOnlineBuddyList() { return(from buddy in _buddyMap where QQStatus.IsGeneralOnline(buddy.Value.Status) select buddy.Value); }
private async Task LoginAsync() { var loginStatusIndex = 0; cboLoginStatus.Invoke(new MethodInvoker(() => { loginStatusIndex = cboLoginStatus.SelectedIndex; })); var status = QQStatus.ValueOfRaw(LoginStatus[1][loginStatusIndex]); var qqCount = 0; lvQQList.Invoke(new MethodInvoker(() => { qqCount = lvQQList.Items.Count; })); for (var i = 0; i < qqCount; ++i) { var qqNumber = ""; var index = i; lvQQList.Invoke(new MethodInvoker(() => { qqNumber = lvQQList.Items[index].SubItems[1].Text; lvQQList.SelectedIndices.Clear(); lvQQList.Focus(); lvQQList.Items[index].Selected = true; lvQQList.Items[index].EnsureVisible(); lvQQList.Items[index].SubItems[4].Text = "正在登录"; })); var client = _qqClients[qqNumber]; if (QQStatus.IsGeneralOnline(client.Account.Status)) { if (client.Account.Status != status) { client.ChangeStatus(status).WaitFinalEvent(1000); } UpdateQQInfo(client, i); continue; } (client as WebQQClient)?.ReadCookie(); //测试同步模式登录 var future = client.Login(status, _eventHandler); ShowMessage(client.Account.Username + "-登录中......"); var Event = await future.WhenFinalEvent(); if (Event.Type == QQActionEventType.EVT_OK) { ShowMessage(client.Account.Username + "-登录成功!!!"); (client as WebQQClient)?.SaveCookie(); await client.GetUserInfo(client.Account, _eventHandler).WhenFinalEvent(); await client.GetUserLevel(client.Account, _eventHandler).WhenFinalEvent(); UpdateQQInfo(client, i); if (qqCount < 5) { var actionEvent = await client.GetBuddyList(_eventHandler).WhenFinalEvent(); ShowMessage(QQActionEventType.EVT_OK == actionEvent.Type ? $"{client.Account.Username}-好友数量:{client.GetBuddyList().Count}" : string.Format(client.Account.Username + "-获取好友列表失败")); actionEvent = await client.GetGroupList(_eventHandler).WhenFinalEvent(); ShowMessage(QQActionEventType.EVT_OK == actionEvent.Type ? $"{client.Account.Username}-群数量:{client.GetGroupList().Count}" : string.Format(client.Account.Username + "-获取群列表失败")); } client.BeginPollMsg(); } else if (Event.Type == QQActionEventType.EVT_ERROR) { client.Account.Status = QQStatus.OFFLINE; var ex = (QQException)Event.Target; ShowMessage(ex.Message); UpdateQQInfo(client); } else { client.Account.Status = QQStatus.OFFLINE; ShowMessage(client.Account.Username + "-登录失败"); UpdateQQInfo(client); } } lvQQList.Invoke(new MethodInvoker(() => { lvQQList.SelectedIndices.Clear(); })); }