2011-01-05 47 views
0

我需要使用C#2010以編程方式在Sharepoint 2010中定義業務數據內容源。我已經查看了在Central Admin內部執行此操作的方法,並從MOSS 2007中看到了代碼片段。但是,我沒有在SP 2010中找到這樣做的例子。任何人都可以引導我朝正確的方向發展嗎?以編程方式創建業務數據內容源

非常感謝您的幫助和指導。

回答

0

This應該可以幫到你。

+1

的鏈接斷開:( – BrutalDev 2017-01-27 16:52:38

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 
+0

你的API例如奏效了我。謝謝! – 2012-02-29 23:43:26