예제 #1
0
 /// <summary>
 /// 显示分布消息聊天记录
 /// </summary>
 /// <param name="e"></param>
 private void LoadChatMessage(TreeNode e)
 {
     RTBRecord.Clear();
     RTBRecord.ClearUndo();
     //SELECT TOP 2 * FROM (SELECT TOP 2 * FROM ChatMessageLog  ORDER BY id DESC) ORDER BY id
     //SELECT * FROM (SELECT TOP " + PageSize + " * FROM (SELECT * FROM (SELECT TOP " + PageSize * int.Parse(txt_pageIndex.Text.ToString()) + " * FROM ChatMessageLog where Jid='" + e.Tag.ToString() + "') ORDER BY id desc) ) ORDER BY ID asc
     OleDbDataReader dr = OleDb.ExSQLReDr("SELECT * FROM (SELECT TOP " + PageSize + " * FROM (SELECT * FROM (SELECT TOP " + PageSize * int.Parse(txt_pageIndex.Text.ToString()) + " * FROM ChatMessageLog where Jid='" + e.Tag.ToString() + "' and Belong='" + XmppConn.MyJID.Bare.ToString() + "' ) ORDER BY id desc) ) ORDER BY ID asc");
     while (dr.Read())
     {
         Document document = new Document();
         document.LoadXml(dr.GetString(3));
         CSS.IM.XMPP.protocol.client.Message top_msg = (CSS.IM.XMPP.protocol.client.Message)document.RootElement;
         if (top_msg.GetTagInt("m_type") == 0)
         {
             RTBRecord_Show(top_msg, false);
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 显示分页后的系统消息
        /// </summary>
        /// <param name="e"></param>
        private void LoadMessage(TreeNode e)
        {
            RTBRecord.Clear();
            RTBRecord.ClearUndo();

            OleDbDataReader dr = OleDb.ExSQLReDr("SELECT * FROM (SELECT TOP " + PageSize + " * FROM (SELECT * FROM (SELECT TOP " + PageSize * int.Parse(txt_pageIndex.Text.ToString()) + " * FROM MessageLog where MessageType='" + e.Tag.ToString() + "' and Belong='" + XmppConn.MyJID.Bare.ToString() + "') ORDER BY id desc) ) ORDER BY ID asc");
            //OleDbDataReader dr = OleDb.ExSQLReDr("SELECT TOP " + PageSize + " * FROM (SELECT TOP " + PageSize * int.Parse(txt_pageIndex.Text.ToString()) + " * FROM MessageLog where MessageType='" + e.Tag.ToString() + "' ORDER BY id DESC) ORDER BY id");
            //OleDbDataReader dr = OleDb.ExSQLReDr("select * from MessageLog where MessageType='" + e.Tag.ToString() + "' order by [ID] asc");
            while (dr.Read())
            {
                Document document = new Document();
                string sytsem_msg = "<message xmlns=\"jabber:client\" from=\"songques@imserver\" to=\"songques@imserver\"><FName>宋体</FName><FSize>9</FSize><FBold>true</FBold><FItalic>false</FItalic><FStrikeout>false</FStrikeout><FUnderline>true</FUnderline><CA>207</CA><CR>119</CR><CG>33</CG><CB>255</CB><body>[系统通知]    " + dr.GetDateTime(4).ToString("yyyy-MM-dd HH:mm:ss") + "</body></message>";
                document.LoadXml(sytsem_msg);
                CSS.IM.XMPP.protocol.client.Message top_msg = (CSS.IM.XMPP.protocol.client.Message)document.RootElement;
                RTBRecord_Show(top_msg, false);

                document.Clear();
                document.LoadXml(dr.GetString(3));
                top_msg = (CSS.IM.XMPP.protocol.client.Message)document.RootElement;
                top_msg.Body = top_msg.Body + "\n";

                MqMessage mqMsg=MessageBoxForm.MarkMessage_Mq(top_msg);
                if (top_msg.GetTag("subject")!=null)
                {
                    top_msg.Body = mqMsg.Herf + "?token=" + mqMsg.Token + "&url=" + mqMsg.Url + "&password=" + Base64.EncodeBase64(XmppConn.Password);
                }
                RTBRecord_Show(top_msg, false);
            }
        }
예제 #3
0
        private void OnGetSessionRequestResponse(IAsyncResult result)
        {
            // grab the custom state object
            WebRequestState state = (WebRequestState)result.AsyncState;
            HttpWebRequest request = (HttpWebRequest)state.WebRequest;

            //state.TimeOutTimer.Dispose();

            // get the Response
            HttpWebResponse resp = (HttpWebResponse)request.EndGetResponse(result);

            // The server must always return a 200 response code,
            // sending any session errors as specially-formatted identifiers.
            if (resp.StatusCode != HttpStatusCode.OK)
            {
                //FireOnError(new PollSocketException("unexpected status code " + resp.StatusCode.ToString()));
                return;
            }

            Stream rs = resp.GetResponseStream();

            int readlen;
            byte[] readbuf = new byte[1024];
            MemoryStream ms = new MemoryStream();
            while ((readlen = rs.Read(readbuf, 0, readbuf.Length)) > 0)
            {
                ms.Write(readbuf, 0, readlen);
            }

            byte[] recv = ms.ToArray();

            if (recv.Length > 0)
            {
                string body = null;
                string stanzas = null;

                string res = Encoding.UTF8.GetString(recv, 0, recv.Length);

                ParseResponse(res, ref body, ref stanzas);

                Document doc = new Document();
                doc.LoadXml(body);
                Body boshBody = doc.RootElement as Body;

                sid         = boshBody.Sid;
                polling     = boshBody.Polling;
                m_MaxPause  = boshBody.MaxPause;

                byte[] bin = Encoding.UTF8.GetBytes(DummyStreamHeader + stanzas);

                base.FireOnReceive(bin, bin.Length);

                // cleanup webrequest resources
                ms.Close();
                rs.Close();
                resp.Close();

                waitingRequests--;

                if (waitingRequests == 0)
                    StartWebRequest();
            }
        }