/// <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()); } }
private void UpdateMessage(MessageObject message, TableContext contentsTable) { int rowIndex = contentsTable.GetRowIndex(message.NodeID.Value); if (rowIndex >= 0) { UpdateMessage(message, contentsTable, rowIndex); } }
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(); }
/// <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); }