所以...我創(chuàng)建了一個 Sharepoint 插件 (C# MVC) 來獲取列表信息和創(chuàng)建/更新項目。我過去已經(jīng)完成了創(chuàng)建/更新,現(xiàn)在不打算解決這個問題。我的問題是將列表項顯示到 MVC 視圖中。到目前為止我做了什么 - >我創(chuàng)建了一個模型(類),其中包含我將在表中顯示的信息:public class IRFItem{ public string Title { get; set; } public string StartDate { get; set; } public string EndDate { get; set; } //public string CreatedBy { get; set; }}在同一個文件中(為了保持我的測試緊湊),我還添加了一種獲取我需要的項目的方法: public static List<IRFItem> GetItems(SharePointContext spContext, CamlQuery camlQuery) { List<IRFItem> items = new List<IRFItem>(); //var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext.Current); using (var clientContext = spContext.CreateUserClientContextForSPAppWeb()) { if (clientContext != null) { List irfList = clientContext.Web.Lists.GetByTitle("IRF"); ListItemCollection irfListItems = irfList.GetItems(camlQuery); clientContext.Load(irfListItems); clientContext.ExecuteQuery(); if (irfListItems != null) { foreach (var irfListItem in irfListItems) { items.Add( new IRFItem { Title = irfListItem["Title"].ToString(), StartDate = irfListItem["StartDate"].ToString(), EndDate = irfListItem["EndDate"].ToString(), }); } }我沒有收到任何錯誤,但我的表總是空的...我什至在 GetItems 中添加了 else 部分來創(chuàng)建一個顯示為空的項目,這樣我就知道它是與共享點(diǎn)相關(guān)的問題還是其他問題。老實說,我的 MVC 經(jīng)驗并不多(一周前才開始學(xué)習(xí),但我是那種邊做邊學(xué)的人)。有沒有人看到這里有任何問題?我已經(jīng)遵循了這個教程,并做了我自己的小改動。參考:https : //www.chakkaradeep.com/2013/10/18/building-apps-for-sharepoint-with-mvc/任何類型的提示都將受到高度贊賞,謝謝。編輯:我通過給應(yīng)用程序更多權(quán)限(為了安全起見列出和 web)跳過了錯誤,我正在返回結(jié)果,但是我無法創(chuàng)建項目,因為 executeQuery 沒有按時完成。知道如何延遲嗎?我記得我在過去的任務(wù)中遇到了一個 bigggg 問題,所以我不知道從哪里開始。
C# MVC 顯示共享點(diǎn)列表中的項目
阿波羅的戰(zhàn)車
2021-11-14 15:05:26