2007年10月9日

http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form-posting-scenarios.aspx

连接地址.

posted @ 2008-09-03 14:52 暗香浮动 阅读(66) | 评论 (0)编辑

移除StringBuilder 末尾制定个数的字符,以前都是适用下面的方法做的

 

 

            StringBuilder sb = new StringBuilder();
            sb.Append("abcd");
            sb.Remove(sb.Length - 3, 3);
            Console.Write(sb.ToString());
            Console.Read();

其实有更简单的方法的。设定StringBuilder 的长度就ok了。

            StringBuilder sb = new StringBuilder();
            sb.Append("abcd");
            sb.Length--;
            Console.Write(sb.ToString());
            Console.Read();

 

注意string类型的length是只读的。所以不能采用该方法。

posted @ 2008-08-11 09:07 暗香浮动 阅读(76) | 评论 (1)编辑

 

因为项目把抛到客户端的异常信息处理统一放在了基类里面处理

需要把项目中这类的代码
try
            {
                User user = UserDTOMapper.MapFromDTO(userdto);
                msg.Result = DepartmentManager.IsInDepartment(departmentid, user);
                msg.Message = msg.Result ? Resources.OperationSuccessful : Resources.OperationFailur;

            }
            catch (CustomerException e)
            {
                msg.Message = e.Message;
                msg.Result = false;
            }

成为这个
                User user = UserDTOMapper.MapFromDTO(userdto);
                msg.Result = DepartmentManager.IsInDepartment(departmentid, user);
                msg.Message = msg.Result ? Resources.OperationSuccessful : Resources.OperationFailur;

使用了一下vs的正则表达式替换。还真不错。

 

try[ \n]*\{{[:a. \=;\n\:\?\\,)\(]*}[ }\n]*catch[ ]*\(CustomerException [e|ce]\)[\n][ {]*[ \n]*[:a. \=;\n]*\}

 

红色这部分在替换的地方使用 \1即可。

发现竟然会写正则了。这个可能写的还有点繁琐。先用吧,以后用得多了就熟练了。

posted @ 2008-07-31 16:30 暗香浮动 阅读(112) | 评论 (0)编辑


-------------------------------------------------------------------------------
!EEHeap [-gc] [-loader]

 

!EEHeap enumerates process memory consumed by internal CLR data structures. You

can limit the output by passing "-gc" or "-loader". All information will be

displayed otherwise.

 

The information for the Garbage Collector lists the ranges of each Segment in

the managed heap. This can be useful if you believe you have an object pointer.

If the pointer falls within a segment range given by "!EEHeap -gc", then you do

have an object pointer, and can attempt to run "!DumpObj" on it.

 

Here is output for a simple program:

 

0:000> !eeheap -gc

Number of GC Heaps: 1

generation 0 starts at 0x00a71018

generation 1 starts at 0x00a7100c

generation 2 starts at 0x00a71000

 segment    begin allocated     size

00a70000 00a71000  00a7e01c 0000d01c(53276)

Large object heap starts at 0x01a71000

 segment    begin allocated     size

01a70000 01a71000  01a76000 0x00005000(20480)

Total Size   0x1201c(73756)

------------------------------

GC Heap Size   0x1201c(73756)

 

So the total size of the GC Heap is only 72K. On a large web server, with

multiple processors, you can expect to see a GC Heap of 400MB or more. The

Garbage Collector attempts to collect and reclaim memory only when required to

by memory pressure for better performance. You can also see the notion of

"generations," wherein the youngest objects live in generation 0, and

long-lived objects eventually get "promoted" to generation 2.

 

The loader output lists various private heaps associated with AppDomains. It

also lists heaps associated with the JIT compiler, and heaps associated with

Modules. For example:

 

0:000> !EEHeap -loader

Loader Heap:

--------------------------------------

System Domain: 5e0662a0

LowFrequencyHeap:008f0000(00002000:00001000) Size: 0x00001000 bytes.

HighFrequencyHeap:008f2000(00008000:00001000) Size: 0x00001000 bytes.

StubHeap:008fa000(00002000:00001000) Size: 0x00001000 bytes.

Total size: 0x3000(12288)bytes

--------------------------------------

Shared Domain: 5e066970

LowFrequencyHeap:00920000(00002000:00001000) 03e30000(00010000:00003000) Size: 0x00004000 bytes.

Wasted: 0x00001000 bytes.

HighFrequencyHeap:00922000(00008000:00001000) Size: 0x00001000 bytes.

StubHeap:0092a000(00002000:00001000) Size: 0x00001000 bytes.

Total size: 0x6000(24576)bytes

--------------------------------------

Domain 1: 14f000

LowFrequencyHeap:00900000(00002000:00001000) 03ee0000(00010000:00003000) Size: 0x00004000 bytes.

Wasted: 0x00001000 bytes.

HighFrequencyHeap:00902000(00008000:00003000) Size: 0x00003000 bytes.

StubHeap:0090a000(00002000:00001000) Size: 0x00001000 bytes.

Total size: 0x8000(32768)bytes

--------------------------------------

Jit code heap:

Normal JIT:03ef0000(00010000:00002000) Size: 0x00002000 bytes.

Total size: 0x2000(8192)bytes

--------------------------------------

Module Thunk heaps:

Module 5ba22410: Size: 0x00000000 bytes.

Module 001c1320: Size: 0x00000000 bytes.

Module 001c03f0: Size: 0x00000000 bytes.

Module 001caa38: Size: 0x00000000 bytes.

Total size: 0x0(0)bytes

--------------------------------------

Module Lookup Table heaps:

Module 5ba22410:Size: 0x00000000 bytes.

Module 001c1320:Size: 0x00000000 bytes.

Module 001c03f0:Size: 0x00000000 bytes.

Module 001caa38:03ec0000(00010000:00002000) Size: 0x00002000 bytes.

Total size: 0x2000(8192)bytes

--------------------------------------

Total LoaderHeap size: 0x15000(86016)bytes

=======================================

 

By using !EEHeap to keep track of the growth of these private heaps, we are

able to rule out or include them as a source of a memory leak.

posted @ 2008-07-07 13:32 暗香浮动 阅读(20) | 评论 (0)编辑
select 操作
获取所选值  $("#id").val()
清空 empty();
添加项 $("<option value='a'>aa</option>")
posted @ 2008-02-28 16:36 暗香浮动 阅读(36) | 评论 (0)编辑
今天看communicaty 的代码的时候发现了下面这段代码。似乎有点味道。
public T GetDataItem<T>() where T : class
        {
            if (this.Weblog is T)
                return this.Weblog as T;
            else
                return null;
        }
难道有什么深意,如下这么些似乎更好一些。
public T GetDataItem<T>() where T : class
        {
            return this.Weblog as T;
        }
posted @ 2007-12-24 19:46 暗香浮动 阅读(46) | 评论 (2)编辑

自从理解了try catch机制后就有意无意的注意一下优秀的开源软件是如何处理异常捕获和返回值的问题的  

下面这段是community server 上的一段代码。
想研究一下他的异常处理机制

Code

这里的处理比较特殊再try catch内部返回bool型的值。跟踪了一下这个方法的调用 发现使用这个方法的地方存在bool判断。这里不便依靠抛出异常来处理。这么处理放到更方便一些。

posted @ 2007-12-12 12:28 暗香浮动 阅读(95) | 评论 (2)编辑
     摘要: SharpDevelop

强大的插件系统,通过Addin构建成一个功能齐全的.net开发IDE。核心是AddInTree。跟随这个项目开发许多有用的组件,比如功能文本编辑器(ICSharpCode.TextEditor),SharpZipLib等。

链接:http://www.icsharpcode.net/  阅读全文
posted @ 2007-11-08 23:58 暗香浮动 阅读(469) | 评论 (3)编辑
     摘要: 深入理解对象模型对我们理解面向对象的继承多态会大有裨益。
一直没找到C#这方面的知识,粗浅的看过一点侯捷C++对象模型,实际分析问题的时候发现还是没有深入理解。
无奈到园子里来请教大家。也希望高手前辈能够不吝赐教。如果有意写一些C#对象模型相关的文章我想对于新人来说可谓是莫大的帮助。期待,提前感谢。  阅读全文
posted @ 2007-11-02 09:59 暗香浮动 阅读(1996) | 评论 (17)编辑
     摘要: 使用代理来模拟多态

今天在写一个把图片处理成HTML文本显示的时候,在两层的循环嵌套内逐个处理像素。
循环内部处理像素的时候有多种选择。(比如处理成彩色的还是处理成黑白的和其他多种算法。)
如果在这里进行判断的话需要上十万次的相同的与非判断。(彩色的都要判断为真,黑白的相反)
虽说影响不是太大,但是本着写程序的时候需要考虑去掉任何可能影响程序性能的非必须操作。

受设计模式的影响,考虑如果实现成类的话最可能选择的就是strategy模式了。
这里一个简单操作。所以考虑使用代理来模拟类的多态。  阅读全文
posted @ 2007-10-28 17:54 暗香浮动 阅读(100) | 评论 (0)编辑

GPS- Deriving British Ordnance Survey Grid Reference from NMEA data - Part 1 - modify NMEAinterpreter class
How to Write a GPS Application - Introduction

PDU 编码

C++,Delphi 7位编码
GSM MODEM接收短信 C编码

手机发送短消息   (全面)
http://blog.csdn.net/qianbo_0423/archive/2006/02/17/601029.aspx

Use P/Invoke to Develop a .NET Base Class Library for Serial Device Communications
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/default.aspx
This article assumes you're familiar with C# and RS232 communications

AT编程相关技术问题
http://blog.csdn.net/zlyperson/archive/2004/12/15/217316.aspx

Palm 串行通讯GPS数据读取的实现
http://yhyblog.bokee.com/4826431.html

AT指令编程必读

http://www.sendsms.cn/technic/03.htm

基于串口通信的远程自动抄表系统实现

http://www.sendsms.cn/technic/07.htm

 

安瑞尔短信网(下载中心)控件

http://www.forwardsoft.net/pages/product_download.html

通信技术专栏

http://www.sendsms.cn/technic.htm

Visual C#实现自定义组件的设计

发邮件

VC 6.0实现串行通信的三种方法

http://htm.winsteps.net/program/5880.htm

带你了解无线上网卡的安装和设置

http://www.topc.cn/Article/portable/2006030714431366768.htm

基于CDMA 1X的远程监控系统设计

http://www.avrw.com/article/art_115_5340.htm

 

无线论坛

http://www.web54.com/list.aspx?u=f/904/1-500.html

简单而强大的多线程串口编程工具CserialPort类(附VC基于MFC单文档协议通讯源程序及详细编程步骤)

http://www.gjwtech.com/scomm/sc2serialportclass.htm

利用SerialPort类实现收发短信(C# 2.0) (DLL

http://blog.csdn.net/veryhappy/archive/2006/04/05/651949.aspx

.net开发手机短信

http://blog.csdn.net/Awinye/archive/2005/11/28/538300.aspx

短信开发

http://blog.csdn.net/hesicong/category/23319.aspx 很全很全很全

如何通过电脑发送短信——开始篇

http://blog.csdn.net/itcoco/archive/2006/01/12/576911.aspx

 

自己动手打造企业级短信平台(上)

http://blog.csdn.net/devercn/archive/2004/09/21/111809.aspx

PDU短信发送编码程序(C# 2.0[]

http://hi.baidu.com/wang_zan/blog/item/f148bc3514feba8ba61e121e.html

各种无线上网方法比较

http://doreso125.bokee.com/5623391.html

 

VisualStudio2005serialPort控件访问串口实例[转载]

http://www.cublog.cn/u/15586/showart_189530.html

C#开发终端式短信的原理和方法

http://blog.csdn.net/gztoby/archive/2004/09/21/112041.aspx

简介

  没发过短信的年轻人肯定是属于那种受保护的稀有动物,通讯发达的今天短信已经成为人们交流的重要手段,其中也蕴含着巨大的市场和经济利益,掌握短信技术的人才也受到各大公司的追捧是目前职场上耀眼的明星。本文介绍了短信的原理和实现方法,重点说明了短信的编码方式、AT指令以及用C#实现串口通讯的方法。

  前言

  目前,主有三种发送短信的方式:

  1 网关方式:就是向当地的电信部门申请,不需要额外的设备,适用于大型的通信公司,像华为、傲天、中兴、亚信等。

  2 终端方式:就是借助像GSM MODEM之类的设置(支持AT指令的手机也行),通过数据线连接电脑,来发送短信,用这种方法比较适用于小型及个人。要实现这种方式必须理解串口通信、AT指令、短信编码、解码,这也是本文讨论的重点。

  3 利用一些网站来实现,方式简单,不过对网站依赖性太高,对网络的要求也比较高,非常不适于进行项目开发

阅读导航

终端短信连接示意图

原理篇

短信编码

AT指令

串口通讯

实践篇

常见问题

下载

本文源代码

编码测试文件


 

posted @ 2007-10-27 09:21 暗香浮动 阅读(766) | 评论 (0)编辑

doc.Add(new Field("degreename",dr["degreename"].ToString(), Field.Store.NO, Field.Index.UN_TOKENIZED));
程序报错
把degreename替换成替他字符就ok了
还没有来得及研究为什么,做个记号。稍后研究。

posted @ 2007-10-25 21:02 暗香浮动 阅读(20) | 评论 (0)编辑
Get the entire book!
HTTP Programming Recipes for C# Bots

如果要做蜘蛛爬虫相关程序的话可以看看。
该书前面几章是关于 http协议以及iis服务器相关的内容。如果对这部分比较感兴趣可以看一下书的示例代码。功能相当的简单,却可以让你理解服务器的工作原理。
The Hypertext Transfer Protocol (HTTP) allows information to be exchanged between a web server and a web browser. C# allows you to program HTTP directly. HTTP programming allows you to create programs that access the web much like a human user would. These programs, which are called bots, can collect information or automate common web programming tasks. This book presents a collection of very reusable recipes for C# bot programming.


http://www.heatonresearch.com/articles/series/20/
posted @ 2007-10-25 16:07 暗香浮动 阅读(164) | 评论 (0)编辑
posted @ 2007-10-25 14:12 暗香浮动 阅读(20) | 评论 (0)编辑

 

一. 服务端通过Response输出相应的HTTP Response Headers信息,和要下载的文件的数据来把文件发送到客户端,HTTP Response Headers表现在html文件中是下面的形式:
<meta http-equiv="Content-Type" content="text/htm ">
http-equiv表示是Headers的名称,content表示这个Headers的值

二. 首先,要输出文件的MIME类型:
Page.Response.AddHeader( "Content-Type", “MIME类型” );

三. 其次,要输出下载的文件的打开位置和文件名:
Page.Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName );
content-disposition 的 HTTP response header 允许指定文档表示的信息。使用这种 header ,你就可以将文档指定成单独打开(而不是在浏览器中打开),还可以根据用户的操作来显示。如果用户要保存文档,你还可以为该文档建议一个文件名。这个建议名称会出现在 Save As 对话框的“文件名”栏中。
attachment ―― 表示作为附件发送到客户端,客户端将单独打开此文件。
inline ―― 表示将在浏览器中打开这个文件。
filename ―― 表示发送到客户端文件的文件名。

四. 准备发送到客户端的文件数据:
不管什么类型的文件都要先转成byte类型的数组,然后将这个byte数组用Response.BinaryWrite方法输出到客户端。

string path ="G:\\download\\down.txt";
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name));

Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();

对于中文名解决方法:
string filename = System.Web.HttpUtility.UrlEncode( System.Text.Encoding.UTF8.GetBytes(filepath));

posted @ 2007-10-24 17:00 暗香浮动 阅读(37) | 评论 (0)编辑
input{background:expression(this.type=="text"?'#ffffff':'#ccccff')}
posted @ 2007-10-16 10:08 暗香浮动 阅读(164) | 评论 (0)编辑
   当网站做了以下声明时,发现网站上的对联广告无效,其实是document.body.scrollTop无效果了。

当网页做了以下声明时

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    原因是声明后document.body.scrollTop的值永远等于0,解决办法是只需把document.body用document.documentElement替换即可。

posted @ 2007-10-09 18:47 暗香浮动 阅读(284) | 评论 (2)编辑

导航

公告

云南的精云腿月饼好吃. 9-4 21:10
<2007年10月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

统计

与我联系

搜索

 

常用链接

留言簿(2)

我管理的小组

我参与的团队

我的标签

随笔分类

随笔档案

文章分类

舎友

最新评论

阅读排行榜

评论排行榜