怎样在Sharepoint 2010中定制开发SharePoint Designer Workflows Activities

Create and Prepare Project 

1. Open Visual Studio 2010 from the Start | Programs | Visual Studio 2010 menu.

2. Create a new project by using File | New Project .

3. Pick the SharePoint | 2010 templates.

4. From the SharePoint | 2010 templates select the Empty Project template.

5. Use SPDWorkflowDemo as the name.

6. Set the location to be C:/SPHOLs .

7. Press OK to create the project .

image

 

 

8. When the SharePoint Customization Wizard dialog appears, select Deploy as a farm solution, and press Finish .

 

 

image

Task 2: Create a new Workflow Activity for use by the Reusable Workflow

1. Right-click on the SPDWorkflowDemo solution in the Solution Explorer and select Add | New Project .

2. Under the Visual C# | Workflow project templates, select  the Workflow Activity Library template.   

3. Name the project SPDActivityDemo and press OK to add the project to the SPDWorkflowDemo solution.  

 

 

image

4. Right-click on the SPActivityDemo project in the Solution Explorer and select Add Reference .

5. Under the .Browse tab, browse to C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/ISAPI  and select both Microsoft.SharePoint.dll and Microsoft.SharePoint.WorkflowActions.dll.

6. Press OK to add these two references to the SPDActivityDemo project.

7. Right-click on the Activity1.cs (under the SPActivityDemo project in the Solution Explorer) and select rename.

8. Rename the file CreateDocumentLibrary.cs .

9. Select Yes when the Microsoft Visual Studio dialog appears to allow Visual Studio to re-factor the code .

 

 

 

Task 3: Add code to create a document library based on parameters passed to our activity.

 

 

1. Right-click on the CreateDocumentLibrary.cs activity and select View Code .

2. Change the CreateDocumentLibrary base class from SeqeuenceActivity to : Activity

 

 

public partial class CreateDocumentLibrary: Activity

 

3. Add the following using statements to the activity:

 

 

using Microsoft.SharePoint;

using Microsoft.SharePoint.Workflow;

using Microsoft.SharePoint.WorkflowActions;

 

4. Add a new DependencyProperty to the CreateDocumentLibrary class named UrlProperty of type string . (Hint – type wdp inside of the class definition and then tab twice – this will create the DependencyProperty using the built-in Workflow Dependency Property snippet )

This will be the location where the document library will be created.

 

 

public static DependencyProperty UrlProperty = DependencyProperty.Register( "Url" , typeof ( string ), typeof (CreateDocumentLibrary));

[DescriptionAttribute( "Url of base site" )]

[CategoryAttribute( "Input Property" )]

[BrowsableAttribute( true )]

[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]

[ValidationOption(ValidationOption.Required)]

public string Url

{

    get

    {

        return (( string )( base .GetValue(CreateDocumentLibrary.UrlProperty)));

    }

     set

    {

        base .SetValue(CreateDocumentLibrary.UrlProperty, value );

    }

}

 

5. Add a new DependencyProperty   of type string to the activity named DocLibNameProperty .

This will be the name of the document library created by the activity.

 

 

 

public static DependencyProperty DocLibNameProperty = DependencyProperty.Register( "DocLibName" , typeof(string), typeof(CreateDocumentLibrary));

[DescriptionAttribute( "Used as doc lib name" )]

[CategoryAttribute( "Input Property" )]

[BrowsableAttribute(true)]

[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]

[ValidationOption(ValidationOption.Required)]

public string DocLibName

{

    get

    {

        return ((string)(base.GetValue(CreateDocumentLibrary.DocLibNameProperty)));

    }

    set

    {

        base.SetValue(CreateDocumentLibrary.DocLibNameProperty, value);

    }

}

 

6. Add the following code inside of the CreateDocumentLibrary class:

 

 

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

{

    CreateDocLib();

    return ActivityExecutionStatus.Closed;

}

 

private void CreateDocLib()

{

    using (SPSite sps = new SPSite(Url))

    {

        using (SPWeb spw = sps.RootWeb)

        {

            Guid ID = spw.Lists.Add(DocLibName, DocLibName + " Document Library" , SPListTemplateType.DocumentLibrary);

            SPList spdl = spw.Lists[ID];

            spdl.OnQuickLaunch = true ;

            spdl.Update();

        }

    }

}

 

Task 4: Configure activity for deployment.

 

 

1. To deploy the assembly to the GAC with your SharePoint project you need to configure the project to have a strong-name.

2. Right-click on the SPActivityDemo project and select Properties.

3. Click on the Signing tab in the properties page.

4. Select New under the Choose a strong name key file text from the combo box.

5. Type key as the Key file name value, uncheck Protect my key file with a password and press OK .

 

 

image

6. Build your project (CTRL-SHIFT-B or use Build | Build Solution ) and fix any errors.

7. Right click on the SPDWorkflowDemo project and click Add | SharePoint Mapped Folder .

 

image

8. Browse to Template/1033/Workflow and select OK to add the mapped folder to the SPWorkflowDemo

9. Right-click on the  SPDWorkflowDemo folder in the Solution Explorer (under the Workflow folder).  

10. Right-click on the Workflow folder and select Add | New Item .

11. Select XML File from the list of Installed Templates, name the file SPDActivityDemo.ACTIONS¸ and select OK to add the file.

image

 

12. Replace the contents of SPDActivityDemo.ACTIONS with the following XML

 

 

< WorkflowInfo >

  < Actions Sequential = " then " Parallel = " and " >

    < Action Name = " Create Document Library "

  ClassName = " SPDActivityDemo.CreateDocumentLibrary "

  Assembly = " SPDActivityDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a4a7a2c3215a71b "

  AppliesTo = " all "

  Category = " Labs " >

      < RuleDesigner Sentence = " Document Library Name %1 to site %2. " >

        < FieldBind Field = " DocLibName " Text = " Document Library Name "   

           DesignerType = " TextArea " Id = " 1 " />

        < FieldBind Field = " Url " Text = " Url of base site " Id = " 2 "  

           DesignerType = " TextArea " />

      </ RuleDesigner >

      < Parameters >

        < Parameter Name = " DocLibName " Type = " System.String, mscorlib "  

      Direction = " In " />

        < Parameter Name = " Url " Type = " System.String, mscorlib "  

      Direction = " In " />

      </ Parameters >

    </ Action >

  </ Actions >

</ WorkflowInfo >

10. IMPORTANT – Update the PublicKeyToken within the .ACTIONS file with the public key token from SPDActivityDemo.dll . Do not use the PublicKeyToken in this example. Ensure you generate your own. 

11. To find the PublicKeyToken start a Visual Studio 2010 Command Prompt from the Start | All Programs | Visual Studio 2010 | Visual Studio Tools |Visual Studio Command Prompt (2010) menu

12. Type the following command:

 

 

sn -tc:/SPHOLS/SPDWorkflowDemo/SPDActivityDemo/bin/Debug/SPDActivityDemo.dll | clip

13. In the of SPDActivityDemo.ACTIONS file highlight the value of the PublicKeyToken ("1a4a7a2c3215a71b") and paste (CTRL-V).

14. Remove all the pasted text except the value of your public key.  Make sure there are no extra spaces or line feed characters after the public key token (the quote needs to be next to the value of the public key token).

15. Highlight the whole value of the Assembly attribute and copy that value to the clipboard (CTRL-C).

 

 

 

Task 5: Add the SPDActivityDemo activity to be deployed with SPDWorkflowDemo.

1. In the Solution Explorer, under the SPDWorkflowDemo project, double-click on Package folder

2. In the Package designer click on Advanced (at the bottom of the designer in the middle pane).

3. Click on the Add button.

4. Click on the ellipses button in the Add Custom Assembly dialog.  Browse to the SPDActivityDemo.dll file (C:/SPHOLS/SPDWorkflowDemo/SPDActivityDemo/bin/debug ).

5. Within Safe Controls add the following:

 

 

Assembly Name: SPDActivityDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=YOURPUBLICKEY – ensure you use a Public Key Token you generated using the sn.exe utility. (Hint – you can paste the value you copied to the clipboard in the last step here).

Name Space: SPDActivityDemo

Safe: Checked

Type Name : *

6. Select OK to add the assembly as part of the SharePoint project deployment package.

 

 

image

 

Task 6: Configure a Feature using Feature Designer

1. Right-click on SPDWorkflowDemo project Features folder and select Add Feature .

2. Right-click on the Feature1 node and select Rename . Rename it to SPDWorkflowDemoFeature

3. In the Feature designer change the value of the Scope combo box to WebApplication .

4. Change the feature title to SPDWorkflowDemoFeature .  

 

 

image

Task 7: Add and code a Event Receiver for the Feature

1. Right-click on the SPDWorkflowDemoFeature in the Solution Explorer and select Add Event Receiver  

 

 

image

2. Add a using statement to the top of the code file that appears in the editor:

 

 

using Microsoft.SharePoint.Administration;

 

3. Add the following code to your FeatureReceiver class declaration: 

 

 

 

public override void FeatureActivated(SPFeatureReceiverProperties properties)

{

    SPWebApplication wappCurrent = (SPWebApplication)properties.Feature.Parent;

    SPWebConfigModification modAuthorizedType = new SPWebConfigModification();

    modAuthorizedType.Name = "AuthType" ;

    modAuthorizedType.Owner = "SPDActivityDemo" ;

    modAuthorizedType.Path = 

    "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes" ;

    modAuthorizedType.Type =

    SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;

    modAuthorizedType.Value = @"<authorizedType Assembly=""SPDActivityDemo, 

    Version=1.0.0.0, Culture=neutral, PublicKeyToken=YOURPUBLICKEYTOKEN"" 

    Namespace=""SPDActivityDemo"" TypeName=""*"" Authorized=""True"" />" ;

    wappCurrent.WebConfigModifications.Add(modAuthorizedType);

    wappCurrent.WebService.ApplyWebConfigModifications();

}

 

4. Note: You will need to update the YOURPUBLICKEYTOKEN section in the above code with the correct key from the SPDActivityDemo.ACTIONS file.

5. Build and Deploy the SPDWorkflowDemo project by right-clicking on the SPDWorkflowDemo project in the Solution Explorer and select Deploy .


http://sharepointbloggin.com/2010/02/10/walkthrough-3-sharepoint-designer-workflows-imported-to-visual-studio-2010/

本数据集来源于 2024 年 7 月在江西省中东部余干县、贵溪市、金溪县丘陵林地采集的千枚岩、红砂岩、花岗岩母质发育红壤关键带剖面土壤实测数据,空间覆盖 3 个县域不同岩性风化壳林地,采样点位经纬度分别为千枚岩剖面 P10(116.8316°E,28.5269°N)、红砂岩剖面 P08(117.1048°E,28.3492°N)、花岗岩剖面 P04(116.6883°E,27.9963°N);垂直空间采样深度存在差异,千枚岩与花岗岩剖面采样深度 0~600 cm,红砂岩剖面采样深度 0~450 cm,垂直分层采样分辨率为 0~50 cm 区间分 0~20 cm、20~50 cm 两层,50 cm 以下土层以 50 cm 为固定间隔分层,整套数据集共包含 36 条土壤剖面分层记录,其中 P10 千枚岩剖面 13 条、P08 红砂岩剖面 11 条、P04 花岗岩剖面 13 条。数据采集时间为 2024 年 7 月,实验室理化指标、矿物测试、酸碱滴定及统计建模工作于 2024 年 7 月 —2026 年 5 月完成,无时间序列连续监测数据,仅为单次野外剖面采样静态数据集。 数据集包含野外剖面基础信息、土壤酸碱滴定原始数据、土壤酸度指标、交换性盐基与交换性酸、土壤机械组成、有机质、黏土与原生矿物半定量 XRD 数据、无定形 / 晶形铁铝氧化物含量。全量理化指标计量单位统一规范:酸缓冲容量 pHBC 单位为 cmol・kg⁻¹・pH⁻¹,交换性酸、交换性盐基离子单位为 cmol・kg⁻¹,矿物以质量百分比(%)表示,、黏粒 / 粉粒 / 砂粒、有机质、铁铝氧化物单位均为g/kg,pH 为无量纲数值。 覆盖范围: 中位纬度: 28.2616 中位经度: 116.89654999999999 南界纬度: 27.9963 西界经度: 116.6883 北界纬度: 28.5269 东界经
【内容概要】 基于 Vite 6 与 TypeScript 5 严格模式构建的企业级前端工程化脚手架模板,开箱集成代码规范、单元测试、持续集成与容器化部署的完整链路。模板将 ESLint 9 扁平化配置、typescript-eslint 类型感知规则、Prettier 3 格式化、Vitest 2 单元测试(含 V8 覆盖率 80% 阈值)、Husky v9 + lint-staged 提交前钩子,以及 GitHub Actions 多版本 Node 矩阵流水线打通到位,另附多阶段 Dockerfile 与 nginx 静态托管配置,可在本地 pnpm install 或 docker compose up 直接启动。源码层面提供分级日志器 Logger、强类型事件总线 EventBus(基于 mitt)、Rust 风格 Result 类型、数字与字节时长格式化工具、可复用 Counter 组件等示例,并配套 32 个 Vitest 用例,演示如何在严格类型约束下编写可测试、可维护的工程化代码。 【适合人群】 1. 准备搭建中大型前端项目,需要一份可直接落地的工程化基线模板的全栈工程师; 2. 希望系统理解 Vite 构建配置、ESLint 9 扁平配置、Vitest 覆盖率门槛与 GitHub Actions 流水线如何串联的中级前端开发者; 3. 在团队中负责制定前端规范、CI 流程与 Docker 部署方案的技术负责人; 4. 学习 TypeScript 严格模式下编写类型安全工具库、组件、事件系统的实战示范的学习者。 【能学到什么】 1. Vite 6 + TypeScript 5 严格模式(strict、noUncheckedIndexedAccess、exactOptionalPropertyTypes)下的工程结构组织方式; 2. ESLint 9 Fl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值