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); } }
/// <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); }