Example #1
0
        public virtual OutlookItem PreviousConversationItem()
        {
            var    items = AllItems;
            string currentCID;

            if (items[items.Count].EntryID != Current.EntryID)
            {
                if (!Current.TryGetPropertyValue("ConversationID", out currentCID))
                {
                    return(Previous());
                }

                int i;
                for (i = items.Count; i >= 1; i--)
                {
                    if (items[i].EntryID == Current.EntryID)
                    {
                        break;
                    }
                }

                int itemLen = items.Count;
                for (i++; i <= itemLen; i++)
                {
                    string thisCID;
                    var    item = new OutlookItem(items[i]);
                    if (item.TryGetPropertyValue("ConversationID", out thisCID) && currentCID == thisCID)
                    {
                        continue;
                    }
                    return(SetSelected(item));
                }
            }
            return(null);
        }
Example #2
0
        private ConversationDTO GetRelatedItems(OutlookItem sourceItem, bool latestFirst, bool currentFolderOnly = true)
        {
            Conversation    c   = ((dynamic)sourceItem.InnerObject).GetConversation();
            ConversationDTO dto = new ConversationDTO()
            {
                Topic = sourceItem.ConversationTopic
            };
            var table = c.GetTable();

            if (table.GetRowCount() == 0)
            {
                dto.Items = new List <OutlookItem> {
                    sourceItem
                };
                dto.FirstRootItem = sourceItem;
            }
            else
            {
                table.MoveToStart();
                var row  = table.GetNextRow();
                var item = new OutlookItem(table.Session.GetItemFromID(row["EntryID"]));
                dto.FirstRootItem = item;
                SortedDictionary <DateTime, OutlookItem> ordered = new SortedDictionary <DateTime, OutlookItem>();
                while (true)
                {
                    if (!ordered.Values.Any(i => i.EntryID == item.EntryID) && (!currentFolderOnly || item.Parent.Name.Equals(Folder.Name, StringComparison.OrdinalIgnoreCase)))
                    {
                        DateTime sfield = item.TryGetPropertyValue("ReceivedTime", out sfield) ? sfield : item.LastModificationTime;
                        ordered.Add(sfield, item);
                    }
                    if (table.EndOfTable)
                    {
                        break;
                    }
                    row  = table.GetNextRow();
                    item = new OutlookItem(table.Session.GetItemFromID(row["EntryID"]));
                }
                var list = ordered.Values.ToList();
                if (latestFirst)
                {
                    list.Reverse();
                }
                dto.Items = list;
            }

            return(dto);
        }
Example #3
0
        public virtual OutlookItem NextConversationItem()
        {
            var    items = AllItems;
            string currentCID;

            // items are ordered in order from last to first.
            if (items[1].EntryID != Current.EntryID)
            {
                // if the current item is not a part of any conversation, then regular next would occur.
                if (!Current.TryGetPropertyValue("ConversationID", out currentCID))
                {
                    return(Next());
                }

                int i;
                for (i = items.Count; i >= 1; i--)
                {
                    if (items[i].EntryID == Current.EntryID)
                    {
                        break;
                    }
                }

                for (i--; i >= 1; i--)
                {
                    string thisCID;
                    var    item = new OutlookItem(items[i]);
                    if (item.TryGetPropertyValue("ConversationID", out thisCID) && currentCID == thisCID)
                    {
                        continue;
                    }
                    return(SetSelected(item));
                }
            }
            return(null);
        }