Exchange Web服务:为什么ITEMID不是恒定的? [继续] [英] Exchange web services: why is ItemId not constant? [continued]

查看:246
本文介绍了Exchange Web服务:为什么ITEMID不是恒定的? [继续]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些其他人讨论之前(例如,<一个这个问题href=\"http://stackoverflow.com/questions/4164069/exchange-web-services-why-is-itemid-not-constant\">Exchange Web服务:为什么ITEMID不恒定),我想通过冲压GUID作为扩展属性,对我来说,这个解决方案是一种很好的谈论解决方案,我做了什么人建议(虽然我?不知道如何使它与事件的工作),但只有只要应用程序的工作,一旦应用程序重新启动项目的扩展属性消失,所以我现在的问题,是 如何跺在EWS项目扩展属性,使之不断出现?
这是更新日历项目的code(约会)

as some others have discuss this problem before (e.g., Exchange web services: why is ItemId not constant?), I want to talk about the solution, I have done what people have suggested by stamping the Guid as an extended property, For me this solution is kind of nice (although I do not know how to make it work with the occurrences) but only as long as the application works, once the application restarts the extended properties of the items disappear, so my problem now, is "How to stamp the extended property on the EWS item and make it constantly there?" This is the code of updating the calendar items (appointments)

public void SetGuidForAppointement(Appointment appointment)
{         
appointment.SetExtendedProperty((ExtendedPropertyDefinition)_appointementIdPropertyDefinition, Guid.NewGuid().ToString());
appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
}

而这些都是需要上面的属性定义。

And these are the properties definition needed above.

_appointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, "AppointmentID", MapiPropertyType.String);
            _propertyDefinitionBases = new PropertyDefinitionBase[] { _appointementIdPropertyDefinition, ItemSchema.ParentFolderId, AppointmentSchema.Start, AppointmentSchema.End, 
AppointmentSchema.LegacyFreeBusyStatus, AppointmentSchema.Organizer };
            PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, _propertyDefinitionBases);

因此​​,如果任何人有可能他/她提供给我,保持加盖,即使应用程序退出项目的扩展属性的例子这样做过。
谢谢

So if anyone has done this before could he/she provide me with an example that keeps the extended property stamped on the item even if the application exited. Thanks

推荐答案

我已经找到了解决我的问题有时尝试和搜索后。

I have found the solution to my problem after sometime of trying and searching .

private static readonly PropertyDefinitionBase AppointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmentID", MapiPropertyType.String);
public static PropertySet PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointementIdPropertyDefinition);


//Setting the property for the appointment 
 public static void SetGuidForAppointement(Appointment appointment)
{
    try
    {
        appointment.SetExtendedProperty((ExtendedPropertyDefinition)AppointementIdPropertyDefinition, Guid.NewGuid().ToString());
        appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
    }
    catch (Exception ex)
    {
        // logging the exception
    }
}

//Getting the property for the appointment
 public static string GetGuidForAppointement(Appointment appointment)
{
    var result = "";
    try
    {
        appointment.Load(PropertySet);
        foreach (var extendedProperty in appointment.ExtendedProperties)
        {
            if (extendedProperty.PropertyDefinition.Name == "AppointmentID")
            {
                result = extendedProperty.Value.ToString();
            }
        }
    }
    catch (Exception ex)
    {
     // logging the exception
    }
    return result;
} 

这篇关于Exchange Web服务:为什么ITEMID不是恒定的? [继续]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆