宝玉

专注于web开发技术
随笔 - 114, 评论 - 1485 , 引用 - 576

2006年6月22日

加龙语录(1)

加龙周六要去参加网友聚会,所以拒绝了某个MM的邀请,我就建议他把某MM带上一起参加聚会,加龙说:“去森林里转,还需要抱着颗树去吗”

我曾给加龙宣扬过李敖著名的三不原则:“不主动不拒绝不负责”,加龙的看法总是和别人不一样:“不主动,就爬不到美女身上;不拒绝,丑女就会爬到你身上;不负责 早晚有人找你算账”

posted @ 3:14 | Feedback (4)

2006年4月13日

这两天有个小朋友在这里玩的很开心

58.215.65.166   -  江苏省 无锡市

偶忘记禁用Register.aspx了,这位小朋友利用这个注册了若干blog帐号,辛辛苦苦发了若干Blog,呵呵,辛苦了!

posted @ 21:03 | Feedback (6)

2006年2月17日

使用离线工具发布Blog

推荐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获取随笔、发布随笔、将随笔发布到相应的个人分类,修改随笔。
avatar.jpg

posted @ 14:25 | Feedback (3)

2005年6月9日

如是用 MS Virtual Server 2005(zz)

<如是用 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 连接,然后使用该连接来交换文件。这是将测试文件移入移出隔离的虚拟网络的一种简便方法。

*安装虚拟机附件。与其说这是一个窍门,不如说这是一则提示。安装这些附件可以大大增强体验,因而这一步操作是必不可少的。为此,应向硬盘映像中添加附件,从而自动安装这些附件。在准备好将项目部署到生产环境中后,您可以移除这些附件。

posted @ 22:30 | Feedback (5)

2005年3月4日

要当爸爸了

预产期在10月份,辛苦老婆了

posted @ 8:14 | Feedback (30)

2005年1月20日

本Blog停止更新

维护多个blog太麻烦了,此后停止更新此blog,最新blog只发布在 博客堂我的Blog 中,谢谢关注!

posted @ 0:57 | Feedback (4)

2005年1月9日

CnForums 1.2 完整源码版


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


posted @ 22:42 | Feedback (10)

2005年1月7日

让论坛也可以像outlook2003一样有新帖子/留言Popup提示

很多软件,如msn、outlook2003等都有popup提示,可以方便的知道有无新邮件。

IE6有一个非常酷的功能就是Popup,博客园中有几位兄台已经研究过了。

CnForums1.2加入了一个比较好的功能就是Popup提示,让你可以方便快捷的知道新帖子/留言

效果如图(和软件的popup一样,不管你再哪个窗口,都可以弹出):


如果您想体验一下,并且IE版本为6.0,那么可以登录 http://www.cnforums.net 看看效果:)

CnForums1.2正式版全部源码将于下星期一发布

posted @ 1:42 | Feedback (15)

2005年1月6日

ASP.NET 2.0 Resources - MSDN webcasts & whitepapers

 

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.   

posted @ 2:50 | Feedback (4)

2005年1月1日

CnForums 1.2 测试版

牺牲了若干个周末陪MM逛街看电影的时间,在CnForums Beta1基础上进行完善和更新,1.2版内部发布测试。


因为没有经过严格测试,不敢保证此版本的稳定性,所以先内部发行一个测试版本,大家在使用过程中有什么问题请到论坛(http://www.cnforums.net)反馈即可。


CnForums1.2针对Beta1版中用户反馈的一些问题,基本修正了Beta1中存在的BUG,新增了一些功能,如:
支持框架式皮肤界面
支持动网等论坛的导入(动网论坛导入程序及源码随后发布)
版务管理
私人留言可以显示留言条数
……


现在有某个别团队直接在CnForum Beta1的源码基础上作简单修改即声称是自己的作品,保留对其进一步追究的权利。


CnForums1.2的完整源码将在经过大家的使用测试反馈,完善稳定后,加入license,在随后的几天内正式发布。


posted @ 16:30 | Feedback (7)

2004年12月20日

asp.net forums中定时器的应用

在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;
        }


        
#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, true1 );
            }

            
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

posted @ 1:19 | Feedback (4)

2004年12月16日

MemberShip中对用户资料的序列化

前面在《Asp.Net Forums中对.Net中序列化和反序列化的应用》一文中讲了,对于一些扩展属性,可以将字符串集合序列化为二进制,也可以从二进制反序列化为字符串集合。其实我一直有个疑问,对于asp.net中可以很容易实现,但是在asp中该如何?

CSDNN3中都采用了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;