internal void UpdateProperties(IO.Item DBItem) { // Set State and Action switch (this.Action) { case Model.Item.Actions.Create: case Model.Item.Actions.Read: case Model.Item.Actions.Update: this.State = Model.Item.States.Stored; this.Action = Model.Item.Actions.Read; break; case Model.Item.Actions.Delete: this.State = Model.Item.States.Deleted; break; } if (DBItem != null) { // Set PermissionID this.PermissionID = DBItem.GetProperty("permission_id"); // Set LockedByID this.LockedByID = DBItem.GetProperty("locked_by_id"); } }
internal void UpdateProperties(IO.Item DBItem) { this.Cache.UpdateProperties(DBItem); if (DBItem != null) { // Update Classification this.Class = this.ItemType.GetClassFullname(DBItem.GetProperty("classification")); if (this.ID.Equals(DBItem.ID)) { // Update Properties foreach (Property property in this.PropertyCache.Values) { if (property is Properties.Item) { if (property.Type.Name.Equals("source_id")) { ((Properties.Item)property).SetDBValue(this.Store.Source); } else { IO.Item dbpropitem = DBItem.GetPropertyItem(property.Type.Name); if (dbpropitem != null) { property.DBValue = this.Store.Query.Property((PropertyTypes.Item)property.Type).Store.Create(dbpropitem).ID; } else { // Check if just ID Specified String itemid = DBItem.GetProperty(property.Type.Name); if (!String.IsNullOrEmpty(itemid)) { property.DBValue = itemid; } else { property.DBValue = null; } } } } else { property.DBValue = DBItem.GetProperty(property.Type.Name); } } Dictionary <RelationshipType, List <IO.Item> > dbrels = new Dictionary <RelationshipType, List <IO.Item> >(); foreach (IO.Item dbrel in DBItem.Relationships) { ItemType reltype = this.Store.Session.ItemType(dbrel.ItemType); if (reltype is RelationshipType) { if (!dbrels.ContainsKey((RelationshipType)reltype)) { dbrels[(RelationshipType)reltype] = new List <IO.Item>(); } dbrels[(RelationshipType)reltype].Add(dbrel); } } foreach (RelationshipType reltype in dbrels.Keys) { this.RelationshipsCache[reltype].Load(dbrels[reltype]); } } else { throw new Exceptions.ArgumentException("Invalid Item ID: " + DBItem.ID); } } }