Beispiel #1
0
        private async void AddQQToLv(IQQClient qq)
        {
            await qq.GetUserLevel(qq.Account).WhenFinalEvent().ConfigureAwait(false);

            var subitems = new[]
            {
                lvQQList.Items.Count.ToString(),
                qq.Account.QQ.ToString(),
                qq.Account.ClientType.ToString(),
                qq.Account.Status.ToString(),
                qq.Account.LevelInfo.Level.ToString(),
                qq.Account.LevelInfo.RemainDays.ToString(),
            };
            var item = new ListViewItem(subitems)
            {
                Selected = true
            };

            var index = lvQQList.FindFirstItemIndex(qq.Account.QQ.ToString(), new[] { 1 });

            if (index < 0)
            {
                lvQQList.InvokeIfRequired(() =>
                {
                    lvQQList.Items.Add(item);
                });
            }
            else
            {
                lvQQList.InvokeIfRequired(() =>
                {
                    lvQQList.UpdateItem(index, item, new[] { 2, 3, 4, 5 });
                });
            }
        }
Beispiel #2
0
        private void UpdateQQInfo(IQQClient iqqClient, int indexInLV = -1)
        {
            var qqAccount = iqqClient.Account;
            var index     = indexInLV >= 0 ? indexInLV : GetIndexInLV(qqAccount.Username);

            if (index < 0)
            {
                return;
            }

            if (lvQQList.InvokeRequired)
            {
                lvQQList.Invoke(new MethodInvoker(() =>
                {
                    var item = lvQQList.Items[index];
                    item.SubItems[2].Text = iqqClient.Account.Password;
                    item.SubItems[3].Text = iqqClient.ClientType.Value;
                    item.SubItems[4].Text = qqAccount.Status.Description;
                    item.SubItems[5].Text = qqAccount.Level.Level.ToString();
                    item.SubItems[6].Text = qqAccount.Level.RemainDays.ToString();
                }));
            }
            else
            {
                var item = lvQQList.Items[index];
                item.SubItems[2].Text = iqqClient.Account.Password;
                item.SubItems[3].Text = iqqClient.ClientType.Value;
                item.SubItems[4].Text = qqAccount.Status.Description;
                item.SubItems[5].Text = qqAccount.Level.Level.ToString();
                item.SubItems[6].Text = qqAccount.Level.RemainDays.ToString();
            }
        }
Beispiel #3
0
        private void AddQQInfo(IQQClient iqqClient)
        {
            var index = GetIndexInLV(iqqClient.Account.Username);

            if (index >= 0)
            {
                UpdateQQInfo(iqqClient, index);
                return;
            }
            var listViewItem = new ListViewItem((lvQQList.Items.Count + 1).ToString());

            listViewItem.SubItems.Add(iqqClient.Account.Username);
            listViewItem.SubItems.Add(iqqClient.Account.Password);
            listViewItem.SubItems.Add(iqqClient.ClientType.Value);
            listViewItem.SubItems.Add("离线");
            listViewItem.SubItems.Add("0");
            listViewItem.SubItems.Add("0");
            if (lvQQList.InvokeRequired)
            {
                lvQQList.Invoke(new MethodInvoker(() =>
                {
                    lvQQList.Items.Add(listViewItem);
                }));
            }
            else
            {
                lvQQList.Items.Add(listViewItem);
            }
        }
Beispiel #4
0
        private void AddQQToList(string qqNum, string qqPassword, string type = "webqq")
        {
            IQQClient iqqClient = null;

            switch (type.ToLower())
            {
            case "webqq":
                iqqClient = new WebQQClient(qqNum, qqPassword, _notifyHandler, _threadActorDispatcher);
                break;

            default:
                iqqClient = new WebQQClient(qqNum, qqPassword, _notifyHandler, _threadActorDispatcher);
                break;
            }
            _qqClients.Add(qqNum, iqqClient, AddChoice.Update);
            AddQQInfo(iqqClient);
        }
Beispiel #5
0
        private void UpdateQQInfo(IQQClient iqqClient, int indexInLV = -1)
        {
            var qqAccount = iqqClient.Account;
            var index = indexInLV >= 0 ? indexInLV : GetIndexInLV(qqAccount.Username);
            if (index < 0)
            {
                return;
            }

            if (lvQQList.InvokeRequired)
            {
                lvQQList.Invoke(new MethodInvoker(() =>
                {
                    var item = lvQQList.Items[index];
                    item.SubItems[3].Text = iqqClient.ClientType.Value;
                    item.SubItems[4].Text = qqAccount.Status.Description;
                    item.SubItems[5].Text = qqAccount.Level.Level.ToString();
                    item.SubItems[6].Text = qqAccount.Level.RemainDays.ToString();
                }));
            }
            else
            {
                var item = lvQQList.Items[index];
                item.SubItems[3].Text = iqqClient.ClientType.Value;
                item.SubItems[4].Text = qqAccount.Status.Description;
                item.SubItems[5].Text = qqAccount.Level.Level.ToString();
                item.SubItems[6].Text = qqAccount.Level.RemainDays.ToString();
            }
        }
Beispiel #6
0
 private void AddQQInfo(IQQClient iqqClient)
 {
     var index = GetIndexInLV(iqqClient.Account.Username);
     if (index >= 0)
     {
         UpdateQQInfo(iqqClient, index);
         return;
     }
     var listViewItem = new ListViewItem((lvQQList.Items.Count + 1).ToString());
     listViewItem.SubItems.Add(iqqClient.Account.Username);
     listViewItem.SubItems.Add(iqqClient.Account.Password);
     listViewItem.SubItems.Add(iqqClient.ClientType.Value);
     listViewItem.SubItems.Add("离线");
     listViewItem.SubItems.Add("0");
     listViewItem.SubItems.Add("0");
     if (lvQQList.InvokeRequired)
     {
         lvQQList.Invoke(new MethodInvoker(() =>
         {
             lvQQList.Items.Add(listViewItem);
         }));
     }
     else
     {
         lvQQList.Items.Add(listViewItem);
     }
 }
Beispiel #7
0
        public static void Main2(string[] args)
        {
            var       threadActorDispatcher = new SimpleActorDispatcher();
            IQQClient client = null;

start:
            Console.Write("请输入QQ号:");
            var username = Console.ReadLine();

            Console.Write("请输入QQ密码:");
            var password = Console.ReadLine();

            client = new WebQQClient(username, password, Listener, threadActorDispatcher);


            //测试同步模式登录
            var future = client.Login(QQStatus.ONLINE, null);

            client.Logger.LogInformation(client.Account.Username + "-登录中......");

            var Event = future.WaitFinalEvent();

            if (Event.Type == QQActionEventType.EvtOK)
            {
                client.Logger.LogInformation(client.Account.Username + "-登录成功!!!!");

                var getUserInfoEvent = client.GetUserInfo(client.Account, null).WaitFinalEvent();

                if (getUserInfoEvent.Type == QQActionEventType.EvtOK)
                {
                    client.Logger.LogInformation(client.Account.QQ + "-用户信息:" + getUserInfoEvent.Target);


                    client.GetBuddyList(null).WaitFinalEvent();
                    client.Logger.LogInformation(client.Account.QQ + "-Buddy count: " + client.GetBuddyList().Count);

                    foreach (var buddy in client.GetBuddyList())
                    {
                        var f    = client.GetUserQQ(buddy, null);
                        var e    = f.WaitFinalEvent();
                        var name = string.IsNullOrEmpty(buddy.MarkName) ? buddy.Nickname : buddy.MarkName;
                        client.Logger.LogInformation($"{buddy.QQ}, {name}");
                    }
                }
                //所有的逻辑完了后,启动消息轮询
                client.BeginPollMsg();
            }
            else if (Event.Type == QQActionEventType.EvtError)
            {
                var ex = (QQException)Event.Target;
                client.Logger.LogInformation(ex.Message);
                client.Destroy();
                goto start;
            }
            else
            {
                client.Logger.LogInformation(client.Account.Username + "-登录失败");
                client.Destroy();
                goto start;
            }

            client.Logger.LogInformation("按任意键退出");
            Console.ReadLine();
        }
Beispiel #8
0
        private async void AddQQToLv(IQQClient qq)
        {
            await qq.GetUserLevel(qq.Account).WhenFinalEvent().ConfigureAwait(false);
            var subitems = new[]
            {
                    lvQQList.Items.Count.ToString(),
                    qq.Account.QQ.ToString(),
                    qq.Account.ClientType.ToString(),
                    qq.Account.Status.ToString(),
                    qq.Account.LevelInfo.Level.ToString(),
                    qq.Account.LevelInfo.RemainDays.ToString(),
                };
            var item = new ListViewItem(subitems) { Selected = true };

            var index = lvQQList.FindFirstItemIndex(qq.Account.QQ.ToString(), new[] { 1 });
            if (index < 0)
            {
                lvQQList.InvokeIfRequired(() =>
                {
                    lvQQList.Items.Add(item);
                });
            }
            else
            {
                lvQQList.InvokeIfRequired(() =>
                {
                    lvQQList.UpdateItem(index, item, new[] { 2, 3, 4, 5 });
                });
            }
        }