/// <summary> /// Retrieve a list of datatypedefinitions which share the same IDataType datatype /// </summary> /// <param Name="DataTypeId">The unique id of the IDataType</param> /// <returns>A list of datatypedefinitions which are based on the IDataType specified</returns> public static DataTypeDefinition GetByDataTypeId(Guid DataTypeId) { int dfId = 0; foreach (DataTypeDefinition df in DataTypeDefinition.GetAll()) { if (df.DataType.Id == DataTypeId) { dfId = df.Id; break; } } if (dfId == 0) { return(null); } else { return(new DataTypeDefinition(dfId)); } }
/* * public SortedList PreValues { * get { * SortedList retVal = new SortedList(); * SqlDataReader dr = SqlHelper.ExecuteReader(GlobalSettings.DbDSN, CommandType.Text, "select id, value from cmsDataTypePreValues where dataTypeNodeId = @nodeId order by sortOrder", new SqlParameter("@nodeId", this.Id)); * while (dr.Read()) * { * retVal.Add(dr["id"].ToString(), dr["value"].ToString()); * } * dr.Close(); * * return retVal; * } * } */ /// <summary> /// Retrieves a list of all datatypedefinitions /// </summary> /// <returns>A list of all datatypedefinitions</returns> public static DataTypeDefinition[] GetAll() { SortedList retvalSort = new SortedList(); Guid[] tmp = CMSNode.getAllUniquesFromObjectType(_objectType); DataTypeDefinition[] retval = new DataTypeDefinition[tmp.Length]; for (int i = 0; i < tmp.Length; i++) { DataTypeDefinition dt = DataTypeDefinition.GetDataTypeDefinition(tmp[i]); retvalSort.Add(dt.Text + "|||" + Guid.NewGuid().ToString(), dt); } IDictionaryEnumerator ide = retvalSort.GetEnumerator(); int counter = 0; while (ide.MoveNext()) { retval[counter] = (DataTypeDefinition)ide.Value; counter++; } return(retval); }
public static DataTypeDefinition GetDataTypeDefinition(Guid id) { if (System.Web.HttpRuntime.Cache[string.Format("UmbracoDataTypeDefinition{0}", id.ToString())] == null) { DataTypeDefinition dt = new DataTypeDefinition(id); System.Web.HttpRuntime.Cache.Insert(string.Format("UmbracoDataTypeDefinition{0}", id.ToString()), dt); } return (DataTypeDefinition)System.Web.HttpRuntime.Cache[string.Format("UmbracoDataTypeDefinition{0}", id.ToString())]; }
/* public SortedList PreValues { get { SortedList retVal = new SortedList(); SqlDataReader dr = SqlHelper.ExecuteReader(GlobalSettings.DbDSN, CommandType.Text, "select id, value from cmsDataTypePreValues where dataTypeNodeId = @nodeId order by sortOrder", new SqlParameter("@nodeId", this.Id)); while (dr.Read()) { retVal.Add(dr["id"].ToString(), dr["value"].ToString()); } dr.Close(); return retVal; } } */ /// <summary> /// Retrieves a list of all datatypedefinitions /// </summary> /// <returns>A list of all datatypedefinitions</returns> public static DataTypeDefinition[] GetAll() { SortedList retvalSort = new SortedList(); Guid[] tmp = CMSNode.getAllUniquesFromObjectType(_objectType); DataTypeDefinition[] retval = new DataTypeDefinition[tmp.Length]; for(int i = 0; i < tmp.Length; i++) { DataTypeDefinition dt = DataTypeDefinition.GetDataTypeDefinition(tmp[i]); retvalSort.Add(dt.Text + "|||" + Guid.NewGuid().ToString(), dt); } IDictionaryEnumerator ide = retvalSort.GetEnumerator(); int counter = 0; while (ide.MoveNext()) { retval[counter] = (DataTypeDefinition) ide.Value; counter++; } return retval; }
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> /// Adding a PropertyType to the ContentType, will add a new datafield/Property on all Documents of this Type. /// </summary> /// <param Name="dt">The DataTypeDefinition of the PropertyType</param> /// <param Name="Alias">The Alias of the PropertyType</param> /// <param Name="Name">The userfriendly Name</param> public void AddPropertyType(DataTypeDefinition dt, string Alias, string Name) { PropertyType pt = PropertyType.MakeNew(dt, this, Name, Alias); // Optimized call Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(GlobalSettings.DbDSN, CommandType.Text, "insert into cmsPropertyData (contentNodeId, versionId, propertyTypeId) select contentId, versionId, @propertyTypeId from cmsContent inner join cmsContentVersion on cmsContent.nodeId = cmsContentVersion.contentId where contentType = @contentTypeId", new SqlParameter("@propertyTypeId", pt.Id), new SqlParameter("@contentTypeId", Id)); // foreach (Content c in Content.getContentOfContentType(this)) // c.addProperty(pt,c.Version); // Remove from cache FlushFromCache(Id); }