Beispiel #1
0
        protected override void StampItemFromDataObject(Item item, SharingBindingData bindingData)
        {
            item[BindingItemSchema.SharingInitiatorName]  = bindingData.InitiatorName;
            item[BindingItemSchema.SharingInitiatorSmtp]  = bindingData.InitiatorSmtpAddress;
            item[BindingItemSchema.SharingRemoteName]     = bindingData.RemoteFolderName;
            item[BindingItemSchema.SharingRemoteFolderId] = bindingData.RemoteFolderId;
            item[BindingItemSchema.SharingLocalName]      = bindingData.LocalFolderName;
            if (bindingData.LastSyncTimeUtc != null)
            {
                item[BindingItemSchema.SharingLastSync] = new ExDateTime(ExTimeZone.UtcTimeZone, bindingData.LastSyncTimeUtc.Value.ToUniversalTime());
            }
            item[BindingItemSchema.SharingRemoteType] = (item[BindingItemSchema.SharingLocalType] = bindingData.DataType.ContainerClass);
            StoreObjectId storeObjectId = StoreId.GetStoreObjectId(bindingData.LocalFolderId);

            bindingData.LocalFolderId = storeObjectId;
            item[BindingItemSchema.SharingLocalUid]         = storeObjectId.ToHexEntryId();
            item[BindingItemSchema.SharingLocalFolderEwsId] = StoreId.StoreIdToEwsId(this.mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, storeObjectId);
            int num = 11;

            if (bindingData.IsDefaultFolderShared)
            {
                num |= 131072;
            }
            item[BindingItemSchema.SharingFlavor]       = num;
            item[BindingItemSchema.SharingRoamLog]      = SharingContextRoamLog.UnroamedBinding;
            item[BindingItemSchema.SharingStatus]       = SharingContextStatus.Configured;
            item[BindingItemSchema.SharingProviderGuid] = SharingBindingManager.ExternalSharingProviderGuid;
            item[BindingItemSchema.SharingProviderName] = "Microsoft Exchange";
            item[BindingItemSchema.SharingProviderUrl]  = "http://www.microsoft.com/exchange/";
            item[StoreObjectSchema.ItemClass]           = "IPM.Sharing.Binding.In";
        }
 private void FindItemInAllItems()
 {
     this.allItemsItemId = null;
     AllItemsFolderHelper.CheckAndCreateDefaultFolders(this.parent.MailboxSession);
     using (Folder folder = Folder.Bind(this.parent.MailboxSession, this.key.FolderToSearch()))
     {
         PropertyDefinition[] dataColumns = new PropertyDefinition[]
         {
             ItemSchema.Id
         };
         using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, this.key.Filter, null, dataColumns))
         {
             object[][] rows = queryResult.GetRows(1);
             if (rows == null)
             {
                 ExTraceGlobals.SessionTracer.TraceWarning <string, string>((long)this.parent.MailboxSession.GetHashCode(), "AnalysisGroupData.FindItemInAllItems found NO items in folder {0} for the key {1}", this.key.FolderToSearch().ToString(), this.key.ToString());
                 this.allItemsItemId = null;
             }
             else if (rows.Length != 1)
             {
                 ExTraceGlobals.SessionTracer.TraceWarning <string, string, int>((long)this.parent.MailboxSession.GetHashCode(), "AnalysisGroupData.FindItemInAllItems found {2} items in folder {0} for the key {1}", this.key.FolderToSearch().ToString(), this.key.ToString(), rows.Length);
                 this.allItemsItemId = null;
             }
             else
             {
                 this.allItemsItemId = StoreId.GetStoreObjectId(rows[0][0] as StoreId);
             }
         }
     }
 }
Beispiel #3
0
        public static Subscription Create(StoreSession session, NotificationHandler handler, NotificationType notificationType, StoreId id, bool isSyncCallback, bool passthruCallback)
        {
            EnumValidator.ThrowIfInvalid <NotificationType>(notificationType, "notificationType");
            if (session == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Subscription::Create. {0} should not be null.", "session");
                throw new ArgumentNullException("session");
            }
            if (handler == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Subscription::Create. {0} should not be null.", "handler");
                throw new ArgumentNullException("handler");
            }
            if (id == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "Subscription::Create. {0} should not be null.", "id");
                throw new ArgumentNullException("id");
            }
            if ((notificationType & NotificationType.ConnectionDropped) == NotificationType.ConnectionDropped)
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "Subscription::Create. ConnectionDropped not valid on object notifications.");
                throw new InvalidOperationException("ConnectionDropped not valid on object notifications.");
            }
            StoreObjectId            storeObjectId = StoreId.GetStoreObjectId(id);
            NotificationCallbackMode callbackMode  = isSyncCallback ? NotificationCallbackMode.Sync : NotificationCallbackMode.Async;

            return(Subscription.InternalCreate(session, handler, notificationType, storeObjectId, callbackMode, passthruCallback));
        }
Beispiel #4
0
        public ICalendarGroupEntry BindToCalendarGroupEntry(IMailboxSession session, StoreId id)
        {
            StoreObjectId storeObjectId = StoreId.GetStoreObjectId(id);

            if (!storeObjectId.IsFolderId)
            {
                return(CalendarGroupEntry.Bind((MailboxSession)session, id, null));
            }
            return(CalendarGroupEntry.BindFromCalendarFolder((MailboxSession)session, storeObjectId));
        }
Beispiel #5
0
 public StoreParticipantOrigin(StoreId originItemId, EmailAddressIndex emailAddressIndex)
 {
     EnumValidator.ThrowIfInvalid <EmailAddressIndex>(emailAddressIndex);
     if (originItemId == null)
     {
         throw new ArgumentNullException("originItemId");
     }
     this.originItemId      = StoreId.GetStoreObjectId(originItemId);
     this.emailAddressIndex = emailAddressIndex;
 }
        private int UpdateItems(IConversationTree conversationTree, List <GroupOperationResult> results)
        {
            int num = 0;

            foreach (IConversationTreeNode conversationTreeNode in conversationTree)
            {
                for (int i = 0; i < conversationTreeNode.StorePropertyBags.Count; i++)
                {
                    if (!this.CanSkipProcessing(conversationTreeNode.StorePropertyBags[i]))
                    {
                        StoreId       storeId = conversationTreeNode.StorePropertyBags[i].TryGetProperty(ItemSchema.Id) as StoreId;
                        List <string> list    = null;
                        if (ConversationActionItem.MergeCategories(conversationTreeNode.StorePropertyBags[i].TryGetProperty(ItemSchema.Categories) as string[], this.AlwaysCategorizeValue, this.ConversationActionLastCategorySet, out list))
                        {
                            try
                            {
                                using (Item item = Microsoft.Exchange.Data.Storage.Item.Bind(base.Session, storeId, null))
                                {
                                    num++;
                                    item.OpenAsReadWrite();
                                    if (list.Count == 0)
                                    {
                                        item.Delete(ItemSchema.Categories);
                                    }
                                    else
                                    {
                                        item[ItemSchema.Categories] = list.ToArray();
                                    }
                                    item.Save(SaveMode.ResolveConflicts);
                                    results.Add(new GroupOperationResult(OperationResult.Succeeded, new StoreObjectId[]
                                    {
                                        StoreId.GetStoreObjectId(storeId)
                                    }, null));
                                }
                            }
                            catch (LocalizedException storageException)
                            {
                                results.Add(new GroupOperationResult(OperationResult.Failed, new StoreObjectId[]
                                {
                                    StoreId.GetStoreObjectId(storeId)
                                }, storageException));
                            }
                        }
                    }
                }
            }
            if (ConversationActionItem.NeedToAddCategory(this.ConversationActionLastCategorySet, this.AlwaysCategorizeValue))
            {
                this.ConversationActionLastCategorySet = this.AlwaysCategorizeValue;
            }
            return(num);
        }
        internal DefaultFolderType IsDefaultFolderType(StoreId folderId)
        {
            StoreObjectId storeObjectId = StoreId.GetStoreObjectId(folderId);

            for (int i = 0; i < DefaultFolderInfo.DefaultFolderTypeCount; i++)
            {
                StoreObjectId folderId2 = this.defaultFolders[i].FolderId;
                if (!this.defaultFolders[i].IsIdInitialized)
                {
                    this.defaultFolders[i].InitializeFolderId();
                    folderId2 = this.defaultFolders[i].FolderId;
                }
                if (folderId2 != null && storeObjectId.Equals(folderId2))
                {
                    return((DefaultFolderType)i);
                }
            }
            return(DefaultFolderType.None);
        }
        internal void CategoryWasUsed(StoreId itemId, string itemClass, string categoryName)
        {
            if (this.IsLoaded && !this.Contains(categoryName))
            {
                return;
            }
            if (this.categoryUsageLogSize >= 500)
            {
                ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "Category usage log size has reached its maximum of {0} entries. Cannot add this: category=\"{1}\", class=\"{2}\", id=\"{3}\"", new object[]
                {
                    500,
                    categoryName,
                    itemClass,
                    itemId
                });
                return;
            }
            StoreObjectId parentFolderId;

            if (itemId != null)
            {
                StoreObjectId storeObjectId = StoreId.GetStoreObjectId(itemId);
                parentFolderId = this.session.GetParentFolderId(storeObjectId);
            }
            else
            {
                parentFolderId = MasterCategoryList.invalidId;
            }
            MasterCategoryList.PerFolderCategoryUsageLog perFolderCategoryUsageLog;
            if (!this.categoryUsageLog.TryGetValue(parentFolderId, out perFolderCategoryUsageLog))
            {
                perFolderCategoryUsageLog = new MasterCategoryList.PerFolderCategoryUsageLog();
                this.categoryUsageLog.Add(parentFolderId, perFolderCategoryUsageLog);
            }
            MasterCategoryList.CategoryUsageRecord key = new MasterCategoryList.CategoryUsageRecord(categoryName, MasterCategoryList.GetModuleForObjectClass(itemClass));
            perFolderCategoryUsageLog.CategoryUsageRecords[key] = ExDateTime.GetNow(ExTimeZone.UtcTimeZone);
            this.categoryUsageLogSize++;
        }
Beispiel #9
0
 protected override bool IsCompatibleId(StoreId id, ICoreObject coreObject)
 {
     return((coreObject == null || coreObject is ICoreItem) && IdConverter.IsMessageId(StoreId.GetStoreObjectId(id)));
 }
Beispiel #10
0
        private byte[] GetDestinationSpecificEntryId(MapiStore hierarchyStore, StoreId folderId)
        {
            StoreSession storeSession = null;
            object       thisObject   = null;
            bool         flag         = false;

            byte[] result;
            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = hierarchyStore.CreateEntryId(hierarchyStore.GetFidFromEntryId(StoreId.GetStoreObjectId(folderId).ProviderLevelItemId));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RPCPrimaryHierarchyProvider.GetDestinationSpecificEntryId : folderId = {0}", folderId),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RPCPrimaryHierarchyProvider.GetDestinationSpecificEntryId : folderId = {0}", folderId),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
        public IReadableUserConfiguration GetReadOnlyFolderConfiguration(string configName, UserConfigurationTypes freefetchDataTypes, StoreId folderId)
        {
            IReadableUserConfiguration result = null;

            if (!this.TryGetAggregatedConfiguration(() => UserConfigurationDescriptor.CreateFolderDescriptor(configName, freefetchDataTypes, StoreId.GetStoreObjectId(folderId)), out result))
            {
                result = this.GetFolderConfiguration(configName, freefetchDataTypes, folderId);
            }
            return(result);
        }
        private UserConfiguration InternalGetUserConfiguration(StoreId folderId, UserConfigurationName configurationName, UserConfigurationTypes freefetchDataType, StoreObjectId messageId)
        {
            if (this.aggregators.Count > 0)
            {
                lock (this.aggregators)
                {
                    foreach (UserConfigurationManager.AggregationContext aggregationContext in this.aggregators)
                    {
                        ExTraceGlobals.StorageTracer.TraceWarning <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration cache miss = {0}.", configurationName);
                        aggregationContext.FaiCacheMiss();
                    }
                }
            }
            if (folderId == null)
            {
                throw new ArgumentNullException("folderId");
            }
            UserConfiguration userConfiguration = null;
            bool flag2 = false;
            UserConfiguration result;

            try
            {
                userConfiguration = this.userConfigurationCache.Get(configurationName, StoreId.GetStoreObjectId(folderId));
                if (userConfiguration == null)
                {
                    if (messageId != null)
                    {
                        userConfiguration = this.GetMessageConfiguration(configurationName, freefetchDataType, messageId);
                    }
                    if (userConfiguration == null)
                    {
                        ExTraceGlobals.UserConfigurationTracer.TraceDebug <string>((long)this.GetHashCode(), "UserConfigurationManager::InternalBindAndGetUserConfiguration. Miss the cache. ConfigName = {0}.", configurationName.Name);
                        userConfiguration = this.InternalBindAndGetUserConfiguration(folderId, configurationName, freefetchDataType);
                    }
                }
                if ((userConfiguration.DataTypes & freefetchDataType) == (UserConfigurationTypes)0)
                {
                    ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = UserConfigurationType.");
                    throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("UserConfigurationType"));
                }
                flag2  = true;
                result = userConfiguration;
            }
            finally
            {
                if (!flag2 && userConfiguration != null)
                {
                    userConfiguration.Dispose();
                    userConfiguration = null;
                }
            }
            return(result);
        }
Beispiel #13
0
 protected override bool IsCompatibleId(StoreId id, ICoreObject coreObject)
 {
     return((coreObject == null || coreObject is CoreFolder) && IdConverter.IsFolderId(StoreId.GetStoreObjectId(id)));
 }
Beispiel #14
0
        internal static QueryFilter SmartIdFilterToNativeIdFilter(SinglePropertyFilter filter, SmartPropertyDefinition smartProperty, PropertyDefinition nativeProperty)
        {
            ComparisonFilter comparisonFilter = filter as ComparisonFilter;

            if (comparisonFilter == null || !comparisonFilter.Property.Equals(smartProperty))
            {
                throw smartProperty.CreateInvalidFilterConversionException(filter);
            }
            if (comparisonFilter.ComparisonOperator != ComparisonOperator.Equal && comparisonFilter.ComparisonOperator != ComparisonOperator.NotEqual)
            {
                throw smartProperty.CreateInvalidFilterConversionException(filter);
            }
            StoreId id = (StoreId)comparisonFilter.PropertyValue;

            return(new ComparisonFilter(comparisonFilter.ComparisonOperator, nativeProperty, StoreId.GetStoreObjectId(id).ProviderLevelItemId));
        }