我不清楚把我的毕业设计的东西放上来之后,毕业论文答辩的时候会不会说我是在网上抄袭的,不过我还是果断的发上来与大家分享了!!呵呵,请大家支持!高手就绕道吧!
现在已经放到公网上,并且开始使用,兼容IE6以上各IE浏览器,Chrome,Firefox等。欢迎大家注册账号测试,注意如有使用特殊字符进行测试的,请测试完以后即使删除相关内容,以免给网站带来不美观的影响。谢谢!
这是访问地址:http://www.yestz.com 由于iis连接数有限制,可能会出现问题,如遇到问题请关闭页面,稍后再试,谢谢。
其中涉及到的有:Server-Push(Comet),smtp,jQuery,jQueryUI,XHTML+CSS,Json,Jcrop,图形图像处理技术,Ajax,ADO.NET,kindeditor
开发工具包括:Visual Studio 2010、SqlServer 208、Notepad++、Editplus、SVN版本控制、Chrome、Firefox、IEtest、flashFXP、IIS6.0、IIS7.5
整个项目的流程图如下:
在这里与大家分享几个部分源代码:自己封装的类库与jQuery方法:
取出html标签的类:点击这里下载
/* * 陈盛泰 2011.10.18,写于韶关学院,图形图像处理的类 */ using System; using System.Collections.Generic; using System.Web; using System.Text.RegularExpressions; /// <summary> ///DeleteHtmlElement 的摘要说明 /// </summary> public class DeleteHtmlElement { public DeleteHtmlElement() { // //TODO: 在此处添加构造函数逻辑 // } public static string RemoveHtmlTags(string html) { html = Regex.Replace(html, "<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase); html = Regex.Replace(html, "<[^>]*>", "", RegexOptions.IgnoreCase); return html; } }
图像处理的类:点击这里下载
/* * 陈盛泰 2011.10.15,写于韶关学院,图形图像处理的类 */ using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Drawing.Drawing2D; /// <summary> ///ImageHelper 的摘要说明 /// </summary> public class ImageHelper { public ImageHelper() { // //TODO: 在此处添加构造函数逻辑 // } #region 生成略缩图 /// <summary> /// 生成略缩图 /// </summary> /// <param name="fullpath">图片保存的路径,如:Server.MapPath("~/uploadFile/pro_picture/")</param> /// <param name="filename">文件名</param> /// <param name="saveWidth">保存的宽度</param> /// <param name="saveHeight">保存的高度</param> public static void ThumbnailImageAndSave(string fullpath, string filename, int saveWidth, int saveHeight) { //开始处理图像,将图像缩小到saveWidth*saveHeight using (System.Drawing.Image originalImage = System.Drawing.Image.FromFile(fullpath + filename)) { int originalHeight = originalImage.Height; int originalWidth = originalImage.Width; using (System.Drawing.Image bitmap = new Bitmap(saveWidth, saveHeight)) { using (Graphics graphic = Graphics.FromImage(bitmap)) { graphic.Clear(Color.White); graphic.SmoothingMode = SmoothingMode.AntiAlias; graphic.InterpolationMode = InterpolationMode.HighQualityBicubic; graphic.PixelOffsetMode = PixelOffsetMode.HighQuality; graphic.DrawImage(originalImage, new Rectangle(0, 0, saveWidth, saveHeight), new Rectangle(0, 0, originalWidth, originalHeight), GraphicsUnit.Pixel); //保存略缩图 bitmap.Save(fullpath + "small_" + filename, originalImage.RawFormat); } } } } #endregion #region ThumbnailImageAndSave重载方法,将图片名加上"small_"保存 /// <summary> /// ThumbnailImageAndSave重载方法,将图片名加上"small_"保存 /// </summary> /// <param name="fullpath"></param> /// <param name="filename"></param> public static void ThumbnailImageAndSave(string fullpath, string filename) { //开始处理图像,将图像缩小到saveWidth*saveHeight using (System.Drawing.Image originalImage = System.Drawing.Image.FromFile(fullpath + filename)) { int originalHeight = originalImage.Height; int originalWidth = originalImage.Width; using (System.Drawing.Image bitmap = new Bitmap(originalWidth, originalHeight)) { using (Graphics graphic = Graphics.FromImage(bitmap)) { graphic.Clear(Color.White); graphic.SmoothingMode = SmoothingMode.AntiAlias; graphic.InterpolationMode = InterpolationMode.HighQualityBicubic; graphic.PixelOffsetMode = PixelOffsetMode.HighQuality; graphic.DrawImage(originalImage, new Rectangle(0, 0, originalWidth, originalHeight), new Rectangle(0, 0, originalWidth, originalHeight), GraphicsUnit.Pixel); //保存略缩图 bitmap.Save(fullpath + "small_" + filename, originalImage.RawFormat); } } } } #endregion #region 剪切图片file,保存好已删除的图片后,并将原图片删除 /// <summary> /// 剪切图片file,保存好已删除的图片后,并将原图片删除 /// </summary> /// <param name="file">文件路径</param> /// <param name="X">起点X坐标</param> /// <param name="Y">起点Y坐标</param> /// <param name="Width">原图片剪切的宽度Width</param> /// <param name="Height">原图片剪切的高度Height</param> /// <param name="SaveWidth">要保存的宽度</param> /// <param name="SaveHeight">要保存的高度</param> public static void CutImageAndSave(string file, int X, int Y, int Width, int Height, int SaveWidth, int SaveHeight) { using (Bitmap OriginalImage = new Bitmap(file)) { using (Bitmap bmp = new Bitmap(SaveWidth, SaveHeight, OriginalImage.PixelFormat)) { bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution); using (Graphics Graphic = Graphics.FromImage(bmp)) { Graphic.SmoothingMode = SmoothingMode.AntiAlias; Graphic.InterpolationMode = InterpolationMode.HighQualityBicubic; Graphic.PixelOffsetMode = PixelOffsetMode.HighQuality; Graphic.DrawImage(OriginalImage, new Rectangle(0, 0, SaveWidth, SaveHeight), X, Y, Width, Height, GraphicsUnit.Pixel); //保存已剪切的图片 string value = file.Substring(file.LastIndexOf('.')); bmp.Save(file.Replace(value, "_cut" + value)); } } } //删除用来剪切的图片 File.Delete(file); } #endregion }
生成随机数的类,用于验证码:点击这里下载
/* * 陈盛泰 2011.10.18,写于韶关学院,图形图像处理的类 */ 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; /// <summary> /// randomCode 的摘要说明 /// </summary> public class randomCode { public randomCode() { // // TODO: 在此处添加构造函数逻辑 // } /// <summary> /// 验证码 /// </summary> /// <param name="n">验证码的个数</param> /// <returns>返回生成的随机数</returns> public string RandomNum(int n) // { string strchar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; string[] VcArray = strchar.Split(','); string VNum = ""; // int temp = -1; //记录上次随机数值,尽量避免产生几个一样的随机数 //采用一个简单的算法以保证生成随机数的不同 Random rand = new Random(); for (int i = 1; i < n + 1; i++) { if (temp != -1) { rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks)); } int t = rand.Next(61); if (temp != -1 && temp == t) { return RandomNum(n); } temp = t; VNum += VcArray[t]; } return VNum;//返回生成的随机数 } }
使用smtp发送邮件的类(推荐使用Jmail比较稳定):点击这里下载
/*创建人:阿泰 *创建时间:2011-10-15 *说明:通过smtp协议发送邮件 */ using System; using System.Collections.Generic; using System.Web; using System.Net.Mail; using System.Net; /// <summary> ///EmailHelper 的摘要说明 /// </summary> public class EmailHelper { public EmailHelper() { // //TODO: 在此处添加构造函数逻辑 // } /// <summary> /// 发送邮件 /// </summary> /// <param name="toAddress">要发送到的邮箱地址</param> /// <param name="strSubject">邮件主题</param> /// <param name="strBody">邮件内容</param> /// <param name="isBodyHtml">是否显示html格式的文本,true为html格式,false则为text格式</param> /// <returns>发送成功返回Success,失败返回错误信息</returns> public static string SendMail(string toAddress, string strSubject, string strBody, bool isBodyHtml) { try { MailAddress fromAddress = new MailAddress("tiaozaobuluo@126.com", "跳蚤部落"); MailAddress to = new MailAddress(toAddress); MailMessage msg = new MailMessage(); msg.From = fromAddress; msg.To.Add(toAddress); //邮件主题 msg.Subject = strSubject; msg.IsBodyHtml = isBodyHtml; msg.Body = strBody; SmtpClient smtpClient = new SmtpClient(); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.Credentials = new NetworkCredential("tiaozaobuluo@126.com", "邮箱密码"); smtpClient.Port = 25; smtpClient.Host = "smtp.126.com"; smtpClient.Send(msg); return "Success"; } catch (Exception ex) { return ("error:" + ex.Message); } } }
别人的Json序列化类:点击这里下载
//----------------------------------------------------------------------- // Coding by: AC Created date: 2010-8-5 13:10:09 // Description: // Others desc: // Alter History: // [By] [Date] [Version] [Purpose] // AC 2010-8-5 13:10:09 1.0 Create //---------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Text; using System.Data; /// <summary> /// JSON序列器 /// </summary> public class JSONSerializer { private readonly StringBuilder _output = new StringBuilder(); public static string ToJSON(object obj) { return new JSONSerializer().ConvertToJSON(obj); } private string ConvertToJSON(object obj) { WriteValue(obj); return _output.ToString(); } private void WriteValue(object obj) { if (obj == null) _output.Append("null"); else if (obj is sbyte || obj is byte || obj is short || obj is ushort || obj is int || obj is uint || obj is long || obj is ulong || obj is decimal || obj is double || obj is float) _output.Append(Convert.ToString(obj, NumberFormatInfo.InvariantInfo)); else if (obj is bool) _output.Append(obj.ToString().ToLower()); else if (obj is char || obj is Enum || obj is Guid) WriteString("" + obj); else if (obj is DateTime) WriteString(((DateTime)obj).ToString("yyyy-MM-dd")); else if (obj is string) WriteString((string)obj); else if (obj is IDictionary) WriteDictionary((IDictionary)obj); else if (obj is Array || obj is IList || obj is ICollection) WriteArray((IEnumerable)obj); else if (obj is DataTable) WriteDataTable((DataTable)obj); else WriteObject(obj); } private void WriteObject(object obj) { _output.Append("{ "); bool pendingSeparator = false; foreach (FieldInfo field in obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)) { if (pendingSeparator) _output.Append(" , "); WritePair(field.Name, field.GetValue(obj)); pendingSeparator = true; } foreach (PropertyInfo property in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { if (!property.CanRead) continue; if (pendingSeparator) _output.Append(" , "); WritePair(property.Name, property.GetValue(obj, null)); pendingSeparator = true; } _output.Append(" }"); } private void WritePair(string name, object value) { WriteString(name); _output.Append(" : "); WriteValue(value); } private void WriteArray(IEnumerable array) { _output.Append("[ "); bool pendingSeperator = false; foreach (object obj in array) { if (pendingSeperator) _output.Append(','); WriteValue(obj); pendingSeperator = true; } _output.Append(" ]"); } private void WriteDictionary(IDictionary dic) { _output.Append("{ "); bool pendingSeparator = false; foreach (DictionaryEntry entry in dic) { if (pendingSeparator) _output.Append(" , "); WritePair(entry.Key.ToString(), entry.Value); pendingSeparator = true; } _output.Append(" }"); } private void WriteString(string s) { _output.Append('\"'); foreach (char c in s) { switch (c) { case '\t': _output.Append("\\t"); break; case '\r': _output.Append("\\r"); break; case '\n': _output.Append("\\n"); break; case '"': case '\\': _output.Append("\\" + c); break; default: { if (c >= ' ' && c < 128) _output.Append(c); else _output.Append("\\u" + ((int)c).ToString("X4")); } break; } } _output.Append('\"'); } private void WriteDataTable(DataTable table) { List<Hashtable> data = new List<Hashtable>(); foreach (DataRow row in table.Rows) { Hashtable dic = new Hashtable(); foreach (DataColumn c in table.Columns) { dic.Add(c.ColumnName, row[c]); } data.Add(dic); } WriteValue(data); } }
javascript脚本注册类:点击这里下载
/*创建人:陈盛泰,阿泰 *创建时间:2011-7-15 *说明:弹出对话框的类 */ using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; /// <summary> ///弹出对话框的类 /// </summary> public class Jscript { public Jscript() { // //TODO: 在此处添加构造函数逻辑 // } //弹出对话框 /// <summary> /// 弹出对话框 /// </summary> /// <param name="msg">输入弹出内容</param> /// <param name="page">指在那个页面,一般用this,表示当前页</param> public static void AlertMsg(string msg, Page page) { string js = @"<script>alert('" + msg + "')</script>"; page.ClientScript.RegisterStartupScript(page.GetType(), "提示 ", js); } //弹出对话框并转向其他页面 /// <summary> /// 弹出对话框并转向其他页面 /// </summary> /// <param name="msg">输入弹出内容</param> /// <param name="url">转向网页路径</param> /// <param name="page">指在那个页面,一般用this,表示当前页</param> public static void AlertMsg(string msg, string url, Page page) { string js = @"<script>alert('" + msg + "');location.href='" + url + "'</script>"; page.ClientScript.RegisterStartupScript(page.GetType(), "提示 ", js); } //跳转页面 /// <summary> /// 跳转页面 /// </summary> /// <param name="url">转向网页路径</param> /// <param name="page">指在那个页面,一般用this,表示当前页</param> public static void windowOpen(string url, Page page) { string js = @"<script>window.open('" + url + "','_blank');</script>"; page.ClientScript.RegisterStartupScript(page.GetType(), "", js); } //弹出提示对话框后关闭窗口 /// <summary> /// 弹出提示对话框后关闭窗口 /// </summary> /// <param name="msg">提示文字</param> /// <param name="page">指在那个页面,一般用this,表示当前页</param> public static void windowClose(string msg, Page page) { string js = @"<script>alert('" + msg + "');window.close();</script>"; page.ClientScript.RegisterStartupScript(page.GetType(), "", js); } /// <summary> /// 调用js客户端函数 /// </summary> /// <param name="functionName">函数名</param> /// <param name="page">指在那个页面,一般用this,表示当前页</param> public static void ClientFunction(string functionName, Page page) { //阿泰 2011.10.11 加入 拦截片段, //防止 页面因 UI 库的重复渲染 引起脚本重复执行。 string interruptedScript = @"if(window.__yltlClientScriptRegistKey == null || window.__yltlClientScriptRegistKey == undefined || window.__yltlClientScriptRegistKey !='js') { " + "window.__yltlClientScriptRegistKey = 'js' ;\r\n" + functionName + "();\r\n}"; string js = @"<script>" + interruptedScript + "</script>"; page.ClientScript.RegisterStartupScript(page.GetType(), "js ", js); } }
Forms身份验证数据读写类:点击这里下载
/*创建人:阿泰 *创建时间:2011-9-15 *说明:获取、写入forms身份验证所存储的票据,为Forms身份验证登录所用(VS2010版本) */ using System; using System.Collections.Generic; using System.Web; using System.Web.Security; /// <summary> ///FormsData 的摘要说明 /// </summary> public class FormsData { public FormsData() { // //TODO: 在此处添加构造函数逻辑 // } /// <summary> /// 获取登录用户的权限 /// </summary> /// <param name="UserName">用户名</param> /// <param name="IsAdmin">否0,是1</param> /// <param name="IsSuperAdmin">否0,是1</param> /// <returns>返回含有权限的用户登录的票据</returns> public static string GetUserData(string UserName,string IsAdmin,string IsSuperAdmin) { string userData = UserName + "," + IsAdmin+","+IsSuperAdmin; return userData; } /// <summary> /// 获取forms身份验证所存储的票据,未登录则放回空 /// </summary> /// <param name="i">一般情况下,0为用户名,1为是否普通管理员,2为是否超级管理员</param> /// <returns>返回forms身份验证票据</returns> public static string GetFormsTicket(int i) { if (HttpContext.Current.Request.IsAuthenticated) { FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity; string[] userData = identity.Ticket.UserData.Split(','); return userData[i].ToString(); } else { return ""; } } /// <summary> /// 写入forms身份验证所存储的票据,一般为登录所用 /// </summary> /// <param name="username">用户名</param> /// <param name="IsAdmin">是否管理员,是则为1,否则为0</param> /// <param name="IsSuperAdmin">是否超级管理员,是则为1,否则为0</param> /// <param name="expirationDay">票据的期限,以“天”为单位</param> public static void SetFormsTicket(string username, string IsAdmin, string IsSuperAdmin, int expirationDay) { //获取票据 string userData = GetUserData(username,IsAdmin,IsSuperAdmin); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddDays(expirationDay), true, userData); string authTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, authTicket); cookie.Expires = ticket.Expiration; HttpContext.Current.Response.SetCookie(cookie); } /// <summary> /// 写入forms身份验证所存储的票据,一般为登录所用(重载版本,无权限控制的登录) /// </summary> /// <param name="username">用户名</param> /// <param name="expirationDay">票据的期限,以“天”为单位</param> public static void SetFormsTicket(string username, int expirationDay) { SetFormsTicket(username, "0", "0", expirationDay); } }
自定义jQuery方法:widgetUI 1.0 点击这里下载
/* * widgetUI 1.0 * Copyright (c) 2011 陈盛泰,阿泰 http://www.cnblogs.com/chenshengtai * Date: 2011-11-1 * 在FireFox、Chrome、IE8、IE7、IE6中通过测试 *《 使用说明》 * 1、基于jQuery的函数封装,需要在页面中引入jQuery以及jQueryUI样式。 * 2、使用widgetUI可以方便地将表格提示使用体验,给body加上蒙层,弹出当前对话框,若不定义width、height,默认值为300px; * 3、若再iframe中使用,需要设置iframe值为其id的值,不是很灵活,需要将内部的触发函数写在该页面的父页面上。 * 4、该div中事件应该这样处理, 如: $(".testbtn").click(function () { alert("成功!"); }); 修改成: $(".testbtn").live("click",function () { alert("成功!"); }); */ (function ($) { $.fn.widgetUI = function (data) { this.each(function () { var tags = $(this); //若不定义width或者height,默认值为300px; var data_width, data_height, _body = "body", _top = "150px", iframe_top = 0; if (data) { if (data.width) { data_width = data.width; } else { data_width = "300px"; } if (data.height) { data_height = data.height; } else { data_height = "300px"; } if (data.top) { _top = data.top; } if (data.iframe) { _body = window.parent.document.body; iframe_top = $(_body).find("iframe:[id='" + data.iframe + "']").offset().top; _top = _top.substring(0, _top.indexOf("px")); _top = (parseInt(_top) + parseInt(iframe_top)) + "px"; } } else { data_width = "300px"; data_height = "300px"; } //加入蒙层 var body_width = $(_body).css("width"); var body_height = $(_body).css("height"); $(_body).append("<div id='cst_ui_overlay' style='" + body_width + ";height:" + body_height + ";z-index:994;opacity:0.8;' class='ui-widget-overlay' ></div>"); $(_body).append("<div id='cst_ui_overlay_all' style='position:absolute;top:0px;left:0px;" + body_width + ";height:" + body_height + ";z-index:995;' ></div>"); //加入阴影 _top = _top.substring(0, _top.indexOf("px")); var shadow_init_top = ($(window).scrollTop() + _top).toString() + "px"; $(_body).find("div:[id='cst_ui_overlay']").append("<div id='cst_ui_shadow' style=' " + data_width + ";height:" + data_height + "; margin:0px auto;padding: 0px;z-index:996;position:relative;top:" + shadow_init_top + ";' class='ui-widget-shadow' ></div>"); //加入展示层 var shadow_left = ($(_body).find("div:[id='cst_ui_shadow']").offset().left - 10).toString() + "px"; var shadow_top = ($(_body).find("div:[id='cst_ui_shadow']").offset().top - 10).toString() + "px"; $(_body).find("div:[id='cst_ui_overlay_all']").append("<div style='background:White; " + data_width + ";height:" + data_height + ";position:absolute; left:" + shadow_left + ";top:" + shadow_top + ";z-index:997;overflow:hidden;' class='ui-widget-content'>" + "<div style='height:20px;position:relative;padding:5px;background-color:#EEE;'>" + "<div style='float:left;color:Black;font:bold 15px 微软雅黑;'>" + $(tags).attr("title") + "</div>" + "<div style='17px;float:right;' >" + "<span class='ui-icon ui-icon-closethick' id='cst_close' ></span>" + "</div>" + "</div>" + "<div style='margin:10px;'id='cst_inner_html'>" + $(tags).html() + "</div>" + "</div>"); $(tags).html(""); //加载一次,关闭后再打开则不加载 if (window.__yltlClientScriptRegistKey == null || window.__yltlClientScriptRegistKey == undefined || window.__yltlClientScriptRegistKey != 'widgetUI') { window.__yltlClientScriptRegistKey = 'widgetUI'; $(_body).find("span:[id='cst_close']").live("click", function () { $(tags).html($(_body).find("div:[id='cst_inner_html']").html()); $(_body).find("div:[id='cst_ui_overlay']").html("").attr("style", "display:none;").attr("class", "").attr("id", ""); $(_body).find("div:[id='cst_ui_overlay_all']").html("").attr("style", "display:none;").attr("id", ""); }); } }); }; })(jQuery);
效果图如下:
顺便把WebIM即时通信部分的截图发一下,呵呵
就先写这么多吧,等毕业论文答辩结束以后再与大家分享源代码,多谢支持啊!呵呵~~~
技术交流请直接加我QQ:1039189349