Sunday, January 31, 2010

Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
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;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("PowerChatRoom/Chat.aspx");
}
}

Wednesday, January 27, 2010

IPFindAddr.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
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 System.Data.OleDb;
///
/// IPFindAddr 的摘要说明
///

public class IPFindAddr
{
///
/// 数据库联接
///

public static OleDbConnection OleConn
{
get {
return new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Jet OLEDB:Database Password=;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\IP.mdb"); //Access数据库连接字符串
}
}
///
/// 获取真实地址
///

public static string GetAddr
{
get {
string DiZhi = "未知网络";
OleDbConnection Conn = OleConn;
try
{
string IP = IPToInt(HttpContext.Current.Request.UserHostAddress).ToString();

Conn.Open();
object Obj = new OleDbCommand("select top 1 region from ip where IPN1<=" + IP + " and IPN2>=" + IP, Conn).ExecuteScalar();
if (Obj != null)
{
DiZhi = Obj.ToString();
}
}
catch { }
finally { Conn.Close(); }
return DiZhi;
}
}
public IPFindAddr()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
///
/// IP地址和数字之间转化的算法

///

/// 传入IP地址
///

public static uint IPToInt(string ipAddress)
{
string disjunctiveStr = ".,: ";
char[] delimiter = disjunctiveStr.ToCharArray();
string[] startIP = null;
for (int i = 1; i <= 5; i++)
{
startIP = ipAddress.Split(delimiter, i);
}
string a1 = startIP[0].ToString();
string a2 = startIP[1].ToString();
string a3 = startIP[2].ToString();
string a4 = startIP[3].ToString();
uint U1 = uint.Parse(a1);
uint U2 = uint.Parse(a2);
uint U3 = uint.Parse(a3);
uint U4 = uint.Parse(a4);
uint U = U1 << 24;
U += U2 << 16;
U += U3 << 8;
U += U4;
return U;
}
///
/// 数字和IP地址之间转化的算法
///

/// 传入IP地址
///
public static string IntToIP(uint ipAddress)
{
long ui1 = ipAddress & 0xFF000000;
ui1 = ui1 >> 24;
long ui2 = ipAddress & 0x00FF0000;
ui2 = ui2 >> 16;
long ui3 = ipAddress & 0x0000FF00;
ui3 = ui3 >> 8;
long ui4 = ipAddress & 0x000000FF;
string IPstr = "";
IPstr = System.Convert.ToString(ui1) + "." + System.Convert.ToString(ui2) + "." + System.Convert.ToString(ui3) + "." + System.Convert.ToString(ui4);
return IPstr;
}
}

FetionInterFace.cs

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using PowerTalkBoxContrls.Design;
using PowerTalkBoxEnum.Enum;
using PowerTalkBox;
using System.Collections.Generic;

///
/// FetionInterFace 的摘要说明
///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class FetionInterFace : System.Web.Services.WebService
{

public FetionInterFace()
{

//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
///
/// 添加信息
///

/// 我的ID,一般为手机号
/// 对方ID,游客12345
/// 发送的信息
///
[WebMethod]
public void ChatAdd(string MyUserId, string ToUserID, string SendMsg)
{
PowerTalk.AddChatInfo(MyUserId, ToUserID, SendMsg);
}
///
/// 删除
///

/// 我的ID,一般为手机号
[WebMethod]
public void DeleteUserInfo(string DelUserId)
{
PowerTalkBox.PowerTalk.DeleteUserInfo(DelUserId);
}
///
/// 获取聊天内容
///

/// 我的ID,手机号码
///
[WebMethod]
public List GetChatInfos(string MyUserName)
{
List < ChatInfo > LCI = PowerTalk.ReadChatInfo(MyUserName, PowerTalkBoxEnum.Enum.SystemMode.WebToIm);
foreach (ChatInfo In in LCI)
{
In.SendContent = In.SendContent.Replace("

", "").Replace("

","").Replace(" "," ");
}
return LCI;
}

}

Data binding the data items

System.Data.DataView System.Data.DataRowView
System.Data.Common.DbDataReader System.Data.Common.DbDataRecord
System.Collections.ArrayList String
System.Collections.Hashtable System.Collections.DictionaryEntry
XmlDataSource System.Xml. XPathNavigator
ObjectDataSource 业务对象

AJAXEnabledWebSite2.sln

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "E:\...\AJAXEnabledWebSite2\", ".", "{5A29974E-5E8F-427D-852B-21F4E65F2F86}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.VirtualPath = "/AJAXEnabledWebSite2"
Debug.AspNetCompiler.PhysicalPath = "E:\项目\未分类\聊天室\AJAXEnabledWebSite2\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\AJAXEnabledWebSite2\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/AJAXEnabledWebSite2"
Release.AspNetCompiler.PhysicalPath = "E:\项目\未分类\聊天室\AJAXEnabledWebSite2\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\AJAXEnabledWebSite2\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "13495"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A29974E-5E8F-427D-852B-21F4E65F2F86}.Debug|.NET.ActiveCfg = Debug|.NET
{5A29974E-5E8F-427D-852B-21F4E65F2F86}.Debug|.NET.Build.0 = Debug|.NET
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal