Exemplo n.º 1
0
    public string Handler_RemoveItems()
    {
        StringBuilder sbRet = new StringBuilder();
            ContentAPI apiContent = new ContentAPI();
            string sItemList = "";
            int iRet = 0;
            string sKey = "";
            long iNode = 0;
            try
            {
                sItemList = Request.QueryString["itemlist"];
                sKey = EkFunctions.HtmlEncode(Request.QueryString["key"]);

                try
                {
                    string[] aValues;
                    aValues = sItemList.Split(',');
                    if ((aValues != null)&& aValues.Length > 0)
                    {
                        for (int i = 0; i <= (aValues.Length - 1); i++)
                        {
                            if (aValues[i].ToLower().IndexOf(sKey + "_i") == 0)
                            {
                                TaxonomyRequest tReq = new TaxonomyRequest();
                                string[] aVal = (aValues[i]).Split('_');
                                int iType = 0;

                                iNode = long.Parse(Request.QueryString["node"]);
                                tReq.TaxonomyIdList = aVal[1].Substring(1);
                                iType = int.Parse(aVal[2]);
                                switch (iType)
                                {
                                    case 7:
                                        break;

                                    default: // 1 - content
                                        tReq.TaxonomyItemType = (EkEnumeration.TaxonomyItemType)(Ektron.Cms.Common.EkEnumeration.CMSObjectTypes.Content);
                                        break;
                                }
                                tReq.TaxonomyId = iNode;
                                tReq.TaxonomyLanguage = apiContent.ContentLanguage;
                                apiContent.RemoveTaxonomyItem(tReq);
                            }
                            else if (aValues[i].ToLower().IndexOf(sKey + "_f") == 0)
                            {
                                TaxonomyRequest tReq = new TaxonomyRequest();
                                iNode = int.Parse(aValues[i].Substring(((sKey + "_f").Length) + 1 - 1));
                                tReq.TaxonomyId = iNode;
                                tReq.TaxonomyLanguage = apiContent.ContentLanguage;
                                if (iNode > 0)
                                {
                                    apiContent.DeleteTaxonomy(tReq);
                                }
                            }
                        }
                    }
                    iRet = 0;
                }
                catch (Exception ex)
                {
                    EkException.ThrowException(ex);
                }
                sbRet.Append("  <method>RemoveItems</method>").Append(Environment.NewLine);
                sbRet.Append("  <result>").Append(iRet).Append("</result>").Append(Environment.NewLine);
                sbRet.Append("  <key>").Append(sKey).Append("</key>").Append(Environment.NewLine);
                return sbRet.ToString();
            }
            catch (Exception)
            {

            }
            return sbRet.ToString();
    }