internal static object ConvertValueToStore(EwsStoreObjectPropertyDefinition property, object originalValue)
        {
            if (originalValue == null)
            {
                return(null);
            }
            Type type = originalValue.GetType();

            if (type == typeof(ADRecipientOrAddress))
            {
                ADRecipientOrAddress adrecipientOrAddress = (ADRecipientOrAddress)originalValue;
                return(new EmailAddress(adrecipientOrAddress.DisplayName, adrecipientOrAddress.Address, adrecipientOrAddress.RoutingType));
            }
            if (type == typeof(MultiValuedProperty <ADRecipientOrAddress>))
            {
                return((from x in (MultiValuedProperty <ADRecipientOrAddress>) originalValue
                        select x.Address).ToArray <string>());
            }
            if (type == typeof(AuditLogSearchId))
            {
                return(((AuditLogSearchId)originalValue).Guid);
            }
            if (type == typeof(ADObjectId) && property.StorePropertyDefinition.Type == typeof(byte[]))
            {
                return(((ADObjectId)originalValue).GetBytes());
            }
            if (type == typeof(MultiValuedProperty <ADObjectId>) && property.IsMultivalued && property.StorePropertyDefinition is ExtendedPropertyDefinition && ((ExtendedPropertyDefinition)property.StorePropertyDefinition).MapiType == 3)
            {
                return((from x in (MultiValuedProperty <ADObjectId>) originalValue
                        select x.GetBytes()).ToArray <byte[]>());
            }
            if (type != typeof(byte[]) && property.StorePropertyDefinition.Type == typeof(byte[]))
            {
                return(EwsStoreValueConverter.SerializeToBinary(originalValue));
            }
            if (!(property.StorePropertyDefinition.Type == typeof(PolicyTag)))
            {
                return(ValueConvertor.ConvertValue(StoreValueConverter.ConvertValueToStore(originalValue), EwsStoreValueConverter.GetStorePropertyDefinitionActualType(property), null));
            }
            if ((Guid?)originalValue == null)
            {
                return(null);
            }
            return(new PolicyTag(true, (Guid)originalValue));
        }
Example #2
0
        internal static object GetStartedBy(IPropertyBag propertyPag)
        {
            ADRecipientOrAddress adrecipientOrAddress = (ADRecipientOrAddress)propertyPag[AsyncOperationNotificationSchema.StartedByValue];
            string result;

            if (adrecipientOrAddress != null)
            {
                if ((result = adrecipientOrAddress.DisplayName) == null)
                {
                    return(adrecipientOrAddress.Address);
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }
 public static void CreateNotification(OrganizationId organizationId, string id, AsyncOperationType type, AsyncOperationStatus status, LocalizedString displayName, ADRecipientOrAddress owner, KeyValuePair <string, LocalizedString>[] extendedAttributes, bool throwOnError)
 {
     if (AsyncOperationNotificationDataProvider.IsAsyncNotificationDisabled())
     {
         ExTraceGlobals.StorageTracer.TraceWarning(0L, "DisableAsyncNotification is set in registry, no notification will be created.");
         return;
     }
     if (string.IsNullOrEmpty(id))
     {
         throw new ArgumentNullException("id", "id is mandatory.");
     }
     try
     {
         AsyncOperationNotificationDataProvider asyncOperationNotificationDataProvider = new AsyncOperationNotificationDataProvider(organizationId);
         if (asyncOperationNotificationDataProvider.FindItemByAlternativeId(id) != null)
         {
             throw new StoragePermanentException(ServerStrings.ErrorNotificationAlreadyExists);
         }
         asyncOperationNotificationDataProvider.Save(new AsyncOperationNotification
         {
             AlternativeId      = id,
             ExtendedAttributes = extendedAttributes,
             StartedByValue     = owner,
             DisplayName        = displayName,
             Type   = type,
             Status = status
         });
     }
     catch (Exception ex)
     {
         string printableId = AsyncOperationNotificationDataProvider.GetPrintableId(organizationId, id);
         ExTraceGlobals.StorageTracer.TraceError <string, string>(0L, "AsyncOperationNotificationDataProvider::CreateNotification failed: {0}, message: {1}", printableId, ex.Message);
         StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ErrorCreateNotification, printableId, new object[]
         {
             printableId,
             ex
         });
         if (throwOnError)
         {
             throw;
         }
     }
 }
 public static void CreateNotification(OrganizationId organizationId, string id, AsyncOperationType type, LocalizedString displayName, ADRecipientOrAddress owner, KeyValuePair <string, LocalizedString>[] extendedAttributes, bool throwOnError)
 {
     AsyncOperationNotificationDataProvider.CreateNotification(organizationId, id, type, AsyncOperationStatus.Queued, displayName, owner, extendedAttributes, throwOnError);
 }
        public override bool Equals(object obj)
        {
            ADRecipientOrAddress adrecipientOrAddress = obj as ADRecipientOrAddress;

            return(adrecipientOrAddress != null && object.Equals(this.participant, adrecipientOrAddress.participant));
        }