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
示例:
图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
相关文章推荐
- string转为document 根据需要不同转法 动态表单解析设计表单的内容
- SharePoint【用户访问控制】-- 04. SharePoint 2010 内容审核设置
- SharePoint【学习笔记】-- SharePoint 2010 利用JavaScript根据用户使用的语言应用不同的样式
- 根据字符串内容动态设置UILabel大小
- InfoPath 2010:根据选项显示不同的内容
- SharePoint 2010根据不同的用户权限显示不同的导航
- SharePoint 2010 根据IE设置自动选择多语言
- (四)vue开发 - 根据vue-router的meta动态设置html里<title>标签的内容
- SharePoint 2010 calendar inbox folder web part 针对不同用户
- 根据UITextView中的文本内容,动态设置控件
- 每日总结(二)C#判断输入内容为数字、Sharepoint回收应用程序池错误、Asp.Net 会发或回调参数无效、DropDownList动态绑定且设置默认选择项
- 有infopath的sharepoint 2010 Library里的列的设置,infopath上传到sharepoint server
- SharePoint 2010 利用JavaScript根据用户使用的语言应用不同的样式
- 每日总结(二)C#判断输入内容为数字、Sharepoint回收应用程序池错误、Asp.Net 会发或回调参数无效、DropDownList动态绑定且设置默认选择项
- listctrl根据不同的内容设置不同的颜色
- 根据文本框的内容,动态设置控件
- ScrollView嵌套listview 时根据内容动态设置listview高度
- listctrl根据不同的内容设置不同的颜色
- 根据文本内容的长度动态的设置TextView的高度
- SharePoint 2010的Document Library Upload Multiple Documents功能失效的解决方案