Ejemplo n.º 1
0
        public void TC02_RetrieveNewLink()
        {
            DiscussGroupLinkService linkService = new DiscussGroupLinkService();
            List <DiscussGroupLink> list        = linkService.getByStatus(EntityStatus.Waiting);

            Console.WriteLine("获得{0}条未处理的DiscussGroupLink", list.Count);

            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                DiscussGroupLink link = list[i];
                Console.WriteLine("处理DiscussGroupLink, ID={0}", link.ID);

                string root    = (new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location)).Directory.FullName;
                string exeFile = root + "\\files\\ShowNotify.exe";
                Process.Start(exeFile, "2000 " + string.Format("正在处理:{0}/{1}", i, count));

                try
                {
                    linkService.UpdateStatus(link.ID, EntityStatus.Processing, "处理中");
                    string newLink = "";

                    //QQ讨论组
                    if (link.LinkType == "Z")
                    {
                        string oldLink = link.OldLink;

                        //使用默认浏览器(IE)打开指定地址
                        Console.WriteLine("[{0}] 打开IE浏览器", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        JoinTalkWebPage jtPage = new JoinTalkWebPage();
                        jtPage.LaunchUrl(new System.Uri(oldLink));
                        //点击“加入多人聊天”按钮
                        Console.WriteLine("[{0}] 点击“加入多人聊天”按钮", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        jtPage.JoinTalkDoc.BtnJoinTalk.WaitForControlExist();
                        Mouse.Click(jtPage.JoinTalkDoc.BtnJoinTalk);
                        //关闭浏览器
                        Console.WriteLine("[{0}] 关闭浏览器", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        jtPage.Close();
                        jtPage.WaitForControlNotExist();

                        //获取聊天对话框
                        Console.WriteLine("[{0}] 获取聊天对话框", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        QQTalkWindow window = new QQTalkWindow();
                        //获取工具条按钮
                        Console.WriteLine("[{0}] 获取工具条按钮", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        WinSplitButton btnJoinTalk = window.TalkToolBar.BtnJoinTalk;
                        //点击“邀请加入多人聊天”
                        Console.WriteLine("[{0}] 点击“邀请加入多人聊天”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Mouse.Click(btnJoinTalk);

                        //获取弹出窗口
                        Console.WriteLine("[{0}] 获取弹出窗口", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        JoinTalkWindow jtWin = new JoinTalkWindow();
                        //等待弹出窗口显示完毕
                        Console.WriteLine("[{0}] 等待弹出窗口显示完毕", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        jtWin.JoinTalkMenu.JoinTalkItem.WaitForControlExist();
                        //点击“复制邀请链接”
                        Console.WriteLine("[{0}] 点击“复制邀请链接”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Mouse.Click(jtWin.JoinTalkMenu.JoinTalkItem);
                        Console.WriteLine("[{0}] 休眠1秒钟", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Thread.Sleep(1000);

                        //从黏贴板中读取新邀请链接
                        Console.WriteLine("[{0}] 从黏贴板中读取新邀请链接", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        newLink = Clipboard.GetText();
                        if (!string.IsNullOrWhiteSpace(newLink) && newLink.StartsWith("点击链接加入多人聊天"))
                        {
                            newLink = Clipboard.GetText().Split("\r\n".ToCharArray())[1];
                        }

                        //Keyboard.SendKeys(window.Input, ":) just for holding this group. sorry to bother.");
                        //Keyboard.SendKeys(window.Input, KeyboardKeys.ENTER);

                        //关闭讨论组标签
                        Console.WriteLine("[{0}] 关闭讨论组标签", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Keyboard.SendKeys(window, KeyboardKeys.ESC);
                    }
                    else
                    {
                        //QQ群
                    }

                    //保存新Url,http://url.cn/5rUmF4D
                    if (!string.IsNullOrWhiteSpace(newLink))
                    {
                        linkService.UpdateNewLink(link.ID, newLink);
                    }
                    else
                    {
                        linkService.UpdateStatus(link.ID, EntityStatus.Fail, "获取新链接失败");
                    }
                }
                catch (Exception ex)
                {
                    linkService.UpdateStatus(link.ID, EntityStatus.Fail, HttpUtility.UrlEncode(ex.Message));
                }

                //break;
            }
        }
Ejemplo n.º 2
0
        public void TC04_GetQQTaoLunZuList()
        {
            OrigionLinkService olService = new OrigionLinkService();

            MsgManWindow mmw = new MsgManWindow();

            Mouse.Click(mmw.MsgManTabs.MultipleTalksTabPage);
            Mouse.Click(mmw.LeftList.MyMultipleTalk);

            WinListItem last = null;
            int         i    = 0;

            while (mmw.HasNext(mmw.MidList, i))
            {
                if (last != null)
                {
                    Mouse.Click(last);
                    Keyboard.SendKeys(KeyboardKeys.DOWN);
                }

                WinListItem item = mmw.Next(mmw.MidList, i);
                Mouse.DoubleClick(item);

                #region
                //获取聊天对话框
                Console.WriteLine("[{0}] 获取聊天对话框", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                QQTalkWindow window = new QQTalkWindow();
                //获取工具条按钮
                Console.WriteLine("[{0}] 获取工具条按钮", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                WinSplitButton btnJoinTalk = window.TalkToolBar.BtnJoinTalk;
                //点击“邀请加入多人聊天”
                Console.WriteLine("[{0}] 点击“邀请加入多人聊天”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                Mouse.Click(btnJoinTalk);

                //获取弹出窗口
                Console.WriteLine("[{0}] 获取弹出窗口", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                JoinTalkWindow jtWin = new JoinTalkWindow();
                //等待弹出窗口显示完毕
                Console.WriteLine("[{0}] 等待弹出窗口显示完毕", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                jtWin.JoinTalkMenu.JoinTalkItem.WaitForControlExist();
                //点击“复制邀请链接”
                Console.WriteLine("[{0}] 点击“复制邀请链接”", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                //Mouse.Click(jtWin.JoinTalkMenu.JoinTalkItem);
                Keyboard.SendKeys(KeyboardKeys.DOWN);
                Keyboard.SendKeys(KeyboardKeys.DOWN);
                Keyboard.SendKeys(KeyboardKeys.ENTER);
                Console.WriteLine("[{0}] 休眠1秒钟", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                Thread.Sleep(1000);

                //从黏贴板中读取新邀请链接
                Console.WriteLine("[{0}] 从黏贴板中读取新邀请链接", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                string newLink = Clipboard.GetText();
                if (!string.IsNullOrWhiteSpace(newLink) && newLink.StartsWith("点击链接加入多人聊天"))
                {
                    newLink = Clipboard.GetText().Split("\r\n".ToCharArray())[1];
                }

                //关闭讨论组标签
                Console.WriteLine("[{0}] 关闭讨论组标签", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                Keyboard.SendKeys(window, KeyboardKeys.ESC);
                #endregion

                OrigionLink link = new OrigionLink()
                {
                    QQOwner      = "",
                    RetrieveDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")),
                    Type         = "Z",
                    Name         = item.Name.Substring(0, 1000),
                    JoinLink     = newLink
                };

                try
                {
                    olService.Insert(link);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(link.ToString());
                    Console.WriteLine(ex.Message);
                }

                last = item;
                //if (++i >= 595) break;
            }
        }