档案

Archive for the ‘计算机与 Internet’ Category

中国的互联网是开放的

2010年01月14日 2 条评论
中国的互联网是开放的
中国的互联网是开放的
中国的互联网是开放的
中国的互联网是开放的
中国的互联网是开放的
中国的互联网是开放的
中国的互联网是开放的
 
 
说那么多,你信吗?
 

杯具啊! Bookmark Sync被墙了

2009年11月23日 3 条评论
Chrome是我目前的主力浏览器。我非常看重的一点就是Bookmark Sync。
 
最近在公司里添加的书签,在家里却无法显示。重新登录总是报告"Could not connect to the server"。把笔记本拿到公司翻墙,功能正常。
 
Great Firewall!
 
 

使用魅族M8的一些体会

2009年09月3日 3 条评论
3月份的时候,家里手机1个坏了,1个偷了。不得已,只好同时入手2个手机。考虑到每个预算2000元左右,其中一个选择了水货 HTC Diamond,另外一个就选择了魅族M8。
 
以前从来没用过魅族的产品,也很少见到它的广告。曾经听到某个同事说他买了好几个魅族的MP3,家里人人手一个,让我很吃惊。在一些论坛上,魅族口碑也非常好。( 选择魅族M8的另外一个原因是想体验一下水果机的操作方式。)
 
经过几个月的使用,有下面这些体会:
1。这是个认真做事情的公司(中国不缺少大吹"手机中的战斗机"的公司,但是缺少认真做事埋头苦干的公司)。有篇文章介绍魅族,虽然有吹捧之嫌,但是可以参考一下。
2。产品做工精致,硬件非常棒。3.4寸屏幕720×480 分辨率,非常细腻,字体清晰通透。单凭这块屏幕,2000元左右的手机中性价比最高。(我应该是公司里第一个买M8的,现在同一层楼里估计1/3的人都买了。)
3。 M8虽然是基于Windows CE的,但是操作方式却是模仿水果机的。不得不称赞一下Apple,正是iphone的推出,改变了大家习以为常的手机操作方式,用过之后才知道,原来还能这么做 (以前看到成功人士们左手拿个手机,右手拿只笔在那里戳戳点点。现在都out了)最近老婆抱怨Diamond难用,所以和她换了。习惯了那种操作,再使用Windows Mobile的手机(已经升级到Windows Mobile 6.5),觉得太难用了。(按这个趋势,估计Windows Mobile 7 会长得像水果机)
4。媒体播放效果好,MP3就不用买了(能播放无损压缩的APE格式)
5。利用WIFI,使用内置的Opera浏览器和安装3G坛,在家里基本不用开电脑了。
 
缺点:
使用者或者是其家人最好是喜欢摆弄手机,对电脑系统熟悉点的。
 
 
 
 
 

挣钱要低调啊!

2009年06月15日 2 条评论
一旦高调起来,这个价值4000w的Green Dam就被大家放在聚光灯下照,难免不会爆些漏洞。但是让大家没想到的是,这些漏洞如此低级,又不免让人感慨"哦,这个公司是xx省的"。
 
让我们看看老外对它的评测:
 

http://www.cse.umich.edu/~jhalderm/pub/gd/

 

 

Conclusion

Our brief testing proves that Green Dam contains very serious security vulnerabilities. Unfortunately, these problems seem to reflect systemic flaws in the code. The software makes extensive use of programming techniques that are known to be unsafe, such as deprecated C string processing functions including sprintf and fscanf. These problems are compounded by the design of the program, which creates a large attack surface: since Green Dam filters and processes all Internet traffic, large parts of its code are exposed to attack.

If Green Dam is deployed in its current form, it will significantly weaken China’s computer security. While the flaws we discovered can be quickly patched, correcting all the problems in the Green Dam software will likely require extensive rewriting and thorough testing. This will be difficult to achieve before China’s July 1 deadline for deploying Green Dam nationwide.

 
作为在中国从事IT业的民工,感到羞愧啊。
 
顺便再贴2个同事提供的链接:
 
 

微软必硬?

2009年05月29日 1条评论
 
 
 
 

沃,潮

2009年04月29日 3 条评论
联通"沃"的宣传片里,一群潮人对着镜头撅着嘴喊"沃"。我真得被雷到了。
 
显然联通准备把3G定位于移动一样的动感地带,70年代的人彻底被放弃了。沃,潮。
 
 
 
 
 
 

Microsoft 收购列表

2008年09月5日 1条评论

如何在Workflow项目中使用web service(2)

2006年10月9日 留下评论

17. 在Solution Explorer中双击Workflow1.cs回到设计版面。从Toolbox拖放一个Code activityifElseActivity1的右边分支ifElseBranchActivity2中,并改名为GuessIncorrect。然后鼠标右键点击GuessIncorrect,选择Generate Handles。在 handler中添加代码显示猜错信息,结果如下:

        private void GuessIncorrect_ExecuteCode(object sender, EventArgs e)

        {

            Console.WriteLine("Your Guess was incorrect…");

 

        }

 

18. 在Solution Explorer中双击Workflow1.cs回到设计版面。从Toolbox拖放一个Code activityifElseActivity1下面。并改名为PlayAgain。这个activity接受用户输入,决定是否退出程序。然后鼠标右键点击PlayAgain,选择Generate Handles。在 handler中添加代码接受用户输入是否继续,结果如下:

        private void PlayAgain_ExecuteCode(object sender, EventArgs e)

        {

            Console.Write("Do you want to play again (y/n)?");

            bPlayAgain = Console.ReadKey().Key == ConsoleKey.Y;

            Console.WriteLine();

        }           

 

19. 在Solution Explorer中双击Workflow1.cs回到设计版面。从Toolbox拖放一个Code activitywhileActivity1下面。并改名为GameOver。这个activity用来显示结束信息。然后鼠标右键点击GameOver,选择Generate Handles。在 handler中添加代码,结果如下:

 

        private void GameOver_ExecuteCode(object sender, EventArgs e)

        {

            Console.WriteLine("Game Over");

 

            int nPercent = (int)((double)nCorrectGuesses / nTurns * 100);

 

Console.WriteLine("You played {0} time(s) and were correct {1} time(s).", nTurns, nCorrectGuesses);

            Console.WriteLine("Your accuracy was {0}%", nPercent);

        }

 

20. 从菜单上选Build — > Build Solution确保编译成功。

21. 在Solution Explorer里鼠标右击CoinFlipWorkflow.Workflow1_WebService.asmx然后选择View in Browser,这样asp.net development server会启动并且监听在2149端口上。

22. 在Solution Explorer里鼠标右击CoinToss项目,选择Set as Startup Project。然后按 F5 开始程序,运行状况如图5:

如何在Workflow项目中使用web service(1)

2006年10月9日 留下评论

 

Solution Explorer里鼠标右击.asmx (在这个例子里是CoinFlipWorkflow.Workflow1_WebService.asmx) 然后选择View in Browser

我们应该能正确访问这个web service。记住浏览器里地址栏里的URL.  在这个例子里是

http://localhost:2149/CoinFlipWorkflow_WebService/CoinFlipWorkflow.Workflow1_WebService.asmx

然后我们需要创建一个猜硬币正反面的程序。这个程序会调用刚产生的web service来获得模拟扔硬币正反面的结果。

  1. Visual Studio 2005菜单 上点击 File – > Add — > New ProjectAdd New Project对话框弹出。从Project types里选Visual C# — > Workflow。在templates列表里选Sequential Workflow Console Application。设置NameCoinToss作为新的项目名。点击OK创建了新的workflow project
  2. Toolbox上把一个Code activity拖到设计版面上。改名为Welcome
  3. 然后鼠标右键点击Welcome,选择Generate Handles handler中添加提示代码,结果如下:

        private void Welcome_ExecuteCode(object sender, EventArgs e)

        {

            Console.WriteLine("Welcome to Coin Toss");

            Console.WriteLine("To play, enter either H for Heads or T for Tails.");

        }

  1. 然后在Workflow1 class里添加一个变量作为判断是否结束程序的条件:

        bool bPlayAgain = true;

 

  1. Solution Explorer中双击Workflow1.cs回到设计版面。从Toolbox中把一个While activity拖放到Welcome下面。在属性窗口里设置Condition”Declarative Rule Condition”。展开 Condition设置ConditionNameGameLoopCondition。选中Expression属性,点击右边的省略号按钮,弹出”Rule Condition Editor”。输入(图3):

点击OK关闭。

  1. 因为While activity只允许包含一个activity,我们需要找另外的容器来包含多个activity。从Toolbox中把一个Sequence activity拖放到刚创建的whileActivity1中。
  2. 然后从Toolbox中把一个InvokeWebService activity拖放到刚创建的sequenceActivity1中。”Add web reference”对话框会弹出。在URL文本框中输入web serviceURL。在这个例子里是

http://localhost:2149/CoinFlipWorkflow_WebService/CoinFlipWorkflow.Workflow1_WebService.asmx

点击Go按钮。然后再点击Add Reference加入这个web reference

  1. 鼠标右键点击设计版面然后选择 View Code切换到代码试图。在namespace中加入一个enum代码硬币的正反面:

    enum CoinFlipValue

    {

        cfHeads = 1,

        cfTails = 2

    }

  1. Workflow1类中创建一个成员变量cfCoinToss

CoinFlipValue cfCoinToss;

和一个公共属性CoinToss来存储扔硬币的结果

        public int CoinToss

        {

            get { return (int)cfCoinToss; }

            set

            {

                cfCoinToss = (CoinFlipValue)value;

            }

 }

  1. Solution Explorer中双击Workflow1.cs回到设计版面。
  2. 将刚创建的invokeWebServiceActivity1改名为invokeCoinFlipService。在它的属性窗口里设置MethodNameFlipCoin。然后选中(ReturnValue)属性点击右边的省略号按钮。在Bind to an existing member中选择刚创建的公共属性CoinToss。点击OK。这样invokeCoinFlipService会调用web service并将返回值赋予成员变量 cfCoinToss
  3. Toolbox中把一个Code activity拖到invokeCoinFlipService下面。改名为GetGuess。这个activity用来获取用户的输入。
  4. 然后鼠标右键点击GetGuess,选择Generate Handles。在 handler中添加获取用户输入的代码:

 

        private void GetGuess_ExecuteCode(object sender, EventArgs e)

        {

            // Increment Turn Counter

            nTurns++;

            bool bValidEntry = false;

            while (!bValidEntry)

            {

                bValidEntry = true;

                Console.Write("Enter your guess: H for Heads, T for Tails: ");

                ConsoleKey cGuess = Console.ReadKey().Key;

                Console.WriteLine();

                if (cGuess == ConsoleKey.H)

                {

                    cfGuess = CoinFlipValue.cfHeads;

                }

                else if(cGuess == ConsoleKey.T)

                {

                    cfGuess = CoinFlipValue.cfTails;

                }

                else

                {

                    Console.WriteLine("Invalid Entry.");

                    bValidEntry = false;

                }

            }

 }

 

  1. 添加Workflow1类的成员变量nTurns用来记录猜硬币的次数和cfGuess用来记录用户的输入:

        int nTurns = 0;

            CoinFlipValue cfGuess;

 

 

  1. Solution Explorer中双击Workflow1.cs回到设计版面。从Toolbox把一个IfElse activity拖放到GetGuess下面。选中这个ifElseActivity1左边分支ifElseBranchActivity1,将它改名为IfCorrect。然后在属性窗口里设置Condition”Code Condition”。然后展开Condition。在下面的Condition属性输入CheckGuessRule,然后回车。 如图:

成员函数CheckGuessRule会被自动产生,我们添加如下代码用来判断是否猜对硬币:

        private void CheckGuessRule(object sender, ConditionalEventArgs e)

        {

            e.Result = cfGuess == cfCoinToss;

 

        }

  1. Solution Explorer中双击Workflow1.cs回到设计版面。从Toolbox拖放一个Code activityIfCorrect中,并改名为GuessCorrect。然后鼠标右键点击GuessCorrect,选择Generate Handles。在 handler中添加代码显示猜对信息,结果如下:

        private void GuessCorrect_ExecuteCode(object sender, EventArgs e)

        {

            nCorrectGuesses++;

            Console.WriteLine("Your Guess was correct!");

 

        }

再添加一个Workflow1类的成员变量nCorrectGuesses用来记录猜中的次数:

        int nCorrectGuesses = 0;

 

如何把Workflow项目发布成web service

2006年10月9日 留下评论

这里讲的workflow指的是Windows Workflow Foundation (WF) 生成的workflow。

http://wf.netfx3.com/

 

将一个workflow发布成web service需要以下的额外步骤:

  1. 定义一个interface作为web serviceinterface.
  2. WebServiceInputActivity WebServiceOutputActivity拖到你的workflow上并且和你所定义的web service interface绑定。
  3. WebServiceInputActivity WebServiceOutputActivity属性里的输入参数和返回值和workflow里的变量绑定。
  4. 运行向导把你的 workflow项目发布为web service

 

我们以一个翻硬币的程序作为例子。

Task  1  创建一个 workflow project

  1. 打开 Visual Studio 2005
  2. 从菜单选择 File — > New — > Project。出现 New project对话框。
  3. Project types 树中选择 Visual C# — > Workflow。在templates列表中选Sequential Workflow Library。输入项目名字 CoinFlipWorkflow
  4. 然后点击OK产生一个空的workflow project

 

Task 2 – 编辑一个翻硬币的workflow

  1. Solution Explorer里鼠标右键选择Workflow1.cs,然后选择View Code
  2. 将下面的interface定义添加到namespace

    //Webservice interface definition for the workflow

    public interface ICoinFlipService

    {

        int FlipCoin();

    }

  1. 这个interface作为web service的接口。
  2. Solution Explorer里双击Workflow1.cs 回到Design View。从Toolbox中把一个WebServiceInput activity拖到设计版面上Sequential Workflow绿色箭头下面。改名为 webServiceReceive
  3. Toolbox中把一个WebServiceOutput activity拖到webServiceReceive activity下面。并改名为webServiceResponse
  4. 在设计版面上选中webServiceReceive,在Property窗口里选择Interface Type,然后点击旁边的省略号按钮。在弹出的”Browse and Select a .Net type”窗口中,选中我们刚刚定义的接口ICoinFlipService。点击OK按钮。
  5. Property窗口里设置如下的属性:
    1. IsActivating: True
    2. MethodName: FlipCoin
  6. 在设计版面上选中webServiceResponse。在Property窗口里将InputActivityName设置为webServiceReceive。然后选择(ReturnValue)属性,点击点击旁边的省略号按钮。选择”Bind to a new member”分页。再选择”Create Field”,New member name改为nFlipValue。最后点击OK。这样一个新的成员变量被产生在Workflow1里。鼠标右键点击设计版面然后选择”View Code”。下面的代码已经被添加在类Workflow1里:

public Int32 nFlipValue = default(System.Int32);

  1. Solution Explorer里双击Workflow1.cs 回到Design View。从Toolbox里把一个Code activity拖曳到webServiceReceivewebServiceResponse中间。
  2. 鼠标右键点击codeActivity1,选择Generate Handles。以下的成员函数会被自动创建:

        private void codeActivity1_ExecuteCode(object sender, EventArgs e)

        {

 

        }

  1. 在上面的成员函数里添加代码,随机产生整数121代表硬币的正面,2代表反面。并将结果赋予成员变量nFlipValue。最终代码如下:

        private void codeActivity1_ExecuteCode(object sender, EventArgs e)

        {

            // 1 for Heads, 2 for Tails

            nFlipValue = new Random().Next(1, 3);

        }

Solution Explorer里双击Workflow1.cs 回到Design View。图1是这个workflow的视图。

 

Task 3 – workflow发布为一个web service

  1. 从菜单上选Build — > Build Solution确保这个workflow能编译成功。
  2. Solution Explorer里鼠标右键点击CoinFlipWorkflow项目然后选择”Publish as Web Service”
  3. 一个新的project CoinFlipWorkflow_WebService被产生于同一个solution下面。
  4. 你会注意到:
    1. 一个新的.asmx文件指出这个web service是从CoinFlipWorkflow.Workflow1_WebService继承下来。

<%@WebService Class="CoinFlipWorkflow.Workflow1_WebService" %>

    1. web.config 中修改HTTPPipeline来运行workflow

            <httpModules>

                    <add type="System.Workflow.Runtime.Hosting.WorkflowWebHostingModule, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="WorkflowHost"/>

            </httpModules>

    1. web.config中加入workflow runtime services的配置

    <configSections>

            <section name="WorkflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

    </configSections>

    <WorkflowRuntime Name="WorkflowServiceContainer">

            <Services>

                    <add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

                    <add type="System.Workflow.Runtime.Hosting.DefaultWorkflowCommitWorkBatchService, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

            </Services>

    </WorkflowRuntime>

 

  1. web service被成功创建后,一个确认对话框会弹出(图2)。点击OK关闭。

 

  6. 在Solution Explorer里选中刚产生的web service project,在属性窗口把”Use Dynamic ports”改为false,然后设置Port number。在这个例子里我们设置端口号为2149