2014-05-22 89 views
0

我創建提供程序託管的應用程序,該應用程序應該在SharePoint中創建一個calendarlist。我希望它稍後成爲一個組日曆,但首先我只需要執行第1步:創建日曆。提供程序託管的Sharepoint應用程序,創建SharePoint日曆

我無法找到任何提供商託管的指南,瞭解如何以編程方式創建SharePoint日曆。我無法找到日曆ListTemplateStyle所以我想事件的模板,我不知道它goint工作,因爲有顯示出來,當我嘗試運行下面這段代碼的錯誤:

Uri hostWeb = new Uri(Request.QueryString["SPHostUrl"]); 

     using (var clientContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(hostWeb, Request.LogonUserIdentity)) 
     { 
      Web web = clientContext.Web; 
      ListCreationInformation listCreator = new ListCreationInformation(); 
      listCreator.Title = "CompanyCalendar"; 
      listCreator.Description = "Workcalendar"; 
      listCreator.TemplateType = (int)ListTemplateType.Events; //106 = events 
      //clientContext.Load(web); 
      web.Lists.Add(listCreator); 
      clientContext.ExecuteQuery(); 

     } 

System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Line 27:     //clientContext.Load(web); 
Line 28:     web.Lists.Add(listCreator); 
Line 29:     clientContext.ExecuteQuery(); 
Line 30: 
Line 31:    } 

這似乎是未經授權在這裏創建一個列表出於某種原因。我有Web權限設置爲完全控制,我的證書看起來像這樣:

<appSettings> 
<add key="ClientId" value="ebcb24ca-afbb-4822-8887-f91504f3d25f" /> 
<add key="ClientSigningCertificatePath" value="C:\Certs\HighTrustSampleCert.pfx" /> 
<add key="ClientSigningCertificatePassword" value="1234" /> 
<add key="IssuerId" value="11111111-1111-1111-1111-111111111111" /> 
</appSettings> 

任何idéas?

我的第二個問題是:我需要學習如何使日曆成爲組日曆?任何提示?

感謝

回答

0
+0

我想我不能以編程方式創建日曆,所以我想我必須首先創建一個通用的列表,然後以某種方式創建一個CalendarView但在這裏我的問題是,我不明白。允許在我的開發者網站上創建一個簡單的列表。我不知道該怎麼辦 :( – Hannes

0

我自己解決了它。

我明顯使用SharePoint開發人員站點進行調試(在我的情況下爲「https://[email protected]」)。由於我在虛擬機上工作,我應該使用本地服務器站點(在我的情況下爲"http://SERVER1)。

當我登錄到我的虛擬機時,我用我的Windows用戶名和密碼登錄(在我的情況下,用戶名是「開發人員」),並且能夠使用那個登錄碼和我的調試網站的codenippet "Request.LogonUserIdentity"必須是虛擬服務器(在我的情況下是"http://SERVER1「)。

當我更改爲SERVER1它的工作和ListTemplateType.Events這是一個日曆的模板得到創建和問題得到解決。

問題1:如何創建sharepointcalendar。
Answear:(int)ListTemplateType.Events;

問題2:System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Answear:檢查您的debugsite。確保"Request.LogonUserIdentity"或(用戶您登錄到與Windows)的promission到你的網站,你對

問題3調試:如何以"true"的「組日曆選項」設置程序上承載的privider應用程序。
Answear:沒有解決 :(

相關問題