protected void PopulateMediaFromReader(IRecordsReader dr) { bool _hc = false; if (dr.GetInt("children") > 0) { _hc = true; } int?masterContentType = null; if (!dr.IsNull("masterContentType")) { masterContentType = dr.GetInt("masterContentType"); } SetupMediaForTree(dr.GetGuid("uniqueId") , dr.GetShort("level") , dr.GetInt("parentId") , dr.GetInt("nodeUser") , dr.GetString("path") , dr.GetString("text") , dr.GetDateTime("createDate") , dr.GetString("icon") , _hc , dr.GetString("alias") , dr.GetString("thumbnail") , dr.GetString("description") , masterContentType , dr.GetInt("contentTypeId")); }
/// <summary> /// Read all UserType data and store it in cache. /// </summary> private static void Cache() { //don't query the database is the cache is not null if (HttpRuntime.Cache[CACHE_KEY] != null) { return; } List <UserType> tmp = new List <UserType>(); using (IRecordsReader dr = SqlHelper.ExecuteReader("select id, userTypeName, userTypeAlias, userTypeDefaultPermissions from umbracoUserType")) { while (dr.Read()) { tmp.Add(new UserType( dr.GetShort("id"), dr.GetString("userTypeName"), dr.GetString("userTypeDefaultPermissions"), dr.GetString("userTypeAlias"))); } } UserTypes = tmp; }
private void setupUser(int ID) { _id = ID; using (IRecordsReader dr = SqlHelper.ExecuteReader( "Select userNoConsole, userDisabled, userType,startStructureID, startMediaId, userName,userLogin,userEmail,userDefaultPermissions, userLanguage, defaultToLiveEditing from umbracoUser where id = @id", SqlHelper.CreateParameter("@id", ID))) { if (dr.Read()) { _userNoConsole = dr.GetBoolean("usernoconsole"); _userDisabled = dr.GetBoolean("userDisabled"); _name = dr.GetString("userName"); _loginname = dr.GetString("userLogin"); _email = dr.GetString("userEmail"); _language = dr.GetString("userLanguage"); _startnodeid = dr.GetInt("startStructureID"); if (!dr.IsNull("startMediaId")) { _startmediaid = dr.GetInt("startMediaID"); } _usertype = UserType.GetUserType(dr.GetShort("UserType")); _defaultToLiveEditing = dr.GetBoolean("defaultToLiveEditing"); } else { throw new ArgumentException("No User exists with ID " + ID.ToString()); } } _isInitialized = true; }
protected void PopulateFromReader(IRecordsReader dr) { _id = Convert.ToInt32(dr.GetShort("id")); _cultureAlias = dr.GetString("languageISOCode"); UpdateNames(); }
//public CmsNode GetNodeById(Guid uniqueId) //{ // CmsNode cmsNode; // var id = SqlHelper.ExecuteScalar<int>("SELECT id FROM umbracoNode WHERE uniqueID = @uniqueId", SqlHelper.CreateParameter("@uniqueId", uniqueId)); // using (IRecordsReader dr = SqlHelper.ExecuteReader(m_SQLSingle, // SqlHelper.CreateParameter("@id", id))) // { // if (dr.Read() || dr.IsNull("uniqueID")) // { // cmsNode = new CmsNode // { // UniqueId = dr.GetGuid("uniqueID"), // NodeObjectType = dr.GetGuid("nodeObjectType"), // ContentTypeId = dr.GetInt("contentTypeId"), // Level = dr.GetShort("level"), // Path = dr.GetString("path"), // ParentId = dr.GetInt("parentId"), // Text = dr.GetString("text"), // SortOrder = dr.GetInt("sortOrder"), // UserId = dr.GetInt("nodeUser"), // CreateDate = dr.GetDateTime("createDate"), // IsTrashed = dr.GetBoolean("trashed") // }; // } // else // { // throw new ArgumentException(string.Format("No node exists with id '{0}' ({1})", id, uniqueId)); // } // } // return cmsNode; //} public IEnumerable <T> GetNodesByIds <T>(Guid[] uniqueIds) where T : CmsNode, new() { var cmsNodes = new List <T>(); // TODO: parameterize this the "right" way to prevent future sql injection var strUIds = string.Format("'{0}'", string.Join("','", uniqueIds)); var ids = new List <int>(); using (IRecordsReader reader = SqlHelper.ExecuteReader(string.Format("SELECT id FROM umbracoNode WHERE uniqueID in ({0})", strUIds))) { while (reader.Read()) { ids.Add(reader.GetInt("id")); } } var strIds = string.Join(",", ids); using (IRecordsReader dr = SqlHelper.ExecuteReader(string.Format(m_SQMultiple, strIds))) { while (dr.Read()) { cmsNodes.Add(new T { UniqueId = dr.GetGuid("uniqueID"), NodeObjectType = dr.GetGuid("nodeObjectType"), ContentTypeId = dr.GetInt("contentTypeId"), Level = dr.GetShort("level"), Path = dr.GetString("path"), ParentId = dr.GetInt("parentId"), Text = dr.GetString("text"), SortOrder = dr.GetInt("sortOrder"), UserId = dr.GetInt("nodeUser"), CreateDate = dr.GetDateTime("createDate"), IsTrashed = dr.GetBoolean("trashed") }); } } if (typeof(T) == typeof(DocType)) { // Fill out property data foreach (var node in cmsNodes) { var docType = node as DocType; if (docType != null) { docType.Properties = GetPropertyTypes(node).ToList(); } } } return(cmsNodes); }
private void setup() { using (IRecordsReader dr = SqlHelper.ExecuteReader("select macro, macroPropertyHidden, macroPropertyType, macroPropertySortOrder, macroPropertyAlias, macroPropertyName from cmsMacroProperty where id = @id", SqlHelper.CreateParameter("@id", _id))) { if (dr.Read()) { m_macro = new Macro(dr.GetInt("macro")); _public = dr.GetBoolean("macroPropertyHidden"); _sortOrder = (int)dr.GetByte("macroPropertySortOrder"); _alias = dr.GetString("macroPropertyAlias"); _name = dr.GetString("macroPropertyName"); _type = new MacroPropertyType(dr.GetShort("macroPropertyType")); } else { throw new ArgumentException("No macro property found for the id specified"); } } }
protected void PopulateMediaFromReader(IRecordsReader dr) { var hc = dr.GetInt("children") > 0; SetupMediaForTree(dr.GetGuid("uniqueId") , dr.GetShort("level") , dr.GetInt("parentId") , dr.GetInt("nodeUser") , dr.GetString("path") , dr.GetString("text") , dr.GetDateTime("createDate") , dr.GetString("icon") , hc , dr.GetString("alias") , dr.GetString("thumbnail") , dr.GetString("description") , null , dr.GetInt("contentTypeId") , dr.GetBoolean("isContainer")); }
protected void PopulateCMSNodeFromReader(IRecordsReader dr) { // testing purposes only > original umbraco data hasn't any unique values ;) // And we need to have a newParent in order to create a new node .. // Should automatically add an unique value if no exists (or throw a decent exception) if (dr.IsNull("uniqueID")) { _uniqueID = Guid.NewGuid(); } else { _uniqueID = dr.GetGuid("uniqueID"); } _nodeObjectType = dr.GetGuid("nodeObjectType"); _level = dr.GetShort("level"); _path = dr.GetString("path"); _parentid = dr.GetInt("parentId"); _text = dr.GetString("text"); _sortOrder = dr.GetInt("sortOrder"); _userId = dr.GetInt("nodeUser"); _createDate = dr.GetDateTime("createDate"); _isTrashed = dr.GetBoolean("trashed"); }
public virtual List <CMSPreviewNode> GetNodesForPreview(bool childrenOnly) { List <CMSPreviewNode> nodes = new List <CMSPreviewNode>(); string sql = @" select umbracoNode.id, umbracoNode.parentId, umbracoNode.level, umbracoNode.sortOrder, cmsPreviewXml.xml from umbracoNode inner join cmsPreviewXml on cmsPreviewXml.nodeId = umbracoNode.id where trashed = 0 and path like '{0}' order by level,sortOrder"; string pathExp = childrenOnly ? Path + ",%" : Path; IRecordsReader dr = SqlHelper.ExecuteReader(String.Format(sql, pathExp)); while (dr.Read()) { nodes.Add(new CMSPreviewNode(dr.GetInt("id"), dr.GetGuid("uniqueID"), dr.GetInt("parentId"), dr.GetShort("level"), dr.GetInt("sortOrder"), dr.GetString("xml"), false)); } dr.Close(); return(nodes); }
protected void PopulateMemberFromReader(IRecordsReader dr) { SetupNodeForTree(dr.GetGuid("uniqueId"), _objectType, dr.GetShort("level"), dr.GetInt("parentId"), dr.GetInt("nodeUser"), dr.GetString("path"), dr.GetString("text"), dr.GetDateTime("createDate"), false); if (!dr.IsNull("Email")) m_Email = dr.GetString("Email"); m_LoginName = dr.GetString("LoginName"); m_Password = dr.GetString("Password"); }
protected void PopulateDocumentFromReader(IRecordsReader dr) { var hc = dr.GetInt("children") > 0; SetupDocumentForTree(dr.GetGuid("uniqueId") , dr.GetShort("level") , dr.GetInt("parentId") , dr.GetInt("nodeUser") , dr.GetInt("documentUser") , !dr.GetBoolean("trashed") && (dr.GetInt("isPublished") == 1) //set published... double check trashed property , dr.GetString("path") , dr.GetString("text") , dr.GetDateTime("createDate") , dr.GetDateTime("updateDate") , dr.GetDateTime("versionDate") , dr.GetString("icon") , hc , dr.GetString("alias") , dr.GetString("thumbnail") , dr.GetString("description") , null , dr.GetInt("contentTypeId") , dr.GetInt("templateId") , dr.GetBoolean("isContainer")); if (!dr.IsNull("releaseDate")) _release = dr.GetDateTime("releaseDate"); if (!dr.IsNull("expireDate")) _expire = dr.GetDateTime("expireDate"); }
protected void PopulateFromReader(IRecordsReader dr) { _id = Convert.ToInt32(dr.GetShort("id")); _cultureAlias = dr.GetString("languageISOCode"); updateNames(); }
protected void PopulateDocumentFromReader(IRecordsReader dr) { bool _hc = false; if (dr.GetInt("children") > 0) _hc = true; int? masterContentType = null; if (!dr.IsNull("masterContentType")) masterContentType = dr.GetInt("masterContentType"); SetupDocumentForTree(dr.GetGuid("uniqueId") , dr.GetShort("level") , dr.GetInt("parentId") , dr.GetInt("nodeUser") , dr.GetInt("documentUser") , (dr.GetInt("isPublished") == 1) , dr.GetString("path") , dr.GetString("text") , dr.GetDateTime("createDate") , dr.GetDateTime("updateDate") , dr.GetDateTime("versionDate") , dr.GetString("icon") , _hc , dr.GetString("alias") , dr.GetString("thumbnail") , dr.GetString("description") , masterContentType , dr.GetInt("contentTypeId") , dr.GetInt("templateId")); }