OC2007与Web 应用系统的集成,会让你的系统大放异彩,获得意想不到的收获。
通过前面几课的学习,大家可能对OC的强大功能有所了解了吧,她的即时通信、她的语音聊天、她的视频会议、她的分组、她的联系人查找等等等,都是其它IM工具所无法比拟的,再加之她的二次开发接口,更是锦上添花。
前面几课,无论是web 标签页的扩展、OC状态的自定义,还是菜单功能的扩展,都是针对于OC进行扩充与完善。试想,如果一个论坛与OC进行集成,在线人员一栏,就不是一些干涩文字,直接用OC的在线状态显示出来,如果想与之交流,就直接可以用OC进行交流了,如下图所示:
与电话联系表的集成,此时可以直接与对方通过OC 交流,即方便又适用。
与文章管理系统的集成,如果读者看了这篇文章后,有什么感想、有什么心得、或者有什么不同的见解,都可以立即与作者、与审核人员进行OC沟通,再不用另外查找他的通信方式。而且,也不必把对方加入联系人中,就可以直接通信。
怎么实现呢,其实很简单,请参照下面的代码就,依样画葫芦就可以了。
OC与Web 网页的集成源码
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebTest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language='javascript' src='owsbrows.js'></SCRIPT>
<SCRIPT language='javascript' src='ows.js'></SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 88px; WIDTH: 424px; POSITION: absolute; TOP: 136px; HEIGHT: 24px"
cellSpacing="1" cellPadding="1" width="424" border="1">
<TR>
<TD>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="PADDING-RIGHT: 3px"><img border="0" valign="middle" height="12" width="12" src="../Resource/../Resource/image/blank.gif"
onload="IMNRC('goumh@domain.com.cn');" id="{95100999-a43f-4db3-bc74-a74fad6473a7}" Sortable="1">
<td style="PADDING-TOP: 1px" class="ms-vb">苟茂华(Goumh)
</td>
</tr>
</table>
</TD>
</TR>
</TABLE>
</FONT>
</form>
</body>
</HTML>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebTest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language='javascript' src='owsbrows.js'></SCRIPT>
<SCRIPT language='javascript' src='ows.js'></SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 88px; WIDTH: 424px; POSITION: absolute; TOP: 136px; HEIGHT: 24px"
cellSpacing="1" cellPadding="1" width="424" border="1">
<TR>
<TD>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="PADDING-RIGHT: 3px"><img border="0" valign="middle" height="12" width="12" src="../Resource/../Resource/image/blank.gif"
onload="IMNRC('goumh@domain.com.cn');" id="{95100999-a43f-4db3-bc74-a74fad6473a7}" Sortable="1">
<td style="PADDING-TOP: 1px" class="ms-vb">苟茂华(Goumh)
</td>
</tr>
</table>
</TD>
</TR>
</TABLE>
</FONT>
</form>
</body>
</HTML>
如果想与DataGrid 绑定,也非常简单
C#代码
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebTest
{
/**//// <summary>
/// msn1 的摘要说明。
/// </summary>
public class msn1 : BN.Web .UI .BNPage
{
protected BN.Web.UI.WebControls.BNDataGrid BNDataGrid1;
protected BN.Web.UI.WebControls.BNDropDownList BNDropDownList1;
protected System.Web.UI.WebControls.Label Label1;
protected BN.Web.UI.WebControls.BNDataGrid BNDataGrid2;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
BN.Data.DBTrans Sqlca = BN.Data.DBTrans.GetDBCInstance ("server=d1-hgh;database=HumanResource;uid=sa;pwd=29jDF?XvTt");
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (this.IsPostBack )
return ;
DataTable dt ;
string strSql = "select distinct lngShopID,strShopName from dbo.View_Employee_Right ";
dt = this.Sqlca .GetDataTable (strSql);
this.BNDropDownList1 .DataBind (dt,"strShopName","lngShopID");
this.DataGridBind();
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.BNDataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.BNDataGrid1_ItemDataBound);
this.BNDropDownList1.SelectedIndexChanged += new System.EventHandler(this.BNDropDownList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void BNDataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
System.Web .UI .WebControls .Image img ;
img = (System.Web .UI .WebControls .Image)e.Item .FindControl ("Image1");
string s = e.Item .Cells [1].Text + "@domain.com.cn";
if (img != null)
img.Attributes .Add ("onload","IMNRC('"+s+"');");
}
private void DataGridBind()
{
string strSql = "select lngShopID,strShopName,strEmployeeName,strOperatorName from dbo.View_Employee_Right where lngShopID = " + this.BNDropDownList1 .Value ;
DataTable dt = this.Sqlca .GetDataTable (strSql);
// this.BNDataGrid1 .DataBind (dt);
this.DataGrid1.DataSource = dt.DefaultView ;
this.DataGrid1 .DataBind ();
}
private void BNDropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DataGridBind ();
}
private void Handle()
{
}
}
}
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebTest
{
/**//// <summary>
/// msn1 的摘要说明。
/// </summary>
public class msn1 : BN.Web .UI .BNPage
{
protected BN.Web.UI.WebControls.BNDataGrid BNDataGrid1;
protected BN.Web.UI.WebControls.BNDropDownList BNDropDownList1;
protected System.Web.UI.WebControls.Label Label1;
protected BN.Web.UI.WebControls.BNDataGrid BNDataGrid2;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
BN.Data.DBTrans Sqlca = BN.Data.DBTrans.GetDBCInstance ("server=d1-hgh;database=HumanResource;uid=sa;pwd=29jDF?XvTt");
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (this.IsPostBack )
return ;
DataTable dt ;
string strSql = "select distinct lngShopID,strShopName from dbo.View_Employee_Right ";
dt = this.Sqlca .GetDataTable (strSql);
this.BNDropDownList1 .DataBind (dt,"strShopName","lngShopID");
this.DataGridBind();
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.BNDataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.BNDataGrid1_ItemDataBound);
this.BNDropDownList1.SelectedIndexChanged += new System.EventHandler(this.BNDropDownList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void BNDataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
System.Web .UI .WebControls .Image img ;
img = (System.Web .UI .WebControls .Image)e.Item .FindControl ("Image1");
string s = e.Item .Cells [1].Text + "@domain.com.cn";
if (img != null)
img.Attributes .Add ("onload","IMNRC('"+s+"');");
}
private void DataGridBind()
{
string strSql = "select lngShopID,strShopName,strEmployeeName,strOperatorName from dbo.View_Employee_Right where lngShopID = " + this.BNDropDownList1 .Value ;
DataTable dt = this.Sqlca .GetDataTable (strSql);
// this.BNDataGrid1 .DataBind (dt);
this.DataGrid1.DataSource = dt.DefaultView ;
this.DataGrid1 .DataBind ();
}
private void BNDropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DataGridBind ();
}
private void Handle()
{
}
}
}
Aspx 代码
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebTest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language='javascript' src='owsbrows.js'></SCRIPT>
<SCRIPT language='javascript' src='ows.js'></SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 160px; POSITION: absolute; TOP: 56px"
runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="strOperatorName" HeaderText="strOperatorName">
<HeaderStyle Wrap="False"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn>
<HeaderStyle Wrap="False"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<ItemTemplate>
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="300" border="0">
<TR>
<TD>
<asp:Label id=strName runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.strEmployeeName") %>'>
</asp:Label>
<asp:Image id="Image1" runat="server" ImageUrl="../Resource/image/blank.gif" Sortable="1"></asp:Image></TD>
<TD><FONT face="宋体"></FONT></TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</FONT>
</form>
</body>
</HTML>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebTest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<SCRIPT language='javascript' src='owsbrows.js'></SCRIPT>
<SCRIPT language='javascript' src='ows.js'></SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 160px; POSITION: absolute; TOP: 56px"
runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="strOperatorName" HeaderText="strOperatorName">
<HeaderStyle Wrap="False"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn>
<HeaderStyle Wrap="False"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<ItemTemplate>
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="300" border="0">
<TR>
<TD>
<asp:Label id=strName runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.strEmployeeName") %>'>
</asp:Label>
<asp:Image id="Image1" runat="server" ImageUrl="../Resource/image/blank.gif" Sortable="1"></asp:Image></TD>
<TD><FONT face="宋体"></FONT></TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</FONT>
</form>
</body>
</HTML>
就这样,短短的几行代码,就会让你的系统,大放异彩。试一试吧,你会有意想不到的收获。