您的位置:首页 > 其它

SharePoint 2010 内容路由根据设置的Rule将Document 动态dispatch到不同的Library或是SubFolder中

2013-08-08 13:31 471 查看
       最近使用了SharePoint 2010的内容路由功能,感觉在管理文档的时候非常的强大。我们可以在一个统一的入口Library List(Drop Off Library)上传文档,上传的文档最终根据我们设置的规则,进入不同的Library List或者同一个Library List的不同的SubFolder中。

示例:

图1:通过Drop Off Library List上传文件。






图2:上传文件结束后,需要填写相关ListItem Property,这里我针对Meeting Type设置了规则,根据Meeting Type的不同,进入不同的Library.






图3:信息录入成功,并将上传的文件和数据放在了lib_IHM这个Library List中。






在Drop Off Library List中没有记录,刚才上传的记录在lib_IHM Library List中了。











实现步骤如下:

1. 启动Site Features中的Content Organizer的Feature.

1.1 选择Site Actions --> Site Settings --> Manage site features



1.2 点击Activate按钮,启动Content Organizer的Feature



2. 创建Custom Content Type

我认为SharePoint的Content Type就是一个模板,可以应用于Library等List上,例如:有2个List结构完全一致,那我们只要建立一个Custom Content Type,然后为这2个List分别加上相同的Content Type,这样2个List的Content Type就一致了。

2.1  创建Site Column

选择Site Actions --> Site Settings --> Site Columns


 

建立SiteContent Type中需要的Column.



2.2 建立Site Content Type

选择Site Actions --> Site Settings --> Site content types



新建Site Content Type



3. 建立Content Organizer Rules

选择Site Actions --> Site Settings --> Content Organizer Rules



新建Content Organizer Rule



根据需要设置Rule,比如我设置了3个Rule,MeetingType等于IHM进lib_IHM Library List, MeetingType等于RTM进lib_RTM Library List, MeetingType等于SAR进lib_SAR Library List。

4. 使用代码进行上传

4.1 引用Web Service

这里不同于我们平时使用SPList对象来上传文件,我们要使用Content Organizer Feature启动后提供给我们的Web Service来进行上传文件操作。

图4.1从Site Settings--> Content Organizer Setting.



在项目中需要引用Web Service Reference http://xxxx/_vti_bin/OfficialFile.asmx,OfficialFileService是Web Service Reference的命名空间。

4.2 代码

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using ConsoleApplication1.OfficialFileService;

using System.IO;

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            string filePath = @"c:\model.txt";

            RecordsRepository repository = new RecordsRepository();

            repository.Url = "http://xxxxxxxxxx/_vti_bin/officialfile.asmx";

            repository.UseDefaultCredentials = true; 

            byte[] fileContent = File.ReadAllBytes(filePath);

            List<OfficialFileService.RecordsRepositoryProperty> properties =

              new List<OfficialFileService.RecordsRepositoryProperty>();

            properties.Add(new OfficialFileService.RecordsRepositoryProperty() { Name = "Title", Type = "Text", Value = "model" });

            properties.Add(new OfficialFileService.RecordsRepositoryProperty() { Name = "Name", Type = "Text"
4000
, Value = "model.txt" });

            properties.Add(new OfficialFileService.RecordsRepositoryProperty() { Name = "MeetingType", Type = "Text", Value = "SAR" });

            properties.Add(new OfficialFileService.RecordsRepositoryProperty() { Name = "ContentType", Type = "Text", Value = "MeetingType" });

            string sourceUrl = filePath;

            string userName = @"xxx\xxx";

            string result = repository.SubmitFile(fileContent, properties.ToArray(),

              null, sourceUrl, userName);

            Console.WriteLine(result);

            Console.ReadLine();

        }

    }

}

4.3 问题

如果返回值是<ResultCode>NotFound</ResultCode>,应该是权限的问题,请在Site Actions--> Site Permissions -->Records Center Web Service Submitters中将你的用户名添加进入这个Group就可以了。



参考文章:

1.
Routing a Record to a SharePoint 2010 Document Library Subfolder  

2. RecordsRepository.SubmitFile Method
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  SharePoint 2010
相关文章推荐