internal PublicFolderViewStates(UserContext userContext, Folder folder)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }
            this.cache = PublicFolderViewStatesCache.GetInstance(userContext);
            OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromStoreObject(folder);

            this.folderId = owaStoreObjectId.ToString();
        }
Example #2
0
        private static void ProcessCalendarItemAfterResponse(ResponseType responseType, CalendarItemBase calendarItemBase, bool intendToSendResponse)
        {
            UserContext userContext = UserContextManager.GetUserContext();

            if (responseType != ResponseType.Decline)
            {
                if (Utilities.IsItemInDefaultFolder(calendarItemBase, DefaultFolderType.DeletedItems))
                {
                    StoreObjectId[] ids = new StoreObjectId[]
                    {
                        calendarItemBase.Id.ObjectId
                    };
                    userContext.MailboxSession.Move(userContext.CalendarFolderId, ids);
                }
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.ItemsUpdated.Increment();
                    return;
                }
            }
            else
            {
                try
                {
                    DeleteItemFlags deleteItemFlags = intendToSendResponse ? DeleteItemFlags.DeclineCalendarItemWithResponse : DeleteItemFlags.DeclineCalendarItemWithoutResponse;
                    if (Utilities.IsItemInDefaultFolder(calendarItemBase, DefaultFolderType.DeletedItems))
                    {
                        deleteItemFlags |= DeleteItemFlags.SoftDelete;
                    }
                    else
                    {
                        deleteItemFlags |= DeleteItemFlags.MoveToDeletedItems;
                    }
                    Utilities.Delete(userContext, deleteItemFlags, new OwaStoreObjectId[]
                    {
                        OwaStoreObjectId.CreateFromStoreObject(calendarItemBase)
                    });
                }
                catch (StoragePermanentException ex)
                {
                    ExTraceGlobals.CalendarTracer.TraceDebug <string>(0L, "Exception on delete calendar item: {0}'", ex.Message);
                    throw;
                }
            }
        }
        // Token: 0x06001914 RID: 6420 RVA: 0x00091A08 File Offset: 0x0008FC08
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            this.userContext   = owaContext.UserContext;
            this.owaContext    = owaContext;
            applicationElement = ApplicationElement.Folder;
            type   = "IPF.Note";
            action = null;
            state  = null;
            PreFormActionResponse preFormActionResponse = null;

            using (Folder folder = this.ProcessWebPartRequest())
            {
                if (folder != null)
                {
                    preFormActionResponse = new PreFormActionResponse();
                    preFormActionResponse.AddParameter("id", OwaStoreObjectId.CreateFromStoreObject(folder).ToBase64String());
                    if (!string.IsNullOrEmpty(this.webPartParameters["view"]))
                    {
                        preFormActionResponse.AddParameter("view", this.webPartParameters["view"]);
                    }
                    if (this.isoDateString != null)
                    {
                        preFormActionResponse.AddParameter("d", this.isoDateString);
                    }
                    type = folder.ClassName;
                    int num = 0;
                    if (int.TryParse(this.webPartParameters["part"], out num) && num == 1)
                    {
                        applicationElement = ApplicationElement.WebPartFolder;
                    }
                    preFormActionResponse.ApplicationElement = applicationElement;
                    preFormActionResponse.Action             = action;
                    preFormActionResponse.Type  = type;
                    preFormActionResponse.State = state;
                }
            }
            return(preFormActionResponse);
        }
Example #4
0
        internal static void DeleteMeetingRequestAfterResponse(MeetingRequest meetingRequest)
        {
            UserContext userContext = UserContextManager.GetUserContext();

            meetingRequest.Load();
            try
            {
                if (userContext.IsInMyMailbox(meetingRequest) && !Utilities.IsItemInDefaultFolder(meetingRequest, DefaultFolderType.DeletedItems))
                {
                    Utilities.Delete(userContext, DeleteItemFlags.MoveToDeletedItems, new OwaStoreObjectId[]
                    {
                        OwaStoreObjectId.CreateFromStoreObject(meetingRequest)
                    });
                }
            }
            catch (StoragePermanentException ex)
            {
                ExTraceGlobals.CalendarTracer.TraceDebug <string>(0L, "Provider exception on delete of meeting request.  {0}'", ex.Message);
                throw;
            }
        }
Example #5
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);
        }
        // Token: 0x06000796 RID: 1942 RVA: 0x00039B98 File Offset: 0x00037D98
        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.Item;
            type   = null;
            action = "Open";
            state  = string.Empty;
            CalendarItemBase calendarItemBase     = null;
            string           queryStringParameter = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "id");
            UserContext      userContext          = owaContext.UserContext;
            OwaStoreObjectId preFormActionId      = OwaStoreObjectId.CreateFromString(queryStringParameter);
            bool             flag  = false;
            Item             item  = null;
            bool             flag2 = false;

            try
            {
                calendarItemBase = Utilities.GetItemForRequest <CalendarItemBase>(owaContext, out item, false, new PropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                });
                flag2 = (item != null);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.CalendarDataTracer.TraceDebug(0L, "calendar item could not be found.");
                string queryStringParameter2 = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "gid", false);
                if (string.IsNullOrEmpty(queryStringParameter2))
                {
                    throw;
                }
                byte[]      globalObjectIdBytes = null;
                VersionedId versionedId         = null;
                try
                {
                    globalObjectIdBytes = Convert.FromBase64String(queryStringParameter2);
                }
                catch (FormatException innerException)
                {
                    throw new OwaInvalidRequestException("Invalid global object id for conflicting calendar item", innerException);
                }
                string           queryStringParameter3 = Utilities.GetQueryStringParameter(owaContext.HttpContext.Request, "fid", false);
                OwaStoreObjectId owaStoreObjectId      = null;
                if (!string.IsNullOrEmpty(queryStringParameter3))
                {
                    owaStoreObjectId = OwaStoreObjectId.CreateFromString(queryStringParameter3);
                }
                else
                {
                    owaStoreObjectId = userContext.CalendarFolderOwaId;
                }
                using (CalendarFolder folder = Utilities.GetFolder <CalendarFolder>(userContext, owaStoreObjectId, new PropertyDefinition[0]))
                {
                    versionedId = folder.GetCalendarItemId(globalObjectIdBytes);
                }
                if (versionedId == null)
                {
                    throw;
                }
                MailboxSession session = (MailboxSession)owaStoreObjectId.GetSession(userContext);
                calendarItemBase = CalendarItemBase.Bind(session, versionedId, new StorePropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                });
                flag = true;
            }
            finally
            {
                using (item)
                {
                    using (calendarItemBase)
                    {
                        if (calendarItemBase != null)
                        {
                            if (!Utilities.IsPublic(calendarItemBase) && calendarItemBase.IsMeeting && !calendarItemBase.IsOrganizer())
                            {
                                type = "IPM.Schedule.Meeting.Request";
                            }
                            else
                            {
                                type = "IPM.Appointment";
                                if (flag2 || !ItemUtility.UserCanEditItem(calendarItemBase) || Utilities.IsItemInExternalSharedInFolder(userContext, calendarItemBase))
                                {
                                    action = string.Empty;
                                }
                            }
                            if (!flag2)
                            {
                                if (flag)
                                {
                                    owaContext.PreFormActionId = OwaStoreObjectId.CreateFromStoreObject(calendarItemBase);
                                }
                                else
                                {
                                    owaContext.PreFormActionId = preFormActionId;
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }