专题图编号:ylbtechOpenSource
1,功能描述 |
仿QQ短信(QQ邮箱里面的功能),登录,短息主界面,发信息,单个话题对话。
2,技术与环境 |
操作系统: |
windows |
开发语言: |
C# |
开发框架: |
数据库: |
SQLServer |
|
开发软件: |
Microsoft Visual Studio 2010 |
||
开发技术: |
ASP.net |
||
项目组长: |
yuanbo |
成员: |
null |
个人主页: |
http://www.cnblogs.com/ylbtech/ |
||
科研团队: |
ylbtech |
教研团队: |
ylbtech |
3,数据库设计 |
-- ============================================= -- ylb;仿QQ短信 -- development time:11:35 2012-04-18 -- ============================================= use master go IF EXISTS (SELECT * FROM master..sysdatabases WHERE name = N'QQMessage') DROP DATABASE QQMessage GO CREATE DATABASE QQMessage GO use QQMessage go -- ============================================= -- ylb;1,Users -- remark:用户表 -- ============================================= create table Users ( userId int primary key identity(100,1), --编号[PK] nickname varchar(200) not null, --昵称 userpass varchar(200) not null, --密码 headImage varchar(200), --头像地址 username varchar(200), --备注姓名 flag int default(0) check(flag in(0,1)) --标识,flag=1,说明此用户已注销,0:正常 ) go -- ============================================= -- ylb;2,Note -- remark:短信表 -- ============================================= create table Message ( msgId int primary key identity(200,1), --编号[PK] toUserId varchar(200) not null, --收信人编号[FK] content varchar(500) not null, --发新内容 pubdate datetime default(getdate()), --发送时间 sendUserId int --发送用户编号[FK] ) -- ============================================= -- ylb;3,Friend -- remark:好友表 -- ============================================= create table Friend ( userId int not null, --用户编号 friendId int not null --用户好友编号 ) print '数据创建成功!' -- ============================================= -- ylb;仿QQ短信 -- development time:11:35 2012-04-18 -- ============================================= use QQMessage go --InsertData insert into Users(nickname,userpass,headImage) values('sunshine','m123','default.jpg') insert into Users(nickname,userpass,headImage) values('rain','m123','default.jpg') insert into Users(nickname,userpass,headImage) values('lanchong','m123','default.jpg') insert into Users(nickname,userpass,headImage) values('sun','m123','default.jpg') select * from Users go --修改备注 update Users set username='袁博' where userId=102 go --登录 select count(*) from Users where userId=100 and userpass='m123' go --删除一组会话 delete Message where toUserId=100 and sendUserId=101 or toUserId=101 and sendUserId=100 go --1,发送信息 --1,outBox insert into Message(toUserId,content,sendUserId) values(100,'I is sunshie',101) --2,inBox insert into Message(toUserId,content,sendUserId) values(101,'Who are you?',100) insert into Message(toUserId,content,sendUserId) values(100,'sunshie',101) go --2,我的收信列表 --2_1,List select userId,nickname,headImage,username from Users where userId in(select sendUserId from Message where toUserId=100) or userId in(select toUserId from Message where sendUserId=100) go --2_2,附属最近的一条短信 select top 1 msgId,toUserId,content,pubdate,sendUserId from Message where toUserId=100 and sendUserId=101 or toUserId=101 and sendUserId=100 order by msgId desc --最新的回复 select top 1 content from Message where toUserId=101 and sendUserId=100 order by msgId desc go select userId,nickname,headImage,username from Users where userId in(select sendUserId from Message where toUserId=100) select userId,nickname,headImage,username,content from Users u left join Message m on u.userId=m.toUserId go --3,单机看详细 select * from Users select * from Message go --3_1,获取备注 select nickname from Users where userId=1 go --3_2,获取列表 select * from Users u left join Message m on u.userId=m.toUserId go --结论 select userId,nickname,headImage,username,msgId,content,pubdate,sendUserId from Users u left join Message m on u.userId=m.toUserId where toUserId=100 and sendUserId=101 or toUserId=101 and sendUserId=100
4,功能截图 |
4.1,前台
4.1.1 /SignIn.aspx
4.1.2 /Menu.aspx 短息主界面
4.1.3 /Write.aspx 写短消息
4.1.4 /Detail.aspx 单个对话组
5,代码分析 |
解决方案属性图
5.1,前台
5.1.1 /Handler/SendMsg.ashx
<%@ WebHandler Language="C#" Class="SendMsg" %> using System; using System.Web; public class SendMsg : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; //发送短信 int toUserId = Convert.ToInt32(context.Request["toUserId"]); int sendUserId = Convert.ToInt32(context.Request["sendUserId"]); MessageInfo dal = new MessageInfo() { ToUserId = toUserId, SendUserId = sendUserId, Content = context.Server.UrlDecode(context.Request["content"]) }; //Call Fun int id= MessageOper.Add(dal); context.Response.Write(id+""); } public bool IsReusable { get { return false; } } }
5.2,后台
无
6,示例|讲解案例下载 |
博客园讲解: http://ylbtech.cnblogs.com/
百度文库开发文档: http://passport.baidu.com/?business&aid=6&un=ylbtech#7
谷歌开源代码下载: http://code.google.com/p/ylbtechopensource/downloads/list
请单击“ver1.1 QQMessage”
本文转自ylbtech博客园博客,原文链接:http://www.cnblogs.com/ylbtech/archive/2012/09/04/2670359.html,如需转载请自行联系原作者