2014-05-22 91 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:没有解决 :(

相关问题