Spiga

顯示具有 SharePoint 標籤的文章。 顯示所有文章
顯示具有 SharePoint 標籤的文章。 顯示所有文章

如何設定 SharePoint 2010 Business Connectivity Services (BCS) 資料傳回數量的限制 ?

當使用 SharePoint 2010 中的 Business Connectivity Services (BCS) 連接外部資料庫時,預設傳回的資料量是有數量限制的 (2000筆),超過的話,External List 這個 webpart 就無法正常顯示,就會出現下列錯誤:

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator. Correlation ID:b944db82-81bd-40a0-8a1a-ba24c57c1eac

##ReadMore##

可以使用 PowerShell 來放寬限制:

Add-PSSnapin Microsoft.SharePoint.PowerShell

Get-SPServiceApplicationProxy

Get-SPBusinessDataCatalogThrottleConfig
-Scope Database
-ThrottleType Items
-ServiceApplicationProxy 28739dbe-cc48-44e3-b7aa-8693e52d4843

$bdc = Get-SPBusinessDataCatalogThrottleConfig
-Scope Database
-ThrottleType Items
-ServiceApplicationProxy 28739dbe-cc48-44e3-b7aa-8693e52d4843

Set-SPBusinessDataCatalogThrottleConfig
-Identity $bdc
-Maximum 50000
-Default 50000

如何讓 MOSS 支援 AJAX

如果要讓 MOSS 支援 AJAX,首先必須先下載 ASP.NET 2.0 AJAX Extensions 1.0 (按 這裡 下載),然後在 MOSS 伺服器上安裝它,安裝完畢之後,接下來要修改 MOSS 網站的 web.config 檔,一般是位於 c:\inetpub\wwwroot\wss\VirtualDirectories\80 資料夾下,也就是當初在建立應用程式時所設定的路徑,如下圖最下面的路徑:
##ReadMore##

1. 在 <configSections> 元素下加入 <sectionGroup> 子元素如下:

<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
</configSections>

2. 在 <system.web>/<pages> 元素下加入 <controls> 子元素如下:

<pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
</pages>

 

3. 在 <compilation> 元素下加入 <assemblies> 子元素如下:

<assemblies>
       <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>

 

4. 在 <httpHandlers> 區段最後面加入以下 handlers 的註冊:

<httpHandlers>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>

 

5. 在 <httpModules> 區段中加入以下模組:

<httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

 

6. 在 <SharePoint>/<SafeControls> 區段中加入以下安全控制項註冊:

<SafeControls>
      <SafeControl Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" />
</SafeControls>

 

7. 在 web.config 最後面的 </configuration> 這一行之前加上:

<system.web.extensions>
    <scripting>
      <webServices>
      <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
      <!--
        <authenticationService enabled="true" requireSSL = "true|false"/>
      -->
      <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. -->
      <!--
      <profileService enabled="true"
                      readAccessProperties="propertyname1,propertyname2"
                      writeAccessProperties="propertyname1,propertyname2" />
      -->
      </webServices>
      <!--
      <scriptResourceHandler enableCompression="true" enableCaching="true" />
      -->
    </scripting>
  </system.web.extensions>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
           type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
</system.webServer>

 

8. 在主版頁面中加入 ScriptManager 控制項,主版面頁檔位於 \\[你網站網址]\_catalogs\masterpage 資料夾之下,預設檔名是 default.master,在 <WebPartPages:SPWebPartManager> 控制項下一行加入 <asp:ScriptManager> 控制項如下:

<WebPartPages:SPWebPartManager id="m" runat="Server"/>

<asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>

 

9. 接下來你就可以在頁面中或 WebPart 中使用 UpdatePanel 這一類的 AJAX 控制項了。

 

參考資料: Integrating ASP.NET AJAX with SharePoint

如何在 MOSS 網頁中使用 C# 程式碼

在使用 SharePoint Designer 2007 設計 MOSS 2007 的頁面 (.aspx) 時,如果要在頁面中加入 C# 程式碼,例如事件:

<%@ Page Language="C#" masterpagefile="~masterurl/default.master" title="未命名 1" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %>

<script type="text/c#" runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text = DateTime.Now.ToString();
}
</script>

<asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderMain">

<asp:Button ID="Button1" runat="server" Height="48px" onclick="Button1_Click"
Text="Button" Width="308px"/>

</asp:Content>

##ReadMore##

在執行時會出現以下錯誤訊息:
image

這是因為在預設的狀況下,MOSS 不允許在頁面中包含 <script> … </script> 的區塊,要解決這個問題,可以修改網站的 web.config 檔,一般是位於 c:\inetpub\wwwroot\wss\VirtualDirectories\80 資料夾下,也就是當初在建立應用程式時所設定的路徑,如下圖最下面的路徑:
image

在 web.config 中找到 <PageParserPaths> 區段,在裡面加入以下設定:

<PageParserPath VirtualPath="/Pages/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />


image

  • VirtualPath="/Pages/*" : 設定 /Pages/ 路徑下的所有 .aspx 頁面都要進行程式碼解析。
  • CompilationMode="Always" : 設定每次都要編譯 .aspx 頁面。
  • AllowServerSideScript="true" : 設定 .aspx 頁面中允許出現 <script> … </script> 的程式碼區塊。
  • IncludeSubFolders="true" : 設定包含 VirtualPath 屬性以下的所有子目錄都有相同的設定。

這樣就可以允許在這個網站下的任何 .aspx 頁面中可以使用 <script> … </script> 的程式碼區塊,就可以撰寫 C# 程式碼了。

使用 KeywordQuery 進行 SharePoint 搜尋

要在程式碼中搜尋 SharePoint,做法如下:

Dim site As New SPSite("http://intra.mcg.com")
Dim qry As New KeywordQuery(site)
qry.QueryText = EditBox1.Text
qry.ResultTypes = ResultType.RelevantResults
'qry.SelectProperties.Add("Path")
'qry.RowLimit = 20

Dim rtc As ResultTableCollection = qry.Execute()
If rtc.Count > 0 Then
Dim rt As ResultTable = rtc(ResultType.RelevantResults)
Dim dt As New DataTable()
dt.Load(rt, LoadOption.OverwriteChanges)

DataGridView1.DataSource = dt
End If
##ReadMore##

要加入的參考:

  • 使用 WSS3.0 (Windows SharePoint Services Search 服務)
    • Microsoft.SharePoint.dll
    • Microsoft.SharePoint.Search.dll
  • 使用 MOSS 2007 (Office SharePoint Server Search 服務)
    • Microsoft.Office.Server.dll
    • Microsoft.Office.Server.Search.dll

    位置: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\ISAPI

    要匯入的空間:

    Imports Microsoft.SharePoint
    Imports Microsoft.SharePoint.Search.Query ' 如果是用 WSS3.0
    Imports Microsoft.Office.Server.Search.Query ' 如果是用 MOSS 2007

    這是因為 KeywordQuery 這個類別有兩個,一個在 Microsoft.SharePoint.Search.Query 空間下,用來透過 WSS3.0 的 Windows SharePoint Services Search 服務來搜尋 SharePoint 網站的內容;另一個則是在 Microsoft.Office.Server.Search.Query 空間下,用來透過 MOSS 2007 的 Office SharePoint Server Search 服務來搜尋 SharePoint 網站之外的內容 (例如: BDC, 共用資料夾, Exchange 公用資料夾, …)。

    這兩個所搜尋出來的東西並不重覆,所以如果要搜尋到全部的東西,就要使用這兩個 KeywordQuery 針對同一組 keyword 做兩次搜尋。

  • MOSS 2007 無法使用總管檢視

    這幾天在重做 MOSS 的開發環境:

    • Windows Server 2008 Enterprise
    • SQL Server 2008 Enterprise
    • Office 2007 Professional
    • SharePoint Designer 2007
    • MOSS 2007 Enterprise with SP1
    • WSS 3.0 SDK
    • MOSS 2007 SDK
    • Visual Studio 2008 Team Suite
    • Windows SharePoint Services 3.0 工具:Visual Studio 2008 Extensions 1.2 版

    但是在使用文件庫時,發現無法使用文件庫的總管檢視,連帶的也沒辦法在 Office Excel, Word, … 中直接儲存或發佈檔案到 MOSS 上 (會出現找不到 http://… 路徑的錯誤),由於要直接在用戶端儲存檔案到 http:// 開頭的路徑,是使用 Web Folder 技術,用戶端的 WebClient 服務必須要啓動,可是我在 Windows Server 2008 裡面卻找不到這個服務 ?!

    於是我查了一下 Windows Vista, Server 2003, XP,這些作業系統上都有 WebClient 服務,我猜應該是 Windows Server 2008 沒有安裝到一些用戶端的功能,於是就到 Windows Server 2008 使用伺服器管理員安裝 "桌面體驗" (Desktop Experience) 這個功能,安裝之後,就有 WebClient 服務可以用了。

    所以如果用戶端出現無法使用 MOSS 文件庫的總管檢視的問題時,記得要去檢查一下 WebClient 這個服務是否有啓動呦。

    ##ShowAll##