Sipo Blog

宁静致远

牛逼的Linq用法

public static void Main()
    {
        // Modify this path as necessary.
        string startFolder = @"c:\program files\Microsoft Visual Studio 9.0\";

        // Take a snapshot of the file system.
        IEnumerable<System.IO.FileInfo> fileList = GetFiles(startFolder);

        // Create the regular expression to find all things "Visual".
        System.Text.RegularExpressions.Regex searchTerm = 
            new System.Text.RegularExpressions.Regex(@"Visual (Basic|C#|C\+\+|J#|SourceSafe|Studio)");

        // Search the contents of each .htm file.
        // Remove the where clause to find even more matches!
        // This query produces a list of files where a match
        // was found, and a list of the matches in that file.
        // Note: Explicit typing of "Match" in select clause.
        // This is required because MatchCollection is not a 
        // generic IEnumerable collection.
        var queryMatchingFiles =
            from file in fileList
            where file.Extension == ".htm"
            let fileText = System.IO.File.ReadAllText(file.FullName)
            let matches = searchTerm.Matches(fileText)
            where searchTerm.Matches(fileText).Count > 0
            select new
            {
                name = file.FullName,
                matches = from System.Text.RegularExpressions.Match match in matches
                          select match.Value
            };

        // Execute the query.
        Console.WriteLine("The term \"{0}\" was found in:", searchTerm.ToString());


        foreach (var v in queryMatchingFiles)
        {
            // Trim the path a bit, then write 
            // the file name in which a match was found.
            string s = v.name.Substring(startFolder.Length - 1);
            Console.WriteLine(s);

            // For this file, write out all the matching strings
            foreach (var v2 in v.matches)
            {
                Console.WriteLine("  " + v2);
            }
        }

        // Keep the console window open in debug mode
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
    }

    // This method assumes that the application has discovery 
    // permissions for all folders under the specified path.
    static IEnumerable<System.IO.FileInfo> GetFiles(string path)
    {
        if (!System.IO.Directory.Exists(path))
            throw new System.IO.DirectoryNotFoundException();

        string[] fileNames = null;
        List<System.IO.FileInfo> files = new List<System.IO.FileInfo>();

        fileNames = System.IO.Directory.GetFiles(path, "*.*", System.IO.SearchOption.AllDirectories);
        foreach (string name in fileNames)
        {
            files.Add(new System.IO.FileInfo(name));
        }
        return files;
    }

狂赞Google挑歌


http://www.google.cn/music/songscreener



曾经我也想做一个这样的东西,当然是用人肉做。还想了很多方法呢。
如今google实现了,特别感叹一下幸亏当时自己没有做。
哇塞
怎么突然觉得这么幸福.
伟大的google

我爱上了FireBug!!

太好用了!

我原来像傻逼一样 alert(record);

现在不用了。终于摆脱alert了。

console.debug(bb);
console.debug(nn);
console.debug(mm);

哇哈哈哈

还要继续发掘 firebug的优势!!!

真是的,这么牛逼的东西现在才想起来用!!!

哎!~

PS:我回北京了

南京~南京~

晚上出差去南京,那么,将会是怎样的生活呢?
恩,住在新街口。貌似离地铁很近啊~~~
很久没有更新BLOG了。好荒凉的感觉。最近都在用校内的说。
SPAM真是头疼。算了,不管那么多了。
现在忽然觉得人的知识越渊博,看的书越多,很多事越不在乎,越能处理好自己的事情。
我算知道为什么很多人都崇尚读书了!
读书是一种调理心境的方法,也是能陶冶情操的。为什么我却无法安心读书呢?
是不是因为有更想完成的事情?还是说没有找到适合自己的书?
那么,什么书适合自己呢?对于书,我总有一种错误的认识,那就是,书都是用来赚钱的。
诚然,也有好书。怎么能否发掘到真正适合自己的好书呢?这是一门学问。
不喜欢读励志的书籍,不喜欢读一个个小故事组成的书籍。难道我喜欢读传记?可是一本都没读过啊。
再说历史人物我也不关心的说,哎,真是头大,居然不知道自己想读什么书。
那么,去泡泡图书馆尝试一下。
恩,绝对不能总工作。要学会安排时间。还是要读书的。
准备找点人,发工资,一起工作。很多事还是要合作的。于是去chinahr登记好了~

IE8很不爽

IE8不好。淘宝也不能用(检查安全控件时直接崩溃)。联通官方充值也不能用(JS错)。

XHS冷库管理软件-冷库管理信息系统

XHS冷库管理信息系统》是集冷库仓储管理、交易、收费结算和物流配送于一体的企业管理软件,具有自主知识产权,适合于各种大中小型冷库,可使企业在管理上节约人力,降低总体运营成本,高效准确便捷。该软件从2003版开始商用,至今已经发展为2009版。

2009》采用B/S(浏览器/服务器)架构,AJAX技术,兼容IEFirefox等浏览器。支持多种数据库:Oracle 9i/10g/11g , Sql Server 2000/2005/2008, MySql 5.0, SQLite 3, Access, Firebird, PostgreSQL给企业用户提供了最大限度的数据存储选择空间。

本系统提供如下功能:

  1. 支持IC卡与手工结合方式的身份验证方式,用户可依权限进行不同操作。
  2. 支持条形码和手工输入方式进行入库出库,生成相关费用单据并打印,条形码是当前廉价且耐低温的高效的自动识别技术。
  3. 支持客户远程WEB查询,手机远程查询功能,可以查询客户库存明细、交费明细、欠费明细、客户通知等内容。
  4. 支持冷藏费按日期波动或固定方式收费,使得企业在变更冷藏费的同时不必为收费结算担忧。可以根据用户编号按任意日期交费,支持费用预交。
  5. 支持万吨级冷库,数据处理效率高,响应时间快速。支持当前库存查询,历史库存查询,库位区位利用率的平面显示。
  6. 支持基本数据设置,包括操作员/客户信息、商品/规格/库位信息、冷藏费/杂费单价类型等。
  7. 货物转仓并生成费用,包括内部转仓外部转仓。库内加工并收取加工费。区位理货可以看到库房区位上货物存放的物理位子并调整查询。
  8. 转户和调户,转户是指货物更换货主并由前货主支付原冷藏费,调户指货物更换货主并且原冷藏费计入后货主帐下。
  9. 租仓,可以对外出租库位签订出租合同,支持库位续租、停租,生成相关报表。
  10. 物流配送,可安排托运车辆,生成运输费、司机工资和相关单据与报表。
  11. 结算,可按日、月、年、客户、商品、时间段等结算生成报表。
  12. 盘点,可以统计库存、盈亏,并实现差额补费。
  13. 业务报表和业务图表,包括吞吐量报表,用户欠费明细,产值报表,商品日报表,库存报表,库存流量分析图表,库存周转率分析图表,财务分析图表等。
  14. 自动备份和自动升级功能。

国内贸易工程设计研究院
地址:北京市右安门外大街99号908室
网址:http://www.xhsrj.com  
电话:010-63565464
传真:010-63565464
手机:13601240832
联系人:梁工
电子邮件:sipo1209@gmail.com

c# 4.0 带命名的默认参数与结合调用法

public class ContactList
{
    List<Contact> SearchForContacts(
        string name = "any",
        int age = -1,
        string address = "any") { ... }

    static void Main()
    {
        ContactList list = new ContactList();
        var x = list.SearchForContacts(age:26);
        list.SearchForContacts(address="home", name="sam", age:30);
    }
}


一个ASP.NET的development server问题?欢迎重现、解释(C#,VS2008)

因为我post到msdn了,想问问为什么,所以开始用鸟文写的。见谅。我鸟文实在不好。

try this code, set two breakpoint at the red text.
先在vs里面试试写下面的这个代码,两个红色的是两个断点,别忘了加上。

class HelloWorldHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();

           //在这个断点触发的时候关上浏览器噢!You must close your browser at this breakpoint,
            context.Response.OutputStream.Write(new byte[]{1}, 0, 1);
            context.Response.Flush();
            var x = context.Response.IsClientConnected;
            //这个时候你发现x是false,如果你看到x=false了那么下面你就能重现我看到的东西了,也就是这个线程不被销毁。 When The x is false then step over next, you will see the thread in server do not destroy.,
            context.Response.End();
        }
        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    } 

//www.dc9.cn
 ----------------

 In order to keep the asp.net development server running ,I use chrome. of course, you can use IE to test this code, if you can keep asp.net development server running when close the IE window.

 因为我用ie做debugger的时候每次关上ie那个什么asp.net development server就跟着关了,让我很光火。于是,在vs上面随便找个文件aspx的吧,点右键,点browse with..选择用chrome做默认的debugger,用这个的好处就是每次关了chrome 你还能监视到asp.net development server的线程。嗯。就这么点作用。要不我就用ie了。

OK, then we need a program to monitor the thread of the asp.net development server , so i use NetLimiter 2 Pro,

然后就是还需要用一个线程监视器,其实用什么无所谓,正好我装了一个netlimiter 2 pro这个就能监视线程了,就用这个了。

You can use any other software to monitor the thread of the asp.net development server .

 当然也可以用其他软件监视asp.net development server

Ok , follow me ,let's go test1.

 好了开始测试1。

1,First, press f5 to Debug. then the chrome window show, vs2008 break at first breakpoint,

1,首先按f5来调试,等到第一个断点触发的时候,把chrome关了。

2,Close the chrome window!

2,对,第一个断点出发的时候关了那个浏览器窗口

3.back to vs2008, press f10 to step over until the next breakpoint

3,然后回去vs2008,f10往下走

4, you will see var x = context.Response.IsClientConnected; the x is false. (  the x must be false,or do it again )

4,走到var x = context.Response.IsClientConnected;的时候你发现x是false,如果x不是false说明你有什么地方没弄好,重来。

5, ok, continue to press f10 to step over context.Response.End();

5,然后继续f10执行完所有代码

6. ok , now all the code have been run. but you can see the current thread of asp.net development server is still alive by  NetLimiter 2 Pro or someother monitor program.

6,这个时候你发现 NetLimiter 2 Pro 监视的刚才的asp.net的线程没有被销毁

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

 

 

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

Ok , now delete the line "var x = context.Response.IsClientConnected;",let's go test2.

 好了,现在你把var x = context.Response.IsClientConnected这句话注释掉,再测试一遍,就正常了!


Code Snippet 2

class HelloWorldHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();

             //在这个断点触发的时候关上浏览器噢!You must close your browser at this breakpoint,
            context.Response.OutputStream.Write(new byte[]{1}, 0, 1);
            context.Response.Flush();
            //var x = context.Response.IsClientConnected;
            //When The x is false then step over next, you will see the thread in server do not destroy.
            context.Response.End();
        }
        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    } 


Ok , follow me ,let's go test2.

 下面开始测试2

1,First, press f5 to Debug. then the chrome window show, vs2008 break at first breakpoint,

1,f5 ,第一个断点到了,关掉浏览器

2,Close the chrome window!

3.back to vs2008, press f10 to step over until the next breakpoint

 3,回到vs 执行完所有代码

4, ok, continue to press f10 to step over context.Response.End();
5. ok , now all the code have been run. you can see the current thread of asp.net development server is destroyed , by  NetLimiter 2 Pro or someother monitor program.

5,你看到那个线程已经被自动销毁了。

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

 

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

我靠,是不是很邪门。 

Oh, It's strange!!!!
 

序列化EXT GRID to Json

var data = new Array();
       var records = mRuKuChuLiPanel.RuKuStore.getRange();
       for (var i = 0; i < records.length; i++) {   
          data.push(records[i].data);
 }
      alert(Ext.util.JSON.encode(data));  
//www.dc9.cn

      

EXT FORM SUBMIT failure 返回的第二个对象

action.response.responseText




form.getForm().submit({
                                    url:'js/tool.aspx',
                                    clientValidation:false,
                                    waitMsg:'Loading...',
                                    params:{action:act,title:n, pkey:JsonKeyParam},
                                    method: 'POST',
                                    success: function(_form,_action){
                                    },
                                    failure: function(_form,_action){
                                        Ext.MessageBox.show({
                                            title: '',
                                            msg: t+'失败<br/>'+_action.response.responseText,
                                            buttons: {cancel:'确定'}
                                        });
                                    }
                                });

«456789101112131415161718»

Powered By Z-Blog 1.8 Walle Build 100427
Copyright Sipo.