10月 31

Abstract Factory(抽象工厂模式):提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类。

Adapter(适配器模式):将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。

Bridge(桥接模式):将抽象部分与它的实现部分分离,使它们都可以独立地变化。

Builder(建造者模式):将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。

Chain of Responsibility(职责链模式):为解除请求的发送者和接收者之间耦合,而使多个对象都有机会处理这个请求。将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它。

Command(命令模式):将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化;对请求排队或记录请求日志,以及支持可取消的操作。

Composite(组合模式):将对象组合成树形结构以表示“部分-整体”的层次结构。它使得客户对单个对象和复合对象的使用具有一致性。

Decorator(装饰模式):动态地给一个对象添加一些额外的职责。就扩展功能而言, 它比生成子类方式更为灵活。

Facade(外观模式):为子系统中的一组接口提供一个一致的界面,Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。

Factory Method(工厂模式):定义一个用于创建对象的接口,让子类决定将哪一个类实例化。Factory Method使一个类的实例化延迟到其子类。

Flyweight(享元模式):运用共享技术有效地支持大量细粒度的对象。

Interpreter(解析器模式):给定一个语言, 定义它的文法的一种表示,并定义一个解释器, 该解释器使用该表示来解释语言中的句子。

Iterator(迭代器模式):提供一种方法顺序访问一个聚合对象中各个元素,而又不需暴露该对象的内部表示。

Mediator(中介模式):用一个中介对象来封装一系列的对象交互。中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互。

Memento(备忘录模式):在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将该对象恢复到保存的状态。

Observer(观察者模式):定义对象间的一种一对多的依赖关系,以便当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并自动刷新。

Prototype(原型模式):用原型实例指定创建对象的种类,并且通过拷贝这个原型来创建新的对象。

Proxy(代理模式):为其他对象提供一个代理以控制对这个对象的访问。

Singleton(单例模式):保证一个类仅有一个实例,并提供一个访问它的全局访问点。 单例模式是最简单的设计模式之一,但是对于Java的开发者来说,它却有很多缺陷。在九月的专栏中,David Geary探讨了单例模式以及在面对多线程(multi-threading)、类装载器(class loaders)和序列化(serialization)时如何处理这些缺陷。

State(状态模式):允许一个对象在其内部状态改变时改变它的行为。对象看起来似乎修改了它所属的类。

Strategy(策略模式):定义一系列的算法,把它们一个个封装起来, 并且使它们可相互替换。本模式使得算法的变化可独立于使用它的客户。

Template Method(模板方法模式):定义一个操作中的算法的骨架,而将一些步骤延迟到子类中。Template Method使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤。

Visitor(访问者模式):表示一个作用于某对象结构中的各元素的操作。它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作。

written by ocean

10月 24

2014.9.16更新一种简单的方法

在IIS里如果没有Web Platform Installer 需要安装

http://www.microsoft.com/web/downloads/

在Web Platform Installer里面安装PHP Manager for IIS

 =====================================华丽丽的分割线=================================================================

Windows添加新的Features

CGI打钩,路径如下

Internet Information Services=>World Wide Web Services=>Application Development Features=>CGI

下载PHP,地址  http://windows.php.net/download/

解压到C盘  "C:\Green\php-5.4.21-Win32-VC9-x86"

IIS管理中  "Handler Mapping"添加映射

Request path    

*.php

Module:

FastCgiModule

Executable

C:\Green\php-5.4.21-Win32-VC9-x86\php-cgi.exe

Name

PHP

修改C:\Green\php-5.4.21-Win32-VC9-x86\php.ini-development

data.timezone修改为data.timezone="Asia/Shanghai”即修改当前的时区

extension_dir修改为extension_dir = "C:\Green\php-5.4.21-Win32-VC9-x86\ext\"

在IIS目录中新建test.php

内容为   <?php phpinfo(); ?>  

written by ocean

10月 19

最近公司项目要做Workflow, 查了一圈下来觉得还是用Microsoft的最好

陆陆续续学了一些东西,最大的疑问就是这些东西怎么实践到具体的项目

找到一个例子 Workflow结合ASP.NET的, 写的挺好,记录一下

基于Visual Studio 2010

Microsoft Windows Workflow Foundation (WWF) 4.5

首先画业务流程,如下(XAML记录)

<Activity mc:Ignorable="sap sap2010 sads" x:Class="WFTest.ActivityLibrary.Greeting"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Members>
    <x:Property Name="Result" Type="OutArgument(x:String)" />
    <x:Property Name="ArgUserName" Type="InArgument(x:String)" />
  </x:Members>
  <sap2010:ExpressionActivityEditor.ExpressionActivityEditor>C#</sap2010:ExpressionActivityEditor.ExpressionActivityEditor>
  <sap2010:WorkflowViewState.IdRef>WFTest.ActivityLibrary.Greeting_1</sap2010:WorkflowViewState.IdRef>
  <TextExpression.NamespacesForImplementation>
    <sco:Collection x:TypeArguments="x:String">
      <x:String>System</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Linq</x:String>
      <x:String>System.Text</x:String>
    </sco:Collection>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <sco:Collection x:TypeArguments="AssemblyReference">
      <AssemblyReference>Microsoft.CSharp</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Activities</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System.Runtime.Serialization</AssemblyReference>
      <AssemblyReference>System.ServiceModel</AssemblyReference>
      <AssemblyReference>System.ServiceModel.Activities</AssemblyReference>
      <AssemblyReference>System.Xaml</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
      <AssemblyReference>System.Xml.Linq</AssemblyReference>
      <AssemblyReference>PresentationFramework</AssemblyReference>
      <AssemblyReference>PresentationCore</AssemblyReference>
      <AssemblyReference>System.Activities.Presentation</AssemblyReference>
      <AssemblyReference>WindowsBase</AssemblyReference>
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>WFTest.ActivityLibrary</AssemblyReference>
    </sco:Collection>
  </TextExpression.ReferencesForImplementation>
  <Sequence sap2010:WorkflowViewState.IdRef="Sequence_1">
    <Assign sap2010:WorkflowViewState.IdRef="Assign_1">
      <Assign.To>
        <OutArgument x:TypeArguments="x:String">
          <mca:CSharpReference x:TypeArguments="x:String">Result</mca:CSharpReference>
        </OutArgument>
      </Assign.To>
      <Assign.Value>
        <InArgument x:TypeArguments="x:String">
          <mca:CSharpValue x:TypeArguments="x:String">"Hello " + ArgUserName</mca:CSharpValue>
        </InArgument>
      </Assign.Value>
    </Assign>
    <sads:DebugSymbol.Symbol>dzNEOlxUZXN0XFdGVGVzdFxXRlRlc3QuQWN0aXZpdHlMaWJyYXJ5XEdyZWV0aW5nLnhhbWwELwM9DgIBATAFOw4CAQI4CzhfAgEGMwszVwIBAw==</sads:DebugSymbol.Symbol>
  </Sequence>
  <sap2010:WorkflowViewState.ViewStateManager>
    <sap2010:ViewStateManager>
      <sap2010:ViewStateData Id="Assign_1" sap:VirtualizedContainerService.HintSize="242,62" />
      <sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="264,186">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="WFTest.ActivityLibrary.Greeting_1" sap:VirtualizedContainerService.HintSize="304,266" />
    </sap2010:ViewStateManager>
  </sap2010:WorkflowViewState.ViewStateManager>
</Activity>

ASP.NET调用

如下

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Workflow.Web.Default" %> 
   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
   
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
        <asp:Label Text="Your name: " runat="server" /> 
        <asp:TextBox ID="TextBoxName" runat="server" /> 
        <asp:Button ID="btnClick" Text="Test Click" runat="server"
            onclick="btnClick_Click" /> 
        <br /> 
        <asp:Label ID="LabelGreeting" Text="" runat="server" /> 
    </div> 
    </form> 
</body> 
</html>
using System; 
using System.Activities; 
using System.Collections.Generic; 
using WorkflowLibrary; 
   
namespace Workflow.Web 
{ 
    public partial class Default : System.Web.UI.Page 
    {  
        protected void btnClick_Click(object sender, EventArgs e) 
        { 
            string username = TextBoxName.Text; 
   
            Greeting greeting = new Greeting { ArgUserName = username }; 
   
            IDictionary<string, object> results = WorkflowInvoker.Invoke(greeting); 
            LabelGreeting.Text = results["Result"].ToString(); 
        } 
    } 
}

 

学习地址:http://social.technet.microsoft.com/wiki/contents/articles/5284.getting-started-windows-workflow-foundation-and-asp-net.aspx

written by ocean

10月 15

主要用到了 SqlWorkflowInstanceStore

SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(Const.ConnectionString);  
InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));  
instanceStore.DefaultInstanceOwner = view.InstanceOwner;

触发持久化数据库

application.Unload();  
    
或者              
    
            application.PersistableIdle = (e) =>  
            {  
                return PersistableIdleAction.Unload;  
            };

 全部代码

 

流程

<Activity mc:Ignorable="sap sap2010 sads" x:Class="WFTest.WorkflowConsole.Activity1"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:local="clr-namespace:WFTest.WorkflowConsole"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
  <x:Members> 
    <x:Property Name="argument1" Type="OutArgument(x:String)" /> 
  </x:Members> 
  <sap2010:ExpressionActivityEditor.ExpressionActivityEditor>C#</sap2010:ExpressionActivityEditor.ExpressionActivityEditor> 
  <sap2010:WorkflowViewState.IdRef>WFTest.WorkflowConsole.Activity1_1</sap2010:WorkflowViewState.IdRef> 
  <TextExpression.NamespacesForImplementation> 
    <sco:Collection x:TypeArguments="x:String"> 
      <x:String>System</x:String> 
      <x:String>System.Collections.Generic</x:String> 
      <x:String>System.Data</x:String> 
      <x:String>System.Linq</x:String> 
      <x:String>System.Text</x:String> 
    </sco:Collection> 
  </TextExpression.NamespacesForImplementation> 
  <TextExpression.ReferencesForImplementation> 
    <sco:Collection x:TypeArguments="AssemblyReference"> 
      <AssemblyReference>Microsoft.CSharp</AssemblyReference> 
      <AssemblyReference>System</AssemblyReference> 
      <AssemblyReference>System.Activities</AssemblyReference> 
      <AssemblyReference>System.Activities.DurableInstancing</AssemblyReference> 
      <AssemblyReference>System.Core</AssemblyReference> 
      <AssemblyReference>System.Data</AssemblyReference> 
      <AssemblyReference>System.Runtime.DurableInstancing</AssemblyReference> 
      <AssemblyReference>System.Runtime.Serialization</AssemblyReference> 
      <AssemblyReference>System.ServiceModel</AssemblyReference> 
      <AssemblyReference>System.ServiceModel.Activities</AssemblyReference> 
      <AssemblyReference>System.Xaml</AssemblyReference> 
      <AssemblyReference>System.Xml</AssemblyReference> 
      <AssemblyReference>System.Xml.Linq</AssemblyReference> 
      <AssemblyReference>WFTest.ActivityLibrary</AssemblyReference> 
      <AssemblyReference>mscorlib</AssemblyReference> 
      <AssemblyReference>WFTest.WorkflowConsole</AssemblyReference> 
    </sco:Collection> 
  </TextExpression.ReferencesForImplementation> 
  <Sequence sap2010:WorkflowViewState.IdRef="Sequence_1"> 
    <WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_1" Text="1111111111" /> 
    <local:noResultBookmark BookmarkName="xxxx" sap2010:WorkflowViewState.IdRef="noResultBookmark_1" /> 
    <WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_2" Text="2222222" /> 
    <sads:DebugSymbol.Symbol>dzREOlxUZXN0XFdGVGVzdFxXRlRlc3QuV29ya2Zsb3dDb25zb2xlXEFjdGl2aXR5MS54YW1sBy0DMg4CAQEuBS5SAgEGLwUvaAIBBDAFME8CAQIuQy5PAgEHLyovMAIBBTBDMEwCAQM=</sads:DebugSymbol.Symbol> 
  </Sequence> 
  <sap2010:WorkflowViewState.ViewStateManager> 
    <sap2010:ViewStateManager> 
      <sap2010:ViewStateData Id="WriteLine_1" sap:VirtualizedContainerService.HintSize="211,62" /> 
      <sap2010:ViewStateData Id="noResultBookmark_1" sap:VirtualizedContainerService.HintSize="211,22" /> 
      <sap2010:ViewStateData Id="WriteLine_2" sap:VirtualizedContainerService.HintSize="211,62" /> 
      <sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="233,350"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="WFTest.WorkflowConsole.Activity1_1" sap:VirtualizedContainerService.HintSize="273,430" /> 
    </sap2010:ViewStateManager> 
  </sap2010:WorkflowViewState.ViewStateManager> 
</Activity>

活动 noResultBookmark

using System; 
using System.Activities; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
  
namespace WFTest.WorkflowConsole 
{ 
    public sealed class noResultBookmark : NativeActivity 
    { 
  
        public InArgument<string> BookmarkName { get; set; } 
  
        protected override bool CanInduceIdle 
        {  
            get 
            { return true; }  
        } 
  
  
        protected override void Execute(NativeActivityContext context) 
        { 
            string bookmark = context.GetValue(BookmarkName); 
  
            context.CreateBookmark(bookmark); 
  
            System.Console.WriteLine("创建bookmark:{0}", bookmark); 
        } 
    } 
}

 

控制类

 

using System; 
using System.Activities; 
using System.Activities.DurableInstancing; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.DurableInstancing; 
using System.Text; 
using System.Threading; 
using System.Threading.Tasks; 
  
namespace WFTest.WorkflowConsole 
{ 
    public class MainClass 
    { 
  
  
        protected static AutoResetEvent reset = new AutoResetEvent(false); 
        public void Start() 
        { 
            WorkflowApplication application = new WorkflowApplication(new Activity1()); 
  
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(Const.ConnectionString); 
            InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30)); 
            instanceStore.DefaultInstanceOwner = view.InstanceOwner; 
  
            application.InstanceStore = instanceStore; 
  
  
  
  
            application.Completed = new Action<WorkflowApplicationCompletedEventArgs>(a => 
            { 
                application = null; 
                System.Console.WriteLine("workflowCompleted:{0}", a.CompletionState.ToString()); 
            }); 
  
  
  
            application.OnUnhandledException = a => 
            { 
                System.Console.WriteLine("unhandledException:{0}", a.UnhandledException.Message); 
                return UnhandledExceptionAction.Cancel; 
            }; 
  
  
  
            application.Aborted = a => 
            { 
                application = null; 
                System.Console.WriteLine("aborted ,Reason:{0}", a.Reason.Message); 
            }; 
  
  
  
            application.Idle = a => 
            { 
                reset.Set(); 
                Console.WriteLine("OnIdle"); 
  
            }; 
               
  
            application.Run(); 
            reset.WaitOne(); 
            application.Unload(); 
  
            application.PersistableIdle = (e) => 
            { 
                return PersistableIdleAction.Unload; 
            }; 
  
  
  
            //获取工作流实列Id 
            Guid installGuid = application.Id; 
  
        } 
  
  
        public void Load() 
        { 
  
            string bookName = "xxxx"; 
  
  
  
  
            WorkflowApplication application = new WorkflowApplication(new Activity1()); 
  
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(Const.ConnectionString); 
            InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30)); 
            instanceStore.DefaultInstanceOwner = view.InstanceOwner; 
  
            application.InstanceStore = instanceStore; 
  
  
            Guid guid = new Guid("0DAEC18F-D828-46B5-A397-D46A8A4DB4D1"); 
            application.Load(guid); 
  
  
  
            if (application.GetBookmarks().Count(p => p.BookmarkName == bookName) == 1) 
            { 
  
                application.ResumeBookmark(bookName, bookName); 
  
            } 
        } 
    } 
}

入口类

using System; 
using System.Linq; 
using System.Activities; 
using System.Activities.Statements; 
using System.Diagnostics; 
using System.Collections.Generic; 
using System.Threading; 
using System.Activities.DurableInstancing; 
using System.Runtime.DurableInstancing; 
  
namespace WFTest.WorkflowConsole 
{ 
  
    class Program 
    { 
  
  
        static void Main(string[] args) 
        { 
  
  
            MainClass main = new MainClass(); 
            //      main.Start();  //创建流程 
            main.Load();     //加载流程 
  
  
            Console.WriteLine("End"); 
  
            Console.Read(); 
        } 
  
  
    } 
}

 

 

written by ocean

10月 11

基于WF4.5  VS2012

 

今天有点发低烧,直接贴代码了

 

xaml代码

 

<Activity mc:Ignorable="sap sap2010 sads" x:Class="WFTest.WorkflowConsole.Activity1" sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#" sap2010:WorkflowViewState.IdRef="WFTest.WorkflowConsole.Activity1_1"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:wa="clr-namespace:WFTest.ActivityLibrary;assembly=WFTest.ActivityLibrary"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
  <TextExpression.NamespacesForImplementation> 
    <sco:Collection x:TypeArguments="x:String"> 
      <x:String>System</x:String> 
      <x:String>System.Collections.Generic</x:String> 
      <x:String>System.Data</x:String> 
      <x:String>System.Linq</x:String> 
      <x:String>System.Text</x:String> 
    </sco:Collection> 
  </TextExpression.NamespacesForImplementation> 
  <TextExpression.ReferencesForImplementation> 
    <sco:Collection x:TypeArguments="AssemblyReference"> 
      <AssemblyReference>Microsoft.CSharp</AssemblyReference> 
      <AssemblyReference>System</AssemblyReference> 
      <AssemblyReference>System.Activities</AssemblyReference> 
      <AssemblyReference>System.Core</AssemblyReference> 
      <AssemblyReference>System.Data</AssemblyReference> 
      <AssemblyReference>System.Runtime.Serialization</AssemblyReference> 
      <AssemblyReference>System.ServiceModel</AssemblyReference> 
      <AssemblyReference>System.ServiceModel.Activities</AssemblyReference> 
      <AssemblyReference>System.Xaml</AssemblyReference> 
      <AssemblyReference>System.Xml</AssemblyReference> 
      <AssemblyReference>System.Xml.Linq</AssemblyReference> 
      <AssemblyReference>WFTest.ActivityLibrary</AssemblyReference> 
      <AssemblyReference>mscorlib</AssemblyReference> 
      <AssemblyReference>WFTest.WorkflowConsole</AssemblyReference> 
    </sco:Collection> 
  </TextExpression.ReferencesForImplementation> 
  <Sequence sap2010:WorkflowViewState.IdRef="Sequence_7"> 
    <WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_2" Text="http://blog.wx6.org Start" /> 
    <Flowchart sap2010:WorkflowViewState.IdRef="Flowchart_1"> 
      <Flowchart.Variables> 
        <Variable x:TypeArguments="x:String" Name="variable1" /> 
      </Flowchart.Variables> 
      <Flowchart.StartNode> 
        <FlowStep x:Name="__ReferenceID0" sap2010:WorkflowViewState.IdRef="FlowStep_1"> 
          <WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_3" Text="Test" /> 
          <FlowStep.Next> 
            <FlowDecision x:Name="__ReferenceID1" Condition="True" sap2010:WorkflowViewState.IdRef="FlowDecision_1"> 
              <FlowDecision.True> 
                <FlowStep x:Name="__ReferenceID4" sap2010:WorkflowViewState.IdRef="FlowStep_4"> 
                  <wa:CodeActivity1 sap2010:WorkflowViewState.IdRef="CodeActivity1_1" InputText="我是自定义的CodeActivity的参数"> 
                    <wa:CodeActivity1.OutputText> 
                      <OutArgument x:TypeArguments="x:String"> 
                        <mca:CSharpReference x:TypeArguments="x:String">variable1</mca:CSharpReference> 
                      </OutArgument> 
                    </wa:CodeActivity1.OutputText> 
                  </wa:CodeActivity1> 
                  <FlowStep.Next> 
                    <FlowStep x:Name="__ReferenceID2" sap2010:WorkflowViewState.IdRef="FlowStep_2"> 
                      <WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_5"> 
                        <InArgument x:TypeArguments="x:String"> 
                          <mca:CSharpValue x:TypeArguments="x:String">variable1</mca:CSharpValue> 
                        </InArgument> 
                      </WriteLine> 
                    </FlowStep> 
                  </FlowStep.Next> 
                </FlowStep> 
              </FlowDecision.True> 
              <FlowDecision.False> 
                <FlowStep x:Name="__ReferenceID3" sap2010:WorkflowViewState.IdRef="FlowStep_3"> 
                  <WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_6" Text="false" /> 
                </FlowStep> 
              </FlowDecision.False> 
            </FlowDecision> 
          </FlowStep.Next> 
        </FlowStep> 
      </Flowchart.StartNode> 
      <x:Reference>__ReferenceID0</x:Reference> 
      <x:Reference>__ReferenceID1</x:Reference> 
      <x:Reference>__ReferenceID2</x:Reference> 
      <x:Reference>__ReferenceID3</x:Reference> 
      <x:Reference>__ReferenceID4</x:Reference> 
    </Flowchart> 
    <WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_4" Text="http://blog.wx6.org End" /> 
    <sads:DebugSymbol.Symbol>dzREOlxUZXN0XFdGVGVzdFxXRlRlc3QuV29ya2Zsb3dDb25zb2xlXEFjdGl2aXR5MS54YW1sECgDWA4CAQEpBSlhAgERKgVVEQIBBFYFVl8CAQIpQyleAgESMAswUgIBDzI9MkMCAQ5JE0lbAgEMNRM7JgIBCD4XQiMCAQVWQ1ZcAgEDMEkwTwIBEElRSVgCAQ04GThoAgEKNWE1eAIBCUAbQGICAQY=</sads:DebugSymbol.Symbol> 
  </Sequence> 
  <sap2010:WorkflowViewState.ViewStateManager> 
    <sap2010:ViewStateManager> 
      <sap2010:ViewStateData Id="WriteLine_2" sap:VirtualizedContainerService.HintSize="211,62" /> 
      <sap2010:ViewStateData Id="WriteLine_3" sap:VirtualizedContainerService.HintSize="211,62"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="CodeActivity1_1" sap:VirtualizedContainerService.HintSize="200,22"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="WriteLine_5" sap:VirtualizedContainerService.HintSize="211,62"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="FlowStep_2"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <av:Point x:Key="ShapeLocation">104.5,519</av:Point> 
            <av:Size x:Key="ShapeSize">211,62</av:Size> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="FlowStep_4"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <av:Point x:Key="ShapeLocation">120,389</av:Point> 
            <av:Size x:Key="ShapeSize">200,22</av:Size> 
            <av:PointCollection x:Key="ConnectorLocation">220,411 220,441 210,441 210,519</av:PointCollection> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="WriteLine_6" sap:VirtualizedContainerService.HintSize="211,62"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="FlowStep_3"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <av:Point x:Key="ShapeLocation">354.431666666667,319.01953125</av:Point> 
            <av:Size x:Key="ShapeSize">211,62</av:Size> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="FlowDecision_1" sap:VirtualizedContainerService.HintSize="70,87"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
            <av:Point x:Key="ShapeLocation">265,226.5</av:Point> 
            <av:Size x:Key="ShapeSize">70,87</av:Size> 
            <av:PointCollection x:Key="TrueConnector">265,270 220,270 220,389</av:PointCollection> 
            <av:PointCollection x:Key="FalseConnector">335,270 459.931666666667,270 459.931666666667,319.01953125</av:PointCollection> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="FlowStep_1"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <av:Point x:Key="ShapeLocation">224.431666666667,129.01953125</av:Point> 
            <av:Size x:Key="ShapeSize">211,62</av:Size> 
            <av:PointCollection x:Key="ConnectorLocation">329.931666666667,191.01953125 329.931666666667,221.01953125 300,221.01953125 300,226.5</av:PointCollection> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="Flowchart_1" sap:VirtualizedContainerService.HintSize="211,51"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">False</x:Boolean> 
            <av:Point x:Key="ShapeLocation">270,2.5</av:Point> 
            <av:Size x:Key="ShapeSize">60,75</av:Size> 
            <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 329.931666666667,107.5 329.931666666667,129.01953125</av:PointCollection> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="WriteLine_4" sap:VirtualizedContainerService.HintSize="211,62" /> 
      <sap2010:ViewStateData Id="Sequence_7" sap:VirtualizedContainerService.HintSize="233,379"> 
        <sap:WorkflowViewStateService.ViewState> 
          <scg:Dictionary x:TypeArguments="x:String, x:Object"> 
            <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
          </scg:Dictionary> 
        </sap:WorkflowViewStateService.ViewState> 
      </sap2010:ViewStateData> 
      <sap2010:ViewStateData Id="WFTest.WorkflowConsole.Activity1_1" sap:VirtualizedContainerService.HintSize="273,459" /> 
    </sap2010:ViewStateManager> 
  </sap2010:WorkflowViewState.ViewStateManager> 
</Activity>

自定义的流程代码

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Activities; 
  
namespace WFTest.ActivityLibrary 
{ 
  
    public sealed class CodeActivity1 : CodeActivity 
    { 
        // Define an activity input argument of type string 
        public InArgument<string> InputText { get; set; } 
  
        // Define an activity input argument of type string 
        public OutArgument<string> OutputText { get; set; }  
  
        // If your activity returns a value, derive from CodeActivity<TResult> 
        // and return the value from the Execute method. 
        protected override void Execute(CodeActivityContext context) 
        { 
            string dbValue = "我是DB里的数据," + context.GetValue(this.InputText); 
  
  
            context.SetValue(this.OutputText, dbValue); 
        } 
    } 
}

调用代码

using System; 
using System.Linq; 
using System.Activities; 
using System.Activities.Statements; 
  
namespace WFTest.WorkflowConsole 
{ 
  
    class Program 
    { 
        static void Main(string[] args) 
        { 
  
            Console.WriteLine("Start"); 
  
            Activity workflow1 = new Activity1(); 
            WorkflowInvoker.Invoke(workflow1); 
  
            Console.WriteLine("End"); 
  
            Console.Read(); 
        } 
    } 
}

结果

Start 
http://blog.wx6.org Start 
Test 
我是DB里的数据,我是自定义的CodeActivity的参数 
http://blog.wx6.org End 
End

 

 

written by ocean

10月 04

从网上下载到hyper-v server 2012的iso文件,直接安装

完成之后直接进入命令模式

一个cmd命令框

一个服务器设置框

都是命令模式,看着高端大气上档次.

设置好Network,Configure Remote Management和Remote Desktop都设置为有效

选择3,添加一个用户,注意这个用户的用户名和密码要和你自己电脑上的用户密码一致

否则等会就不能回自己电脑远程操作了.

话说机房空调开的低,真冷啊

好了  现在就可以回自己电脑上做操作了                

使用Hyper-v Manager连接到服务器

注意防火墙,有可能会连接不上

新建服务器

 一路Next就可以了,没啥好记的

网络需要添加一下,记得加成外部的

 

现在就可以安装系统了,一切OK

等安装完成之后

CMD命令  xcopy "d:\virtualdisk\Server20.vhd" "d:\virtualdisk\Server21.vhd"

复制vhd文件,再做一下附加,就可以复制虚拟机了

安装完成之后设IP,加域等等就不多说

有两个地方需要注意

一个是远程桌面的地方,需要添加  Domain User到允许远程连接用户

   

运行 GPEDIT.MSC

  两个允许登录中接入 Remote Desktop Users

还有一个是把域用户加入管理员组

好啦,大功告成

 

记录一个常见的连接问题

Access Denied. Unable to establish communication between “YYY” and “XXX”

这个问题是处在安装hyper-v manager的客户端

拒绝连接的问题出在安装hyper-v manager的客户端,安全设置不允许匿名登入

运行→dcomcnfg→回车

我的设备是英文版的,自备http://translate.google.cn/

Console Root

  →Component Services

      →Computers

           →My Computer右键

Properties

进入COM Security选项卡,在Access Permissions方框里点击Edit Limits…

你会看到一个ANONYMOUS LOGON选择它,下面有个Remote Access,在Allow选项下面打钩

搞定,重新开启Hyper-V Manager试试吧~

 

PS:在创建VHD文件的时候不成功,因为服务器是R510,搜索一番说了一个bug

于是copy了一个vhd文件解决的        

补充一点CMD命令

打开允许Ping测试    netsh firewall set icmpsetting 8

开启一个文件夹共享  net share ShareFiles=D:\ShareFiles

设置共享文件夹可写  net share ShareFiles=D:\ShareFiles /grant:everyone,full

删除文件夹共享      net share ShareFiles /delete

查看共享信息        net share  

开启匿名访问

第一步  取消简单文件共享
第二步 设置需要共享的文件夹everyone权限
第三步 net user guest /active:y (开户Guest帐户)
第四步 compmgmt.msc 设置共享
第五步 开始-》控制面板-》管理工具-》本地安全策略-》本地策略-》用户权限分配-》"拒绝从网络访问" 去掉Guest(默认不需要)
第六步 开始-》控制面板-》管理工具-》本地安全策略-》本地策略-》用户权限分配-》"从网络访问此计算机" 添加Guest
第七步 开始-》控制面板-》管理工具-》本地安全策略-》本地策略-》安全选项-》网络访问: 本地帐户的共享和安全模型---仅来宾-本地用户用来宾的身份验证

设置完成后 “服务器IP\共享文件夹”访问

 

记录一下命令来操作

cmd里面输入命令启动powershell

powershell

获取虚拟机列表

get-vm

启动虚拟机

start-vm -name Server20

更多命令

https://docs.microsoft.com/en-us/powershell/module/hyper-v/index?view=win10-ps

written by ocean