
置顶随笔
在开发的过程中开发人员不得不经常要写很多重复的代码,
为了把精力放到更重要的方面去很多人为都做了N多努力,随便google一下自动生成工具,
你都会很容易得到很多这样的工具。园子就有好几款,其中李天平的Codematic就十分优秀.
不过可惜的是大多数的代码生成工的都基于数据库引擎,很少有基于建模工具引擎,于是突发奇想,可不可以绕过数据库引擎直接能守建模工具引擎生成?
下面介绍一下我的Anto.exe :
Anto.exe的风格及功能类似Codematic,在这里我要感谢李天平,也极力推荐大家去看看他的Codematic,真的十分优秀,它给我带来了很多方便(我一直用),也让我学到了不少东西。
Anto.exe的优点在于既支持数据库引擎又支持建模工具引擎,当然这还不完善(现在只支持sqk2K/PowerDesigner)因为要完成它不但要知道各种数据库引擎还要了解各种建模工具引擎。
Anto.exe只是一个小平台,我的思路不知道是对是错,在这里我只不过起了一个头,希望对正在研究或对代码生成工具的朋友有所帮助。根据这样的思路可以写出符合自己要求的工具。给开发带来更多的方便。这是我开源的主要原因。
这是我用空余时间写的,而且用的是VS2003,技术含量也不高,希望大家不要见笑。欢迎大家来讨论批评。
原理:
数据库引擎 --|
|--XML(自定义-->解析XML-->生成代码
建模工具引擎 --|
一。必备:
1。必须安有.net 1.1 框架
2。若没有正确显示左边的树请安 .net的树控件
二。用法
1。引擎为PowerDesigner设计文件
双击Anto.exe-->建模工具引擎-->选择test目录下的任一个xml文件-->登陆
效果如 :pd-1.jpg;pd-2.jpg

pd-1.jpg

pd-2.jpg
1。引擎为sql2K
双击Anto.exe-->数据库引擎-->输入你要登录的数据库信息-->登陆(有点慢,他在加载数据库的信息~!)
效果如 :db2K-1.jpg;db2K-2.jpg

db2K-1.jpg

db2K-2.jpg
源代码: 下载地址
应用程序: 下载地址
呵呵,介绍完了。
欢迎提出你宝贵的议建!
E_mail:qqcrazyer@126.com
posted @
2007-02-01 09:37 qqcrazyer 阅读(3865) |
评论 (44) |
编辑
如果你发现session突然无理由的丢失,而当你认真的检查代码并且排除其它常规可能丢失
的可能性时,你可能会像我一样,几乎要接近崩溃~!
后来发现问题出在我用代码创建一个临时目录然后删除临时目录的删除操作上。
现在和大家分享下:希望对碰到类似钉子的朋友有用。。
说白了session丢失实质就是:应用程序重起!
应用程序什么时候自动重起呢?
请参考:Anand在dotnetindia.com发表的文章

原文引用


{
Why ASP.NET Restarts?
Found this link from one of the blogs I was browsing today. This is ASP.NET Forum post by Patrick Y. Ng of MS.

This talks about both 1.0 and 1.1

This behaviour has been bugging lots of people. ASP.Net will restart its application for various reasons. All these reasons are legitimate, but the side effect is that the application will reset all its cache, application state, and InProc session states.
You can detect the restart of application and worker process by using the performance monitor. The counters to monitor are "ASP.NET\Application Restarts" and "ASP.NET\Worker Process Restarts".

For worker process restart, ASP.NET will write an entry in the eventlog to explain why (logLevel in controls how often eventlog is written).

For application restart, however, in v1 and v1.1 there is no easy way for a customer to figure out why a restart happened.

So by listing all reasons for app restart, I hope I can help some customers to understand and avoid the restart.

For v1
------



{
Things that causes application restart:

- The max compilation limit is reached (look for numRecompilesBeforeApprestart in machine.config)

- Physical application path of the web application has changed.

- Change in global.asax or one of the included files

- Change in machine.config

- Change in web.config in the app root

- Change inside bin directory or its subdirs

- A directory is renamed to bin, or bin is created

- Overwhelming change notifications – too many files are changed too fast in one of content directories – could happen if, for example, files are generated on the fly per request

- Change in the code-access security policy file
}

- The settings of various attributes in in machine.config affect the restart/shutdown of the worker process itself. However, if you use Windows 2003, and (by default) you are NOT using IIS5 isolation mode, is ignored. Instead, the settings in "Application Pools" in IIS manager is used.


For v1.1
--------
The list for v1.1 is the same as v1, with the following new conditions:



{
- User code called HttpRuntime.UnloadAppDomain

- Any directory under the web application folder is renamed
}
IIS 6.0
--------
If you're using IIS 6.0, and you're not using IIS 5 compatible mode, then aspnet_wp.exe will be replaced by w3svc.exe. You may want to go to IIS Manager, go to Application Pools/DefaultAppPool, and see if any of the parameters on the Recycling and Performance tabs are causing the IIS worker process (w3svc.exe) to shutdown.
}


也就是说 asp.net 会监视应用程序目录,一但有被监视
的动作发生(比如:修改了config、重命名目录等)应用程序就会自动重起
当然这时你的session一定丢失了。
如果避免不了这种操作(如:重命名目录);这里我们可以用cookie存信息或存到数据库去;
注意:除了以上列出的英文条件外。目录的删除操作一定丢失session。asp.net的内部机制对待目录有点像个守财奴,它死守着目录,你创建它不会管(往里加),一但创建他就会监视该目录,若你要删除或重命名它的(动它的目录),它就发生重起了。。
posted @
2007-01-27 18:11 qqcrazyer 阅读(2096) |
评论 (24) |
编辑
最近在做用asp.net 2.0 开发,在将绑定数据到DropDownList。时抛出了一个很奇怪的异常。
异常详细信息: System.ArgumentOutOfRangeException: “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中。
于是查了一下MSDN:DropDownList.SelectedValue 属性:
此属性返回选定的 ListItem 的 Value 属性。通常使用 SelectedValue 属性确定列表控件中选定项的值。如果选定了多个项,则返回索引最小的选定项的值。如果未选定任何项,则返回一个空字符串 ("")。
SelectedValue 属性还可以用于选择列表控件中的某一项,方法是用该项的值设置此属性。如果列表控件中的任何项都不包含指定值,则会引发 System.ArgumentOutOfRangeException。
检查了一下代码。发现自己在没有绑DropDownList1之前就给DropDownList1.SelectedValue ="qqcrazyer";
怪不得出现异常;这里的DropDownList1没有qqcrazyer这一项。
但是这样赋值在做如市、县连动的值改时候很难避免不碰到赋一个列表没有的值,
怎么办呢?
于是又去反射查了一下SelectedValue的实现,找到了解法。

反射代码
1
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Themeable(false), WebSysDescription("ListControl_SelectedValue"), WebCategory("Behavior"), DefaultValue(""), Bindable(true, BindingDirection.TwoWay)]
2
public virtual string SelectedValue
3

{
4
get
5
{
6
int num1 = this.SelectedIndex;
7
if (num1 >= 0)
8
{
9
return this.Items[num1].Value;
10
}
11
return string.Empty;
12
}
13
set
14
{
15
if (this.Items.Count != 0)
16
{
17
if ((value == null) || (base.DesignMode && (value.Length == 0)))
18
{
19
this.ClearSelection();
20
return;
21
}
22
ListItem item1 = this.Items.FindByValue(value);
23
if ((((this.Page != null) && this.Page.IsPostBack) && this._stateLoaded) && (item1 == null))
24
{
25
throw new ArgumentOutOfRangeException("value", SR.GetString("ListControl_SelectionOutOfRange", new object[]
{ this.ID, "SelectedValue" }));
26
}
27
if (item1 != null)
28
{
29
this.ClearSelection();
30
item1.Selected = true;
31
}
32
}
33
this.cachedSelectedValue = value;
34
}
35
}
36
37
哈哈 原来只有在this.Page.IsPostBack的情况下,赋值才会出错。
只需这样赋值:
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue("qqcrazyer"));
就是如果通过FindByValue没有找到指定项则为null,而Items.IndexOf(null)会返回-1.
posted @
2007-01-26 18:10 qqcrazyer 阅读(5191) |
评论 (15) |
编辑

2007年7月27日
百度百科,开放分类的原理是什么?
他是如何从开放分类中分出,一级分类、二级分类的?
请对这个问题有兴趣朋友给个思路看看..
posted @
2007-07-27 16:37 qqcrazyer 阅读(45) |
评论 (0) |
编辑

2007年2月1日
在开发的过程中开发人员不得不经常要写很多重复的代码,
为了把精力放到更重要的方面去很多人为都做了N多努力,随便google一下自动生成工具,
你都会很容易得到很多这样的工具。园子就有好几款,其中李天平的Codematic就十分优秀.
不过可惜的是大多数的代码生成工的都基于数据库引擎,很少有基于建模工具引擎,于是突发奇想,可不可以绕过数据库引擎直接能守建模工具引擎生成?
下面介绍一下我的Anto.exe :
Anto.exe的风格及功能类似Codematic,在这里我要感谢李天平,也极力推荐大家去看看他的Codematic,真的十分优秀,它给我带来了很多方便(我一直用),也让我学到了不少东西。
Anto.exe的优点在于既支持数据库引擎又支持建模工具引擎,当然这还不完善(现在只支持sqk2K/PowerDesigner)因为要完成它不但要知道各种数据库引擎还要了解各种建模工具引擎。
Anto.exe只是一个小平台,我的思路不知道是对是错,在这里我只不过起了一个头,希望对正在研究或对代码生成工具的朋友有所帮助。根据这样的思路可以写出符合自己要求的工具。给开发带来更多的方便。这是我开源的主要原因。
这是我用空余时间写的,而且用的是VS2003,技术含量也不高,希望大家不要见笑。欢迎大家来讨论批评。
原理:
数据库引擎 --|
|--XML(自定义-->解析XML-->生成代码
建模工具引擎 --|
一。必备:
1。必须安有.net 1.1 框架
2。若没有正确显示左边的树请安 .net的树控件
二。用法
1。引擎为PowerDesigner设计文件
双击Anto.exe-->建模工具引擎-->选择test目录下的任一个xml文件-->登陆
效果如 :pd-1.jpg;pd-2.jpg

pd-1.jpg

pd-2.jpg
1。引擎为sql2K
双击Anto.exe-->数据库引擎-->输入你要登录的数据库信息-->登陆(有点慢,他在加载数据库的信息~!)
效果如 :db2K-1.jpg;db2K-2.jpg

db2K-1.jpg

db2K-2.jpg
源代码: 下载地址
应用程序: 下载地址
呵呵,介绍完了。
欢迎提出你宝贵的议建!
E_mail:qqcrazyer@126.com
posted @
2007-02-01 09:37 qqcrazyer 阅读(3865) |
评论 (44) |
编辑

2007年1月27日
如果你发现session突然无理由的丢失,而当你认真的检查代码并且排除其它常规可能丢失
的可能性时,你可能会像我一样,几乎要接近崩溃~!
后来发现问题出在我用代码创建一个临时目录然后删除临时目录的删除操作上。
现在和大家分享下:希望对碰到类似钉子的朋友有用。。
说白了session丢失实质就是:应用程序重起!
应用程序什么时候自动重起呢?
请参考:Anand在dotnetindia.com发表的文章

原文引用


{
Why ASP.NET Restarts?
Found this link from one of the blogs I was browsing today. This is ASP.NET Forum post by Patrick Y. Ng of MS.

This talks about both 1.0 and 1.1

This behaviour has been bugging lots of people. ASP.Net will restart its application for various reasons. All these reasons are legitimate, but the side effect is that the application will reset all its cache, application state, and InProc session states.
You can detect the restart of application and worker process by using the performance monitor. The counters to monitor are "ASP.NET\Application Restarts" and "ASP.NET\Worker Process Restarts".

For worker process restart, ASP.NET will write an entry in the eventlog to explain why (logLevel in controls how often eventlog is written).

For application restart, however, in v1 and v1.1 there is no easy way for a customer to figure out why a restart happened.

So by listing all reasons for app restart, I hope I can help some customers to understand and avoid the restart.

For v1
------



{
Things that causes application restart:

- The max compilation limit is reached (look for numRecompilesBeforeApprestart in machine.config)

- Physical application path of the web application has changed.

- Change in global.asax or one of the included files

- Change in machine.config

- Change in web.config in the app root

- Change inside bin directory or its subdirs

- A directory is renamed to bin, or bin is created

- Overwhelming change notifications – too many files are changed too fast in one of content directories – could happen if, for example, files are generated on the fly per request

- Change in the code-access security policy file
}

- The settings of various attributes in in machine.config affect the restart/shutdown of the worker process itself. However, if you use Windows 2003, and (by default) you are NOT using IIS5 isolation mode, is ignored. Instead, the settings in "Application Pools" in IIS manager is used.


For v1.1
--------
The list for v1.1 is the same as v1, with the following new conditions:



{
- User code called HttpRuntime.UnloadAppDomain

- Any directory under the web application folder is renamed
}
IIS 6.0
--------
If you're using IIS 6.0, and you're not using IIS 5 compatible mode, then aspnet_wp.exe will be replaced by w3svc.exe. You may want to go to IIS Manager, go to Application Pools/DefaultAppPool, and see if any of the parameters on the Recycling and Performance tabs are causing the IIS worker process (w3svc.exe) to shutdown.
}


也就是说 asp.net 会监视应用程序目录,一但有被监视
的动作发生(比如:修改了config、重命名目录等)应用程序就会自动重起
当然这时你的session一定丢失了。
如果避免不了这种操作(如:重命名目录);这里我们可以用cookie存信息或存到数据库去;
注意:除了以上列出的英文条件外。目录的删除操作一定丢失session。asp.net的内部机制对待目录有点像个守财奴,它死守着目录,你创建它不会管(往里加),一但创建他就会监视该目录,若你要删除或重命名它的(动它的目录),它就发生重起了。。
posted @
2007-01-27 18:11 qqcrazyer 阅读(2096) |
评论 (24) |
编辑

2007年1月26日
最近在做用asp.net 2.0 开发,在将绑定数据到DropDownList。时抛出了一个很奇怪的异常。
异常详细信息: System.ArgumentOutOfRangeException: “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中。
于是查了一下MSDN:DropDownList.SelectedValue 属性:
此属性返回选定的 ListItem 的 Value 属性。通常使用 SelectedValue 属性确定列表控件中选定项的值。如果选定了多个项,则返回索引最小的选定项的值。如果未选定任何项,则返回一个空字符串 ("")。
SelectedValue 属性还可以用于选择列表控件中的某一项,方法是用该项的值设置此属性。如果列表控件中的任何项都不包含指定值,则会引发 System.ArgumentOutOfRangeException。
检查了一下代码。发现自己在没有绑DropDownList1之前就给DropDownList1.SelectedValue ="qqcrazyer";
怪不得出现异常;这里的DropDownList1没有qqcrazyer这一项。
但是这样赋值在做如市、县连动的值改时候很难避免不碰到赋一个列表没有的值,
怎么办呢?
于是又去反射查了一下SelectedValue的实现,找到了解法。

反射代码
1
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Themeable(false), WebSysDescription("ListControl_SelectedValue"), WebCategory("Behavior"), DefaultValue(""), Bindable(true, BindingDirection.TwoWay)]
2
public virtual string SelectedValue
3

{
4
get
5
{
6
int num1 = this.SelectedIndex;
7
if (num1 >= 0)
8
{
9
return this.Items[num1].Value;
10
}
11
return string.Empty;
12
}
13
set
14
{
15
if (this.Items.Count != 0)
16
{
17
if ((value == null) || (base.DesignMode && (value.Length == 0)))
18
{
19
this.ClearSelection();
20
return;
21
}
22
ListItem item1 = this.Items.FindByValue(value);
23
if ((((this.Page != null) && this.Page.IsPostBack) && this._stateLoaded) && (item1 == null))
24
{
25
throw new ArgumentOutOfRangeException("value", SR.GetString("ListControl_SelectionOutOfRange", new object[]
{ this.ID, "SelectedValue" }));
26
}
27
if (item1 != null)
28
{
29
this.ClearSelection();
30
item1.Selected = true;
31
}
32
}
33
this.cachedSelectedValue = value;
34
}
35
}
36
37
哈哈 原来只有在this.Page.IsPostBack的情况下,赋值才会出错。
只需这样赋值:
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue("qqcrazyer"));
就是如果通过FindByValue没有找到指定项则为null,而Items.IndexOf(null)会返回-1.
posted @
2007-01-26 18:10 qqcrazyer 阅读(5191) |
评论 (15) |
编辑
呵呵,开通。。发篇随笔庆祝一下 2007-1-26 这特殊的日子。
终于有了自己的号,希望园子里的园友们多多关照!
一起供同进步。。
posted @
2007-01-26 13:51 qqcrazyer 阅读(55) |
评论 (0) |
编辑