我需要使用C#2010以编程方式在Sharepoint 2010中定义业务数据内容源。我已经在Central Admin中查看了执行此操作的方法,并且已经看过MOSS 2007的片段。但是,我找不到在SP 2010中这样做的例子。任何人都可以引导我朝着正确的方向前进吗?
非常感谢您的帮助和指导。
答案 0 :(得分:3)
使用API
string strURL = "http://mySiteUrl";
SearchContext searchContext;
using (SPSite searchSite = new SPSite(strURL))
{
searchContext = SearchContext.GetContext(searchSite);
}
Content sspContent = new Content(searchContext);
ContentSourceCollection sspContentSources = sspContent.ContentSources;
BusinessDataContentSource bdcs = (BusinessDataContentSource)sspContentSources.Create(typeof(BusinessDataContentSource), "MyBdcContentSource");
bdcs.StartAddresses.Add(BusinessDataContentSource.ConstructStartAddress("Default", new Guid("00000000-0000-0000-0000-000000000000"), "LOBSystemName", "LOBSystemInstanceName"));
使用Powershell
$searchapp = Get-SPEnterpriseSearchServiceApplication "My Search Service Application Name"
$lobSystems = @("LOBSystemName1","LOBSystemNameInstance1")
$proxyGroup = Get-SPServiceApplicationProxyGroup -default
New-SPEnterpriseSearchCrawlContentSource -name "My Content Source Name" -searchapplication $searchApp -Type Business -LOBSystemSet $lobSystems -BDCApplicationProxyGroup $proxyGroup
答案 1 :(得分:0)
This可以帮到你。