/// <summary> /// Loads the data and data bind. /// </summary> private void LoadDataAndDataBind() { DataTable files = FileTreeItem.LoadItemByFolderIdDT(FolderId); DataColumn column = new DataColumn("CheckboxEnabled", typeof(System.Boolean)); files.Columns.Add(column); files.Columns.Add(new DataColumn("ImageUrl", typeof(string))); using (IDataReader reader = FileTreeItem.LoadParent(FolderId)) { if (reader.Read()) { DataRow row = files.NewRow(); row["CheckboxEnabled"] = false; row["PageId"] = (int)reader["PageId"]; row["Name"] = "[..]"; row["IsDefault"] = false; row["IsPublic"] = true; row["IsFolder"] = true; row["Order"] = -1000000; row["SiteId"] = SiteId; row["ImageUrl"] = Page.ResolveUrl("~/Apps/Content/images/Up One Level.png"); files.Rows.InsertAt(row, 0); } reader.Close(); } DataView view = new DataView(files); view.Sort = "IsFolder DESC, Order"; MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("PageId", "SiteId", "IsFolder"); MyListView.DataSource = view; DataBind(); }
/// <summary> /// Populates the languages recursive. /// </summary> /// <param name="folderId">The folder id.</param> private void PopulateLanguagesRecursive(int folderId) { Guid siteId = Guid.Empty; DataTable item = FileTreeItem.GetItemByIdDT(folderId); // We only care about pages if (item != null && item.Rows.Count > 0) { if ((bool)item.Rows[0]["IsFolder"]) { DataTable childItems = FileTreeItem.LoadItemByFolderIdDT(folderId); foreach (DataRow childItem in childItems.Rows) { PopulateLanguagesRecursive((int)childItem["PageId"]); } } } siteId = (Guid)item.Rows[0]["SiteId"]; PageDocument pageDocument = null; //GET PUBLISHED VERSION int statusId = WorkflowStatus.GetLast(); DataTable versionsTable = PageVersion.GetVersionByStatusIdDT(folderId, statusId); // Find page document int templateId = 0; int stateId = 0; int langId = 0; if (versionsTable != null && versionsTable.Rows.Count > 0) { foreach (DataRow versionRow in versionsTable.Rows) { int versionId = 0; int.TryParse(versionRow["VersionId"].ToString(), out versionId); templateId = Int32.Parse(versionRow["templateid"].ToString()); PageDocument.PersistentDocumentStorage = new SqlPageDocumentStorageProvider(); pageDocument = PageDocument.Open(versionId, OpenMode.View, Guid.Empty); stateId = Int32.Parse(versionRow["stateid"].ToString()); langId = Int32.Parse(versionRow["LangId"].ToString()); // Found a non empty page document if (pageDocument != null) { break; } } } // Get list of languages SiteDto siteDto = SiteManager.GetSite(siteId); foreach (SiteDto.SiteLanguageRow langRow in siteDto.SiteLanguage) { IDataReader reader = Language.GetLangByName(langRow.LanguageCode); if (reader.Read()) { int currentLangId = (int)reader["LangId"]; // We skip the default page document language if (currentLangId == langId) { reader.Close(); continue; } // If we already have a specified language define, skip it IDataReader versionReader = PageVersion.GetVersionByLangId(folderId, langId); if (!versionReader.Read()) { versionReader.Close(); continue; } int versionId = PageVersion.AddPageVersion(folderId, templateId, currentLangId, ProfileContext.Current.UserId, stateId, String.Empty); PageDocument.PersistentDocumentStorage = new SqlPageDocumentStorageProvider(); PageDocument.PersistentDocumentStorage.Save(pageDocument, versionId, ProfileContext.Current.UserId); versionReader.Close(); } reader.Close(); } }