以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  用OpenQQ同步数据问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=185677)

--  作者:drcqh
--  发布时间:2023/3/9 16:28:00
--  用OpenQQ同步数据问题
请教老师:我想通过如下代码实现客户端数据表的同步,但执行时没有实现同步,代码如下:

Open客户端的receivedMessage事件中的代码如下:
Dim msg As String = e.Message
If msg.StartsWith("U#") Then \'表示修改了某行
    Dim pts() As String = msg.Split("#")
    If pts.Length = 3 Then
        Dim dr As DataRow = DataTables(pts(1)).Find("[_Identify] = " & pts(2))
        If dr IsNot Nothing  Then
            dr.Load() \'重新加载此行
        End If
    End If
ElseIf msg.StartsWith("A#") Then \'表示增加了行
    Dim pts() As String = msg.Split("#")
    If pts.Length = 3 Then
        DataTables(pts(1)).AppendLoad("[_Identify] = " &  pts(2)) \'追载新增加的行.
    End If
ElseIf msg.StartsWith("D#") Then \'表示删除了行
    Dim pts() As String = msg.Split("#")
    If pts.Length = 3 Then
        DataTables(pts(1)).RemoveFor("[_Identify] = "  & pts(2)) \'移除行
    End If
End If



客户端项目的全局表事件AfterSaveDataRow中写入如下代码:
Dim p, msg As String
If e.StatementType = 0 Then   \'新增行时
    p = "A#"
ElseIf e.StatementType = 1 Then   \'修改行时
    P = "U#"
    Else    \'删除行时 
    p = "D#"
End If
msg = p & e.DataTable.Name & "#" & e.DataRow("_identify")
For Each bd As qqbuddy In QQClient.Buddies
    If bd.OnLine Then
        QQClient.Send(bd.Name, msg)
    End If
Next

这个表事件不能实现同步吗

--  作者:有点蓝
--  发布时间:2023/3/9 16:58:00
--  
调试

Dim msg As String = e.Message
msgbox(msg) ‘这里能不能弹出,弹出什么内容?
If msg.StartsWith("U#") Then \'表示修改了某行
    Dim pts() As String = msg.Split("#")
……

--  作者:drcqh
--  发布时间:2023/3/10 10:01:00
--  
弹不出
--  作者:有点蓝
--  发布时间:2023/3/10 10:17:00
--  
说明用户没有收到消息,应该是没有登录openqq。
--  作者:drcqh
--  发布时间:2023/3/10 23:56:00
--  
测试发现在全局表事件AfterSaveDataRow中写入message.show("aaa")没反应,而在表事件AfterSaveDataRow中写入message.show("aaa")才起作用。一楼我的代码不起作用是不是这个原因呀
[此贴子已经被作者于2023/3/10 23:56:32编辑过]

--  作者:有点蓝
--  发布时间:2023/3/11 8:36:00
--  
全局表事件要开启才能使用:http://www.foxtable.com/webhelp/topics/0671.htm