示例#1
0
文件: Form1.cs 项目: zsea/QnPg
        public string GetGuestNameFromChatRecord()
        {
            string guestName = string.Empty;

            if (cmbQnAccount.SelectedIndex > -1)
            {
                var selectedItem = cmbQnAccount.Items[cmbQnAccount.SelectedIndex].ToString();
                var html         = string.Empty;
                if (GetHtml(out html))
                {
                    var parser     = new ChatRecordParser(selectedItem);
                    var chatRecord = parser.Parse(html);
                    guestName = chatRecord == null ? string.Empty : chatRecord.GuestName;
                    //chatRecord.Statements.ForEach(k =>
                    //{
                    //    Console.WriteLine("speaker={0},time={1},content={2}", k.Speaker, k.Time, k.OneStringWithTrim);
                    //});
                }
            }

            return(guestName);
        }
示例#2
0
        private CBStatement CreateCBStatement(HtmlNode htmlNode)
        {
            CBStatement cbs = null;

            for (int i = 0; i < 2; i++)
            {
                try
                {
                    string   value       = htmlNode.Attributes["data-time"].Value;
                    DateTime time        = ChatRecordParser.TimeSpanToDateTime(Convert.ToInt64(value));
                    string   nick        = htmlNode.Attributes["data-nick"].Value;
                    bool     isSellerMsg = htmlNode.Attributes["class"].Value.Contains("imui-msg-r");
                    htmlNode.Attributes["class"].Value.Contains("imui-msg-l");
                    CBStatement.Role role;
                    if (isSellerMsg)
                    {
                        role = CBStatement.Role.Self;
                    }
                    else
                    {
                        role = CBStatement.Role.Guest;
                    }
                    HtmlNode htmlNode_ = htmlNode.SelectSingleNode(".//div[contains(@class,'msg-body-html')]");
                    string   chatmsg   = this.GetChatContent(htmlNode_);
                    cbs = new CBStatement(nick, chatmsg, time, role);
                    return(cbs);
                }
                catch (OutOfMemoryException ex)
                {
                    GC.Collect();
                }
                catch (Exception ex2)
                {
                }
            }
            return(cbs);
        }