2006年6月22日
加龙周六要去参加网友聚会,所以拒绝了某个MM的邀请,我就建议他把某MM带上一起参加聚会,加龙说:“去森林里转,还需要抱着颗树去吗”
我曾给加龙宣扬过李敖著名的三不原则:“不主动不拒绝不负责”,加龙的看法总是和别人不一样:“不主动,就爬不到美女身上;不拒绝,丑女就会爬到你身上;不负责 早晚有人找你算账”
2006年4月13日
58.215.65.166 - 江苏省 无锡市
偶忘记禁用Register.aspx了,这位小朋友利用这个注册了若干blog帐号,辛辛苦苦发了若干Blog,呵呵,辛苦了!
2006年2月17日
推荐Blog客户端工具:Zoundry Blog Writer
Zoundry Blog Writer配置方法:
在Tools>Blog Account Setting中新建一个帐户,在第一栏中输入帐户的显示名称(任意),第二栏中选择"MetaWeblog",第三栏中输入你的Blog用户名,第四、五栏输入Blog帐户密码,最后一栏输入MetaWeblog访问地址(我的地址为http://www.webuc.net/dotey/services/metablogapi.aspx,您只要把其中的dotey换成您自己的帐号就好了)。
我已经在Zoundry Blog Writer进行了测试,能够正常使用,该文就是从Zoundry Blog Writer发布。
通过Zoundry Blog Writer你可以从自己的Blog获取随笔、发布随笔、将随笔发布到相应的个人分类,修改随笔。

2005年6月9日
<如是用 MS Virtual Server 2005>
*为了获得最佳性能,请添加独立的高速驱动器以承载虚拟硬盘。不要在操作系统所在的分区或其他任何使用量很大的分区上存储虚拟硬盘。
*配置防病毒软件,将 .iso、.vfd、.vhd、.vud 和 .vsv 文件类型排除在外。从实时病毒扫描中排除这些文件可以提高性能。
*限制在后台运行的服务和应用程序的数量。其目的是为虚拟机提供尽可能多的内存和处理器循环。
*确保 Virtual Server 2005、管理网站和虚拟机的安全。
*使用本地系统帐户安装 Virtual Server 2005 以运行管理网站。这样,您就可以使用受约束的委派;访问其他计算机上的资源文件(ISO、VFD 等)必须使用受约束的委派。
*经常对虚拟硬盘所在的磁盘和虚拟机中的虚拟硬盘进行磁盘碎片整理。这样做可以提高性能;如果您使用动态扩展虚拟硬盘,这一点尤为明显。
*创建一个由包含生产环境中常用的桌面配置的虚拟机和虚拟硬盘构成的库。可以快速加载并启动这些虚拟机以测试项目。让此库中包括虚拟机和未格式化的虚拟硬盘,您可以快速复制它们来测试裸机部署。另外,库中还要包括经常使用的虚拟软盘和硬盘,比如远程安装服务 (RIS) 启动盘和 Microsoft Windows 预安装环境 (Windows PE) 启动 CD。
*无限制地使用撤消磁盘,使重新设置配置或启动测试非常快捷。例如,您可以测试在运行 Microsoft Windows 98 的虚拟机上的部署。接着,要删除更改并将 Windows 98 还原到计算机上,请丢弃撤消磁盘(整个过程只需要几秒钟)。
*通过创建内部虚拟网络隔离虚拟实验室。在虚拟网络中模拟生产服务器(包括域控制器、服务器和桌面计算机)。尽可能模拟每一个细节 — 甚至服务器名称也要模拟,这样您的测试就更具代表性,跟踪结果也更方便。
*在主机服务器上安装环回适配器,然后将一个虚拟网络连接到该适配器,从而为该虚拟网络提供 Internet 访问。在主机上,可以使用 Internet 连接共享或路由和远程访问服务来为环回适配器提供 Internet 访问。
*使用虚拟专用网络 (VPN) 连接共享生产网络上的文件。Virtual Server 2005 不允许主机和虚拟机共享文件夹。如果安装了环回适配器并将其连接到了虚拟网络(参见上一项),则可以创建到生产网络的 VPN 连接,然后使用该连接来交换文件。这是将测试文件移入移出隔离的虚拟网络的一种简便方法。
*安装虚拟机附件。与其说这是一个窍门,不如说这是一则提示。安装这些附件可以大大增强体验,因而这一步操作是必不可少的。为此,应向硬盘映像中添加附件,从而自动安装这些附件。在准备好将项目部署到生产环境中后,您可以移除这些附件。
2005年3月4日
2005年1月20日
维护多个blog太麻烦了,此后停止更新此blog,最新blog只发布在 博客堂 的 我的Blog 中,谢谢关注!
2005年1月9日
CnForums1.2针对Beta1版中用户反馈的一些问题,基本修正了大家反馈Beta1中存在的所有BUG,新增了一些功能,如:
支持框架式皮肤界面
支持动网等论坛的导入(动网论坛导入程序及源码随后发布)
版务管理
私人留言可以显示留言条数
桌面提醒功能(Popup提示)
……
现在有某个别团队直接在CnForum Beta1的源码基础上作简单修改即声称是自己的作品,保留对其进一步追究的权利。(如果在同类产品中直接使用CnForums源码,请征得作者同意并在作出相关申明)
谢谢大家对CnForums的支持
如果有任何问题请到论坛提问:http://www.cnforums.net
下载:
http://bbs.openlab.net.cn/ShowThread.aspx?PostID=376725
CnForums 开发团队
2005-01-10
2005年1月7日
很多软件,如msn、outlook2003等都有popup提示,可以方便的知道有无新邮件。
IE6有一个非常酷的功能就是Popup,博客园中有几位兄台已经研究过了。
CnForums1.2加入了一个比较好的功能就是Popup提示,让你可以方便快捷的知道新帖子/留言
效果如图(和软件的popup一样,不管你再哪个窗口,都可以弹出):
如果您想体验一下,并且IE版本为6.0,那么可以登录
http://www.cnforums.net 看看效果:)
CnForums1.2正式版全部源码将于下星期一发布
2005年1月6日
I've been digging into ASP.NET 2.0 lately so thought I'd share some good webcasts and whitepapers I've found along the way...
Planning for Whidbey webcast
Here’s a fantastic webcast by Stefan Schackow discussing “planning for Whidbey”. It was great as he had a good presentation and demos, but also took time to answer a LOT of questions that popped up during the webcast:
http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032258691&CountryCode=US
Data Provider
Here’s a 400 level webcast on the Design patterns used in the Provider model. Also check out this blog by Andy on the basic design pattern of the provider model.
MSDN Webcast: Designing Flexible Applications Using the Provider Model in ASP.NET 2.0 (Level 400)
MSDN Webcast: Building A Google Data Source Control with ASP.NET 2.0 (Level 400)
ASP.NET 2.0 Webcasts
MSDN Webcast: Using the Time-Saving Membership Features in ASP.NET 2.0 (Level 200)
MSDN Webcast: Building Mobile Web Sites in ASP.NET 2.0 (Level 300)
MSDN Webcast: Fundamentals of ASP.NET Mobile Controls (Level 200)
MSDN Webcast: Working With The GridView and DetailsView Controls in ASP.NET 2.0 (Level 300)
MSDN Webcast: Data Access Using ASP.NET 2.0 (Level 200)
MSDN Webcast: Exploring the New Personalization Features in ASP.NET 2.0 (Level 200)
MSDN Webcast: A First Look at ASP.NET 2.0 (Level 200)
MSDN Webcast: Introduction to ASP.NET 2.0 Security (Level 200)
MSDN Webcast: Working with Data Using the Enhanced GridView and DetailsView Controls in ASP.NET 2.0 (Level 200)
ASP.NET 2.0 Beta 1 Articles on MSDN
Let's Get Personal: Personalizing Web Sites in ASP.NET 2.0
Learn how to personalize your data-driven Web applications by using profiles, Web parts, theming, and skins. Also see how to implement XML-driven forms using the new XMLDataSource object.
Introducing the ASP.NET 2.0 Web Parts Framework
Web Parts provide you with the infrastructure for creating customizable Web applications. When you build a Web site with Web Parts, the Web site can be easily customized by either the administrator of the Web site or the individual users of the Web site. Web Parts are all about flexibility.
ASP.NET 2.0 Localization Features - A Fresh Approach to Localizing Web Applications
Creating global Web applications with Microsoft ASP.NET is becoming more and more important. ASP.NET 2.0 makes it even easier to provide support for multiple cultures and locales through improved runtime and tool support.
Create Web Application Themes in ASP.NET 2.0
Learn to use cascading style sheets and images with themes in ASP.NET 2.0, and how you can dynamically load themes at run time.
Storing User Information with ASP.NET 2.0 Profiles
Use the new Profile object in ASP.NET 2.0 to track user preferences, create a shopping cart, and more.
Working with the ASP.NET 2.0 ObjectDataSource Control
Learn how to use the ObjectDataSource control to build a proper multi-tier Web application with the ASP.NET 2.0 Framework.
Introducing the ASP.NET 2.0 TreeView and Menu Controls
Discover how you can use the TreeView and Menu controls in ASP.NET 2.0 to represent hierarchical data in your applications. Use both controls with various data sources and customize the appearance of both controls.
Web Site Operations in ASP.NET 2.0
Use ASP.NET 2.0, Internet Information Services 6.0, and the Microsoft .NET Framework 2.0 to make deploying, configuring, monitoring, and maintaining Web applications easier than ever before.
ASP.NET 2.0: Speed Up Your Site with the Improved View State in ASP.NET 2.0 – MSDN Magazine, October 2004
The release of ASP.NET 2.0 brings several improvements to the view state mechanism that will make it easier to use without hindering your site's performance. These improvements include a reduction in encoding size, the introduction of control state to separate behavioral state from content, and intelligent integration with data-bound controls.
ASP.NET 2.0 Internals
While 100 percent backward compatible with ASP.NET 1.1, ASP.NET 2.0 brings a number of internal changes to ASP.NET. These include changes to the code model, compilation, page lifecycle, and more. This article outlines those changes.
Code Less to Access Data with ASP.NET 2.0
Leverage the new ASP.NET 2.0 data access controls to reduce the code you have to write when developing a data-driven Web application.
Master Pages in ASP.NET 2.0
Master Pages enable you to create ASP.NET pages that follow a consistent theme and style. Stephen Walther shows you how to take advantage of this new feature.
Changes to the Validation Controls in ASP.NET 2.0
While ASP.NET 1.x supported validating user input, ASP.NET 2.0 increases the flexibility of the validation through the addition of validation groups. This article looks at this new feature, and shows you how you can use it in a number of common scenarios.
Introducing the ASP.NET 2.0 GridView and DetailsView Controls
Display and edit database data and single database records with GridView and DetailsView, two new controls in the ASP.NET 2.0 framework.
Personalize Better with ASP.NET 2.0
Create personalized Web sites faster, and build entirely new classes of applications, with the new personalization features in ASP.NET 2.0.
Migrate from ASP.NET 1.x to ASP.NET 2.0
Explore features new to ASP.NET 2.0 from ASP.NET 1.x that offer a better set of options for Web development within the .NET Framework.
Migrate from ASP to ASP.NET 2.0
Tour the advantages of developing with ASP.NET 2.0, and gives guidance to developers in migrating from ASP to ASP.NET 2.0.
Creating Custom Web Controls with ASP.NET 2.0
The new adaptive rendering model in ASP.NET 2.0 provides a number of new options for control writers. This article shows how those options make creating custom controls for ASP.NET easier than before.
GridView: Move Over DataGrid, There's a New Grid in Town!
Go beyond the DataGrid!
New Security Features in ASP.NET 2.0
ASP.NET 2.0 includes a number of new features to make securing your ASP.NET applications easier than before. See how you can use the new controls, tools, and APIs to control access to pages, and make it easier to store information about your users.
Improved Caching in ASP.NET 2.0
Stephen Walther looks at the new caching features included in ASP.NET 2.0, and how you can use them to improve the performance and scalability of your ASP.NET applications.
2005年1月1日
牺牲了若干个周末陪MM逛街看电影的时间,在CnForums Beta1基础上进行完善和更新,1.2版内部发布测试。
因为没有经过严格测试,不敢保证此版本的稳定性,所以先内部发行一个测试版本,大家在使用过程中有什么问题请到论坛(http://www.cnforums.net)反馈即可。
CnForums1.2针对Beta1版中用户反馈的一些问题,基本修正了Beta1中存在的BUG,新增了一些功能,如:
支持框架式皮肤界面
支持动网等论坛的导入(动网论坛导入程序及源码随后发布)
版务管理
私人留言可以显示留言条数
……
现在有某个别团队直接在CnForum Beta1的源码基础上作简单修改即声称是自己的作品,保留对其进一步追究的权利。
CnForums1.2的完整源码将在经过大家的使用测试反馈,完善稳定后,加入license,在随后的几天内正式发布。
2004年12月20日
在Asp.Net中使用定时器,破宝之前已有Blog写过《在 ASP.NET 中使用计时器(Timer)》,这里主要针对Asp.Net Forums来说一下其具体实现。
在Asp.Net Forums中,对定时器有如下应用:
1. 更新论坛统计信息
2. 定时索引指定条数的帖子
3. 定时群发队列中的邮件
Forums中对定时器的调用是放在自定义HttpModule的Init方法中(如果您没有使用HttpModule,也可以在Globals.aspx中的Application_OnStart 中调用定时器)。
// 定时器
static Timer statsTimer;
static Timer emailTimer;
// 定时间隔
private long EmailInterval = ForumConfiguration.GetConfig().ThreadIntervalEmail * 60000;
private long StatsInterval = ForumConfiguration.GetConfig().ThreadIntervalStats * 60000;

public String ModuleName
{

get
{ return "ForumsHttpModule"; }
}
// *********************************************************************
// ForumsHttpModule
//

/**//// <summary>
/// Initializes the HttpModule and performs the wireup of all application
/// events.
/// </summary>
/// <param name="application">Application the module is being run for</param> 
public void Init(HttpApplication application)
{
// Wire-up application events
//
// 略去其他代码
ForumConfiguration forumConfig = ForumConfiguration.GetConfig();
// 如果使用定时器并且定时器还没初始化
if( forumConfig != null

&& forumConfig.IsBackgroundThreadingDisabled == false )
{
if (emailTimer == null)
// 新建定时器
// 新建一个TimerCallback委托,具体要执行的方法在ScheduledWorkCallbackEmailInterval中
emailTimer = new Timer(new TimerCallback(ScheduledWorkCallbackEmailInterval), application.Context, EmailInterval, EmailInterval);
if( forumConfig.IsIndexingDisabled == false

&& statsTimer == null )
{
statsTimer = new Timer(new TimerCallback(ScheduledWorkCallbackStatsInterval), application.Context, StatsInterval, StatsInterval);
}
}
}

/**//// <summary>
/// 释放定时器
/// </summary> 
public void Dispose()
{
statsTimer = null;
emailTimer = null;
}

Timer Callbacks#region Timer Callbacks

/**//// <summary>
/// 定时发送队列中待发送的邮件
/// </summary>

private void ScheduledWorkCallbackEmailInterval (object sender)
{

try
{
// 当处理邮件时暂停定时器
emailTimer.Change( System.Threading.Timeout.Infinite, EmailInterval );
// 发送队列中的邮件
//
Emails.SendQueuedEmails( (HttpContext) sender);
// 更新匿名用户
//
Users.UpdateAnonymousUsers( (HttpContext) sender);
}

catch( Exception e )
{
ForumException fe = new ForumException( ForumExceptionType.EmailUnableToSend, "Scheduled Worker Thread failed.", e );
fe.Log();
}

finally
{
// 重新启动定时器
emailTimer.Change( EmailInterval, EmailInterval );
}
}

/**//// <summary>
/// 定时索引帖子和定时更新论坛统计信息
/// </summary>

private void ScheduledWorkCallbackStatsInterval(object sender)
{

try
{
// 休眠定时器
statsTimer.Change( System.Threading.Timeout.Infinite, StatsInterval );
// 每次索引100篇帖子
//
Search.IndexPosts( (HttpContext) sender, 100);
// 更新论坛统计信息
SiteStatistics.LoadSiteStatistics( (HttpContext) sender, true, 1 );
}

catch( Exception e )
{
ForumException fe = new ForumException( ForumExceptionType.UnknownError, "Failure performing scheduled statistics maintenance.", e );
fe.Log();
}

finally
{
// 唤醒定时器
statsTimer.Change( StatsInterval, StatsInterval);
}
}
#endregion 其实稍加改进就可以应用到我们自己的项目中,例如前不久刚做一个项目,因为数据量过于庞大,每次从数据库取非常慢,然后改成使用定时器,每隔12小时将最新的数据列表生成静态的文本。
BTW: 有技术八股文之嫌哦:P
2004年12月16日
前面在《Asp.Net Forums中对.Net中序列化和反序列化的应用》一文中讲了,对于一些扩展属性,可以将字符串集合序列化为二进制,也可以从二进制反序列化为字符串集合。其实我一直有个疑问,对于asp.net中可以很容易实现,但是在asp中该如何?
在CS和DNN3中都采用了asp.net2.0的新特性MemberShip,今天研究了一下CSBeta2,特地研究了一下MemberShip中对于用户资料的序列化保存。发现在aspnet_Profile表中有三个特殊字段PropertyNames、PropertyValuesString和PropertyValuesBinary,其中的PropertyValuesBinary十之八九就是保存序列化为二进制后的内容。对于PropertyNames、PropertyValuesString这两个字段倒是不知道,打开查看,发现其中一条记录这两个字段的内容分别为下面两行的内容:
publicEmail:S:0:0:yahooIM:S:0:0:timezone:S:0:1:birthdate:B:0:-1:gender:S:1:6:location:S:7:0:fontsize:S:7:1:signature:S:8:0:dateFormat:S:8:10:webLog:S:18:7:enablePostPreviewPopup:B:0:-1:language:S:25:5:interests:S:30:0:occupation:S:30:0:webAddress:S:30:7:icqIM:S:37:0:aolIM:S:37:0:signatureFormatted:S:37:0:msnIM:S:37:0:
8NotSet0MM-dd-yyyyhttp://zh-CNhttp://
借助Reflector分析了一下源码,终于明白了,原来在PropertyNames字段中,由“:”分割为若干个数组,其中每个属性占数组的4项(如publicEmail:S:0:0:为一个属性的整体):
第1项为属性名称
第2项有两种可能值,B表示该属性值为null,S表示不为null
第3项表示在PropertyValuesString字段中字符串的起始位置
第4项表示长度
那么publicEmail:S:0:0:就表示为空值,timezone:S:0:1:表示“8NotSet0MM-dd-yyyyhttp://zh-CNhttp://“中从0开始取1个字符长度为“8”,birthdate:B:0:-1:就表示为null,dateFormat:S:8:10:就表示取“8NotSet0MM-dd-yyyyhttp://zh-CNhttp://”中第8位开始取10个字符为“MM-dd-yyyy”……
通过这种序列化为字符串的方式,即使是一些弱语言,如vbscript,jscript都可以实现序列化和反序列化了,那么在asp中也就可以共享asp.net的MemberShip了。
贴两段核心代码参考一下:
internal static void PrepareDataForSaving(ref string allNames, ref string allValues, ref byte[] buf, bool binarySupported, SettingsPropertyValueCollection properties, bool userIsAuthenticated)


{
StringBuilder builder1 = new StringBuilder();
StringBuilder builder2 = new StringBuilder();
MemoryStream stream1 = binarySupported ? new MemoryStream() : null;
try

{
bool flag1 = false;
foreach (SettingsPropertyValue value1 in properties)

{
if (!value1.IsDirty)

{
continue;
}
if (userIsAuthenticated || ((bool) value1.Property.Attributes["AllowAnonymous"]))

{
flag1 = true;
break;
}
}
if (!flag1)

{
return;
}
foreach (SettingsPropertyValue value2 in properties)

{
if (!userIsAuthenticated && !((bool) value2.Property.Attributes["AllowAnonymous"]))

{
continue;
}
if (value2.IsDirty || !value2.UsingDefaultValue)

{
int num1 = 0;
int num2 = 0;
string text1 = null;
if (value2.Deserialized && (value2.PropertyValue == null))

{
num1 = -1;
}
else

{
object obj1 = value2.SerializedValue;
if (obj1 == null)

{
num1 = -1;
}
else

{
if (!(obj1 is string) && !binarySupported)

{
obj1 = Convert.ToBase64String((byte[]) obj1);
}
if (obj1 is string)

{
text1 = (string) obj1;
num1 = text1.Length;
num2 = builder2.Length;
}
else

{
byte[] buffer1 = (byte[]) obj1;
num2 = (int) stream1.Position;
stream1.Write(buffer1, 0, buffer1.Length);
stream1.Position = num2 + buffer1.Length;
num1 = buffer1.Length;
}
}
}

string[] textArray1 = new string[8]
{ value2.Name, ":", (text1 != null) ? "S" : "B", ":", num2.ToString(CultureInfo.InvariantCulture), ":", num1.ToString(CultureInfo.InvariantCulture), ":" } ;
builder1.Append(string.Concat(textArray1));
if (text1 != null)

{
builder2.Append(text1);
}
}
}
if (binarySupported)

{
buf = stream1.ToArray();
}
}
catch

{
throw;
}
finally

{
if (stream1 != null)

{
stream1.Close();
}
}
allNames = builder1.ToString();
allValues = builder2.ToString();
}
internal static void ParseDataFromDB(string[] names, string values, byte[] buf, SettingsPropertyValueCollection properties)


{
for (int num1 = 0; num1 < (names.Length / 4); num1++)

{
string text1 = names[num1 * 4];
SettingsPropertyValue value1 = properties[text1];
if (value1 != null)

{
int num2 = int.Parse(names[(num1 * 4) + 2], CultureInfo.InvariantCulture);
int num3 = int.Parse(names[(num1 * 4) + 3], CultureInfo.InvariantCulture);
if (num3 == -1)

{
if (!value1.Property.PropertyType.IsValueType)

{
value1.PropertyValue = null;
value1.IsDirty = false;
value1.Deserialized = true;
}
}
else

{
if (((names[(num1 * 4) + 1] == "S") && (num2 >= 0)) && ((num3 > 0) && (values.Length >= (num2 + num3))))

{
value1.SerializedValue = values.Substring(num2, num3);
}
if (((names[(num1 * 4) + 1] == "B") && (num2 >= 0)) && ((num3 > 0) && (buf.Length >= (num2 + num3))))

{
byte[] buffer1 = new byte[num3];
Buffer.BlockCopy(buf, num2, buffer1, 0, num3);
value1.SerializedValue = buffer1;
}
}
}
}
}
几个月前,写过一篇关于Asp无组件上传带进度条的Blog,当时主要分析了一下通过Web文件上传并在后台获取分析数据的实现原理。其中实现进度条的根本就是要实现分块获取数据,根据分块大小和块数记录已上传大小。还有一些具体的细节问题当时并没有说清楚:
Q: 进度信息如何访问?
A: 进度信息保存在Application中,每次上传时生成一个进度ID,根据这个进度ID可以检索Application中的当前上传进度信息。
Q: 进度信息以什么形式保存在Application中?
A: Asp太弱了,我分别试过Scripting.Dictionary和XMLDom,但是Asp中Application不能保存这种对象,要是asp.net就直接可以用Hashtable了。最后是在Application中用一个ADODB.Recordset对象来保存进度相关信息。
Q: 怎么保证的页面能即时反应显示进度条信息?
A:
文件开头加上<%@enablesessionstate=false%>声明来关闭会话状态
要保证禁用缓存:
Response.CacheControl = "no-cache"
Response.Expires = -1
Q: 可以上传多大文件?
A: 这个和网速,服务器内存等多方面因素有关,将Server.ScriptTimeout设置足够长,那么理论上可以和服务器保持连接很长时间。因为在asp中,不能实现对文件的“追加”写入,必须将所有待写入文件的数据都先保存在内存,这样如果上传大文件,那么将很占用服务器内存(文本文件可以使用TextStream.Write追加写入)。在asp.net下就比较爽了,分块读取的时候,每读一块分析一块,然后将上传文件的数据内容“追加”写入硬盘文件中,对内存占用很小很小。一般几十MB的文件还是没问题,太大的上传其实对于web下也不是很有意义。
写了一个比较完善的实例,可以直接下载使用:
演示下载
2004年12月10日
2004年12月8日
附件: cs_beta2_3.zip
Download Community Server Beta 2 Now!
Beta 2 introduces new UI, addresses many bug fixes, and begins to introduce some of the new navigation.
The graphical tabs in the new banner do not work yet. We also have some new UI updates to both blogs and galleries that did not make it in today's beta 2 release.
You can browse a demo at http://stage.telligentsystems.com/
2004年12月6日
js的数组中有一个sort方法,默认是按照ASCII 字符顺序进行升序排列。如果需要自定义排序,例如希望通过二维数组中的第二列数据排序:
<script language="javascript">
<!--
var testArray = new Array();
testArray[0]= new Array('e','2','g');
testArray[1]= new Array('b','3','c');
testArray[2]= new Array('a','1','a');
testArray[3]= new Array('d','4','h');
testArray.sort(sortfunction);
alert(testArray[0] + "\n" + testArray[1] + "\n" + testArray[2] + "\n" + testArray[3])
// 排序方法中有两个参数,表示数组中两个用来排序的元素
//
function sortfunction(x,y)
{
return x[2].charCodeAt(0) - y[2].charCodeAt(0);//根据二维数组的第三列的第一个字母的ASCII码来降序排序
}
// -->
</script>
2004年12月5日
假如我们要写一个存储过程,取表中前N条记录,其中N为参数,以Northwind库中的Orders表为例,有两种方法:
第一种是拼SQL
CREATE PROCEDURE GetTopNOrders
(
@RowsToReturn int
)
AS
declare @sql varchar(8000)
set @sql='select top '+cast(@RowsToReturn as varchar)+' * from orders'
exec (@sql)
第二种是借用RowCount属性
CREATE PROCEDURE GetTopNOrders
(
@RowsToReturn int
)
AS
SET ROWCOUNT @RowsToReturn
SELECT * FROM Orders order by orderid
对于这个例子不管哪种效果都是一样的,但是第二种应该更灵活一点,只是知道的人比较少罢了!
GetTopNOrders 20
希望能对大家有所帮助:)
2004年12月2日
2004年11月30日
HttpModule 是个好东西,很多程序都有用到,例如DotText、Asp.Net Forums等,但是有一个问题,当我们将使用了HttpModule 的程序设置为站点根目录(以将DotText设置为站点目录为例),然后再在根目录下建虚拟目录,运行虚拟目录里的asp.net程序会提示出错:
分析器错误信息: 找不到文件或程序集名称“Dottext.Web”,或找不到它的一个依赖项。
源错误:
行 145: 行 146: <httpModules> 行 147: <add name="ServiceRouter" type= "Dottext.Web.Modules.BlogServiceModule, Dottext.Web" /> 行 148: </httpModules> 行 149: |
源文件: D:\DotText095\DottextWeb\web.config 行: 147
也就是说对于虚拟目录中的asp.net应用程序,会首先去加载其所在站点中的HttpModule,而一般虚拟目录中的bin目录是不会有HttpModule所在的DLL的,所以就会出如上的错误。
注意,其中的错误提示信息(找不到文件或程序集名称“Dottext.Web”,或找不到它的一个依赖项。)很有误导性,一开始让我以为是需要每个虚拟目录拷贝一个Dottext.Web.dll进去呢,但是将dll拷贝过去后,其HttpModule会对虚拟目录中的asp.net应用程序产生影响,因此这个问题曾让我郁闷了很久。
后来偶然查msdn中,发现web.config里面的HttpModule是有三种子节点的:
<httpModules>
<add type="classname,assemblyname" name="modulename"/>
<remove name="modulename"/>
<clear/>
</httpModules>
| 子标记 | 说明 |
| <add> | 将 HttpModule 类添加到应用程序。 请注意,如果以前已指定了相同的谓词/路径组合(例如在父目录的 Web.config 文件中),则对 的第二个调用将重写以前的设置。 |
| <remove> | 从应用程序移除 HttpModule 类。 |
| <clear> | 从应用程序移除所有 HttpModule 映射。 |
所以遇到类似这样的问题,在虚拟目录中的web.config中Remove一下不需要的HttpModule就好了!如:
<httpModules>
<remove name="ServiceRouter"/>
</httpModules>
注意一般表用<clear/>,因为用<clear/>会把machine.config中定义的httpModule一起清除了从而导致asp.net程序不能正常运行。
有一点我很疑惑的是既然都是用remove移除这个HttpModule了,还要将该HttpModule对应的dll拷贝到虚拟目录的dll下。
httpHandlers的处理方法也类似。
2004年11月28日
在我们写程序时,不可避免的要经常写有用户验证功能的界面,一个常见但可能被忽视的问题就是,究竟应该是“登录”系统?还是“登陆”系统?用拼音输入法时两个字的发音都是dēnglù,而似乎都可以表示进入系统的意思。
在网上,关于登录和登陆似乎都是通用的,可能在同一个网站中,有的网页用的是“登陆”,而另一个网页又用的是“登录”
,但是对于一些相对正规的大网站(如微软,Sina等),都是是用“登录”而基本没有用“登陆”的。
之前我也一直没注意到这个问题,有次项目中技术总监特地给我们详细解释了一下,应该用“登录”而不是“登陆”,当时是怎么解释的我忘记了,倒是记住了应该是“登录”,所以现在看到“登陆”都比较过敏了。
我语文不够好,无法给大家解释为什么应该是“登录”而不是“登陆”,给大家提个醒,如果谁能有比较正规的解释欢迎补充
附金山词霸中关于两个词意的解释:
登陆dēnglù
渡过海洋或江河登上陆地
登录dēnglù
列入;记载
2004年11月21日
序
CS1.0 Beta经过几天的跳票,在N多人的期待下终于匆匆发布,而且没有开源,说是要Release才开源,天知道会不会开源!
安装篇
您可以从http://www.communityserver.org/下载,下载后,是一个压缩包,解压后,有一个readme.txt,是安装说明,按照上面一步步操作即可。安装非常简单,首先为解压后的web文件夹设虚拟目录为http://localhost/cs,然后根据data文件夹中的sql安装数据库,不过安装数据库时要注意一下:
执行Data\CS_2004_11_17_Full.sql 脚本,会自动创建一个数据库,但是安装的SQL文件在中文SQL Server上会提示排序规则冲突,必须对SQL作如下修改(谢谢progame的帮助):
找到sp: forums_Posts_UpdatePostsInCategories
where C.[Category] is not null and C.[Category] not in ( Select [Name] FROM forums_Post_Categories where CategoryType = @CategoryType and ForumID = @ForumID )
修改为:
where C.[Category] is not null and C.[Category] COLLATE Latin1_General_CI_AS not in ( Select [Name] FROM forums_Post_Categories where CategoryType = @CategoryType and ForumID = @ForumID ) 就是在not in前面加上COLLATE Latin1_General_CI_AS
然后执行Data\DefaultCommunity.sql脚本创建默认站点(默认站点:http://localhost/cs;账号/密码:admin/pa$$word),执行完后会有一些警告错误信息,不过不用管他。
注意要给root/blogs 和 root/gallery 文件夹有写的权限。
使用篇
安装完后就可以用http://localhost/cs 来访问传说中的Community Server 1.0 了,首页很简单,主要是Forums/Blog/Photo Galleries的介绍和链接。
首先进入Forums,发现Forums和原来的Forums2.01没有任何区别,只是这时候还没有任何板块/讨论组,使用默认的管理员账号/密码(admin/pa$$word)登录,进入后台(http://localhost/cs/admin),发现后台已经大变样了!
先进入System选项,有一排链接,分别是:
Manage Blogs|Manage Forums|Manage Galleries|Configuration|Reports|Tools

这里的Configuration|Reports|Tools就是以前Forums后台管理中的一些内容,这里就不多介绍。
Manage Blogs|Manage Forums|Manage Galleries实际上内容是一样的,都是管理各自的“组”、“分类”,权限分配,以Manage Blogs为例:

进入"Manage/Create Blogs and new groupings":

可以方便的管理/创建Blog分组/blog。同时,每创建一个blog,会在Web\blogs目录下创建相应的文件夹和空的default.aspx文件(这就是为什么该目录需要“写”的权限了),Blog名不能为中文。
这里可以给每个blog分配角色,选择哪些角色可以对该blog进行相关操作:

设置某角色对该Blog有何种权限:

Manage Forums、Manage Galleries和Manage Blogs基本类似。
新建好Blog后,就可以对建好的Blog进行管理更新了:

Blog的操作和原来的DotText基本上差不多的,可以方便的发表随笔/文章:

在System中建好相册类别后,也可以对相册进行管理了:

上传照片还是很方便的:

相册的配置选项:

后台上传完照片,到前台看看效果:

Blog还是老样子,看看Blog首页:

进入某个Blog:

技术篇
因为CS1.0 Beta没有开源而我也没深入研究,所以只是从有限的资源进行简单分析了一下。从数据库、命名空间和目录结构等可以看出,Community Server是在Forums的架构基础上,加上了Blog和相册,继续保持了Forums的换皮肤,多语言等特性。
数据库
数据库还是在Forums的数据库基础上,包括forums_的前缀大部分都还在(可能会要改掉),用户资料已经转移到aspnet_Users表和aspnet_Membership表中,三个系统共用。角色也转移到aspnet_Roles表中。cs_ApplicationType表主要保存Community Server中的系统类别,目前有论坛/blog/相册。blog和Forums的帖子内容都forums_Posts表中。有几个cs_和aspnet_开头的表作用暂时还不是很清楚,需要等文档和源码后才方便分析。
目录结构
Forums/Blogs/Gallery在web根目录下分别有单独目录,另外一些公用文件夹,如FreeTextBox、Languages、Msgs、Themes等都在根目录下,Blogs和Gallery中,每创建一个blog/相册就会在其目录下创建一个相应的文件夹和空的default.aspx,类似于DotText中用来做url重定向用。
后记
Community Server总的来说还是挺不错的,安装后就有了一个强大的论坛/blog/相册系统,对于一般网站来说可以足够用了,虽然还有很多很多bug,但是毕竟还只是Beta版,还在慢慢完善中。可惜没有开源,所以一些比较好的设计思想还没能深入学习了解。
有一点我还是很疑惑,我本以为用户新注册后就可以有自己的blog/相册,但是我发现blog/相册只能管理员开通/维护,而且如果需要让某用户可以维护一个blog/Gallery,那么必须为这个用户先建一个角色,然后让这个角色可以维护某个Blog/Gallery,并让该用户属于这个角色。如果要给每个用户开通一个blog/Gallery,那岂不是要给每个用户新建一个角色,再让这一个个角色和这一个个blog/Gallery对应起来?!
Release发布估计是明年的事情了,不过现在也不如以前那么期待了!
2004年11月17日
因为一直以来主要精力都在开发程序,
CnForums直到
Beta1版发布的时候,还没有加入自己的LICENSE。
众所周知,
CnForums是在
Community Server :: Forums (原asp.net forums论坛)基础上进行本地化而成,遵守其协议,保留了其eula.gif和链接,而且
CnForums也是继续开源的。
对于
CnForums,我们(
PSP团队)是花了很多精力和时间的,并且
CnForums也得到了大家的认可,目前很多网站都开始采用
CnForums。而有些个人/团队却不尊重我们的劳动,无视
CnForums的版权,直接在源码/界面上稍加改进,不但没有保留
CnForums相关链接,也没有任何申明和相关说明。
出现这种情况也是我们意料之中的事情,现在对
我们来说,最重要的还是继续完善改进
CnForums的程序,将这些无耻的盗版者远远甩在身后!同时也希望得到大家的支持!
目前正在致力于CnForums Beta2的开发,估计不久后就会发布,针对用户的反馈修正了很多BUG,新增了一些比较实用的功能。同时支持dvbbs等论坛的导入。
BTW: CS1.0 BETA跳票了,而且Beta不开源了。据说要等到Release版才开源。期待……
2004年11月13日
这些样式表,你都用过么?
在Web开发时,不可避免要用到CSS,把我这几年在Web开发过程中积累的一些不常用但是很实用的CSS整理了一下,希望对大家有所帮助!
filter:chroma(color:#FFFFFF);
让指定的背景色透明,例:
![]() | ![]() |
| 未使用该滤镜 | 使用该滤镜 |
word-break:break-all;
强制换行,例:
当未使用该样式时,虽然我设置了表格宽度为100px,但是面对这样连续的字符,表格无法自动换行,表格会被撑破:
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
再看看使用该样式后的效果:
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
writing-mode:tb-rl;
用于设置文本的书写方向,可以有两个取值:
lr-tb:表示左右-上下,left right - top bottom
tb-rl:表示上下-右左,top bottom - right left
需要 IE 5.5+ 才支持,例:
第一组垂直文字第一组水平文字第二组水平文字
第二组水平文字第三组竖直文字第三组水平文字
text-indent:2em;
首行缩进,例:
有时候,我们需要将段落的首行缩进两个文字,一般我们都是用4个HTML的空格( )来实现,其实我们还可以用样式表来达到这种效果!
background-color: transparent;
transparent表示透明色,例:
border-collapse:collapse;
它会自动把相同的边框线合并,例:
不使用border-collapse:collapse;
使用border-collapse:collapse;
background-position: 0 -78;
设置背景图片的位置,例:
《background-position的妙用》
table-layout: fixed;
固定布局的算法。在这算法中,水平布局是仅仅基于表格的宽度,表格边框的宽度,单元格间距,列的宽度,而和表格内容无关。也就是说,内容可能被裁切,例:
看看我以前写的一个仿msn的htc网格中应用这个属性的效果吧,仿照MSN的网格,单元格中文字过长会自动被截取(在Table中使用样式table-layout: fixed;),鼠标移上会全部显示(使用一个浮动的层覆盖在上面): 演示 下载
display:inline;
设置或检索对象是否及如何显示,inline表示内联,例:
大家都知道两个表格在一起,默认是会自动换行的,但是利用display:inline;属性可以让两个表格并排在一起:
overflow: auto;
检索或设置当对象的内容超过其指定高度及宽度时如何管理内容。auto : 在需要时剪切内容并添加滚动条,例:
| 使用前的TextArea | 使用后的TextArea |
| |
font:12px/18px;
字体大小/行高,例:
| 未使用CSS | 使用该CSS |
| 在这里行高是系统默认的,不会受影响的 | 这里的12px就表示字体大小,18px其实就等价于css中的line-height。 |
clip : rect ( 0 64 64 0 )
字体大小/行高,例:
原图: 
裁减后:
可以利用这个来做动画:)
font-size: expression(document.body.clientWidth / 20);
expression是IE浏览器特有的功能,可以直接执行脚本而算出css的值,例:
《CSS也能控制表格的交替颜色 》
字体大小随着浏览器大小而变化,始终为浏览器宽度的1/20
对于支持HTML的BBS来说,这可能会是一个安全隐患! position: absolute;
这个我想绝大多数人都知道——绝对定位,我所要说的是偶然发现的一个隐含功能,例:
当给一个网页元素的CSS设置为"position: absolute;",那么它会绝对定位,然后根据css中的left,top属性确定自己的位置。但是如果我们仅仅设置一个元素样式表的"position: absolute;"属性,而不设置其left,top属性,那么该元素会浮在其html所在位置。看个例子,我将一个tr的CSS设置为"position: absolute;":
第一行浮在第二行上了,这个特性可以很方便的来制作重叠效果,例如我以前写过的自定义按钮和flash播放器都用到了这个特性来实现重叠:
自定义按钮:一个自定义按钮,底下是一个普通的Button,利用"position:absolute;"在Button上面覆盖图片,这样看起来就像自定义按钮,而实际点击确是点击底下真实的Button(
下载)
Flash播放器:这个播放器的进度条就是通过这种方法来重叠的。(
下载)
2004年11月10日
很荣幸能够加入博客堂,继续努力,多发高质量的技术性blog。
这边的blog继续维护,相对来说这边更随意一些,可以随便写写,那边主要就发一些技术性的blog。
越来越多的网站采用了CnForums,其中包括微软中文社区的bbs,努力把CnForums作的更好。
不久后CS1.0 就要发布了,到时候会将CnForums升级到CS1.0:Forums。暂时对CnForums不做大的变动,等CS1.0发布后再迁移过去。
2004年11月3日
CS是 community server 的简写,集成了论坛(Asp.Net Forums),Blog(DotText),相册(nGallery)
官方预计是11月中旬发布,不过跳票的可能性非常大,目前还没有任何Alpha/Beta版本!
所以暂缓CnForums的开发,待CS1.0发布后,和PSP团队成员一起第一时间发布CS1.0的本地化版本:)
