/// <summary> /// Retrieve a property given the propertytype /// </summary> /// <param Name="pt">PropertyType</param> /// <returns>The property with the given propertytype</returns> public Property getProperty(propertytype.PropertyType pt) { object o = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(_ConnString, CommandType.Text, "select id from cmsPropertyData where versionId=@version and propertyTypeId=@propertyTypeId", new SqlParameter("@version", this.Version), new SqlParameter("@propertyTypeId", pt.Id)); if (o == null) { return(null); } int propertyId; if (!int.TryParse(o.ToString(), out propertyId)) { return(null); } try { return(new Property(propertyId, pt)); } catch { return(null); } }
/// <summary> /// Retrieve a Property given the alias /// </summary> /// <param Name="alias">Propertyalias (defined in the documenttype)</param> /// <returns>The property with the given alias</returns> public Property getProperty(string alias) { ContentType ct = this.ContentType; if (ct == null) { return(null); } propertytype.PropertyType pt = ct.getPropertyType(alias); if (pt == null) { return(null); } return(getProperty(pt)); }
/// <summary> /// Add a property to the Content /// </summary> /// <param Name="pt">The PropertyType of the Property</param> /// <param Name="VersionId">The version of the document on which the property should be add'ed</param> /// <returns>The new Property</returns> public property.Property addProperty(propertytype.PropertyType pt, Guid VersionId) { return(property.Property.MakeNew(pt, this, VersionId)); }
public static PropertyType MakeNew(DataTypeDefinition dt, ContentType ct, string Name, string Alias) { PropertyType pt; try { pt = new PropertyType(int.Parse(Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(_connstring, CommandType.Text, "insert into cmsPropertyType (DataTypeId, ContentTypeId, alias, Name) values (" + dt.Id + "," + ct.Id + ",'" + Alias + "','" + Name + "') Select @@Identity").ToString())); } finally { // Clear cached items System.Web.Caching.Cache c = System.Web.HttpRuntime.Cache; if (c != null) { System.Collections.IDictionaryEnumerator cacheEnumerator = c.GetEnumerator(); while (cacheEnumerator.MoveNext()) { if (cacheEnumerator.Key is string && ((string)cacheEnumerator.Key).StartsWith(UmbracoPropertyTypeCacheKey)) { Cache.ClearCacheItem((string)cacheEnumerator.Key); } } } } return pt; }
/// <summary> /// Helper method for getting the Tab id from a given PropertyType /// </summary> /// <param Name="pt">The PropertyType from which to get the Tab Id</param> /// <returns>The Id of the Tab on which the PropertyType is placed</returns> public static int getTabIdFromPropertyType(PropertyType pt) { object tmp = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(_ConnString, CommandType.Text, "Select tabId from cmsPropertyType where id = " + pt.Id.ToString()); if (tmp == DBNull.Value) return 0; else return int.Parse(tmp.ToString()); }
/// <summary> /// Removing a PropertyType from the associated Tab /// </summary> /// <param Name="pt">The PropertyType which should be freed from its tab</param> public void removePropertyTypeFromTab(PropertyType pt) { Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(_ConnString, CommandType.Text, "update cmsPropertyType set tabId = NULL where id = " + pt.Id.ToString()); // Remove from cache FlushFromCache(Id); }
/// <summary> /// Adding a PropertyType to a Tab, the Tabs are primarily used for making the /// editing interface more userfriendly. /// /// </summary> /// <param Name="pt">The PropertyType</param> /// <param Name="TabId">The Id of the Tab</param> public void SetTabOnPropertyType(PropertyType pt, int TabId) { Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(_ConnString, CommandType.Text, "update cmsPropertyType set tabId = " + TabId.ToString() + " where id = " + pt.Id.ToString()); // Remove from cache FlushFromCache(Id); foreach (TabI t in getVirtualTabs) FlushTabCache(t.Id); }