예제 #1
0
        /// <summary>
        /// Dissociate child folder from this (parent) folder, changes will be saved immediately
        /// </summary>
        public void RemoveChildFolder(PSTFolder childFolder)
        {
            TableContext hierarchyTable = GetHierarchyTable();
            int          rowIndex       = hierarchyTable.GetRowIndex(childFolder.NodeID.Value);

            if (rowIndex >= 0)
            {
                if (this.ChildFolderCount == 1)
                {
                    PropertyContext pc = this.PC;
                    pc.SetBooleanProperty(PropertyID.PidTagSubfolders, false);
                    pc.SaveChanges(NodeID);

                    // update hierarchy table of parent (set PidTagSubfolders of current folder to false):
                    TableContext parentHierarchyTable = ParentFolder.GetHierarchyTable();
                    int          rowIndexOfFolder     = parentHierarchyTable.GetRowIndex(NodeID.Value);
                    parentHierarchyTable.SetBooleanProperty(rowIndexOfFolder, PropertyID.PidTagSubfolders, false);
                    parentHierarchyTable.SaveChanges(ParentFolder.GetHierarchyTableNodeID());
                }

                hierarchyTable.DeleteRow(rowIndex);

                hierarchyTable.SaveChanges(GetHierarchyTableNodeID());
            }
        }
예제 #2
0
 public static void CopyBytesProperty(PropertyContext pc, TableContext tc, int rowIndex, PropertyID propertyID)
 {
     byte[] value = pc.GetBytesProperty(propertyID);
     if (value != null && tc.ContainsPropertyColumn(propertyID, PropertyTypeName.PtypBinary))
     {
         tc.SetBytesProperty(rowIndex, propertyID, value);
     }
 }
예제 #3
0
        public static void CopyDateTimeProperty(PropertyContext pc, TableContext tc, int rowIndex, PropertyID propertyID)
        {
            Nullable <DateTime> value = pc.GetDateTimeProperty(propertyID);

            if (value.HasValue && tc.ContainsPropertyColumn(propertyID, PropertyTypeName.PtypTime))
            {
                tc.SetDateTimeProperty(rowIndex, propertyID, value.Value);
            }
        }
예제 #4
0
        public static void CopyInt64Property(PropertyContext pc, TableContext tc, int rowIndex, PropertyID propertyID)
        {
            Nullable <long> value = pc.GetInt64Property(propertyID);

            if (value.HasValue && tc.ContainsPropertyColumn(propertyID, PropertyTypeName.PtypInteger64))
            {
                tc.SetInt64Property(rowIndex, propertyID, value.Value);
            }
        }
예제 #5
0
        public static void CopyBooleanProperty(PropertyContext pc, TableContext tc, int rowIndex, PropertyID propertyID)
        {
            Nullable <bool> value = pc.GetBooleanProperty(propertyID);

            if (value.HasValue && tc.ContainsPropertyColumn(propertyID, PropertyTypeName.PtypBoolean))
            {
                tc.SetBooleanProperty(rowIndex, propertyID, value.Value);
            }
        }
예제 #6
0
        public static void CopyStringProperty(NamedPropertyContext pc, TableContext tc, int rowIndex, PropertyName propertyName)
        {
            Nullable <PropertyID> propertyID = pc.Map.GetIDFromName(propertyName);

            if (propertyID.HasValue)
            {
                CopyStringProperty(pc, tc, rowIndex, propertyID.Value);
            }
        }
예제 #7
0
        public static void CopyStringProperty(PropertyContext pc, TableContext tc, int rowIndex, PropertyID propertyID)
        {
            string value = pc.GetStringProperty(propertyID);

            if (value != null && tc.ContainsPropertyColumn(propertyID, PropertyTypeName.PtypString))
            {
                tc.SetStringProperty(rowIndex, propertyID, value);
            }
        }
예제 #8
0
        private void UpdateMessage(MessageObject message, TableContext contentsTable)
        {
            int rowIndex = contentsTable.GetRowIndex(message.NodeID.Value);

            if (rowIndex >= 0)
            {
                UpdateMessage(message, contentsTable, rowIndex);
            }
        }
예제 #9
0
        /// <summary>
        /// Properties that were removed from the message must be explicitly removed from the TC
        /// </summary>
        public void UpdateMessage(MessageObject message, TableContext contentsTable, int rowIndex)
        {
            TableContextHelper.CopyProperties(message.PC, contentsTable, rowIndex);
            // Note: Outlook 2003 simply iterates over all of the table columns:

            // Outlook 2003 Content Table Template fields:
            contentsTable.SetInt32Property(rowIndex, PropertyID.PidTagLtpRowId, (int)message.NodeID.Value);
            // UNDOCUMENTED - Outlook uses dwUnique for PidTagLtpRowVer
            contentsTable.SetInt32Property(rowIndex, PropertyID.PidTagLtpRowVer, (int)File.Header.AllocateNextUniqueID());
        }
예제 #10
0
        public MessageObject GetMessage(int index)
        {
            TableContext tc = GetContentsTable();

            if (tc != null)
            {
                if (index < tc.RowCount)
                {
                    // dwRowID is the MessageID
                    NodeID        nodeID  = new NodeID(tc.GetRowID(index));
                    MessageObject message = this.File.GetMessage(nodeID);
                    return(message);
                }
            }
            return(null);
        }
예제 #11
0
        public override void SaveChanges()
        {
            if (m_contentCount.HasValue)
            {
                TableContext parentHierarchyTable = ParentFolder.GetHierarchyTable();
                int          rowIndexOfFolder     = parentHierarchyTable.GetRowIndex(NodeID.Value);
                parentHierarchyTable.SetInt32Property(rowIndexOfFolder, PropertyID.PidTagContentCount, m_contentCount.Value);
                parentHierarchyTable.SaveChanges(ParentFolder.GetHierarchyTableNodeID());
            }

            if (m_contentsTable != null)
            {
                m_contentsTable.SaveChanges(GetContentsTableNodeID());
            }
            base.SaveChanges();
        }
예제 #12
0
        public Note GetNote(int index)
        {
            TableContext tc = GetContentsTable();

            if (tc != null)
            {
                if (index < tc.RowCount)
                {
                    // dwRowID is the MessageID
                    NodeID nodeID = new NodeID(tc.GetRowID(index));
                    Note   note   = Note.GetNote(this.File, nodeID);
                    return(note);
                }
            }
            return(null);
        }
예제 #13
0
        public Appointment GetAppointment(int index)
        {
            TableContext tc = GetContentsTable();

            if (tc != null)
            {
                if (index < tc.RowCount)
                {
                    // dwRowID is the MessageID
                    NodeID      nodeID      = new NodeID(tc.GetRowID(index));
                    Appointment appointment = Appointment.GetAppointment(this.File, nodeID);
                    return(appointment);
                }
            }
            return(null);
        }
예제 #14
0
        /// <summary>
        /// Changes will be saved immediately
        /// </summary>
        public PSTFolder CreateChildFolder(string folderName, FolderItemTypeName folderItemType)
        {
            PSTFolder       childFolder = CreateNewFolder(this.File, folderName, folderItemType, this.NodeID);
            PropertyContext pc          = this.PC;

            if (!pc.GetBooleanProperty(PropertyID.PidTagSubfolders).Value)
            {
                pc.SetBooleanProperty(PropertyID.PidTagSubfolders, true);
                pc.SaveChanges(NodeID);
            }
            // update hierarchy table of parent (set PidTagSubfolders of current folder to true):
            TableContext parentHierarchyTable = ParentFolder.GetHierarchyTable();
            int          rowIndexOfFolder     = parentHierarchyTable.GetRowIndex(NodeID.Value);

            if (!parentHierarchyTable.GetBooleanProperty(rowIndexOfFolder, PropertyID.PidTagSubfolders).Value)
            {
                parentHierarchyTable.SetBooleanProperty(rowIndexOfFolder, PropertyID.PidTagSubfolders, true);
                parentHierarchyTable.SaveChanges(ParentFolder.GetHierarchyTableNodeID());
            }

            // update hierarchy table:
            TableContext hierarchyTable = GetHierarchyTable();

            hierarchyTable.AddRow(childFolder.NodeID.Value);
            int rowIndex = hierarchyTable.RowCount - 1;

            // Template properties (assured to be present)
            hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagContentCount, 0);
            hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagContentUnreadCount, 0);
            hierarchyTable.SetBooleanProperty(rowIndex, PropertyID.PidTagSubfolders, false);
            hierarchyTable.SetStringProperty(rowIndex, PropertyID.PidTagDisplayName, folderName);
            hierarchyTable.SetStringProperty(rowIndex, PropertyID.PidTagContainerClass, GetContainerClass(folderItemType));
            hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagLtpRowId, (int)childFolder.NodeID.Value);
            // PidTagLtpRowVer uses dwUnique
            int rowVersion = (int)File.Header.AllocateNextUniqueID();

            hierarchyTable.SetInt32Property(rowIndex, PropertyID.PidTagLtpRowVer, rowVersion);

            hierarchyTable.SaveChanges(GetHierarchyTableNodeID());

            this.File.SearchManagementQueue.AddFolder(childFolder.NodeID, this.NodeID);

            return(childFolder);
        }
예제 #15
0
        public static void CopyProperties(PropertyContext pc, TableContext tc, int rowIndex)
        {
            // Note: Outlook 2003 simply iterates over all of the table columns:
            foreach (TableColumnDescriptor descriptor in tc.Columns)
            {
                switch (descriptor.PropertyType)
                {
                case PropertyTypeName.PtypBoolean:
                    CopyBooleanProperty(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                case PropertyTypeName.PtypInteger16:
                    CopyInt16Property(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                case PropertyTypeName.PtypInteger32:
                    CopyInt32Property(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                case PropertyTypeName.PtypInteger64:
                    CopyInt64Property(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                case PropertyTypeName.PtypTime:
                    CopyDateTimeProperty(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                case PropertyTypeName.PtypGuid:
                    CopyGuidProperty(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                case PropertyTypeName.PtypBinary:
                    CopyBytesProperty(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                case PropertyTypeName.PtypString:
                    CopyStringProperty(pc, tc, rowIndex, descriptor.PropertyID);
                    break;

                default:
                    break;
                }
            }
        }
예제 #16
0
        public PSTFolder FindChildFolder(string displayNameToFind)
        {
            TableContext tc = GetHierarchyTable();

            if (tc != null)
            {
                for (int index = 0; index < tc.RowCount; index++)
                {
                    string displayName = tc.GetStringProperty(index, PropertyID.PidTagDisplayName);
                    if (displayName == displayNameToFind)
                    {
                        NodeID childNodeID = new NodeID(tc.GetRowID(index));
                        return(PSTFolder.GetFolder(File, childNodeID));
                    }
                }
            }

            return(null);
        }
예제 #17
0
        public List <PSTFolder> GetChildFolders()
        {
            TableContext tc = GetHierarchyTable();

            List <PSTFolder> result = new List <PSTFolder>();

            if (tc != null)
            {
                for (int index = 0; index < tc.RowCount; index++)
                {
                    // dwRowID is the NodeID
                    NodeID childNodeID = new NodeID(tc.GetRowID(index));
                    if (childNodeID.nidType == NodeTypeName.NID_TYPE_NORMAL_FOLDER)
                    {
                        PSTFolder childFolder = PSTFolder.GetFolder(File, childNodeID);
                        result.Add(childFolder);
                    }
                }
            }
            return(result);
        }
예제 #18
0
 public NamedTableContext(TableContext tc, PropertyNameToIDMap map) : base(tc.Heap, tc.SubnodeBTree)
 {
     m_map = map;
 }
예제 #19
0
        public void UpdateMessage(MessageObject message)
        {
            TableContext contentsTable = GetContentsTable();

            UpdateMessage(message, contentsTable);
        }