本文整理汇总了C#中IFolder.GetResource方法的典型用法代码示例。如果您正苦于以下问题:C# IFolder.GetResource方法的具体用法?C# IFolder.GetResource怎么用?C# IFolder.GetResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFolder
的用法示例。
在下文中一共展示了IFolder.GetResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IterateCalendarItems
private void IterateCalendarItems(IFolder folder, Outlook.Folder olFolder, string tmpFilename)
{
List<string> processedIds = new List<string>();
IHierarchyItem[] remoteItems = folder.GetChildren();
foreach (IHierarchyItem remoteItem in remoteItems)
{
if (remoteItem.ItemType != ItemType.Resource) continue;
processedIds.Add(remoteItem.DisplayName);
IResource resource = folder.GetResource(remoteItem.DisplayName);
Outlook.AppointmentItem existItem = (Outlook.AppointmentItem)olFolder.Items.Find(String.Format("[remoteID] = '{0}'", remoteItem.DisplayName));
if (existItem != null)
{
// if contact is not modified then skip.
// TODO fix dates. Time is rounded in UserProperty. WTF?
if (remoteItem.LastModified != existItem.UserProperties.Find("modifyDate").Value)
{
existItem.Delete();
}
else
{
continue;
}
}
// TODO replace this code with in-memory procedure
using (Stream stream = resource.GetReadStream())
{
using (Stream f = File.OpenWrite(tmpFilename))
{
CopyStream(stream, f);
}
}
// TODO fix bug with encodings. UTF8 is recognized as CP1252. WTF?
Outlook.AppointmentItem item = (Outlook.AppointmentItem)Application.Session.OpenSharedItem(tmpFilename);
File.Delete(tmpFilename);
item.UserProperties.Add("remoteID", Outlook.OlUserPropertyType.olText).Value = remoteItem.DisplayName;
item.UserProperties.Add("modifyDate", Outlook.OlUserPropertyType.olDateTime).Value = remoteItem.LastModified;
item.Move(olFolder);
item.Save();
}
string filter = String.Empty;
foreach (string id in processedIds)
{
filter += String.Format("[remoteID] <> '{0}' And ", id);
}
Outlook.Items itemsForDelete = olFolder.Items;
if (filter.Length > 0)
{
filter = filter.Substring(0, filter.Length - 5);
itemsForDelete = itemsForDelete.Restrict(filter);
}
foreach (Outlook.AppointmentItem item in itemsForDelete)
{
item.Delete();
}
}