Пример #1
0
        // Token: 0x06000CEA RID: 3306 RVA: 0x00045C70 File Offset: 0x00043E70
        private bool LegacyRespond(StoreObjectId itemId, string requestId, string userResponse, bool usingLongId)
        {
            MeetingRequest   meetingRequest   = null;
            CalendarItemBase calendarItemBase = null;
            StoreObjectId    storeObjectId    = null;
            StoreObjectId    storeObjectId2   = null;
            Item             item             = null;

            try
            {
                base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRItems);
                try
                {
                    item = Item.Bind(base.MailboxSession, itemId, null);
                }
                catch (ObjectNotFoundException)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, userResponse, "Cannot find the meeting-request as specified in the reqest.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemNotFound");
                    return(false);
                }
                meetingRequest = (item as MeetingRequest);
                if (base.Version >= 141 && meetingRequest == null)
                {
                    calendarItemBase = (item as CalendarItemBase);
                    if (calendarItemBase != null)
                    {
                        calendarItemBase.OpenAsReadWrite();
                    }
                }
                if (meetingRequest == null && calendarItemBase == null)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, userResponse, "The item is not meeting-request or calendar item.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemNotValid");
                    return(false);
                }
                item = null;
                if (meetingRequest != null)
                {
                    if (meetingRequest.IsOrganizer())
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "The organizer of this meeting request is the mailbox owner. Checking meetingRequest.", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MRIsOrganizer");
                        return(false);
                    }
                    if (meetingRequest.IsDelegated())
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "Cannot respond to a delegated meeting request.  Use Outlook", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MRIsDelegated");
                        return(false);
                    }
                    if (meetingRequest.IsOutOfDate())
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "Cannot respond to a OutOfDated meeting request.", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MRIsOutOfDate");
                        return(false);
                    }
                    meetingRequest.OpenAsReadWrite();
                    storeObjectId    = meetingRequest.Id.ObjectId;
                    calendarItemBase = meetingRequest.UpdateCalendarItem(false);
                }
                if (calendarItemBase == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NullCalItemInMRCmd");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, null, false);
                }
                if (calendarItemBase.IsOrganizer())
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "The organizer of this meeting request is the mailbox owner. Checking calendarItem.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CalIsOrganizer");
                    return(false);
                }
                if (calendarItemBase.IsCancelled)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "Cannot respond to a canceled meeting.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CalIsCancelled");
                    return(false);
                }
                if (userResponse != null)
                {
                    ResponseType responseType;
                    if (!(userResponse == "1"))
                    {
                        if (!(userResponse == "2"))
                        {
                            if (!(userResponse == "3"))
                            {
                                goto IL_22F;
                            }
                            responseType = ResponseType.Decline;
                        }
                        else
                        {
                            responseType = ResponseType.Tentative;
                        }
                    }
                    else
                    {
                        responseType = ResponseType.Accept;
                    }
                    try
                    {
                        using (calendarItemBase.RespondToMeetingRequest(responseType))
                        {
                        }
                    }
                    catch (SaveConflictException ex)
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "A conflict calendar item has been detected: " + ex.Message, usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SavedWithConflicts");
                        return(false);
                    }
                    calendarItemBase.Load();
                    if (meetingRequest != null)
                    {
                        meetingRequest.Save(SaveMode.ResolveConflicts);
                    }
                    if (responseType != ResponseType.Decline)
                    {
                        if (calendarItemBase is CalendarItemOccurrence)
                        {
                            storeObjectId2 = ((CalendarItemOccurrence)calendarItemBase).MasterId.ObjectId;
                        }
                        else
                        {
                            storeObjectId2 = calendarItemBase.Id.ObjectId;
                        }
                    }
                    else
                    {
                        base.MailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                        {
                            calendarItemBase.Id
                        });
                    }
                    calendarItemBase.Dispose();
                    calendarItemBase = null;
                    if (storeObjectId != null)
                    {
                        base.MailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                        {
                            storeObjectId
                        });
                    }
                    goto IL_339;
                }
IL_22F:
                throw new ArgumentException(string.Format("Unexpected userResponse value \"{0}\"", userResponse));
            }
            finally
            {
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                }
                if (meetingRequest != null)
                {
                    meetingRequest.Dispose();
                }
                if (item != null)
                {
                    item.Dispose();
                }
            }
IL_339:
            string calendarId = null;

            if (storeObjectId2 != null)
            {
                MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId2);
                if (this.CalendarItemIdMapping.Contains(mailboxSyncItemId))
                {
                    calendarId = this.CalendarItemIdMapping[mailboxSyncItemId];
                }
                else
                {
                    calendarId = this.CalendarItemIdMapping.Add(mailboxSyncItemId);
                    this.calendarSyncStateChangedFlag = true;
                }
            }
            this.AppendXmlNode(requestId, StatusCode.Success, calendarId, userResponse, usingLongId);
            return(true);
        }
Пример #2
0
        private static string BuildDiagnosticString(ActivityId id, ClientId clientId, ExDateTime timeStamp, Guid clientSessionId, string clientVersion, long sequenceNumber, IMailboxSession mailboxSession, StoreObjectId itemId = null, StoreObjectId previousItemId = null, IDictionary <string, string> customProperties = null)
        {
            string text = string.Empty;

            if (mailboxSession != null && mailboxSession.MailboxOwner != null)
            {
                text = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
            }
            return(string.Format("id:{0}, clientId:{1}, timeStamp:{2}, clientSessionId:{3}, clientVersion:{4}, sequenceNumber:{5}, owner:{6}, itemId:{7}, previousItemId:{8}, customProperties:{9}", new object[]
            {
                id,
                (clientId == null) ? string.Empty : clientId.ToString(),
                timeStamp.ToISOString(),
                clientSessionId,
                clientVersion,
                sequenceNumber,
                text,
                (itemId == null) ? string.Empty : itemId.ToBase64ProviderLevelItemId(),
                (previousItemId == null) ? string.Empty : previousItemId.ToBase64ProviderLevelItemId(),
                (customProperties == null) ? string.Empty : Activity.SerializeDictionaryAsString(customProperties)
            }));
        }
Пример #3
0
        private static StoreObjectId CreateFreeBusyFolder(PublicFolderSession session, StoreObjectId parentFolder, string folderName)
        {
            Exception ex = null;

            try
            {
                using (Folder folder = Folder.Create(session, parentFolder, StoreObjectType.Folder, folderName, CreateMode.OpenIfExists))
                {
                    folder[FolderSchema.ResolveMethod] = (ResolveMethod.LastWriterWins | ResolveMethod.NoConflictNotification);
                    FolderSaveResult folderSaveResult = folder.Save();
                    if (folderSaveResult.OperationResult == OperationResult.Succeeded)
                    {
                        folder.Load();
                        StoreObjectId objectId = folder.Id.ObjectId;
                        FreeBusyFolder.Tracer.TraceDebug <string, StoreObjectId, StoreObjectId>(0L, "Created free/busy folder '{0}' under folder '{1}' with id '{2}'.", folderName, parentFolder, objectId);
                        return(objectId);
                    }
                    ex = folderSaveResult.Exception;
                }
            }
            catch (PropertyErrorException ex2)
            {
                ex = ex2;
            }
            catch (CorruptDataException ex3)
            {
                ex = ex3;
            }
            catch (ObjectNotFoundException ex4)
            {
                ex = ex4;
            }
            if (ex != null)
            {
                FreeBusyFolder.Tracer.TraceError <string, StoreObjectId, Exception>(0L, "Failed to create free/busy folder '{0}' under folder '{1}' due exception: {2}", folderName, parentFolder, ex);
            }
            return(null);
        }
Пример #4
0
        public AddressBookSearchViewState(ClientViewState lastClientViewState, AddressBook.Mode mode, string addressBookToSearch, string searchString, int pageNumber, StoreObjectId itemId, string itemChangeKey, RecipientItemType recipientWell, ColumnId sortColumnId, SortOrder sortOrder) : base(lastClientViewState, mode, pageNumber, itemId, itemChangeKey, recipientWell, sortColumnId, sortOrder)
        {
            this.searchLocation = addressBookToSearch;
            this.searchString   = searchString;
            ISearchViewState searchViewState = lastClientViewState as ISearchViewState;

            if (searchViewState != null)
            {
                this.lastClientViewStateBeforeSearch = searchViewState.ClientViewStateBeforeSearch();
                return;
            }
            this.lastClientViewStateBeforeSearch = lastClientViewState;
        }
Пример #5
0
 // Token: 0x0600170F RID: 5903 RVA: 0x0008A384 File Offset: 0x00088584
 public void SetCollectionIdFromBytes(byte[] collectionBytes)
 {
     this.folderId = StoreObjectId.Deserialize(collectionBytes);
 }
        // Token: 0x06000301 RID: 769 RVA: 0x0001B08C File Offset: 0x0001928C
        private static bool DoMove(StoreObjectId folderId, StoreObjectId[] itemIds, string[] itemClassNames, OwaContext owaContext)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("OwaContext");
            }
            UserContext userContext = owaContext.UserContext;
            Folder      folder      = null;
            Exception   ex          = null;

            try
            {
                folder = Folder.Bind(userContext.MailboxSession, folderId, new PropertyDefinition[]
                {
                    StoreObjectSchema.ContainerClass
                });
            }
            catch (StoragePermanentException ex2)
            {
                ex = ex2;
            }
            catch (StorageTransientException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                InfobarMessage.PutExceptionInfoIntoContextInfobarMessage(ex, owaContext);
                ((InfobarMessage)owaContext[OwaContextProperty.InfobarMessage]).IsActionResult = true;
                return(false);
            }
            bool flag = true;

            if (folder.ClassName != null)
            {
                for (int i = 0; i < itemClassNames.Length; i++)
                {
                    if (!MoveItemPreFormAction.IsMoveAllowed(itemClassNames[i], folder.ClassName))
                    {
                        flag = false;
                        break;
                    }
                }
            }
            folder.Dispose();
            if (!flag)
            {
                MoveItemPreFormAction.AddInfobarMessageToContext(432946224, InfobarMessageType.Error, owaContext);
                return(false);
            }
            AggregateOperationResult aggregateOperationResult = userContext.MailboxSession.Move(folderId, itemIds);
            OperationResult          operationResult          = aggregateOperationResult.OperationResult;

            if (operationResult == OperationResult.Succeeded)
            {
                MoveItemPreFormAction.AddInfobarMessageToContext(-1303045509, InfobarMessageType.Informational, owaContext);
                return(true);
            }
            if (operationResult == OperationResult.PartiallySucceeded)
            {
                MoveItemPreFormAction.AddInfobarMessageToContext(-324890159, InfobarMessageType.Error, owaContext);
                return(false);
            }
            MoveItemPreFormAction.AddInfobarMessageToContext(-842347964, InfobarMessageType.Error, owaContext);
            return(false);
        }
Пример #7
0
        protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize)
        {
            if (sortBy != null)
            {
                throw new NotSupportedException("sortBy");
            }
            if (rootId != null && !(rootId is MailboxFolderId))
            {
                throw new NotSupportedException("rootId: " + rootId.GetType().FullName);
            }
            if (!typeof(MailboxFolder).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()))
            {
                throw new NotSupportedException("FindPaged: " + typeof(T).FullName);
            }
            if (filter == null)
            {
                filter = MailboxFolderDataProvider.nonHiddenFilter;
            }
            else
            {
                filter = new AndFilter(new QueryFilter[]
                {
                    filter,
                    MailboxFolderDataProvider.nonHiddenFilter
                });
            }
            Dictionary <StoreObjectId, MapiFolderPath> knownFolderPathsCache = new Dictionary <StoreObjectId, MapiFolderPath>();

            knownFolderPathsCache.Add(base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root), MapiFolderPath.IpmSubtreeRoot);
            knownFolderPathsCache.Add(base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration), MapiFolderPath.NonIpmSubtreeRoot);
            StoreObjectId  xsoRootIdentity;
            MapiFolderPath xsoRootFolderPath;

            if (rootId == null)
            {
                xsoRootIdentity   = base.MailboxSession.SafeGetDefaultFolderId(DefaultFolderType.Root);
                xsoRootFolderPath = MapiFolderPath.IpmSubtreeRoot;
            }
            else
            {
                MailboxFolderId mailboxFolderId = (MailboxFolderId)rootId;
                if (mailboxFolderId.StoreObjectIdValue == null)
                {
                    StoreObjectId storeObjectId = base.ResolveStoreObjectIdFromFolderPath(mailboxFolderId.MailboxFolderPath);
                    if (storeObjectId == null)
                    {
                        yield break;
                    }
                    xsoRootIdentity = storeObjectId;
                }
                else
                {
                    xsoRootIdentity = mailboxFolderId.StoreObjectIdValue;
                }
                xsoRootFolderPath = mailboxFolderId.MailboxFolderPath;
            }
            MailboxFolder rootFolder = (MailboxFolder)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));

            PropertyDefinition[] xsoProperties = rootFolder.Schema.AllDependentXsoProperties;
            Folder xsoFolder = Folder.Bind(base.MailboxSession, xsoRootIdentity, xsoProperties);

            rootFolder.LoadDataFromXso(base.MailboxSession.MailboxOwner.ObjectId, xsoFolder);
            rootFolder.SetDefaultFolderType(base.MailboxSession.IsDefaultFolderType(xsoRootIdentity));
            if (null == xsoRootFolderPath)
            {
                xsoRootFolderPath = MailboxFolderDataProvider.CalculateMailboxFolderPath(base.MailboxSession, rootFolder.InternalFolderIdentity.ObjectId, rootFolder.InternalParentFolderIdentity, rootFolder.Name, knownFolderPathsCache);
            }
            else if (!knownFolderPathsCache.ContainsKey(rootFolder.InternalFolderIdentity.ObjectId))
            {
                knownFolderPathsCache.Add(rootFolder.InternalFolderIdentity.ObjectId, xsoRootFolderPath);
            }
            rootFolder.FolderPath = xsoRootFolderPath;
            if (deepSearch)
            {
                yield return((T)((object)rootFolder));
            }
            QueryResult queryResults = xsoFolder.FolderQuery(deepSearch ? FolderQueryFlags.DeepTraversal : FolderQueryFlags.None, filter, null, new PropertyDefinition[]
            {
                FolderSchema.Id
            });

            for (;;)
            {
                object[][] folderRows = queryResults.GetRows((pageSize == 0) ? 1000 : pageSize);
                if (folderRows.Length <= 0)
                {
                    break;
                }
                foreach (object[] row in folderRows)
                {
                    MailboxFolder oneFolder = (MailboxFolder)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));
                    using (Folder oneXsoFolder = Folder.Bind(base.MailboxSession, ((VersionedId)row[0]).ObjectId, xsoProperties))
                    {
                        oneFolder.LoadDataFromXso(base.MailboxSession.MailboxOwner.ObjectId, oneXsoFolder);
                        oneFolder.SetDefaultFolderType(base.MailboxSession.IsDefaultFolderType(oneFolder.InternalFolderIdentity));
                        oneFolder.FolderPath = MailboxFolderDataProvider.CalculateMailboxFolderPath(base.MailboxSession, oneFolder.InternalFolderIdentity.ObjectId, oneFolder.InternalParentFolderIdentity, oneFolder.Name, knownFolderPathsCache);
                        yield return((T)((object)oneFolder));
                    }
                }
            }
            yield break;
        }
        private static Folder GetRootFolder(MailboxSession mailboxSession, ElcFolderType folderType)
        {
            Folder result = null;

            if (folderType == ElcFolderType.Inbox)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Inbox, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Calendar)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Calendar, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.SentItems)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.SentItems, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.DeletedItems)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.DeletedItems, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Contacts)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Contacts, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Calendar)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Calendar, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Drafts)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Drafts, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Outbox)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Outbox, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.JunkEmail)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.JunkEmail, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Tasks)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Tasks, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Journal)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Journal, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.Notes)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Notes, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.All)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Root, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.SyncIssues)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.SyncIssues, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.RssSubscriptions)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.RssSubscription, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.ConversationHistory)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.CommunicatorHistory, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.LegacyArchiveJournals)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.LegacyArchiveJournals, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.NonIpmRoot)
            {
                result = Folder.Bind(mailboxSession, DefaultFolderType.Configuration, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.RecoverableItems)
            {
                if (mailboxSession.GetDefaultFolderId(DefaultFolderType.RecoverableItemsRoot) == null)
                {
                    return(null);
                }
                result = Folder.Bind(mailboxSession, DefaultFolderType.RecoverableItemsRoot, GetMailboxFolderStatistics.folderStatProps);
            }
            else if (folderType == ElcFolderType.ManagedCustomFolder)
            {
                StoreObjectId storeObjectId = null;
                string        text          = null;
                string        text2         = null;
                ProvisionedFolderReader.GetElcRootFolderInfo(mailboxSession, out storeObjectId, out text, out text2);
                if (storeObjectId == null)
                {
                    return(null);
                }
                result = Folder.Bind(mailboxSession, storeObjectId, GetMailboxFolderStatistics.folderStatProps);
            }
            return(result);
        }
Пример #9
0
        // Token: 0x06001F8B RID: 8075 RVA: 0x000B5938 File Offset: 0x000B3B38
        private void RenderConversationPartRow(TextWriter writer, Folder contextFolder, Folder dataFolder, ExDateTime?lastDeliveryTime, int maximumIndentLevel)
        {
            IConversationTreeNode currentNode = this.ConversationPartsDataSource.GetCurrentNode();

            if (!ConversationUtilities.ShouldRenderItem(currentNode, (MailboxSession)dataFolder.Session))
            {
                return;
            }
            StoreObjectId itemProperty = this.DataSource.GetItemProperty <StoreObjectId>(StoreObjectSchema.ParentItemId);
            bool          flag         = (bool)this.DataSource.GetItemProperty <object>(MessageItemSchema.IsRead);
            bool          flag2        = !ConversationUtilities.IsLocalNode(currentNode);
            bool          flag3        = Utilities.IsDefaultFolderId((MailboxSession)dataFolder.Session, itemProperty, DefaultFolderType.DeletedItems);

            writer.Write("<div id=\"");
            writer.Write("ver");
            writer.Write("\" class=\"");
            writer.Write(flag2 ? "df " : string.Empty);
            writer.Write(flag ? string.Empty : "ur");
            writer.Write((this.DataSource.CurrentItem == this.DataSource.EndRange) ? " eclr" : string.Empty);
            writer.Write("\">");
            writer.Write("<div class=cData");
            ItemList2.RenderRowId(writer, this.DataSource.GetItemId());
            this.RenderConversationPartMetaDataExpandos(writer, currentNode, dataFolder, itemProperty, lastDeliveryTime);
            writer.Write(">");
            writer.Write("</div>");
            int num2;

            if (this.ConversationPartsDataSource.SortOrder == ConversationTreeSortOrder.DeepTraversalAscending || this.ConversationPartsDataSource.SortOrder == ConversationTreeSortOrder.DeepTraversalDescending)
            {
                IConversationTreeNode conversationTreeNode = currentNode;
                int num = 0;
                while (conversationTreeNode != null && num < maximumIndentLevel)
                {
                    num++;
                    conversationTreeNode = conversationTreeNode.ParentNode;
                }
                num2 = num * 4 + 18;
            }
            else
            {
                num2 = 22;
            }
            writer.Write("<div class=expc2 style=\"");
            writer.Write(base.UserContext.IsRtl ? "right:" : "left:");
            writer.Write(num2);
            writer.Write("px;width:");
            writer.Write(20);
            writer.Write("px;\">");
            base.RenderMessageIcon(writer);
            writer.Write("</div>");
            writer.Write("<div class=expc3 style=\"");
            writer.Write(base.UserContext.IsRtl ? "right:" : "left:");
            writer.Write(num2 + 20);
            writer.Write("px;\">");
            if (flag3)
            {
                writer.Write("<strike>");
            }
            base.RenderColumn(writer, ColumnId.From);
            if (flag3)
            {
                writer.Write("</strike>");
            }
            writer.Write("</div>");
            if (flag2)
            {
                base.UserContext.ClearFolderNameCache();
                writer.Write("<div class=\"expc4 df\">");
                base.RenderVLVAnchorOpen(writer);
                writer.Write(Utilities.HtmlEncode(base.UserContext.GetCachedFolderName(itemProperty, (MailboxSession)dataFolder.Session)));
                base.RenderVLVAnchorClose(writer);
                writer.Write("</div>");
            }
            else
            {
                writer.Write("<div class=\"expc4 r\">");
                base.RenderColumn(writer, ColumnId.DeliveryTime);
                writer.Write("</div>");
            }
            FlagStatus itemProperty2 = this.DataSource.GetItemProperty <FlagStatus>(ItemSchema.FlagStatus, FlagStatus.NotFlagged);

            writer.Write("<div class=\"c7");
            if (itemProperty2 != FlagStatus.NotFlagged)
            {
                writer.Write(" stky");
            }
            writer.Write("\" id=");
            writer.Write("divFlg");
            writer.Write(">");
            base.RenderColumn(writer, ColumnId.FlagDueDate);
            writer.Write("</div>");
            string[] itemProperty3 = this.DataSource.GetItemProperty <string[]>(ItemSchema.Categories, null);
            writer.Write("<div class=\"r c6");
            if (itemProperty3 != null && itemProperty3.Length > 0)
            {
                writer.Write(" stky");
            }
            writer.Write("\" id=");
            writer.Write("divCat");
            writer.Write(">");
            base.RenderColumn(writer, ColumnId.Categories);
            writer.Write("</div>");
            writer.Write("<div class=c5 style=\"text-decoration:none;\">");
            bool flag4 = base.RenderColumn(writer, ColumnId.Importance, false);

            base.RenderColumn(writer, ColumnId.HasAttachment, !flag4);
            writer.Write("</div>");
            base.RenderSelectionImage(writer);
            writer.Write("</div>");
        }
Пример #10
0
        // Token: 0x06001F70 RID: 8048 RVA: 0x000B4F1C File Offset: 0x000B311C
        private bool LoadById(ObjectId seekToObjectId, SeekDirection seekDirection, int itemCount, bool adjacent)
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "FolderListViewDataSource.Load(IUniqueItemId seekToItemId, SeekDirection seekDirection, int itemCount)");
            if (itemCount < 1)
            {
                throw new ArgumentOutOfRangeException("itemCount", "itemCount must be greater than 0");
            }
            if (seekToObjectId == null)
            {
                throw new ArgumentNullException("seekToObjectId");
            }
            if (!this.UserHasRightToLoad)
            {
                return(true);
            }
            StoreId storeId = Utilities.TryGetStoreId(seekToObjectId);

            PropertyDefinition[] requestedProperties = base.GetRequestedProperties();
            if (this.folder.ItemCount == 0)
            {
                return(true);
            }
            bool flag  = false;
            bool flag2 = false;

            try
            {
                if (this.queryResult == null)
                {
                    this.queryResult = this.CreateQueryResult(this.filterQuery, this.sortBy, requestedProperties);
                }
                if (!this.conversationMode)
                {
                    StoreObjectId storeObjectId = storeId as StoreObjectId;
                    if (storeObjectId != null)
                    {
                        flag2 = this.queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.Id, storeObjectId));
                    }
                }
                else
                {
                    ConversationId conversationId = storeId as ConversationId;
                    if (conversationId != null)
                    {
                        if (adjacent)
                        {
                            OwaStoreObjectId owaStoreObjectId = seekToObjectId as OwaStoreObjectId;
                            if (owaStoreObjectId.InstanceKey != null)
                            {
                                flag2 = this.queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.InstanceKey, owaStoreObjectId.InstanceKey));
                            }
                        }
                        else
                        {
                            flag2 = this.queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ConversationItemSchema.ConversationId, conversationId));
                            if (flag2)
                            {
                                IStorePropertyBag[] propertyBags = this.queryResult.GetPropertyBags(1);
                                byte[] instanceKey = propertyBags[0].TryGetProperty(ItemSchema.InstanceKey) as byte[];
                                this.newSelectionId = OwaStoreObjectId.CreateFromConversationId(conversationId, this.Folder, instanceKey);
                                this.queryResult.SeekToOffset(SeekReference.OriginCurrent, -1);
                            }
                        }
                    }
                }
                if (adjacent && !flag2)
                {
                    return(false);
                }
                if (!flag2)
                {
                    this.queryResult.SeekToOffset(SeekReference.OriginBeginning, 0);
                }
                switch (seekDirection)
                {
                case SeekDirection.Next:
                    if (adjacent)
                    {
                        this.queryResult.SeekToOffset(SeekReference.OriginCurrent, 1);
                    }
                    else if (this.queryResult.EstimatedRowCount < this.queryResult.CurrentRow + itemCount + 1)
                    {
                        this.queryResult.SeekToOffset(SeekReference.OriginCurrent, this.queryResult.EstimatedRowCount - this.queryResult.CurrentRow - itemCount);
                    }
                    break;

                case SeekDirection.Previous:
                {
                    int offset;
                    if (adjacent)
                    {
                        if (this.queryResult.CurrentRow == 0)
                        {
                            return(true);
                        }
                        if (this.queryResult.CurrentRow < itemCount)
                        {
                            itemCount = this.queryResult.CurrentRow;
                        }
                        offset = -1 * itemCount;
                    }
                    else if (this.queryResult.CurrentRow + 1 < itemCount)
                    {
                        offset = -1 * (this.queryResult.CurrentRow + 1);
                    }
                    else
                    {
                        offset = 1 - itemCount;
                    }
                    this.queryResult.SeekToOffset(SeekReference.OriginCurrent, offset);
                    break;
                }
                }
                this.GetView(this.queryResult, itemCount, this.queryResult.CurrentRow);
                flag = true;
            }
            finally
            {
                if (!flag || this.shouldDisposeQueryResult)
                {
                    this.DisposeQueryResultIfPresent();
                }
            }
            return(true);
        }
        private MailboxFolderConfiguration GetFolderInformation(int folderIndex, List <object[]> allFolderRows, MailboxSession mailboxSession, IConfigurationSession adConfigSession)
        {
            MailboxFolderConfiguration mailboxFolderConfiguration = null;

            object[] array = allFolderRows[folderIndex];
            if (GetMailboxFolderStatistics.PropertyExists(array[1]) && GetMailboxFolderStatistics.PropertyExists(array[15]))
            {
                mailboxFolderConfiguration = new MailboxFolderConfiguration();
                string folderPath = (string)array[15];
                mailboxFolderConfiguration.FolderPath = folderPath;
                mailboxFolderConfiguration.SetIdentity(new MailboxFolderId(this.Identity.ToString(), mailboxFolderConfiguration.FolderPath));
                mailboxFolderConfiguration.Date = (DateTime)((ExDateTime)array[10]);
                if (GetMailboxFolderStatistics.PropertyExists(array[0]))
                {
                    mailboxFolderConfiguration.Name = (string)array[0];
                }
                else
                {
                    this.WriteWarning(Strings.UnableToRetrieveFolderName(mailboxFolderConfiguration.FolderPath));
                }
                StoreObjectId objectId = ((VersionedId)array[1]).ObjectId;
                mailboxFolderConfiguration.FolderId = objectId.ToBase64String();
                long num = 0L;
                if (GetMailboxFolderStatistics.PropertyExists(array[6]))
                {
                    num = (long)array[6];
                }
                mailboxFolderConfiguration.FolderSize = ByteQuantifiedSize.FromBytes(checked ((ulong)num));
                if (GetMailboxFolderStatistics.PropertyExists(array[4]))
                {
                    mailboxFolderConfiguration.ItemsInFolder = (int)array[4];
                    mailboxFolderConfiguration.ItemsInFolderAndSubfolders = mailboxFolderConfiguration.ItemsInFolder;
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[5]))
                {
                    mailboxFolderConfiguration.ItemsInFolder += (int)array[5];
                    mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array[5];
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[11]))
                {
                    mailboxFolderConfiguration.DeletedItemsInFolder = (int)array[11];
                    mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders = mailboxFolderConfiguration.DeletedItemsInFolder;
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[12]))
                {
                    mailboxFolderConfiguration.DeletedItemsInFolder += (int)array[12];
                    mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += mailboxFolderConfiguration.DeletedItemsInFolder;
                }
                int num2 = -1;
                if (GetMailboxFolderStatistics.PropertyExists(array[3]))
                {
                    num2 = (int)array[3];
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[2]) && (bool)array[2])
                {
                    bool flag  = false;
                    bool flag2 = false;
                    for (int i = folderIndex + 1; i < allFolderRows.Count; i++)
                    {
                        object[] array2 = allFolderRows[i];
                        if (GetMailboxFolderStatistics.PropertyExists(array2[15]) && GetMailboxFolderStatistics.PropertyExists(array2[3]))
                        {
                            int num3 = (int)array2[3];
                            if (num3 <= num2)
                            {
                                break;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[6]))
                            {
                                long num4 = (long)array2[6];
                                if (num4 > 0L)
                                {
                                    num += num4;
                                }
                            }
                            else
                            {
                                flag2 = true;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[4]))
                            {
                                mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array2[4];
                            }
                            else
                            {
                                flag = true;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[5]))
                            {
                                mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array2[5];
                            }
                            else
                            {
                                flag = true;
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[11]))
                            {
                                mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += (int)array2[11];
                            }
                            if (GetMailboxFolderStatistics.PropertyExists(array2[12]))
                            {
                                mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += (int)array2[12];
                            }
                        }
                    }
                    if (flag)
                    {
                        this.WriteWarning(Strings.TotalFolderCount(mailboxFolderConfiguration.FolderPath));
                    }
                    if (flag2)
                    {
                        this.WriteWarning(Strings.TotalFolderSize(mailboxFolderConfiguration.FolderPath));
                    }
                }
                mailboxFolderConfiguration.FolderAndSubfolderSize = ByteQuantifiedSize.FromBytes(checked ((ulong)num));
                if (GetMailboxFolderStatistics.PropertyExists(array[7]))
                {
                    bool flag3 = ((int)array[7] & 1) != 0;
                    mailboxFolderConfiguration.FolderType = (flag3 ? ElcFolderType.ManagedCustomFolder.ToString() : null);
                }
                if (mailboxFolderConfiguration.FolderType == null)
                {
                    VersionedId       folderId          = (VersionedId)array[1];
                    DefaultFolderType defaultFolderType = mailboxSession.IsDefaultFolderType(folderId);
                    if (defaultFolderType == DefaultFolderType.None)
                    {
                        if (GetMailboxFolderStatistics.PropertyExists(array[9]))
                        {
                            StoreObjectId folderId2 = (StoreObjectId)array[9];
                            defaultFolderType = mailboxSession.IsDefaultFolderType(folderId2);
                        }
                        switch (defaultFolderType)
                        {
                        case DefaultFolderType.AdminAuditLogs:
                        case DefaultFolderType.Audits:
                            mailboxFolderConfiguration.FolderType = defaultFolderType.ToString();
                            break;

                        default:
                            mailboxFolderConfiguration.FolderType = Strings.UserCreatedFolder;
                            break;
                        }
                    }
                    else
                    {
                        mailboxFolderConfiguration.FolderType = defaultFolderType.ToString();
                    }
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[8]))
                {
                    Guid             guid          = new Guid((string)array[8]);
                    ADObjectId       valueToSearch = new ADObjectId(guid.ToByteArray());
                    List <ELCFolder> list          = ELCTaskHelper.FindELCFolder(adConfigSession, valueToSearch, FindByType.FolderAdObjectId);
                    if (list == null || list.Count != 1)
                    {
                        this.WriteWarning(Strings.UnableToRetrieveManagedFolder);
                    }
                    else
                    {
                        mailboxFolderConfiguration.ManagedFolder = new ELCFolderIdParameter(list[0].Id);
                    }
                }
                IConfigurationSession configurationSession = null;
                if (GetMailboxFolderStatistics.PropertyExists(array[13]))
                {
                    byte[] array3 = (byte[])array[13];
                    if (array3 != null)
                    {
                        Guid tagGuid = new Guid(array3);
                        configurationSession = this.CreateConfigurationSession(mailboxSession);
                        List <RetentionPolicyTag> list2 = ELCTaskHelper.FindRetentionPolicyTag(configurationSession, tagGuid);
                        if (list2 == null || list2.Count != 1)
                        {
                            this.WriteWarning(Strings.UnableToRetrieveDeletePolicyTag);
                        }
                        else
                        {
                            mailboxFolderConfiguration.DeletePolicy = new RetentionPolicyTagIdParameter(list2[0].Id);
                        }
                    }
                }
                if (GetMailboxFolderStatistics.PropertyExists(array[14]))
                {
                    byte[] array4 = (byte[])array[14];
                    if (array4 != null)
                    {
                        Guid tagGuid2 = new Guid(array4);
                        if (configurationSession == null)
                        {
                            configurationSession = this.CreateConfigurationSession(mailboxSession);
                        }
                        List <RetentionPolicyTag> list3 = ELCTaskHelper.FindRetentionPolicyTag(configurationSession, tagGuid2);
                        if (list3 == null || list3.Count != 1)
                        {
                            this.WriteWarning(Strings.UnableToRetrieveArchivePolicyTag);
                        }
                        else
                        {
                            mailboxFolderConfiguration.ArchivePolicy = new RetentionPolicyTagIdParameter(list3[0].Id);
                        }
                    }
                }
            }
            return(mailboxFolderConfiguration);
        }
        public bool DoesMatchCriteria(StoreObjectId parentFolderId, StoreObjectId storeObjectId)
        {
            IConversationTreeNode conversationTreeNode;

            return(!this.ExcludedFolders.Contains(parentFolderId) && (this.Conversation == null || this.Conversation.ConversationTree.TryGetConversationTreeNode(storeObjectId, out conversationTreeNode)));
        }
Пример #13
0
        // Token: 0x06002AD3 RID: 10963 RVA: 0x000F1110 File Offset: 0x000EF310
        private void RenderMemberEmailLink(string routingAddress, string displayName, string smtpAddress, string routingType, AddressOrigin addressOrigin, StoreObjectId storeObjectId, EmailAddressIndex emailAddressIndex)
        {
            StringBuilder stringBuilder = new StringBuilder("openItm(\"?ae=Item&t=IPM.Note&a=New&to=");

            stringBuilder.Append(Utilities.JavascriptEncode(Utilities.HtmlEncode(Utilities.UrlEncode(routingAddress))));
            stringBuilder.Append("&nm=");
            stringBuilder.Append(Utilities.JavascriptEncode(Utilities.HtmlEncode(Utilities.UrlEncode(displayName))));
            stringBuilder.Append("&rt=");
            stringBuilder.Append(Utilities.JavascriptEncode(Utilities.HtmlEncode(Utilities.UrlEncode(routingType))));
            if (addressOrigin != AddressOrigin.Unknown)
            {
                stringBuilder.Append("&ao=");
                stringBuilder.Append((int)addressOrigin);
            }
            if (storeObjectId != null)
            {
                stringBuilder.Append("&stId=");
                stringBuilder.Append(Utilities.JavascriptEncode(Utilities.HtmlEncode(Utilities.UrlEncode(storeObjectId.ToBase64String()))));
                if (!Utilities.IsMapiPDL(routingType))
                {
                    stringBuilder.Append("&ei=");
                    stringBuilder.Append((int)emailAddressIndex);
                }
            }
            string text = smtpAddress ?? routingAddress;

            if (Utilities.IsCustomRoutingType(text, routingType))
            {
                text = string.Concat(new string[]
                {
                    "[",
                    routingType,
                    ": ",
                    text,
                    "]"
                });
            }
            stringBuilder.Append("\");");
            base.Response.Write("<a class=lnk ");
            Utilities.RenderScriptHandler(base.Response.Output, "onclick", stringBuilder.ToString());
            base.Response.Write(" title=\"");
            Utilities.HtmlEncode(text, base.Response.Output);
            base.Response.Write("\">");
            Utilities.HtmlEncode(text, base.Response.Output);
            base.Response.Write("</a>");
        }
Пример #14
0
        private void RenderAppointmentData(CalendarViewBase view, int i, ExDateTime itemStart, ExDateTime itemEnd)
        {
            ICalendarDataSource     dataSource      = view.DataSource;
            CalendarItemTypeWrapper wrappedItemType = dataSource.GetWrappedItemType(i);

            this.output.Write("new Item(\"");
            OwaStoreObjectId            itemId    = dataSource.GetItemId(i);
            string                      changeKey = dataSource.GetChangeKey(i);
            PublishedCalendarDataSource publishedCalendarDataSource = dataSource as PublishedCalendarDataSource;

            if (publishedCalendarDataSource != null && publishedCalendarDataSource.DetailLevel != DetailLevelEnumType.AvailabilityOnly)
            {
                StoreObjectId itemStoreObjectId = publishedCalendarDataSource.GetItemStoreObjectId(i);
                Utilities.JavascriptEncode(itemStoreObjectId.ToString(), this.output);
                this.output.Write("\",\"");
                if (this.IsOneOfRecurrence(wrappedItemType))
                {
                    StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(itemStoreObjectId.ProviderLevelItemId);
                    Utilities.JavascriptEncode(storeObjectId.ToString(), this.output);
                }
                else
                {
                    this.output.Write("0");
                }
            }
            else
            {
                if (itemId != null)
                {
                    Utilities.JavascriptEncode(itemId.ToString(), this.output);
                }
                this.output.Write("\",\"");
                if (itemId != null && this.IsOneOfRecurrence(wrappedItemType))
                {
                    OwaStoreObjectId providerLevelItemId = itemId.ProviderLevelItemId;
                    Utilities.JavascriptEncode(providerLevelItemId.ToString(), this.output);
                }
                else
                {
                    this.output.Write("0");
                }
            }
            this.output.Write("\",\"");
            if (changeKey != null)
            {
                Utilities.JavascriptEncode(changeKey, this.output);
            }
            this.output.Write("\",\"");
            this.output.Write(DateTimeUtilities.GetJavascriptDate(itemStart));
            this.output.Write("\",\"");
            this.output.Write(DateTimeUtilities.GetJavascriptDate(itemEnd));
            this.output.Write("\",\"");
            Utilities.JavascriptEncode(dataSource.GetSubject(i), this.output);
            this.output.Write("\",\"");
            Utilities.JavascriptEncode(dataSource.GetLocation(i), this.output);
            BusyTypeWrapper wrappedBusyType = dataSource.GetWrappedBusyType(i);

            this.output.Write("\",");
            this.output.Write((int)wrappedBusyType);
            this.output.Write(",\"");
            if (itemId != null)
            {
                Utilities.JavascriptEncode(ObjectClass.GetContainerMessageClass(itemId.StoreObjectType), this.output);
            }
            this.output.Write("\"");
            bool flag = dataSource.IsMeeting(i);

            this.output.Write(flag ? ",1" : ",0");
            this.output.Write(dataSource.IsCancelled(i) ? ",1" : ",0");
            bool flag2 = dataSource.IsOrganizer(i);

            this.output.Write(flag2 ? ",1" : ",0");
            this.output.Write(",\"");
            if (flag)
            {
                Utilities.JavascriptEncode(dataSource.GetOrganizerDisplayName(i), this.output);
            }
            this.output.Write("\"");
            bool flag3 = dataSource.IsPrivate(i);

            this.output.Write(flag3 ? ",1," : ",0,");
            this.output.Write((int)wrappedItemType);
            this.output.Write(dataSource.HasAttachment(i) ? ",1" : ",0");
            this.output.Write(",\"");
            this.output.Write(dataSource.GetCssClassName(i));
            this.output.Write("\"");
            this.output.Write(")");
        }
        private List <IStorePropertyBag> GetChildNodesNotOnThreadTree(ConversationId conversationThreadId, StoreObjectId itemId)
        {
            IConversationTreeNode    equivalentNodeFromConversationTree = this.GetEquivalentNodeFromConversationTree(itemId);
            List <IStorePropertyBag> list = new List <IStorePropertyBag>();

            foreach (IConversationTreeNode conversationTreeNode in equivalentNodeFromConversationTree.ChildNodes)
            {
                if (!conversationTreeNode.ConversationThreadId.Equals(conversationThreadId))
                {
                    list.Add(conversationTreeNode.MainPropertyBag);
                }
            }
            return(list);
        }
Пример #16
0
        // Token: 0x06001F8D RID: 8077 RVA: 0x000B5D14 File Offset: 0x000B3F14
        private void RenderConversationPartMetaDataExpandos(TextWriter writer, IConversationTreeNode current, Folder dataFolder, StoreObjectId currentFolderId, ExDateTime?lastDeliveryTime)
        {
            base.RenderMessageViewItemMetaDataExpandos(writer);
            if (lastDeliveryTime != null && this.DataSource.GetItemProperty <ExDateTime>(ItemSchema.ReceivedTime, ExDateTime.MinValue) == lastDeliveryTime)
            {
                writer.Write(" ");
                writer.Write("fLR");
                writer.Write("=");
                writer.Write(1);
            }
            if (current.ParentNode != null && current.ParentNode.ParentNode != null)
            {
                VersionedId versionedId = (VersionedId)current.ParentNode.StorePropertyBags[0].TryGetProperty(ItemSchema.Id);
                if (versionedId != null)
                {
                    writer.Write(" ");
                    writer.Write("pId");
                    writer.Write("=");
                    Utilities.HtmlEncode(Utilities.GetItemIdString(versionedId.ObjectId, dataFolder), writer);
                }
            }
            writer.Write(" ");
            writer.Write("fId");
            writer.Write("=");
            Utilities.HtmlEncode(currentFolderId.ToBase64String(), writer);
            StoreObjectId storeObjectId = base.UserContext.GetDeletedItemsFolderId((MailboxSession)dataFolder.Session).StoreObjectId;

            writer.Write(" ");
            writer.Write("fInDelItms");
            writer.Write("=");
            Utilities.HtmlEncode(currentFolderId.Equals(storeObjectId) ? "1" : "0", writer);
            bool flag = Utilities.IsDefaultFolderId(base.UserContext.MailboxSession, currentFolderId, DefaultFolderType.JunkEmail);

            writer.Write(" ");
            writer.Write("fJnk");
            writer.Write("=");
            writer.Write(flag ? "1" : "0");
        }
Пример #17
0
 // Token: 0x06000C1C RID: 3100 RVA: 0x000533C0 File Offset: 0x000515C0
 public static bool TryParseMailTo(string mailToUrlValue, UserContext userContext, out StoreObjectId mailToItemId)
 {
     if (mailToUrlValue == null)
     {
         throw new ArgumentNullException("mailToUrlValue");
     }
     if (userContext == null)
     {
         throw new ArgumentNullException("userContext");
     }
     mailToItemId = null;
     if (null == Utilities.TryParseUri(mailToUrlValue))
     {
         return(false);
     }
     using (MessageItem messageItem = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId))
     {
         messageItem[ItemSchema.ConversationIndexTracking] = true;
         if (Globals.ArePerfCountersEnabled)
         {
             OwaSingleCounters.ItemsCreated.Increment();
         }
         if (!MailToParser.TryMailToParse(messageItem, mailToUrlValue))
         {
             return(false);
         }
         messageItem.Save(SaveMode.ResolveConflicts);
         messageItem.Load();
         mailToItemId = messageItem.Id.ObjectId;
     }
     return(true);
 }
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            applicationElement = ApplicationElement.NotSet;
            type   = string.Empty;
            state  = string.Empty;
            action = string.Empty;
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();

            preFormActionResponse.Type = owaContext.FormsRegistryContext.Type;
            preFormActionResponse.ApplicationElement = ApplicationElement.Item;
            bool flag  = false;
            bool flag2 = false;
            CalendarItemBaseData calendarItemBaseData = EditCalendarItemHelper.GetUserContextData(owaContext.UserContext);
            StoreObjectId        storeObjectId        = QueryStringUtilities.CreateItemStoreObjectId(owaContext.UserContext.MailboxSession, owaContext.HttpContext.Request, false);

            if (calendarItemBaseData != null && calendarItemBaseData.Id != null && storeObjectId != null && !calendarItemBaseData.Id.Equals(storeObjectId))
            {
                EditCalendarItemHelper.ClearUserContextData(owaContext.UserContext);
                calendarItemBaseData = null;
            }
            if (calendarItemBaseData != null)
            {
                flag  = calendarItemBaseData.IsOrganizer;
                flag2 = calendarItemBaseData.IsMeeting;
            }
            else
            {
                if (storeObjectId == null)
                {
                    throw new OwaLostContextException("Lost changes since last save.");
                }
                CalendarItemBase calendarItemBase2;
                CalendarItemBase calendarItemBase = calendarItemBase2 = CalendarItemBase.Bind(owaContext.UserContext.MailboxSession, storeObjectId);
                try
                {
                    flag  = calendarItemBase.IsOrganizer();
                    flag2 = calendarItemBase.IsMeeting;
                }
                finally
                {
                    if (calendarItemBase2 != null)
                    {
                        ((IDisposable)calendarItemBase2).Dispose();
                    }
                }
            }
            if (flag2 && !flag)
            {
                preFormActionResponse.Action = "Read";
            }
            else
            {
                preFormActionResponse.Action = "Open";
            }
            string text = "ae,a,t,s";

            for (int i = 0; i < owaContext.HttpContext.Request.QueryString.Count; i++)
            {
                string text2 = owaContext.HttpContext.Request.QueryString.Keys[i];
                if (text.IndexOf(text2, StringComparison.Ordinal) == -1)
                {
                    preFormActionResponse.AddParameter(text2, owaContext.HttpContext.Request.QueryString[text2]);
                }
            }
            return(preFormActionResponse);
        }
Пример #19
0
        internal static MapiFolderPath CalculateMailboxFolderPath(StoreSession session, StoreObjectId storeFolderId, StoreObjectId parentStoreFolderId, string displayName, Dictionary <StoreObjectId, MapiFolderPath> knownFolderPathsCache)
        {
            if (storeFolderId == null)
            {
                throw new ArgumentNullException("storeFolderId");
            }
            if (parentStoreFolderId == null)
            {
                throw new ArgumentNullException("parentStoreFolderId");
            }
            if (knownFolderPathsCache == null)
            {
                throw new ArgumentNullException("knownFolderPathsCache");
            }
            Stack <string>        stack          = new Stack <string>();
            Stack <StoreObjectId> stack2         = new Stack <StoreObjectId>();
            MapiFolderPath        mapiFolderPath = null;

            while (null == mapiFolderPath)
            {
                if (knownFolderPathsCache.ContainsKey(storeFolderId))
                {
                    mapiFolderPath = knownFolderPathsCache[storeFolderId];
                }
                else if (knownFolderPathsCache.ContainsKey(parentStoreFolderId))
                {
                    mapiFolderPath = knownFolderPathsCache[parentStoreFolderId];
                    stack.Push(displayName);
                    stack2.Push(storeFolderId);
                }
                else
                {
                    using (Folder folder = Folder.Bind(session, parentStoreFolderId, new PropertyDefinition[]
                    {
                        FolderSchema.DisplayName,
                        StoreObjectSchema.ParentItemId
                    }))
                    {
                        stack.Push(displayName);
                        stack2.Push(storeFolderId);
                        storeFolderId       = parentStoreFolderId;
                        parentStoreFolderId = (StoreObjectId)folder[StoreObjectSchema.ParentItemId];
                        displayName         = (string)folder[FolderSchema.DisplayName];
                    }
                }
            }
            MapiFolderPath mapiFolderPath2 = mapiFolderPath;

            while (0 < stack.Count)
            {
                mapiFolderPath2 = MapiFolderPath.GenerateFolderPath(mapiFolderPath2, stack.Pop());
                StoreObjectId key = stack2.Pop();
                if (!knownFolderPathsCache.ContainsKey(key))
                {
                    knownFolderPathsCache.Add(key, mapiFolderPath2);
                }
            }
            return(mapiFolderPath2);
        }
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            UserContext userContext = owaContext.UserContext;
            HttpRequest request     = owaContext.HttpContext.Request;

            string[] array = null;
            applicationElement = ApplicationElement.Item;
            type   = string.Empty;
            action = string.Empty;
            state  = string.Empty;
            if (!Utilities.IsPostRequest(request))
            {
                return(userContext.LastClientViewState.ToPreFormActionResponse());
            }
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();
            string        formParameter = Utilities.GetFormParameter(request, "hidAB");
            int           num           = 0;
            StoreObjectId storeObjectId = null;
            string        changeKey     = null;

            string[] array2 = formParameter.Split(new char[]
            {
                ';'
            });
            if (array2 != null && array2.Length > 0)
            {
                if (string.CompareOrdinal(array2[0], "Ad") == 0)
                {
                    num = 1;
                }
                else
                {
                    if (string.CompareOrdinal(array2[0], "Con") != 0)
                    {
                        throw new OwaInvalidRequestException("Invalid search location for addressbook");
                    }
                    num = 2;
                }
            }
            string action2 = owaContext.FormsRegistryContext.Action;

            if (action2 == null)
            {
                throw new OwaInvalidRequestException("Action query string parameter is missing");
            }
            object obj = AddressBookPreFormAction.actionParser.Parse(action2);

            AddressBookPreFormAction.Action action3 = (AddressBookPreFormAction.Action)obj;
            string text = request.Form["chkRcpt"];

            if (!string.IsNullOrEmpty(text))
            {
                array = text.Split(new char[]
                {
                    ','
                });
            }
            AddressBook.Mode mode = AddressBookHelper.TryReadAddressBookMode(request, AddressBook.Mode.None);
            if (AddressBook.IsEditingMode(mode))
            {
                string formParameter2 = Utilities.GetFormParameter(request, "hidid", false);
                changeKey = Utilities.GetFormParameter(request, "hidchk", false);
                if (!string.IsNullOrEmpty(formParameter2))
                {
                    storeObjectId = Utilities.CreateStoreObjectId(userContext.MailboxSession, formParameter2);
                    if (storeObjectId == null)
                    {
                        throw new OwaInvalidRequestException("ItemId cannot be null");
                    }
                }
            }
            switch (action3)
            {
            case AddressBookPreFormAction.Action.Done:
                if (AddressBook.IsEditingMode(mode))
                {
                    using (Item item = AddressBookHelper.GetItem(userContext, mode, storeObjectId, changeKey))
                    {
                        if (array != null && array.Length > 0)
                        {
                            RecipientItemType type2          = RecipientItemType.To;
                            string            formParameter3 = Utilities.GetFormParameter(request, "hidrw");
                            if (!string.IsNullOrEmpty(formParameter3))
                            {
                                int num2;
                                if (!int.TryParse(formParameter3, out num2) || num2 < 1 || num2 > 3)
                                {
                                    type2 = RecipientItemType.To;
                                }
                                else
                                {
                                    type2 = (RecipientItemType)num2;
                                }
                            }
                            if (num == 1)
                            {
                                AddressBookHelper.AddRecipientsToDraft(array, item, type2, userContext);
                            }
                            else if (num == 2)
                            {
                                AddressBookHelper.AddContactsToDraft(item, type2, userContext, array);
                            }
                        }
                        preFormActionResponse = AddressBookHelper.RedirectToEdit(userContext, item, mode);
                        break;
                    }
                }
                throw new OwaInvalidRequestException("This action must be in editing mode");

            case AddressBookPreFormAction.Action.Mail:
                if (array != null && array.Length > 0)
                {
                    using (Item item2 = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId))
                    {
                        item2[ItemSchema.ConversationIndexTracking] = true;
                        if (num == 1)
                        {
                            AddressBookHelper.AddRecipientsToDraft(array, item2, RecipientItemType.To, userContext);
                        }
                        else if (num == 2)
                        {
                            AddressBookHelper.AddContactsToDraft(item2, RecipientItemType.To, userContext, array);
                        }
                        preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                        preFormActionResponse.Type   = "IPM.Note";
                        preFormActionResponse.Action = "Open";
                        preFormActionResponse.State  = "Draft";
                        preFormActionResponse.AddParameter("id", item2.Id.ObjectId.ToBase64String());
                        break;
                    }
                }
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type   = "IPM.Note";
                preFormActionResponse.Action = "New";
                break;

            case AddressBookPreFormAction.Action.MeetingRequest:
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type = "IPM.Appointment";
                if (array != null && array.Length > 0)
                {
                    using (CalendarItemBase calendarItemBase = EditCalendarItemHelper.CreateDraft(userContext, userContext.CalendarFolderId))
                    {
                        calendarItemBase.IsMeeting = true;
                        if (num == 1)
                        {
                            AddressBookHelper.AddRecipientsToDraft(array, calendarItemBase, RecipientItemType.To, userContext);
                        }
                        else if (num == 2)
                        {
                            AddressBookHelper.AddContactsToDraft(calendarItemBase, RecipientItemType.To, userContext, array);
                        }
                        preFormActionResponse.Action = "Open";
                        EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase);
                        break;
                    }
                }
                preFormActionResponse.AddParameter("mr", "1");
                preFormActionResponse.Action = "New";
                break;

            case AddressBookPreFormAction.Action.Close:
                if (AddressBook.IsEditingMode(mode))
                {
                    using (Item item3 = AddressBookHelper.GetItem(userContext, mode, storeObjectId, changeKey))
                    {
                        preFormActionResponse = AddressBookHelper.RedirectToEdit(userContext, item3, mode);
                        break;
                    }
                }
                throw new OwaInvalidRequestException("This action must be in editing mode");

            case AddressBookPreFormAction.Action.AddToContacts:
            {
                string type3 = "IPM.Contact";
                string text2 = null;
                if (array == null || array.Length != 1)
                {
                    throw new OwaInvalidRequestException("User must select some recipient to add and can only add one recipient to contacts at one time");
                }
                ADObjectId adobjectId = DirectoryAssistance.ParseADObjectId(array[0]);
                if (adobjectId == null)
                {
                    throw new OwaADObjectNotFoundException();
                }
                IRecipientSession recipientSession = Utilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.FullyConsistent, true, userContext);
                ADRecipient       adrecipient      = recipientSession.Read(adobjectId);
                if (adrecipient == null)
                {
                    throw new OwaADObjectNotFoundException();
                }
                using (ContactBase contactBase = ContactUtilities.AddADRecipientToContacts(userContext, adrecipient))
                {
                    if (contactBase != null)
                    {
                        contactBase.Load();
                        text2 = contactBase.Id.ObjectId.ToBase64String();
                        type3 = contactBase.ClassName;
                    }
                }
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type = type3;
                if (text2 != null)
                {
                    preFormActionResponse.Action = "Open";
                    preFormActionResponse.State  = "Draft";
                    preFormActionResponse.AddParameter("id", text2);
                }
                else
                {
                    preFormActionResponse.Action = "New";
                }
                break;
            }

            default:
                throw new OwaInvalidRequestException("Invalid request for addressbook preformaction");
            }
            return(preFormActionResponse);
        }
        // Token: 0x06002085 RID: 8325 RVA: 0x000BC534 File Offset: 0x000BA734
        public new void Load(ObjectId seekToObjectId, SeekDirection seekDirection, int itemCount)
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "DumpsterListViewDataSource.Load(ObjectId seekToObjectId, SeekDirection seekDirection, int itemCount)");
            if (itemCount < 1)
            {
                throw new ArgumentOutOfRangeException("itemCount", "itemCount must be greater than 0");
            }
            if (seekToObjectId == null)
            {
                throw new ArgumentNullException("seekToObjectId");
            }
            if (!base.UserHasRightToLoad)
            {
                return;
            }
            StoreObjectId storeObjectId = Utilities.TryGetStoreId(seekToObjectId) as StoreObjectId;

            if (storeObjectId == null)
            {
                throw new ArgumentException("seekToObjectId could not be converted to a StoreObjectId");
            }
            PropertyDefinition[] requestedProperties = base.GetRequestedProperties();
            using (QueryResult queryResult = base.Folder.FolderQuery(FolderQueryFlags.SoftDeleted, null, DumpsterListViewDataSource.folderSortBy, requestedProperties))
            {
                using (QueryResult queryResult2 = base.Folder.ItemQuery(ItemQueryType.SoftDeleted, null, base.SortBy, requestedProperties))
                {
                    this.totalCount = queryResult.EstimatedRowCount + queryResult2.EstimatedRowCount;
                    object[][] itemsItemQuery = null;
                    if (this.totalCount != 0)
                    {
                        queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.Id, storeObjectId));
                        switch (seekDirection)
                        {
                        case SeekDirection.Next:
                            if (this.totalCount < queryResult.CurrentRow + itemCount + 1)
                            {
                                queryResult.SeekToOffset(SeekReference.OriginCurrent, this.totalCount - queryResult.CurrentRow - itemCount);
                            }
                            break;

                        case SeekDirection.Previous:
                        {
                            int offset;
                            if (queryResult.CurrentRow + 1 < itemCount)
                            {
                                offset = -1 * (queryResult.CurrentRow + 1);
                            }
                            else
                            {
                                offset = 1 - itemCount;
                            }
                            queryResult.SeekToOffset(SeekReference.OriginCurrent, offset);
                            break;
                        }
                        }
                        object[][] array = Utilities.FetchRowsFromQueryResult(queryResult, itemCount);
                        if (array.Length > 0)
                        {
                            base.StartRange = queryResult.CurrentRow - array.Length;
                        }
                        itemCount -= array.Length;
                        if (itemCount > 0)
                        {
                            if (array.Length == 0)
                            {
                                queryResult2.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.Id, storeObjectId));
                                switch (seekDirection)
                                {
                                case SeekDirection.Next:
                                    if (queryResult2.EstimatedRowCount < queryResult2.CurrentRow + itemCount + 1)
                                    {
                                        queryResult2.SeekToOffset(SeekReference.OriginCurrent, queryResult2.EstimatedRowCount - queryResult2.CurrentRow - itemCount);
                                    }
                                    break;

                                case SeekDirection.Previous:
                                {
                                    int offset2;
                                    if (queryResult2.CurrentRow + 1 < itemCount)
                                    {
                                        offset2 = -1 * (queryResult2.CurrentRow + 1);
                                        int num = itemCount - queryResult2.CurrentRow;
                                        int estimatedRowCount = queryResult.EstimatedRowCount;
                                        if (num > estimatedRowCount)
                                        {
                                            num = estimatedRowCount;
                                        }
                                        queryResult.SeekToOffset(SeekReference.OriginCurrent, -1 * num);
                                        array = Utilities.FetchRowsFromQueryResult(queryResult, num);
                                    }
                                    else
                                    {
                                        offset2 = 1 - itemCount;
                                    }
                                    queryResult.SeekToOffset(SeekReference.OriginCurrent, offset2);
                                    break;
                                }
                                }
                            }
                            itemsItemQuery = Utilities.FetchRowsFromQueryResult(queryResult2, itemCount);
                        }
                        this.CombineView(array, itemsItemQuery, queryResult, queryResult2);
                    }
                }
            }
        }
        // Token: 0x06001A99 RID: 6809 RVA: 0x00063744 File Offset: 0x00061944
        protected override PeopleFilter[] InternalExecute()
        {
            UserContext userContext = UserContextManager.GetUserContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, true);

            ExchangeVersion.Current = ExchangeVersion.Latest;
            MailboxSession      mailboxIdentityMailboxSession = base.MailboxIdentityMailboxSession;
            MailboxId           mailboxId = new MailboxId(mailboxIdentityMailboxSession);
            List <PeopleFilter> list      = new List <PeopleFilter>();

            list.Add(this.MakePeopleFilter(mailboxIdentityMailboxSession.GetDefaultFolderId(DefaultFolderType.MyContacts), mailboxIdentityMailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration), mailboxId, ClientStrings.MyContactsFolderName.ToString(), 1, true));
            PeopleFilterGroupPriorityManager peopleFilterGroupPriorityManager = new PeopleFilterGroupPriorityManager(mailboxIdentityMailboxSession, new XSOFactory());

            foreach (IStorePropertyBag storePropertyBag in new ContactFoldersEnumerator(mailboxIdentityMailboxSession, new XSOFactory(), ContactFoldersEnumeratorOptions.SkipHiddenFolders | ContactFoldersEnumeratorOptions.SkipDeletedFolders, PeopleFilterGroupPriorityManager.RequiredFolderProperties))
            {
                StoreObjectId       objectId          = ((VersionedId)storePropertyBag.TryGetProperty(FolderSchema.Id)).ObjectId;
                StoreObjectId       parentId          = storePropertyBag.TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId;
                string              valueOrDefault    = storePropertyBag.GetValueOrDefault <string>(FolderSchema.DisplayName, string.Empty);
                int                 sortGroupPriority = peopleFilterGroupPriorityManager.DetermineSortGroupPriority(storePropertyBag);
                ExtendedFolderFlags valueOrDefault2   = storePropertyBag.GetValueOrDefault <ExtendedFolderFlags>(FolderSchema.ExtendedFolderFlags, (ExtendedFolderFlags)0);
                bool                isReadOnly        = (valueOrDefault2 & ExtendedFolderFlags.ReadOnly) == ExtendedFolderFlags.ReadOnly;
                list.Add(this.MakePeopleFilter(objectId, parentId, mailboxId, valueOrDefault, sortGroupPriority, isReadOnly));
            }
            if (userContext.FeaturesManager.ClientServerSettings.OwaPublicFolders.Enabled)
            {
                IFavoritePublicFoldersManager favoritePublicFoldersManager = new FavoritePublicFoldersManager(mailboxIdentityMailboxSession);
                List <IFavoritePublicFolder>  list2 = new List <IFavoritePublicFolder>();
                using (IEnumerator <IFavoritePublicFolder> enumerator2 = favoritePublicFoldersManager.EnumerateContactsFolders().GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        IFavoritePublicFolder folder = enumerator2.Current;
                        if (!list2.Exists((IFavoritePublicFolder storedFavorite) => storedFavorite.FolderId.Equals(folder.FolderId)))
                        {
                            list2.Add(folder);
                        }
                    }
                }
                if (list2.Count > 0)
                {
                    for (int i = 0; i < list2.Count; i++)
                    {
                        list.Add(this.MakePublicFolderPeopleFilter(list2[i], i));
                    }
                }
            }
            ClientSecurityContext clientSecurityContext = base.CallContext.EffectiveCaller.ClientSecurityContext;
            IExchangePrincipal    mailboxOwner          = base.MailboxIdentityMailboxSession.MailboxOwner;
            AddressLists          addressLists          = new AddressLists(clientSecurityContext, mailboxOwner, userContext);

            if (addressLists.GlobalAddressList != null)
            {
                list.Add(new PeopleFilter
                {
                    DisplayName = addressLists.GlobalAddressList.DisplayName,
                    FolderId    = new AddressListId
                    {
                        Id = addressLists.GlobalAddressList.Id.ObjectGuid.ToString()
                    },
                    SortGroupPriority = 1000,
                    IsReadOnly        = true
                });
            }
            if (addressLists.AllRoomsAddressList != null)
            {
                list.Add(new PeopleFilter
                {
                    DisplayName = addressLists.AllRoomsAddressList.DisplayName,
                    FolderId    = new AddressListId
                    {
                        Id = addressLists.AllRoomsAddressList.Id.ObjectGuid.ToString()
                    },
                    SortGroupPriority = 1001,
                    IsReadOnly        = true
                });
            }
            foreach (AddressBookBase addressBookBase in addressLists.AllAddressLists)
            {
                if ((addressLists.GlobalAddressList == null || !addressBookBase.Id.Equals(addressLists.GlobalAddressList.Id)) && (addressLists.AllRoomsAddressList == null || !addressBookBase.Id.Equals(addressLists.AllRoomsAddressList.Id)) && !string.IsNullOrEmpty(addressBookBase.RecipientFilter) && (!addressBookBase.IsModernGroupsAddressList || userContext.FeaturesManager.ClientServerSettings.ModernGroups.Enabled))
                {
                    list.Add(new PeopleFilter
                    {
                        DisplayName = addressBookBase.DisplayName,
                        FolderId    = new AddressListId
                        {
                            Id = addressBookBase.Id.ObjectGuid.ToString()
                        },
                        SortGroupPriority = (addressBookBase.IsModernGroupsAddressList ? 1009 : this.GetSortGroupPriority(addressBookBase.RecipientFilter)),
                        IsReadOnly        = true
                    });
                }
            }
            list.Sort(new PeopleFilterComparer(mailboxIdentityMailboxSession.PreferedCulture));
            return(list.ToArray());
        }
Пример #23
0
        // Token: 0x06000942 RID: 2370 RVA: 0x000424EC File Offset: 0x000406EC
        public Folder Execute(UserContext userContext, Folder folder, SearchScope searchScope, string searchString, bool newSearch, bool asyncSearch)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }
            MailboxSession   mailboxSession   = (MailboxSession)folder.Session;
            QueryFilter      queryFilter      = SearchFilterGenerator.Execute(searchString, mailboxSession.Mailbox.IsContentIndexingEnabled, userContext.UserCulture, new PolicyTagMailboxProvider(userContext.MailboxSession), folder, searchScope, this.advancedQueryFilter);
            string           text             = (queryFilter == null) ? string.Empty : queryFilter.ToString();
            OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromStoreObject(folder);
            SearchFolder     searchFolder     = null;
            bool             flag             = false;
            Folder           result;

            try
            {
                if (userContext.SearchFolderId != null)
                {
                    if (!newSearch && userContext.LastSearchFolderId.Equals(owaStoreObjectId) && userContext.LastSearchQueryFilter.CompareTo(text) == 0 && userContext.LastSearchScope == searchScope)
                    {
                        try
                        {
                            searchFolder = SearchFolder.Bind(userContext.SearchFolderId.GetSession(userContext), userContext.SearchFolderId.StoreObjectId, FolderSearch.PrefetchProperties);
                        }
                        catch (ObjectNotFoundException)
                        {
                        }
                        if (searchFolder != null)
                        {
                            if (asyncSearch)
                            {
                                SearchPerformanceData searchPerformanceData = userContext.MapiNotificationManager.GetSearchPerformanceData(mailboxSession);
                                if (searchPerformanceData != null)
                                {
                                    searchPerformanceData.RefreshStart();
                                }
                                OwaContext.Current.SearchPerformanceData = searchPerformanceData;
                            }
                            flag = true;
                            return(searchFolder);
                        }
                    }
                    if (userContext.IsPushNotificationsEnabled)
                    {
                        userContext.MapiNotificationManager.CancelSearchNotifications(mailboxSession);
                        userContext.MapiNotificationManager.AddSearchFolderDeleteList(mailboxSession, userContext.SearchFolderId.StoreObjectId);
                    }
                    else
                    {
                        mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            userContext.SearchFolderId.StoreObjectId
                        });
                    }
                    userContext.SearchFolderId = null;
                }
                using (Folder folder2 = Folder.Bind(mailboxSession, userContext.GetSearchFoldersId(mailboxSession).StoreObjectId))
                {
                    searchFolder = SearchFolder.Create(mailboxSession, folder2.Id.ObjectId, "OWA Search " + userContext.Key.UserContextId + " " + DateTime.UtcNow.ToString("o"), CreateMode.CreateNew);
                }
                searchFolder.Save();
                searchFolder.Load(FolderSearch.PrefetchProperties);
                userContext.SearchFolderId        = OwaStoreObjectId.CreateFromStoreObject(searchFolder);
                userContext.LastSearchFolderId    = owaStoreObjectId;
                userContext.LastSearchQueryFilter = text;
                userContext.LastSearchScope       = searchScope;
                if (queryFilter == null)
                {
                    flag   = true;
                    result = searchFolder;
                }
                else
                {
                    bool      flag2 = FolderSearch.FailNonContentIndexedSearch(folder, queryFilter);
                    bool      flag3;
                    StoreId[] folderScope;
                    if (searchScope == SearchScope.SelectedFolder || !mailboxSession.Mailbox.IsContentIndexingEnabled)
                    {
                        flag3       = false;
                        folderScope = new StoreId[]
                        {
                            folder.Id.ObjectId
                        };
                    }
                    else if (searchScope == SearchScope.SelectedAndSubfolders)
                    {
                        flag3       = true;
                        folderScope = new StoreId[]
                        {
                            folder.Id.ObjectId
                        };
                    }
                    else
                    {
                        if (searchScope != SearchScope.AllFoldersAndItems && searchScope != SearchScope.AllItemsInModule)
                        {
                            throw new ArgumentOutOfRangeException();
                        }
                        flag3       = true;
                        folderScope = new StoreId[]
                        {
                            userContext.GetRootFolderId(mailboxSession)
                        };
                    }
                    if (searchScope != SearchScope.SelectedFolder)
                    {
                        if (!folder.Id.ObjectId.Equals(userContext.JunkEmailFolderId))
                        {
                            QueryFilter queryFilter2 = new ComparisonFilter(ComparisonOperator.NotEqual, StoreObjectSchema.ParentItemId, userContext.JunkEmailFolderId);
                            queryFilter = new AndFilter(new QueryFilter[]
                            {
                                queryFilter,
                                queryFilter2
                            });
                        }
                        StoreObjectId storeObjectId = userContext.GetDeletedItemsFolderId((MailboxSession)folder.Session).StoreObjectId;
                        if (!folder.Id.ObjectId.Equals(storeObjectId))
                        {
                            QueryFilter queryFilter3 = new ComparisonFilter(ComparisonOperator.NotEqual, StoreObjectSchema.ParentItemId, storeObjectId);
                            queryFilter = new AndFilter(new QueryFilter[]
                            {
                                queryFilter,
                                queryFilter3
                            });
                        }
                    }
                    ExTraceGlobals.MailDataTracer.TraceDebug((long)this.GetHashCode(), "Search\nFilter: {0}\nDeep Traversal: {1}\nFolder: {2}\nContent Indexing Enabled: {3}", new object[]
                    {
                        queryFilter,
                        flag3,
                        folder.Id,
                        mailboxSession.Mailbox.IsContentIndexingEnabled ? "Yes" : "No"
                    });
                    SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(queryFilter, folderScope);
                    searchFolderCriteria.DeepTraversal               = flag3;
                    searchFolderCriteria.MaximumResultsCount         = new int?(1000);
                    searchFolderCriteria.FailNonContentIndexedSearch = flag2;
                    SearchPerformanceData searchPerformanceData;
                    if (!userContext.IsPushNotificationsEnabled || !asyncSearch)
                    {
                        searchPerformanceData = new SearchPerformanceData();
                        searchPerformanceData.StartSearch(searchString);
                        IAsyncResult asyncResult = searchFolder.BeginApplyOneTimeSearch(searchFolderCriteria, null, null);
                        Stopwatch    stopwatch   = Utilities.StartWatch();
                        bool         flag4       = asyncResult.AsyncWaitHandle.WaitOne(30000, false);
                        searchPerformanceData.Complete(!flag4, true);
                        if (flag4)
                        {
                            searchFolder.EndApplyOneTimeSearch(asyncResult);
                        }
                        else
                        {
                            ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "FolderSearch.Execute. Search timed out.");
                            if (Globals.ArePerfCountersEnabled)
                            {
                                OwaSingleCounters.SearchesTimedOut.Increment();
                            }
                        }
                        Utilities.StopWatch(stopwatch, "FolderSearch.Execute (Wait for search to complete)");
                        if (Globals.ArePerfCountersEnabled)
                        {
                            PerformanceCounterManager.UpdateSearchTimePerformanceCounter(stopwatch.ElapsedMilliseconds);
                            OwaSingleCounters.TotalSearches.Increment();
                        }
                        searchFolder.Save();
                        searchFolder.Load(FolderSearch.PrefetchProperties);
                    }
                    else
                    {
                        userContext.MapiNotificationManager.InitSearchNotifications(mailboxSession, userContext.SearchFolderId.StoreObjectId, searchFolder, searchFolderCriteria, searchString);
                        searchPerformanceData = userContext.MapiNotificationManager.GetSearchPerformanceData(mailboxSession);
                    }
                    if (!flag2)
                    {
                        searchPerformanceData.SlowSearchEnabled();
                    }
                    OwaContext.Current.SearchPerformanceData = searchPerformanceData;
                    flag   = true;
                    result = searchFolder;
                }
            }
            finally
            {
                if (!flag && searchFolder != null)
                {
                    searchFolder.Dispose();
                }
            }
            return(result);
        }
Пример #24
0
        public static void DeleteMeetingMessageCalendarItem(StoreObjectId meetingMessageId)
        {
            if (meetingMessageId == null)
            {
                throw new ArgumentNullException("meetingRequestId");
            }
            MeetingMessage   meetingMessage   = null;
            CalendarItemBase calendarItemBase = null;
            UserContext      userContext      = UserContextManager.GetUserContext();

            try
            {
                try
                {
                    meetingMessage = (MeetingMessage)Item.Bind(userContext.MailboxSession, meetingMessageId, ItemBindOption.LoadRequiredPropertiesOnly);
                }
                catch (ObjectNotFoundException)
                {
                    ExTraceGlobals.CalendarDataTracer.TraceDebug(0L, "Meeting request could not be found.");
                    throw;
                }
                calendarItemBase = MeetingUtilities.TryGetCorrelatedItem(meetingMessage);
                if (calendarItemBase != null)
                {
                    if (!calendarItemBase.IsOrganizer())
                    {
                        MeetingRequest meetingRequest = meetingMessage as MeetingRequest;
                        if (meetingRequest != null)
                        {
                            if (meetingRequest.MeetingRequestType == MeetingMessageType.InformationalUpdate || meetingRequest.MeetingRequestType == MeetingMessageType.Outdated || calendarItemBase.ResponseType == ResponseType.Accept || calendarItemBase.ResponseType == ResponseType.Tentative)
                            {
                                return;
                            }
                        }
                        else
                        {
                            if (!(meetingMessage is MeetingCancellation))
                            {
                                throw new OwaInvalidRequestException("Meeting message must be either a meeting invite or meeting cancellation");
                            }
                            if (meetingMessage.IsOutOfDate(calendarItemBase))
                            {
                                return;
                            }
                        }
                        calendarItemBase.DeleteMeeting(DeleteItemFlags.MoveToDeletedItems);
                    }
                }
            }
            finally
            {
                if (meetingMessage != null)
                {
                    meetingMessage.Dispose();
                    meetingMessage = null;
                }
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                    calendarItemBase = null;
                }
            }
        }
Пример #25
0
        public Activity(ActivityId id, ClientId clientId, ExDateTime timeStamp, Guid clientSessionId, string clientVersion, long sequenceNumber, IMailboxSession mailboxSession, StoreObjectId itemId = null, StoreObjectId previousItemId = null, IDictionary <string, string> customProperties = null) : this(new MemoryPropertyBag())
        {
            ArgumentValidator.ThrowIfNull("clientId", clientId);
            ArgumentValidator.ThrowIfNullOrEmpty("clientVersion", clientVersion);
            ArgumentValidator.ThrowIfNull("mailboxSession", mailboxSession);
            EnumValidator <ActivityId> .ThrowIfInvalid(id);

            if (id == ActivityId.Min)
            {
                throw new ArgumentException("The value supplied for ActivityId is invalid (ActivityId.Min)");
            }
            if (clientId == ClientId.Min)
            {
                throw new ArgumentException("The value is not a valid ClientId (ClientId.Min)");
            }
            if (!timeStamp.HasTimeZone)
            {
                throw new ArgumentException("Timestamp has unspecified timezone: " + Activity.BuildDiagnosticString(id, clientId, timeStamp, clientSessionId, clientVersion, sequenceNumber, mailboxSession, itemId, previousItemId, customProperties));
            }
            this.Id              = id;
            this.ClientId        = clientId;
            this.TimeStamp       = timeStamp.ToUtc();
            this.ClientSessionId = clientSessionId;
            this.SequenceNumber  = sequenceNumber;
            this.ClientVersion   = clientVersion;
            this.MailboxGuid     = mailboxSession.MailboxGuid;
            IUserPrincipal userPrincipal = mailboxSession.MailboxOwner as IUserPrincipal;

            this.NetId = ((userPrincipal != null) ? userPrincipal.NetId : null);
            if (mailboxSession.Capabilities != null && mailboxSession.Capabilities.CanHaveCulture && mailboxSession.PreferedCulture != null)
            {
                this.LocaleName = mailboxSession.PreferedCulture.Name;
                this.LocaleId   = Activity.GetLcidFromMailboxSession(mailboxSession);
            }
            IExchangePrincipal mailboxOwner = mailboxSession.MailboxOwner;

            if (mailboxOwner != null)
            {
                if (mailboxOwner.MailboxInfo.OrganizationId != null && mailboxOwner.MailboxInfo.OrganizationId.OrganizationalUnit != null)
                {
                    this.TenantName = mailboxOwner.MailboxInfo.OrganizationId.OrganizationalUnit.Name;
                }
                this.mailboxType = new long?((long)mailboxOwner.RecipientTypeDetails);
            }
            if (itemId != null)
            {
                this.ItemId = itemId;
            }
            if (previousItemId != null)
            {
                this.PreviousItemId = previousItemId;
            }
            this.CustomPropertiesDictionary = (customProperties ?? new Dictionary <string, string>());
            if (clientId.Equals(ClientId.Other, true))
            {
                this.customPropertiesDictionary["ClientString"] = mailboxSession.ClientInfoString;
                IActivityScope currentActivityScope = ActivityContext.GetCurrentActivityScope();
                if (currentActivityScope != null && !string.IsNullOrEmpty(currentActivityScope.ClientInfo))
                {
                    this.customPropertiesDictionary["ActivityScopeClientInfo"] = currentActivityScope.ClientInfo;
                }
            }
            this.activityCreationTime = ExDateTime.UtcNow;
        }
Пример #26
0
        // Token: 0x06000F60 RID: 3936 RVA: 0x0003BCB8 File Offset: 0x00039EB8
        private static ItemType GetItemFromDataRow(OwaSearchContext searchContext, MailboxSession mailboxSession, object[] row, Dictionary <PropertyDefinition, int> orderDictionary)
        {
            StoreId       itemProperty  = SearchFolderDataRetrieverBase.GetItemProperty <StoreId>(row, orderDictionary[ItemSchema.Id], null);
            StoreObjectId storeObjectId = StoreId.GetStoreObjectId(itemProperty);
            ItemType      itemType      = ItemType.CreateFromStoreObjectType(storeObjectId.ObjectType);

            itemType.ItemId = SearchFolderDataRetrieverBase.StoreIdToEwsItemId(itemProperty, new MailboxId(mailboxSession.MailboxGuid, false));
            byte[] itemProperty2 = SearchFolderDataRetrieverBase.GetItemProperty <byte[]>(row, orderDictionary[ItemSchema.InstanceKey], new byte[0]);
            itemType.InstanceKey       = itemProperty2;
            itemType.InstanceKeyString = Convert.ToBase64String(itemProperty2);
            itemType.ParentFolderId    = new FolderId(SearchFolderDataRetrieverBase.GetEwsId(SearchFolderDataRetrieverBase.GetItemProperty <StoreId>(row, orderDictionary[StoreObjectSchema.ParentItemId], null), mailboxSession.MailboxGuid), null);
            itemType.ConversationId    = new ItemId(IdConverter.ConversationIdToEwsId(mailboxSession.MailboxGuid, SearchFolderDataRetrieverBase.GetItemProperty <ConversationId>(row, orderDictionary[ItemSchema.ConversationId], null)), null);
            itemType.Subject           = SearchFolderDataRetrieverBase.GetItemProperty <string>(row, orderDictionary[ItemSchema.Subject], string.Empty);
            itemType.ImportanceString  = SearchFolderDataRetrieverBase.GetItemProperty <Importance>(row, orderDictionary[ItemSchema.Importance], Importance.Normal).ToString();
            itemType.SensitivityString = SearchFolderDataRetrieverBase.GetItemProperty <Sensitivity>(row, orderDictionary[ItemSchema.Sensitivity], Sensitivity.Normal).ToString();
            string dateTimeProperty = SearchFolderDataRetrieverBase.GetDateTimeProperty(searchContext.RequestTimeZone, row, orderDictionary[ItemSchema.ReceivedTime]);

            if (!string.IsNullOrEmpty(dateTimeProperty))
            {
                itemType.DateTimeReceived = dateTimeProperty;
            }
            string dateTimeProperty2 = SearchFolderDataRetrieverBase.GetDateTimeProperty(searchContext.RequestTimeZone, row, orderDictionary[ItemSchema.SentTime]);

            if (!string.IsNullOrEmpty(dateTimeProperty2))
            {
                itemType.DateTimeSent = dateTimeProperty2;
            }
            itemType.HasAttachments = new bool?(SearchFolderDataRetrieverBase.GetItemProperty <bool>(row, orderDictionary[ItemSchema.HasAttachment], false));
            itemType.IsDraft        = new bool?(SearchFolderDataRetrieverBase.GetItemProperty <bool>(row, orderDictionary[MessageItemSchema.IsDraft], false));
            itemType.ItemClass      = SearchFolderDataRetrieverBase.GetItemProperty <string>(row, orderDictionary[StoreObjectSchema.ItemClass], string.Empty);
            itemType.Preview        = SearchFolderDataRetrieverBase.GetItemProperty <string>(row, orderDictionary[ItemSchema.Preview], string.Empty);
            MessageType messageType = itemType as MessageType;

            if (messageType != null)
            {
                Participant itemProperty3 = SearchFolderDataRetrieverBase.GetItemProperty <Participant>(row, orderDictionary[ItemSchema.From], null);
                if (itemProperty3 != null)
                {
                    messageType.From = RowNotificationHandler.CreateRecipientFromParticipant(itemProperty3);
                }
                Participant itemProperty4 = SearchFolderDataRetrieverBase.GetItemProperty <Participant>(row, orderDictionary[ItemSchema.Sender], null);
                if (itemProperty4 != null)
                {
                    messageType.Sender = RowNotificationHandler.CreateRecipientFromParticipant(itemProperty4);
                }
                messageType.IsRead = new bool?(SearchFolderDataRetrieverBase.GetItemProperty <bool>(row, orderDictionary[MessageItemSchema.IsRead], false));
            }
            IconIndex itemProperty5 = SearchFolderDataRetrieverBase.GetItemProperty <IconIndex>(row, orderDictionary[ItemSchema.IconIndex], IconIndex.Default);

            if (itemProperty5 != IconIndex.Default)
            {
                itemType.IconIndexString = itemProperty5.ToString();
            }
            FlagType flagType = new FlagType();

            itemType.Flag             = flagType;
            flagType.FlagStatus       = SearchFolderDataRetrieverBase.GetItemProperty <FlagStatus>(row, orderDictionary[ItemSchema.FlagStatus], FlagStatus.NotFlagged);
            itemType.DateTimeCreated  = SearchFolderDataRetrieverBase.GetDateTimeProperty(searchContext.RequestTimeZone, row, orderDictionary[StoreObjectSchema.CreationTime]);
            itemType.LastModifiedTime = SearchFolderDataRetrieverBase.GetDateTimeProperty(searchContext.RequestTimeZone, row, orderDictionary[StoreObjectSchema.LastModifiedTime]);
            itemType.Size             = SearchFolderDataRetrieverBase.GetItemProperty <int?>(row, orderDictionary[ItemSchema.Size], null);
            itemType.DisplayTo        = SearchFolderDataRetrieverBase.GetItemProperty <string>(row, orderDictionary[ItemSchema.DisplayTo], null);
            itemType.Categories       = SearchFolderDataRetrieverBase.GetItemProperty <string[]>(row, orderDictionary[ItemSchema.Categories], null);
            return(itemType);
        }
Пример #27
0
 public static Item CreateFreeBusyItem(PublicFolderSession session, StoreObjectId freeBusyFolderId, string legacyDN)
 {
     return(FreeBusyFolder.RetryOnStorageTransientException <Item>(() => FreeBusyFolder.CreateFreeBusyItemInternal(session, freeBusyFolderId, legacyDN)));
 }
Пример #28
0
        // Token: 0x06001589 RID: 5513 RVA: 0x0007F070 File Offset: 0x0007D270
        internal override Command.ExecutionState ExecuteCommand()
        {
            MessageItem      clientMessage    = null;
            Item             item             = null;
            MessageItem      messageItem      = null;
            VersionedId      versionedId      = null;
            CalendarItemBase calendarItemBase = null;

            try
            {
                base.ValidateBody();
                StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts);
                clientMessage = MessageItem.Create(base.MailboxSession, defaultFolderId);
                base.ParseMimeToMessage(clientMessage);
                clientMessage.Save(SaveMode.NoConflictResolution);
                clientMessage.Load();
                versionedId = clientMessage.Id;
                clientMessage.Dispose();
                clientMessage = MessageItem.Bind(base.MailboxSession, versionedId);
                item          = base.GetSmartItem();
                RmsTemplate            rmsTemplate = null;
                bool                   isReplyAll  = false;
                SendMailBase.IrmAction irmAction   = base.GetIrmAction(delegate(RightsManagedMessageItem originalRightsManagedItem)
                {
                    if (originalRightsManagedItem == null)
                    {
                        throw new ArgumentNullException("originalRightsManagedItem");
                    }
                    isReplyAll = this.IsIrmReplyAll(originalRightsManagedItem, clientMessage);
                }, ref item, out rmsTemplate);
                Microsoft.Exchange.Data.Storage.BodyFormat bodyFormat = clientMessage.Body.Format;
                MeetingMessage meetingMessage = item as MeetingMessage;
                string         text;
                if ((base.ReplaceMime || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) && meetingMessage != null && !meetingMessage.IsDelegated() && (meetingMessage is MeetingCancellation || meetingMessage is MeetingRequest))
                {
                    text = string.Empty;
                }
                else
                {
                    using (TextReader textReader = clientMessage.Body.OpenTextReader(bodyFormat))
                    {
                        text = textReader.ReadToEnd();
                    }
                    Body body = (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.ReusePublishingLicenseInlineOriginalBody) ? ((RightsManagedMessageItem)item).ProtectedBody : item.Body;
                    if (body.Format == Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml)
                    {
                        if (bodyFormat == Microsoft.Exchange.Data.Storage.BodyFormat.TextPlain)
                        {
                            XmlDocument  xmlDocument  = new SafeXmlDocument();
                            XmlNode      xmlNode      = xmlDocument.CreateElement("PRE");
                            XmlAttribute xmlAttribute = xmlDocument.CreateAttribute("STYLE");
                            xmlAttribute.Value = "word-wrap:break-word; font-size:10.0pt; font-family:Tahoma; color:black";
                            xmlNode.Attributes.Append(xmlAttribute);
                            xmlNode.InnerText = text;
                            text = xmlNode.OuterXml;
                        }
                        bodyFormat = Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml;
                    }
                }
                ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                replyForwardConfiguration.ConversionOptionsForSmime = AirSyncUtility.GetInboundConversionOptions();
                replyForwardConfiguration.AddBodyPrefix(text);
                if (item is MessageItem)
                {
                    MessageItem messageItem2 = (MessageItem)item;
                    if (!messageItem2.IsReplyAllowed)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ReplyNotAllowed");
                        AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MessageReplyNotAllowed, null, false);
                        throw ex;
                    }
                    if (isReplyAll)
                    {
                        messageItem = messageItem2.CreateReplyAll(defaultFolderId, replyForwardConfiguration);
                    }
                    else
                    {
                        messageItem = messageItem2.CreateReply(defaultFolderId, replyForwardConfiguration);
                    }
                    if (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicense || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseInlineOriginalBody || irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage)
                    {
                        messageItem = base.GetRightsManagedReplyForward(messageItem, irmAction, rmsTemplate);
                    }
                }
                else if (item is CalendarItem)
                {
                    CalendarItem item2 = (CalendarItem)item;
                    calendarItemBase = base.GetCalendarItemBaseToReplyOrForward(item2);
                    messageItem      = calendarItemBase.CreateReply(defaultFolderId, replyForwardConfiguration);
                }
                if (messageItem == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ReplyFailed");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false);
                }
                base.CopyMessageContents(clientMessage, messageItem, true, (irmAction == SendMailBase.IrmAction.CreateNewPublishingLicenseAttachOriginalMessage) ? item : null);
                base.SendMessage(messageItem);
            }
            finally
            {
                if (clientMessage != null)
                {
                    if (versionedId != null)
                    {
                        base.MailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            versionedId
                        });
                    }
                    clientMessage.Dispose();
                }
                if (item != null)
                {
                    item.Dispose();
                }
                if (messageItem != null)
                {
                    messageItem.Dispose();
                }
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                }
            }
            return(Command.ExecutionState.Complete);
        }
        // Token: 0x060004A3 RID: 1187 RVA: 0x00022124 File Offset: 0x00020324
        protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog)
        {
            ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "MapiEvent is handled: {0}", mapiEvent);
            this.ManageCache(mapiEvent.MailboxGuid);
            if (this.IsIgnorableDraft(mapiEvent, item))
            {
                return;
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);

            cachedState.LockForRead();
            UserRetentionPolicyCache userRetentionPolicyCache = null;

            try
            {
                userRetentionPolicyCache = RetentionPolicyCheck.DetailedCheckForRetentionPolicy(mapiEvent, itemStore, item, cachedState);
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            if (RetentionPolicyCheck.IsEventConfigChange(mapiEvent))
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: updated configuration {1}", TraceContext.Get(), mapiEvent);
                return;
            }
            if (userRetentionPolicyCache != null && userRetentionPolicyCache.UnderRetentionPolicy)
            {
                bool flag = false;
                if (!this.IsEventOnRelevantFolder(userRetentionPolicyCache, mapiEvent))
                {
                    return;
                }
                if (mapiEvent.ClientType == MapiEventClientTypes.Transport && !this.InSentItems(userRetentionPolicyCache, mapiEvent))
                {
                    ElcEventBasedAssistant.Tracer.TraceDebug <ElcEventBasedAssistant, MapiEvent>((long)this.GetHashCode(), "{0} Event is from transport and item not in SentItems. Ignoring from HandleEvent. Mapievent: {1}", this, mapiEvent);
                    return;
                }
                if (TagAssistantHelper.IsConflictableItem(mapiEvent.ObjectClass, mapiEvent.ParentEntryId, userRetentionPolicyCache.DeletedItemsId))
                {
                    return;
                }
                if ((mapiEvent.EventMask & MapiEventTypeFlags.ObjectMoved) != (MapiEventTypeFlags)0 && mapiEvent.ItemType == ObjectType.MAPI_FOLDER)
                {
                    userRetentionPolicyCache.ResetFolderCaches();
                }
                StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(mapiEvent.ItemEntryId);
                if (mapiEvent.ItemType == ObjectType.MAPI_FOLDER && item == null && mapiEvent.ItemEntryId != null && (mapiEvent.EventMask & MapiEventTypeFlags.ObjectDeleted) == (MapiEventTypeFlags)0)
                {
                    Exception ex = null;
                    try
                    {
                        ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: A folder was changed and needs to be manually loaded {1}", TraceContext.Get(), mapiEvent);
                        item = Folder.Bind(itemStore, storeObjectId, ElcEventBasedAssistantType.InternalPreloadItemProperties);
                        flag = true;
                    }
                    catch (ObjectNotFoundException ex2)
                    {
                        ex = ex2;
                    }
                    catch (ConversionFailedException ex3)
                    {
                        ex = ex3;
                    }
                    catch (VirusMessageDeletedException ex4)
                    {
                        ex = ex4;
                    }
                    if (ex != null)
                    {
                        ElcEventBasedAssistant.Tracer.TraceDebug <ElcEventBasedAssistant, Exception>((long)this.GetHashCode(), "{0}: Problems loading a folder. It will not be processed. Exception: {1}", this, ex);
                        return;
                    }
                }
                try
                {
                    StoreObjectId     parentId          = StoreObjectId.FromProviderSpecificId(mapiEvent.ParentEntryId);
                    ElcEventProcessor elcEventProcessor = ElcEventProcessor.GetElcEventProcessor();
                    elcEventProcessor.ValidateStoreObject(userRetentionPolicyCache, itemStore, parentId, storeObjectId, item, mapiEvent);
                }
                finally
                {
                    if (flag)
                    {
                        item.Dispose();
                    }
                }
            }
        }
Пример #30
0
        // Token: 0x06000CE9 RID: 3305 RVA: 0x000459B0 File Offset: 0x00043BB0
        private bool Respond(StoreObjectId itemId, string requestId, MeetingResponseCommand.RequestNodeData response, bool usingLongId)
        {
            if (base.Version <= 141)
            {
                return(this.LegacyRespond(itemId, requestId, response.UserResponse, usingLongId));
            }
            if (response.RespondToEventParameters == null)
            {
                throw new InvalidOperationException("Response.RespondToEventParameters must not be null at this point.");
            }
            StoreObjectId storeObjectId = null;
            string        calendarId    = null;

            if (this.CalendaringContainer == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Set default CalendaringContainer");
                this.CalendaringContainer = new CalendaringContainer(base.MailboxSession, null);
            }
            if (this.MailboxGuid == Guid.Empty)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Set default MailboxGuid");
                this.MailboxGuid = base.MailboxSession.MailboxGuid;
            }
            string  key = EntitySyncItem.GetKey(this.MailboxGuid, itemId);
            IEvents events;

            if (itemId.ObjectType == StoreObjectType.CalendarItem || itemId.ObjectType == StoreObjectType.CalendarItemOccurrence || itemId.ObjectType == StoreObjectType.CalendarItemSeries)
            {
                storeObjectId = itemId;
                events        = EntitySyncItem.GetEvents(this.CalendaringContainer, base.MailboxSession, itemId);
            }
            else
            {
                if (itemId.ObjectType != StoreObjectType.MeetingRequest)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "The item is not meeting-request or calendar item.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UnsupportedObjectType" + itemId.ObjectType);
                    return(false);
                }
                using (MeetingMessage meetingMessage = MeetingMessage.Bind(base.MailboxSession, itemId))
                {
                    if (meetingMessage == null)
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "Cannot find the meeting-request as specified in the reqest.", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemNotFound");
                        return(false);
                    }
                    using (CalendarItemBase correlatedItem = meetingMessage.GetCorrelatedItem())
                    {
                        if (meetingMessage == null)
                        {
                            this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "Cannot find the correlated meeitng item.", usingLongId);
                            base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NullCalItemInMRCmd");
                            return(false);
                        }
                        storeObjectId = correlatedItem.Id.ObjectId;
                    }
                }
                response.RespondToEventParameters.MeetingRequestIdToBeDeleted = key;
                key    = EntitySyncItem.GetKey(this.MailboxGuid, storeObjectId);
                events = this.CalendaringContainer.Calendars.Default.Events;
            }
            try
            {
                events.Respond(key, response.RespondToEventParameters, null);
            }
            catch (LocalizedException ex)
            {
                this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, response.UserResponse, ex.Message, usingLongId);
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EntityRespondError");
                return(false);
            }
            if (storeObjectId != null)
            {
                MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId);
                if (this.CalendarItemIdMapping.Contains(mailboxSyncItemId))
                {
                    calendarId = this.CalendarItemIdMapping[mailboxSyncItemId];
                }
                else
                {
                    calendarId = this.CalendarItemIdMapping.Add(mailboxSyncItemId);
                    this.calendarSyncStateChangedFlag = true;
                }
            }
            this.AppendXmlNode(requestId, StatusCode.Success, calendarId, response.UserResponse, usingLongId);
            return(true);
        }