/// <summary> /// Binds the form. /// </summary> private void BindForm() { bool pageExists = false; if (PageId > 0) { using (IDataReader reader = FileTreeItem.GetItemById(PageId)) { if (reader.Read()) { pageExists = true; Name.Text = reader["Name"].ToString(); } reader.Close(); } } if (!pageExists) { // update UI for creating a new folder BindParentFolderList(); ParentFolderRow.Visible = true; } BindRoles(); }
/// <summary> /// Binds the form. /// </summary> private void BindForm() { bool pageExists = false; if (PageId > 0) { using (IDataReader reader = FileTreeItem.GetItemById(PageId)) { if (reader.Read()) { pageExists = true; Name.Text = reader["Name"].ToString(); IsDefault.IsSelected = (bool)reader["IsDefault"]; MasterPageText.Text = (reader["MasterPage"] != DBNull.Value) && (reader["MasterPage"] != null) ? (string)reader["MasterPage"] : String.Empty; } reader.Close(); } // Load meta attributes using (IDataReader reader = PageAttributes.GetByPageId(PageId)) { if (reader.Read()) { txtTitle.Text = (string)reader["Title"]; txtKeywords.Text = (string)reader["MetaKeys"]; txtDescription.Text = (string)reader["MetaDescriptions"]; } else { // add default site attributes PageAttributes.Add(PageId, GlobalVariable.GetVariable(_GlobalVariableTitleKey, SiteId), GlobalVariable.GetVariable(_GlobalVariableMetaKeywordsKey, SiteId), GlobalVariable.GetVariable(_GlobalVariableMetaDescriptionKey, SiteId)); txtTitle.Text = GlobalVariable.GetVariable(_GlobalVariableTitleKey, SiteId); txtKeywords.Text = GlobalVariable.GetVariable(_GlobalVariableMetaKeywordsKey, SiteId); txtDescription.Text = GlobalVariable.GetVariable(_GlobalVariableMetaDescriptionKey, SiteId); } reader.Close(); } } if (!pageExists) { // update UI for creating a new page BindParentFolderList(); ParentFolderRow.Visible = true; } // since mater page is not used anywhere for now, hide it alway MasterPageRow.Visible = false; }
/// <summary> /// Gets the page URL. /// </summary> /// <param name="VersionId">The version id.</param> /// <returns></returns> protected string GetPageUrl(int VersionId) { string path = String.Empty; using (IDataReader reader = FileTreeItem.GetItemById(PageId)) { if (reader.Read()) { path = "~" + (string)reader["Outline"]; } reader.Close(); } path += "?VersionId=" + VersionId.ToString(); return(path.Trim()); }
/// <summary> /// Binds the folders. /// </summary> private void BindFolders() { List <JsonTreeNode> nodes = new List <JsonTreeNode>(); using (IDataReader reader = FileTreeItem.GetItemById(FileTreeItem.GetRoot(SiteId))) { if (reader.Read()) { string nodeId = MakeNodeId("folder-" + reader["PageId"].ToString()); JsonTreeNode node = JsonTreeNode.CreateNode(nodeId, reader["PageId"].ToString(), "/", "Content", "Folder-List", String.Format("folderid={0}&siteid={1}", reader["PageId"].ToString(), SiteId.ToString()), TreeListType.Folders.ToString()); nodes.Add(node); BindFolders(node, (int)reader["PageId"]); } reader.Close(); } WriteArray(nodes); }
/// <summary> /// Checks if entered name unique. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param> public void NameCheck(object sender, ServerValidateEventArgs args) { bool pageExists = false; int idToCheck = 0; if (PageId > 0) { using (IDataReader reader = FileTreeItem.GetItemById(PageId)) { if (reader.Read()) { pageExists = true; // get parent id using (IDataReader parentReader = FileTreeItem.LoadParent(PageId)) { if (parentReader.Read()) { idToCheck = (int)parentReader[_PageIdKey]; } parentReader.Close(); } } reader.Close(); } } if (!pageExists) { idToCheck = Int32.Parse(Root.SelectedValue); } // check if page exists string newPageName = MakePageName(Name.Text); if (PageExists(idToCheck, newPageName)) { args.IsValid = false; return; } args.IsValid = true; }
/// <summary> /// Checks is folder with secified name exists. /// </summary> /// <param name="parentId">The parent id.</param> /// <param name="name">The name.</param> /// <returns></returns> private bool DirExists(int parentId, string name) { bool exists = false; string parentPath = string.Empty; Guid siteId = Guid.Empty; using (IDataReader reader = FileTreeItem.GetItemById(parentId)) { if (reader.Read()) { parentPath = (string)reader[_OutlineKey] == "/" ? "" : (string)reader[_OutlineKey]; siteId = (Guid)reader[_SiteIdKey]; } reader.Close(); } if (!parentPath.EndsWith("/")) { parentPath = parentPath + "/"; } string childPath = parentPath + name + "/"; using (IDataReader reader2 = FileTreeItem.GetItemByOutlineAll(childPath, siteId)) { if (reader2.Read()) { if (PageId != (int)reader2[_PageIdKey]) { exists = true; } } reader2.Close(); } return(exists); }
/// <summary> /// Saves the changes. /// </summary> /// <param name="context">The context.</param> public void SaveChanges(IDictionary context) { bool pageExists = false; if (PageId > 0) { using (IDataReader reader = FileTreeItem.GetItemById(PageId)) { if (reader.Read()) { // edit folder pageExists = true; EditFolder(reader); } reader.Close(); } } if (!pageExists) { CreateFolder(); } }