本文整理汇总了C#中ListItemCollection.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# ListItemCollection.Cast方法的具体用法?C# ListItemCollection.Cast怎么用?C# ListItemCollection.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListItemCollection
的用法示例。
在下文中一共展示了ListItemCollection.Cast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendIndividualDocument
/// <summary>
/// Sends individual document to OneDrive
/// </summary>
/// <param name="clientContext">SP client context</param>
/// <param name="collectionOfAttachments">Dictionary object containing attachment URLs and their stream data</param>
/// <param name="listItemsColl">List item collection of Legal Briefcase folder</param>
/// <param name="allAttachmentUrl">A string array containing all the attachment URLs</param>
/// <param name="web">Object of site</param>
/// <param name="usersMySite">My Site URL of the user</param>
/// <param name="collectionOfOriginalAttachments">Dictionary object containing attachment URLs</param>
/// <param name="defaultContentTypeId">Default content type Id</param>
/// <param name="status">Status of documents sent to OneDrive</param>
/// <returns>Status of documents sent to OneDrive</returns>
internal static string SendIndividualDocument(ClientContext clientContext, Dictionary<string, Stream> collectionOfAttachments, ListItemCollection listItemsColl, string[] allAttachmentUrl, Microsoft.SharePoint.Client.Web web, string usersMySite, Dictionary<string, string> collectionOfOriginalAttachments, string defaultContentTypeId, string status)
{
int documentCount = 0, count = 0;
string fileNameKey = string.Empty;
string overwriteDocumentURLs = string.Empty;
foreach (string key in collectionOfAttachments.Keys)
{
fileNameKey = key.Split(new string[] { ConstantStrings.DOLLAR }, StringSplitOptions.RemoveEmptyEntries)[0];
var selectedItems = from li in listItemsColl.Cast<ListItem>()
from files in li.Folder.Files
where files.Name.ToUpperInvariant() == fileNameKey.ToUpperInvariant()
select files;
if (selectedItems.FirstOrDefault() != null)
{
overwriteDocumentURLs += allAttachmentUrl[count] + ConstantStrings.Semicolon;
}
else
{
SendDocumentToOneDrive(web, usersMySite, fileNameKey, collectionOfAttachments[key], collectionOfOriginalAttachments[key], defaultContentTypeId);
documentCount++;
}
count++;
web.Update();
clientContext.ExecuteQuery();
MailAttachmentDetails.CheckoutFailedPosition++;
status = string.Concat(usersMySite, ServiceConstantStrings.OneDriveDocumentLibraryTitle, ConstantStrings.Semicolon, documentCount, ConstantStrings.Semicolon, collectionOfAttachments.Count, ConstantStrings.Semicolon, overwriteDocumentURLs);
}
return status;
}