我一直在阅读在排队多个项目以便在SP列表中处理之后只执行一个查询。
我有以下代码,其中有一个按钮,可以将一堆记录加载到Excel电子表格中的空SP列表中。如果我在每个item.update之后执行executequery就行了......但是我觉得应该有更好的方法..我可以排队数组中的项目并一次发送所有项目。我看到了如何使用exisitng列表项来做到这一点的示例......但我还没有看到使用新项目的方法。我能够删除项目...将它们全部缓存并执行一次执行查询以删除所有项目......这显然比每个项目的eq快1000倍。所以希望通过添加新项目来做同样的事情。谢谢你的任何想法。
ER
private void buttonAddIndividualApplicants_Click(object sender, EventArgs e)
{
logThis("Start adding all individual applicants...");
//Set up SCOM
ClientContext context = new ClientContext(textBoxSPSite.Text);
List list = context.Web.Lists.GetByTitle(textBoxSPList.Text);
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem oListItem = list.AddItem(itemCreateInfo);
//ListItemCollection items = new[];
//Set up Excel
var package = new ExcelPackage(new FileInfo(GlobalVars.ssFileName));
ExcelWorksheet workSheet = package.Workbook.Worksheets[GlobalVars.ssApplicantsTab];
//Start iterating through ss
for (int i = workSheet.Dimension.Start.Row + 1;
i <= workSheet.Dimension.End.Row;
i++)
{
logThis("Row:" + i);
string van = workSheet.Cells[i, 1].Value.ToString();
string appID = workSheet.Cells[i, 2].Value.ToString();
string name = workSheet.Cells[i, 3].Value.ToString();
string email = workSheet.Cells[i, 4].Value.ToString();
logThis(van + "-" + appID + "-" + name + "-" + email + " queued for processing.");
//Push an item to the stack:
oListItem["AppID"] = appID;
oListItem["ApplicantName"] = name;
oListItem["VAN"] = van;
oListItem["ApplicantEmailAddress"] = email;
oListItem.Update();
//context.ExecuteQuery(); ***with ExecuteQuery here it works
}
//After all items pushed onto stack...call ExQuery to apply
logThis("Starting ExecuteQuery to process queued list items...");
context.ExecuteQuery(); //Here it gives me only last name in spreadsheet
logThis("FINISHED ADDING INDIVIDUAL APPLICANTS");
}
答案 0 :(得分:2)
弄清楚了。我把ListItem放在了错误的地方。需要它在我的for循环中而不是在它之外。下面的工作代码:
componentDidMount() {
dbx.filesListFolder({ path: '/my-photos' })
.then(res => res.entries.map(file => file.path_display))
.then(res => {
let photoArray = res.map(path => dbx.filesGetTemporaryLink({ path: path }));
console.log(photoArray);
});
}