当前位置: 首页>>代码示例>>C#>>正文


C# TreeProvider.SelectNodes方法代码示例

本文整理汇总了C#中TreeProvider.SelectNodes方法的典型用法代码示例。如果您正苦于以下问题:C# TreeProvider.SelectNodes方法的具体用法?C# TreeProvider.SelectNodes怎么用?C# TreeProvider.SelectNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeProvider的用法示例。


在下文中一共展示了TreeProvider.SelectNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplySettings

    /// <summary>
    /// Apply control settings.
    /// </summary>
    public bool ApplySettings()
    {
        if (MasterTemplateId <= 0)
        {
            lblError.Text = GetString("TemplateSelection.SelectTemplate");
            return false;
        }
        else
        {
            // Update all culture versions
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
            DataSet ds = tree.SelectNodes(SiteName, "/", TreeProvider.ALL_CULTURES, false, "CMS.Root", null, null, -1, false);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    // Update the document
                    TreeNode node = TreeNode.New(dr, "CMS.Root", tree);
                    node.DocumentPageTemplateID = MasterTemplateId;
                    node.Update();

                    // Update search index for node
                    if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled))
                    {
                        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());
                    }
                }
            }
        }

        return true;
    }
开发者ID:v-jli,项目名称:jean0407large,代码行数:35,代码来源:SelectMasterTemplate.ascx.cs

示例2: SetupControl

    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        string path = (string)this.GetValue("Path");
        string formatPath = path.Substring(1);

        try
        {
            litArchive.Text = (string)this.GetValue("Header");

            DataSet dataSet = null;
            TreeProvider tree = new TreeProvider();
            dataSet = tree.SelectNodes("Custom.BlogMonth").Path(formatPath, PathTypeEnum.Children)
                            .Where("")
                            .OrderBy("NodeLevel, NodeOrder, NodeName");

            if (dataSet != null)
            {
                rptblogLister.DataSource = dataSet.Tables[0];
                rptblogLister.DataBind();
            }
        }

        catch (Exception ex1)
        {
            Response.Write(ex1.Message.ToString() + ex1.StackTrace.ToString());
        }
    }
开发者ID:DeepakV1985,项目名称:MyCompany,代码行数:30,代码来源:BlogArchive.ascx.cs

示例3: ApplySettings

    /// <summary>
    /// Apply control settings.
    /// </summary>
    public bool ApplySettings()
    {
        if (MasterTemplateId <= 0)
        {
            lblError.Text = GetString("TemplateSelection.SelectTemplate");
            return false;
        }
        else
        {
            // Update all culture versions
            TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
            DataSet ds = tree.SelectNodes(SiteName, "/", TreeProvider.ALL_CULTURES, false, "CMS.Root", null, null, -1, false);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    // Update the document
                    TreeNode node = TreeNode.New("CMS.Root", dr, tree);

                    node.SetDefaultPageTemplateID(MasterTemplateId);

                    node.Update();

                    // Update search index for node
                    if (DocumentHelper.IsSearchTaskCreationAllowed(node))
                    {
                        SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, TreeNode.OBJECT_TYPE, SearchFieldsConstants.ID, node.GetSearchID(), node.DocumentID);
                    }
                }
            }
        }

        return true;
    }
开发者ID:arvind-web-developer,项目名称:csharp-projects-Jemena-Kentico-CMS,代码行数:37,代码来源:SelectMasterTemplate.ascx.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialization
        productId = QueryHelper.GetInteger("productId", 0);
        skuGuid = QueryHelper.GetGuid("skuguid", Guid.Empty);
        currentSite = SiteContext.CurrentSite;

        var skuObj = SKUInfoProvider.GetSKUInfo(productId);

        if ((skuObj != null) && skuObj.IsProductVariant)
        {
            // Get parent product of variant
            var parent = skuObj.Parent as SKUInfo;

            if (parent != null)
            {
                productId = parent.SKUID;
                skuGuid = parent.SKUGUID;
            }
        }

        string where = null;
        if (productId > 0)
        {
            where = "NodeSKUID = " + productId;
        }
        else if (skuGuid != Guid.Empty)
        {
            where = "SKUGUID = '" + skuGuid + "'";
        }

        if ((where != null) && (currentSite != null))
        {
            TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
            DataSet ds = tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, "", where);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // Ger specified product url
                url = DocumentURLProvider.GetUrl(Convert.ToString(ds.Tables[0].Rows[0]["NodeAliasPath"]));
            }
        }

        if ((url != "") && (currentSite != null))
        {
            // Redirect to specified product
            URLHelper.RedirectPermanent(url, currentSite.SiteName);
        }
        else
        {
            // Display error message
            lblInfo.Visible = true;
            lblInfo.Text = GetString("GetProduct.NotFound");
        }
    }
开发者ID:dlnuckolls,项目名称:pfh-paypalintegration,代码行数:54,代码来源:GetProduct.aspx.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialization
        productId = QueryHelper.GetInteger("productId", 0);
        skuGuid = QueryHelper.GetGuid("skuguid", Guid.Empty);
        currentSite = CMSContext.CurrentSite;

        string where = null;
        if (productId > 0)
        {
            where = "NodeSKUID = " + productId;
        }
        else if (skuGuid != Guid.Empty)
        {
            where = "SKUGUID = '" + skuGuid.ToString() + "'";
        }

        if ((where != null) && (currentSite != null))
        {
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
            DataSet ds = tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, "", where);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // Ger specified product url
                url = CMSContext.GetUrl(Convert.ToString(ds.Tables[0].Rows[0]["NodeAliasPath"]));
            }
        }

        if (url != "")
        {
            // Redirect to specified product
            URLHelper.Redirect(url);
        }
        else
        {
            // Display error message
            lblInfo.Visible = true;
            lblInfo.Text = GetString("GetProduct.NotFound");
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:40,代码来源:GetProduct.aspx.cs

示例6: SetupControl

    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        string category = Request.QueryString["Cat"];
        string path = (string)this.GetValue("Path");
        string formatPath = path.Substring(1);

        if(Request.QueryString["Cat"] != null)
        {
              DataSet dataSet = null;
                TreeProvider tree = new TreeProvider();
                dataSet = tree.SelectNodes("Custom.BlogDetails").Path(formatPath, PathTypeEnum.Children)
                                .Where("BlogCategory", QueryOperator.Like, "%" + category + "%")
                                .OrderBy("NodeLevel, NodeOrder, NodeName");

                if (dataSet != null)
                {
                    rptblogLister.DataSource = dataSet.Tables[0];
                    rptblogLister.DataBind();
                }

        }
    }
开发者ID:DeepakV1985,项目名称:MyCompany,代码行数:25,代码来源:CategoryFilter.ascx.cs

示例7: SetupControl

    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        string aliasPath = DocumentContext.CurrentDocument.NodeAliasPath.ToString();

        try
        {
            DataSet dataSet = null;
            TreeProvider tree = new TreeProvider();
            dataSet = tree.SelectNodes("Custom.BlogDetails").Path(aliasPath, PathTypeEnum.Children)
                            .Where("")
                            .OrderBy("NodeLevel, NodeOrder, NodeName");

            if (dataSet != null)
            {
                rptblogLister.DataSource = dataSet.Tables[0];
                rptblogLister.DataBind();
            }
        }

        catch (Exception ex1)
        {
            Response.Write(ex1.Message.ToString() + ex1.StackTrace.ToString());
        }
    }
开发者ID:DeepakV1985,项目名称:MyCompany,代码行数:27,代码来源:BlogList.ascx.cs

示例8: GetExpiredAssociationCount

        internal int GetExpiredAssociationCount(TreeProvider tp, CMS.DocumentEngine.TreeNode nodeToClone)
        {
            int count = 0;
            count = GetExpiredAssociationCountforNode(nodeToClone.NodeID);
            if (IsIncludeChildNodeRequested(DocumentAction.Value))
            {
                TreeNodeDataSet nodeToClone_DS = tp.SelectNodes(CMSContext.CurrentSiteName, nodeToClone.NodeAliasPath + "/%", "en-us", false);
                if (nodeToClone_DS != null && nodeToClone_DS.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in nodeToClone_DS.Tables[0].Rows)
                    {
                        if (!string.IsNullOrEmpty(row["NodeID"].ToString()))
                        {
                            count += GetExpiredAssociationCountforNode((int)row["NodeId"]);
                        }

                    }
                }
            }
            return count;
        }
开发者ID:ezimaxtechnologies,项目名称:ASP.Net,代码行数:21,代码来源:AddExistingSearch.aspx.cs

示例9: cloneNode

        internal static Boolean cloneNode(TreeProvider tp, CMS.DocumentEngine.TreeNode nodeToClone, CMS.DocumentEngine.TreeNode destinationNode, string action)
        {
            if (action == null) action = "0";
            bool includeChildNodes = (action == "1" || action == "3");
            bool includeAssociations = (action == "2" || action == "3");
            if ((tp != null) && (nodeToClone != null) && (destinationNode != null))
            {
                CMS.DocumentEngine.TreeNode newTreeNode = DocumentHelper.CopyDocument(nodeToClone, destinationNode.NodeID, false, tp);
                
                if (newTreeNode != null)
                {                    
                    //Remove Average Rating and Review count from the New Document
                    //US15667
                    if (IsShared == "true")
                    {
                        int allowUser = Convert.ToInt32(Math.Pow(2, Convert.ToInt32(NodePermissionsEnum.Delete))) + Convert.ToInt32(Math.Pow(2, Convert.ToInt32(NodePermissionsEnum.Read)));
                        int deniedUser = Convert.ToInt32(Math.Pow(2, Convert.ToInt32(NodePermissionsEnum.Modify))) + Convert.ToInt32(Math.Pow(2, Convert.ToInt32(NodePermissionsEnum.ModifyPermissions)));
                        AclProvider aclUser = new AclProvider(tp);
                        aclUser.SetUserPermissions(newTreeNode, allowUser, deniedUser, theSharedUserRoles);
                    }

                    UpdateRatingAvgNCountsInKenticoDB(newTreeNode.NodeID);
                    
                    //Copy the parent node associations
                    if (includeAssociations)
                        CopyDocumentPlanAssociationDetails(nodeToClone.NodeID, newTreeNode.NodeID);

                    if (includeChildNodes)
                    {
                        DataSet nodeToClone_DS = tp.SelectNodes(CMSContext.CurrentSiteName, nodeToClone.NodeAliasPath + "/%", "en-us", false, null, null, null, 1);
                        if (nodeToClone_DS != null && nodeToClone_DS.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow row in nodeToClone_DS.Tables[0].Rows)
                            {
                                int src = (int) row["NodeId"];
                                CMS.DocumentEngine.TreeNode childNode = DocumentHelper.GetDocument(src, "en-us", tp);
                                if (childNode["ExpirationDate"] != null)
                                {
                                    DateTime expirationDate = Convert.ToDateTime(childNode["ExpirationDate"]);
                                    if (expirationDate.Date < DateTime.Today) continue;
                                }
                                
                                cloneNode(tp, childNode, newTreeNode, action);                                
                            }
                        }
                        }
                    }

                return true;
            }
            return false;
        }
开发者ID:ezimaxtechnologies,项目名称:ASP.Net,代码行数:52,代码来源:AddExistingSearch.aspx.cs

示例10: ObjectManager_OnSaveData

    /// <summary>
    /// Save button action.
    /// </summary>
    protected void ObjectManager_OnSaveData(object sender, SimpleObjectManagerEventArgs e)
    {
        // Template has to exist
        if (PageTemplate == null)
        {
            return;
        }

        // Limit text length
        txtTemplateCodeName.Text = TextHelper.LimitLength(txtTemplateCodeName.Text.Trim(), 100, "");
        txtTemplateDisplayName.Text = TextHelper.LimitLength(txtTemplateDisplayName.Text.Trim(), 200, "");

        // Finds whether required fields are not empty
        string result = String.Empty;

        result = new Validator().NotEmpty(txtTemplateDisplayName.Text, GetString("Administration-PageTemplate_General.ErrorEmptyTemplateDisplayName")).NotEmpty(txtTemplateCodeName.Text, GetString("Administration-PageTemplate_General.ErrorEmptyTemplateCodeName"))
            .IsCodeName(txtTemplateCodeName.Text, GetString("general.invalidcodename"))
            .Result;

        if ((result == String.Empty) && (SelectedPageType == PageTemplateTypeEnum.Aspx || SelectedPageType == PageTemplateTypeEnum.AspxPortal))
        {
            if (!FileSystemSelector.IsValid())
            {
                result = FileSystemSelector.ValidationError;
            }
        }

        // If name changed, check if new name is unique
        if ((result == String.Empty) && (CMSString.Compare(PageTemplate.CodeName, txtTemplateCodeName.Text, true) != 0))
        {
            if (PageTemplateInfoProvider.PageTemplateNameExists(txtTemplateCodeName.Text))
            {
                result = GetString("general.codenameexists");
            }
        }

        // Check dashboard prerequisites
        if ((PageTemplate.PageTemplateId > 0) && (SelectedPageType == PageTemplateTypeEnum.Dashboard))
        {
            // Check live site usage
            TreeProvider tp = new TreeProvider(CMSContext.CurrentUser);
            NodeSelectionParameters parameters = new NodeSelectionParameters()
            {
                ClassNames = TreeProvider.ALL_CLASSNAMES,
                SiteName = TreeProvider.ALL_SITES,
                Columns = "NodeID",
                Where = String.Format("DocumentPageTemplateID = {0} OR NodeTemplateID = {0} OR NodeWireframeTemplateID = {0}", PageTemplate.PageTemplateId)
            };

            DataSet ds = tp.SelectNodes(parameters);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                result = GetString("template.dahsboardliveused");
            }

            // Check valid zones
            if (String.IsNullOrEmpty(result))
            {
                PageTemplateInstance inst = PageTemplate.TemplateInstance;
                if (inst != null)
                {
                    foreach (WebPartZoneInstance zone in inst.WebPartZones)
                    {
                        switch (zone.WidgetZoneType)
                        {
                            case WidgetZoneTypeEnum.Dashboard:
                            case WidgetZoneTypeEnum.None:
                                continue;
                        }

                        result = GetString("template.dashboardinvalidzone");
                        break;
                    }
                }
            }
        }

        if (String.IsNullOrEmpty(result))
        {
            // Update page template info
            PageTemplate.DisplayName = txtTemplateDisplayName.Text;
            PageTemplate.CodeName = txtTemplateCodeName.Text;
            PageTemplate.Description = txtTemplateDescription.Text;
            PageTemplate.CategoryID = Convert.ToInt32(categorySelector.Value);

            if (SelectedPageType == PageTemplateTypeEnum.MVC)
            {
                // MVC template
                PageTemplate.IsPortal = false;
                PageTemplate.FileName = String.Empty;

                PageTemplate.ShowAsMasterTemplate = false;
                PageTemplate.PageTemplateCloneAsAdHoc = false;

                PageTemplate.PageTemplateDefaultController = txtController.Text;
                PageTemplate.PageTemplateDefaultAction = txtAction.Text;
            }
//.........这里部分代码省略.........
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:101,代码来源:PageTemplate_General.aspx.cs

示例11: GetExpiredChildCountforNode

        internal static int GetExpiredChildCountforNode(TreeProvider tp, CMS.DocumentEngine.TreeNode nodeToClone, CMS.DocumentEngine.TreeNode destinationNode, string action)
        {
            int i = 0;
            TreeNodeDataSet nodeToClone_DS = tp.SelectNodes(CMSContext.CurrentSiteName, nodeToClone.NodeAliasPath + "/%", "en-us", false);
            if (nodeToClone_DS != null && nodeToClone_DS.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in nodeToClone_DS.Tables[0].Rows)
                {
                    CMS.DocumentEngine.TreeNode childDoc = DocumentHelper.GetDocument((int)row["NodeID"], "en-us", tp);
                    if (childDoc["ExpirationDate"] != null)
                    {
                        DateTime expirationDate = (DateTime)(childDoc["ExpirationDate"]);
                        if (expirationDate.Date < DateTime.Today)
                            i++;
                    }

                }
            }
            return i;
        }
开发者ID:ezimaxtechnologies,项目名称:ASP.Net,代码行数:20,代码来源:AddExistingSearch.aspx.cs

示例12: SaveData

    /// <summary>
    /// Updates the current Group or creates new if no GroupID is present.
    /// </summary>
    public void SaveData()
    {
        if (!CheckPermissions("cms.groups", PERMISSION_MANAGE, GroupID))
        {
            return;
        }

        // Trim display name and code name
        string displayName = txtDisplayName.Text.Trim();
        string codeName = txtCodeName.Text.Trim();

        // Validate form entries
        string errorMessage = ValidateForm(displayName, codeName);
        if (errorMessage == "")
        {
            GroupInfo group = null;

            try
            {
                bool newGroup = false;

                // Update existing item
                if ((GroupID > 0) && (gi != null))
                {
                    group = gi;
                }
                else
                {
                    group = new GroupInfo();
                    newGroup = true;
                }

                if (group != null)
                {
                    if (displayName != group.GroupDisplayName)
                    {
                        // Refresh a breadcrumb if used in the tabs layout
                        ScriptHelper.RefreshTabHeader(Page, displayName);
                    }

                    if (DisplayAdvanceOptions)
                    {
                        // Update Group fields
                        group.GroupDisplayName = displayName;
                        group.GroupName = codeName;
                        group.GroupNodeGUID = ValidationHelper.GetGuid(groupPageURLElem.Value, Guid.Empty);
                    }

                    if (AllowChangeGroupDisplayName && IsLiveSite)
                    {
                        group.GroupDisplayName = displayName;
                    }

                    group.GroupDescription = txtDescription.Text;
                    group.GroupAccess = GetGroupAccess();
                    group.GroupSiteID = SiteID;
                    group.GroupApproveMembers = GetGroupApproveMembers();
                    group.GroupSendJoinLeaveNotification = chkJoinLeave.Checked;
                    group.GroupSendWaitingForApprovalNotification = chkWaitingForApproval.Checked;
                    groupPictureEdit.UpdateGroupPicture(group);

                    // If new group was created
                    if (newGroup)
                    {
                        // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user
                        var user = MembershipContext.AuthenticatedUser;
                        if (user != null)
                        {
                            group.GroupCreatedByUserID = user.UserID;
                            group.GroupApprovedByUserID = user.UserID;
                            group.GroupApproved = true;
                        }
                    }

                    if (!IsLiveSite && (group.GroupNodeGUID == Guid.Empty))
                    {
                        plcStyleSheetSelector.Visible = false;
                    }

                    // Save theme
                    int selectedSheetID = ValidationHelper.GetInteger(ctrlSiteSelectStyleSheet.Value, 0);
                    if (plcStyleSheetSelector.Visible)
                    {
                        if (group.GroupNodeGUID != Guid.Empty)
                        {
                            // Save theme for every site culture
                            var cultures = CultureSiteInfoProvider.GetSiteCultureCodes(SiteContext.CurrentSiteName);
                            if (cultures != null)
                            {
                                TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);

                                // Return class name of selected tree node
                                TreeNode treeNode = tree.SelectSingleNode(group.GroupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName);
                                if (treeNode != null)
                                {
                                    // Return all culture version of node
                                    DataSet ds = tree.SelectNodes(SiteContext.CurrentSiteName, null, TreeProvider.ALL_CULTURES, false, treeNode.NodeClassName, "NodeGUID ='" + group.GroupNodeGUID + "'", String.Empty, -1, false);
//.........这里部分代码省略.........
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:101,代码来源:GroupEdit.ascx.cs

示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string nodeIdsString = QueryHelper.GetString("sourcenodeids", string.Empty);

        // Load node IDs to session for the first time
        if (!URLHelper.IsPostback() && !String.IsNullOrEmpty(nodeIdsString))
        {
            StringBuilder aliasPaths = new StringBuilder();
            TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
            DataSet ds = tree.SelectNodes(SiteContext.CurrentSiteName, TreeProvider.ALL_DOCUMENTS, TreeProvider.ALL_CULTURES, true, null, String.Format("NodeID IN ({0})", nodeIdsString.Trim('|').Replace("|", ",")), null, TreeProvider.ALL_LEVELS, false, 0, DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",NodeParentID, DocumentName, NodeAliasPath, NodeLinkedNodeID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                const string lineBreak = "<br />";

                // Create list of paths
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    aliasPaths.Append(ValidationHelper.GetString(dr["NodeAliasPath"], string.Empty));
                    if (ValidationHelper.GetInteger(dr["NodeLinkedNodeID"], 0) != 0)
                    {
                        aliasPaths.Append(DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link));
                    }
                    aliasPaths.Append(lineBreak);
                }

                // Trim last line break
                if (aliasPaths.Length > lineBreak.Length)
                {
                    aliasPaths = aliasPaths.Remove(aliasPaths.Length - lineBreak.Length, lineBreak.Length);
                }
            }

            SessionHelper.SetValue("CopyMoveDocAliasPaths", aliasPaths.ToString());
            SessionHelper.Remove("CopyMoveDocCopyPermissions");
        }
    }
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:36,代码来源:DocCopyMoveProperties.ascx.cs

示例14: Delete

    /// <summary>
    /// Deletes document(s).
    /// </summary>
    private void Delete(object parameter)
    {
        if (parameter == null || nodeIds.Count < 1)
        {
            return;
        }

        if (!LicenseHelper.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Blogs, ObjectActionEnum.Edit))
        {
            AddError(ResHelper.GetString("cmsdesk.blogdeletelicenselimitations", currentCulture));
            return;
        }

        if (!LicenseHelper.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Documents, ObjectActionEnum.Edit))
        {
            AddError(ResHelper.GetString("cmsdesk.documentdeletelicenselimitations", currentCulture));
            return;
        }
        int refreshId = 0;

        TreeProvider tree = new TreeProvider(currentUser);
        tree.AllowAsyncActions = false;

        string[] parameters = ((string)parameter).Split(';');

        bool allLevelsSelected = ValidationHelper.GetBoolean(parameters[3], false);

        try
        {
            string siteName = parameters[1];
            bool isMultipleDelete = ValidationHelper.GetBoolean(parameters[2], false);

            // Prepare the where condition
            string where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true);
            string columns = SqlHelper.MergeColumns(DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS, "NodeAliasPath, ClassName, DocumentCulture, NodeParentID");

            bool combineWithDefaultCulture = false;
            string cultureCode = parameters[0];

            switch (parameters[4])
            {
                // Standard page deletion
                case "documentoptions":
                    combineWithDefaultCulture = chkAllCultures.Checked;
                    cultureCode = combineWithDefaultCulture ? TreeProvider.ALL_CULTURES : parameters[0];
                    break;

                // Root page deletion
                case "rootoptions":
                    cultureCode = rblRoot.SelectedValue == "allpages" ? TreeProvider.ALL_CULTURES : parameters[0];
                    where = rblRoot.SelectedValue == "allculturepages" ? String.Empty : where;
                    break;
            }

            // Begin log
            AddLog(ResHelper.GetString("ContentDelete.DeletingDocuments", currentCulture));

            string orderBy = "NodeAliasPath DESC";
            if (cultureCode == TreeProvider.ALL_CULTURES)
            {
                // Default culture has to be selected on last position
                string defaultCulture = CultureHelper.GetDefaultCultureCode(siteName);
                orderBy += ", CASE WHEN DocumentCulture = '" + SqlHelper.EscapeQuotes(defaultCulture) + "' THEN 1 ELSE 0 END";
            }

            // Get the documents
            DataSet ds = tree.SelectNodes(siteName, "/%", cultureCode, combineWithDefaultCulture, null, where, orderBy, TreeProvider.ALL_LEVELS, false, 0, columns);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                string altPath = Convert.ToString(selAltPath.Value);
                TreeNode altNode = null;
                if (chkUseDeletedPath.Checked && !String.IsNullOrEmpty(altPath))
                {
                    NodeSelectionParameters nsp = new NodeSelectionParameters();
                    nsp.AliasPath = altPath;
                    nsp.CultureCode = TreeProvider.ALL_CULTURES;
                    nsp.ClassNames = TreeProvider.ALL_CLASSNAMES;
                    nsp.CombineWithDefaultCulture = true;
                    nsp.SiteName = siteName;
                    nsp.MaxRelativeLevel = TreeProvider.ALL_LEVELS;
                    nsp.TopN = 1;

                    altNode = DocumentHelper.GetDocument(nsp, tree);

                    // Check whether user is authorized to use alternating document
                    if (altNode != null)
                    {
                        if (currentUser.IsAuthorizedPerDocument(altNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
                        {
                            throw new Exception(GetString("contentdelete.notallowedalternating"));
                        }
                    }
                    else
                    {
                        // Do not allow to delete a page with specified redirection URL which is not valid
                        throw new Exception(GetString("contentdelete.redirectionurlisnotvalid"));
                    }
//.........这里部分代码省略.........
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:101,代码来源:Delete.aspx.cs

示例15: SaveSites

    protected void SaveSites()
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usSites.Value, null);
        string items = DataHelper.GetNewItemsInList(newValues, currentValues);
        bool somethingChanged = false;
        bool hasErrors = false;

        if (!string.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId);
                    CultureInfo ci = CultureInfoProvider.GetCultureInfo(culture.CultureID);
                    if ((si != null) && (ci != null))
                    {
                        // Check if site does not contain document from this culture
                        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
                        DataSet nodes = tree.SelectNodes(si.SiteName, "/%", ci.CultureCode, false, null, null, null, -1, false, 1, "NodeID");
                        if (DataHelper.DataSourceIsEmpty(nodes))
                        {
                            CultureInfoProvider.RemoveCultureFromSite(culture.CultureID, siteId);
                            somethingChanged = true;
                        }
                        else
                        {
                            hasErrors = true;
                            ShowError(string.Format(GetString("Culture_Edit_Sites.ErrorRemoveSiteFromCulture"), si.DisplayName));
                            continue;
                        }
                    }
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!string.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    // Add cullture to site
                    SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId);
                    if (si != null)
                    {
                        if (CultureInfoProvider.LicenseVersionCheck(si.DomainName, FeatureEnum.Multilingual, VersionActionEnum.Insert))
                        {
                            CultureInfoProvider.AddCultureToSite(culture.CultureID, siteId);
                            somethingChanged = true;
                        }
                        else
                        {
                            hasErrors = true;
                            ShowError(GetString("licenselimitation.siteculturesexceeded"));
                            break;
                        }
                    }
                }
            }
        }

        // If there were some errors, reload uniselector
        if (hasErrors)
        {
            usSites.Value = GetCultureSites();
            usSites.Reload(true);
        }

        if (somethingChanged)
        {
            ShowInformation(GetString("General.ChangesSaved"));
        }
    }
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:85,代码来源:Culture_Edit_Sites.aspx.cs


注:本文中的TreeProvider.SelectNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。