private static void CreateNewItem(string ClassId, string errorMessage)
{
try
{
Guid SPListId = new Guid(ConfigurationHelper.GetSPListId());
OfficeDevPnP.Core.AuthenticationManager authManager = new OfficeDevPnP.Core.AuthenticationManager();
using (var clientContext = authManager.GetNetworkCredentialAuthenticatedContext(ConfigurationHelper.GetSPSiteURL(), ConfigurationHelper.GetSPUserAccount(), ConfigurationHelper.GetSPUserPassword(), ConfigurationHelper.GetDomainName()))
{
List list = clientContext.Web.Lists.GetById(SPListId);
ListItemCreationInformation listItemCreation = new ListItemCreationInformation();
ListItem newItem = list.AddItem(listItemCreation);
//课程ID
newItem["Class"] = ClassId;
//错误信息
newItem["Description"] = errorMessage;
newItem.Update();
clientContext.ExecuteQuery();
}
}
catch (Exception ex)
{
}
}