/// <summary> /// Initializes the category provider /// </summary> private void InitCategoryProvider() { // Create and set category provider UniTreeProvider categoryProvider = new UniTreeProvider(); categoryProvider.DisplayNameColumn = "DisplayName"; categoryProvider.IDColumn = "ObjectID"; categoryProvider.LevelColumn = "ObjectLevel"; categoryProvider.OrderColumn = "CategoryOrder"; categoryProvider.ParentIDColumn = "ParentID"; categoryProvider.PathColumn = "ObjectPath"; categoryProvider.ValueColumn = "ObjectID"; categoryProvider.ChildCountColumn = "CompleteChildCount"; categoryProvider.QueryName = "cms.pagetemplatecategory.selectallview"; categoryProvider.ObjectTypeColumn = "ObjectType"; categoryProvider.Columns = "DisplayName, CodeName, ObjectID, ObjectLevel, CategoryOrder, ParentID, ObjectPath, CompleteChildCount, ObjectType, CategoryChildCount, CategoryImagePath, Parameter"; categoryProvider.ImageColumn = "CategoryImagePath"; categoryProvider.ParameterColumn = "Parameter"; if (!SelectPageTemplates) { categoryProvider.WhereCondition = "ObjectType = 'pagetemplatecategory'"; categoryProvider.ChildCountColumn = "CategoryChildCount"; categoryProvider.ObjectTypeColumn = ""; treeElem.DefaultImagePath = GetImageUrl("Objects/CMS_PageTemplateCategory/list.png"); } else { categoryProvider.OrderBy = "ObjectType DESC, DisplayName ASC"; treeElem.OnGetImage += new CMSAdminControls_UI_Trees_UniTree.GetImageEventHandler(treeElem_OnGetImage); } // Do not show AdHoc category if (!ShowAdHocCategory) { categoryProvider.WhereCondition = SqlHelperClass.AddWhereCondition(categoryProvider.WhereCondition, "CodeName <> 'AdHoc'"); } // Do not show empty categories if (!ShowEmptyCategories) { categoryProvider.WhereCondition = SqlHelperClass.AddWhereCondition(categoryProvider.WhereCondition, "CategoryTemplateChildCount > 0 OR CategoryChildCount > 0"); TreeProvider tp = new TreeProvider(CMSContext.CurrentUser); CMS.DocumentEngine.TreeNode node = DocumentHelper.GetDocument(DocumentID, tp); string culture = CMSContext.PreferredCultureCode; int level = 0; string path = string.Empty; if (node != null) { level = node.NodeLevel; path = node.NodeAliasPath; if (IsNewPage) { level++; path = path + "/%"; } else { culture = node.DocumentCulture; } } // Add where condition for scopes categoryProvider.WhereCondition += " AND (ObjectLevel = 0 OR (SELECT TOP 1 ObjectID FROM View_CMS_PageTemplateCategoryPageTemplate_Joined AS X WHERE X.ObjectType = 'pagetemplate' "; categoryProvider.WhereCondition += " AND (X.PageTemplateType IS NULL OR X.PageTemplateType <> N'" + PageTemplateInfoProvider.GetPageTemplateTypeCode(PageTemplateTypeEnum.Dashboard) + "')"; if (ShowOnlySiteTemplates) { categoryProvider.WhereCondition += " AND X.ObjectID IN (SELECT PageTemplateID FROM CMS_PageTemplateSite WHERE SiteID = " + CMSContext.CurrentSiteID + ") "; } if (node != null) { categoryProvider.WhereCondition += " AND (" + PageTemplateScopeInfoProvider.GetScopeWhereCondition(path, culture, node.NodeClassName, level, CMSContext.CurrentSiteName, "X", "ObjectID") + ") "; } categoryProvider.WhereCondition += " AND (X.ObjectPath LIKE View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectPath + '/%')) IS NOT NULL)"; // Add column count column - minimal number of children categoryProvider.Columns += @", (SELECT TOP 1 Count(*) FROM View_CMS_PageTemplateCategoryPageTemplate_Joined AS Y WHERE (Y.ObjectID = View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectID AND Y.ObjectLevel = 0) OR ( View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectType = 'PageTemplateCategory' AND View_CMS_PageTemplateCategoryPageTemplate_Joined.CategoryChildCount > 0 AND Y.ObjectType = 'PageTemplate' AND Y.ObjectLevel > View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectLevel + 1 "; if (ShowOnlySiteTemplates) { categoryProvider.Columns += "AND Y.ObjectID IN (SELECT PageTemplateID FROM CMS_PageTemplateSite WHERE SiteID = " + CMSContext.CurrentSiteID + ") "; } if (node != null) { categoryProvider.Columns += " AND ( " + PageTemplateScopeInfoProvider.GetScopeWhereCondition(path, culture, node.NodeClassName, level, CMSContext.CurrentSiteName, "Y", "ObjectID") + " ) "; } categoryProvider.Columns += " AND Y.ObjectPath LIKE View_CMS_PageTemplateCategoryPageTemplate_Joined.ObjectPath + '/%')) AS MinNumberOfChilds"; categoryProvider.ChildCountColumn = "MinNumberOfChilds"; } // Handle the root path if (!String.IsNullOrEmpty(RootPath) && (RootPath != "/")) { categoryProvider.RootLevelOffset = RootPath.Split('/').Length - 1; categoryProvider.WhereCondition = SqlHelperClass.AddWhereCondition(categoryProvider.WhereCondition, String.Format("((ObjectPath = '{0}' OR ObjectPath LIKE '{0}/%'))", RootPath)); } treeElem.ProviderObject = categoryProvider; }
internal void RenameRootFolder(RecoveryFileState state) { if (!RecoveryFolderStructure.PathIsNetworkPath(_rootPath)) { string[] shardPath = null; shardPath = RootPath.Split(new string[] { RecoveryFolderStructure.SHARD_BACKUP_FOLDER }, StringSplitOptions.RemoveEmptyEntries); switch (state) { case RecoveryFileState.Cancelled: string destination = string.Empty; if (RootPath.EndsWith(RecoveryFolderStructure.INPROGRESS)) { string[] name = RootPath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = name[0] + RecoveryFolderStructure.CANCELLED; if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } destination = RootPath.Replace(RecoveryFolderStructure.INPROGRESS, RecoveryFolderStructure.CANCELLED); Directory.Move(RootPath, destination); RootPath = destination; } break; case RecoveryFileState.Completed: string[] folderName = RootPath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = folderName[0] + RecoveryFolderStructure.COMPLETED; if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } destination = RootPath.Replace(RecoveryFolderStructure.INPROGRESS, RecoveryFolderStructure.COMPLETED); Directory.Move(RootPath, destination); RootPath = destination; break; case RecoveryFileState.Failed: string[] rootName = RootPath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = rootName[0] + RecoveryFolderStructure.FAILED; if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } destination = RootPath.Replace(RecoveryFolderStructure.INPROGRESS, RecoveryFolderStructure.FAILED); Directory.Move(RootPath, destination); RootPath = destination; break; } if (new DirectoryInfo(shardPath[0]).GetDirectories().Count() == 0) { Directory.Delete(shardPath[0]); } } }