版本:2008 Beta1 (8.0.054.201)
引用:Interop.RTXCAPILib.dll
Interop.RTXClient.dll
Interop.RTXSAPILib.dll
using RTXCAPILib;
using RTXSAPILib;
using RTXClient;
本文完全按照腾讯公司提供的Demo操作
------------------------------------------------------------------
VS 2005
1.新建网站 RTX_test
功能一:单点登录
前台:
<table style="position: relative">
<tr>
<td style="width: 100px">
服务器地址:</td>
<td style="width: 100px">
<asp:TextBox ID="txtServerIP" runat="server" Style="position: relative">127.0.0.1</asp:TextBox></td>
<td style="width: 122px">
AppServer端口:</td>
<td style="width: 100px">
<asp:TextBox ID="txtAppServerPort" runat="server" Style="position: relative">8006</asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
用户名:</td>
<td style="width: 100px">
<asp:TextBox ID="txtUserName" runat="server" Style="position: relative">wf</asp:TextBox></td>
<td style="width: 122px">
登录端口:</td>
<td style="width: 100px">
<asp:TextBox ID="txtServerPort" runat="server" Style="position: relative">8000</asp:TextBox></td>
</tr>
<tr>
<td align=center colspan="4" style="height: 26px">
<asp:Button ID="Button1" runat="server" Style="position: relative" Text="登录" OnClick="Button1_Click" /></td>
</tr>
</table>
后台:
using RTXCAPILib;
using RTXSAPILib;
using RTXClient;
protected void Button1_Click(object sender, EventArgs e)
{
//登录
RTXClient.RTXAPIClass ObjApi = new RTXAPIClass(); //创建一个客户端SDK主对象
RTXCAPILib.IRTXCRoot RTXCRoot = (RTXCAPILib.IRTXCRoot)ObjApi.GetObject("KernalRoot"); //通过主对象获取CRoot对象
try
{
string Account = txtUserName.Text; //帐号
string SessionKey = GetSessionKey(Account);//获取SessionKey
RTXCRoot.LoginSessionKey(txtServerIP.Text, Convert.ToInt16(txtServerPort.Text), Account, SessionKey); //SessionKey 登录
Response.Redirect("browinfo.aspx");
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}
private string GetSessionKey(string Account) //服务器端代码
{
string SessionKey = "";
RTXSAPILib.RTXSAPIRootObj RootObj = new RTXSAPIRootObj(); //创建一个根对象
RTXSAPILib.RTXSAPIUserAuthObj UserAuthObj = RootObj.UserAuthObj; //创建一个用户认证对象
RootObj.ServerIP = txtServerIP.Text; //设置服务器IP
RootObj.ServerPort = Convert.ToInt16(txtAppServerPort.Text); //设置Appserver端口
try
{
SessionKey = UserAuthObj.GetSessionKey(Account); //通过用户认证对象获取SessionKey
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
return SessionKey; //返回SessionKey
}
功能二:查询企业信息
前台:
<body>
<form id="form1" runat="server">
<div>
<table style="position: relative">
<tr>
<td style="width: 100px; height: 39px;">
服务器地址:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrIP" runat="server" Style="position: relative">127.0.0.1</asp:TextBox></td>
<td style="width: 128px; height: 39px;">
AppServer端口:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrPort" runat="server" Style="position: relative">8006</asp:TextBox></td>
</tr>
</table>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="position: relative"
Text="查询企业信息" />
<asp:TextBox ID="txtResult" runat="server" Style="position: relative" TextMode="MultiLine">查询企业信息</asp:TextBox>
</form>
</body>
后台:
RTXSAPILib.RTXSAPIRootObj RootObj; //声明一个根对象
protected void Page_Load(object sender, EventArgs e)
{
RootObj = new RTXSAPIRootObj(); //创建根对象
RootObj.ServerIP = txtSvrIP.Text; //设置服务器IP
RootObj.ServerPort = Convert.ToInt16(txtSvrPort.Text); //设置服务器端口
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
txtResult.Text = RootObj.GetEnterpriseInfo(); //获取企业信息
}
catch (Exception xe)
{
Response.Write(xe.Message.ToString());
}
}
功能三:发送消息提示
using RTXSAPILib;
using RTXClient;
<body>
<form id="form1" runat="server">
<table style="position: relative">
<tr>
<td style="width: 100px; height: 39px;">
服务器地址:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrIP" runat="server" Style="position: relative">127.0.0.1</asp:TextBox></td>
<td style="width: 128px; height: 39px;">
AppServer端口:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrPort" runat="server" Style="position: relative">8006</asp:TextBox></td>
</tr>
</table>
<div>
<table style="width: 502px; position: relative">
<tr>
<td style="width: 133px">
消息提醒接收者:</td>
<td style="width: 250px">
<asp:TextBox ID="txtReceivers" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px">
息提醒标题:</td>
<td style="width: 250px">
<asp:TextBox ID="txtMsgTitle" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px">
息提醒停留时间:</td>
<td style="width: 250px">
<asp:TextBox ID="txtTime" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px">
消息内容:</td>
<td style="width: 250px">
<asp:TextBox ID="txtMsgContent" runat="server" Style="position: relative" TextMode="MultiLine"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px; height: 26px;">
</td>
<td style="width: 250px; height: 26px;">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="position: relative"
Text="发送" /></td>
</tr>
</table>
<br />
查询用户状态<br />
<table style="width: 445px; position: relative">
<tr>
<td style="width: 100px">
用户名:<asp:TextBox ID="txtUserName" runat="server" Style="position: relative"></asp:TextBox>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Style="position: relative"
Text="查询用户状态" /><br />
<asp:TextBox ID="txtResult" runat="server" Style="position: relative" TextMode="MultiLine" Height="134px" Width="423px"></asp:TextBox><br />
<asp:Button ID="Button5" runat="server" OnClick="Button5_Click" Style="position: relative"
Text="用户权限列表" /></td>
</tr>
</table>
</div>
<br />
用户登录验证<br />
<table style="position: relative">
<tr>
<td style="width: 100px">
用户</td>
<td style="width: 100px">
<asp:TextBox ID="txtUserNa" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
密码</td>
<td style="width: 100px">
<asp:TextBox ID="txtPwd" runat="server" Style="left: 1px; position: relative"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Style="position: relative"
Text="登录验证" /></td>
</tr>
</table>
<br />
<br />
获取版本信息<br />
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Style="position: relative"
Text="获取版本信息" />
</form>
</body>
后台:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using RTXSAPILib;
using RTXClient;
public partial class SendNotifyf : System.Web.UI.Page
{
RTXSAPILib.RTXSAPIRootObj RootObj; //声明一个根对象
protected void Page_Load(object sender, EventArgs e)
{
RootObj = new RTXSAPIRootObj(); //创建根对象
RootObj.ServerIP = txtSvrIP.Text; //设置服务器IP
RootObj.ServerPort = Convert.ToInt16(txtSvrPort.Text); //设置服务器端口
}
protected void Button1_Click(object sender, EventArgs e)
{//发送信息
try
{
RootObj.SendNotify(txtReceivers.Text, txtMsgTitle.Text, Convert.ToInt32(txtTime.Text), txtMsgContent.Text); //获取版本信息
Response.Write("发送成功");
}
catch (Exception xe)
{
Response.Write(xe.Message.ToString());
}
}
protected void Button2_Click(object sender, EventArgs e)
{//查询状态
try
{
txtResult.Text = RootObj.QueryUserState(txtUserName.Text); //获取用户状态
}
catch (Exception xe)
{
Response.Write(xe.Message.ToString());
}
}
protected void Button3_Click(object sender, EventArgs e)
{
// 用户登录认证
//RTXClient.RTXAPIClass ObjApi = new RTXAPIClass(); //创建一个客户端SDK主对象
//RTXCAPILib.IRTXCRoot RTXCRoot = (RTXCAPILib.IRTXCRoot)ObjApi.GetObject("KernalRoot"); //通过主对象获取CRoot对象
//try
//{
// short sResult =RTXCRoot..Login(txtSvrIP.Text,Convert.ToInt16(txtSvrPort.Text),txtUserNa.Text, txtPwd.Text); //用户登录验证
// if (0 == sResult)
// Response.Write("验证成功");
// else
// Response.Write("验证失败,用户名或密码不正确");
//}
//catch (Exception xe)
//{
// Response.Write(xe.Message.ToString());
//}
}
protected void Button4_Click(object sender, EventArgs e)
{
try
{
txtResult.Text = RootObj.GetVersion(); //获取版本信息
// Response.Write(Text);
}
catch (Exception xe)
{
Response.Write(xe.Message.ToString());
}
}
protected void Button5_Click(object sender, EventArgs e)
{
try
{
txtResult.Text = RootObj.GetUserRightList(txtUserName.Text); //获取用户权限列表
}
catch (Exception xe)
{
Response.Write(xe.Message.ToString());
}
}
}
功能四:状态感知
<script language="JScript.Encode" src="js/browinfo.js"></script>
<script language="JScript.Encode" src="js/rtxint.js"></script>
实现该功能的步骤:
1. 把服务器端安装目录下Webroot目录下的image和js两个文件夹拷进拷贝到您的Web应用工作目录下。
2. 在Web应用中引用这两个Js文件。
language="JScript.Encode" src="js/browinfo.js"></script>
language="JScript.Encode" src="js/rtxint.js"></script>
3. 嵌入代码,如:
<img align="absbottom" width=16 height=16 src="/images/blank.gif" onload="RAP('share');">
4. 下载示例页面,把该网页拷贝在服务器端Webroot目录下,把里面的用户名改为您自己的用户名即可演示。
本文来自CSDN博客,转载请标明出处:
http://blog.csdn.net/yunfan555/archive/2008/09/25/2978284.aspx
谁能给个最简单的例子呀,就是用asp.net(c#)调用rtxsdk发送信息就行。
...
usingRTXSAPILib;
..
RTXSAPIRootObjClassRTXRootObj=newRTXSAPIRootObjClass();
RTXSAPIObjRTXObj=RTXRootObj.CreateAPIObj();
RTXObj.AppGUID="{79210E58-99EB-45D0-8890-763EFEAA143F}";
RTXObj.ServerIP="127.0.0.1";
RTXObj.ServerPort=8012;
RTXObj.RegisterApp();
RTXObj.StartApp("",4);
RTXRootObj.SendNotify("1081","hello",100,"你好呀");
RTXObj.StopApp();
RTXObj.UnRegisterApp();
...
执行的时候总是提示
带有CLSID{79210E58-99EB-45D0-8890-763EFEAA143F}的COM对象无效或未注册。
请问是怎么解决?
答:<OBJECTclassid=clsid:5EEEA87D-160E-4A2D-8427-B6C333FEDA4Did=RTXAXRunat=Server></OBJECT>
答:web中com组件用一楼方式调用,可以参见trx的sdk中的sample
答:<scripttype="text/vbscript"language="vbscript">
SubSendByRTX(receivers,content)
setRTXObj=createobject("rtxserver.rtxobj")
setRTXParams=createobject("rtxserver.collection")
RTXObj.Name="SYSTOOLS"
RTXParams.Add"USERNAME",receivers
RTXParams.Add"MSGINFO",content
Onerrorresumenext
RTXResult=RTXobj.Call2(&H2100,RTXParams)
if(err.number<0)then
document.getElementByIdx_xx("hidResult").value=err.Description&";"
else
document.getElementByIdx_xx("hidResult").value="发送RTX消息成功;"
endif
EndSub
</script>
本文作者:yunfan555 来源:网络
CIO之家 www.ciozj.com 微信公众号:imciow