Esempio n. 1
0
    private void UpdateCustomProperties()
    {
        int i = 0;
        Ektron.Cms.Framework.Core.CustomProperty.CustomProperty cp = new Ektron.Cms.Framework.Core.CustomProperty.CustomProperty();
        Ektron.Cms.Framework.Core.CustomProperty.CustomPropertyObject cpo = new Ektron.Cms.Framework.Core.CustomProperty.CustomPropertyObject();
        System.Collections.Generic.List<Ektron.Cms.Common.CustomPropertyObjectData> listData;
        string[] selectedIds = null;
        string[] selectedValues = null;

        PagingInfo pageInfo = new PagingInfo();
        pageInfo.CurrentPage = 1;
        pageInfo.RecordsPerPage = 99999;

        listData = cpo.GetList(TaxonomyId, m_refApi.ContentLanguage, EkEnumeration.CustomPropertyObjectType.TaxonomyNode, pageInfo);
        if (Request.Form[hdnSelectedIDS.UniqueID] != "")
        {
            selectedIds = Request.Form[hdnSelectedIDS.UniqueID].Remove(System.Convert.ToInt32(Request.Form[hdnSelectedIDS.UniqueID].Length - 1), 1).Split(";".ToCharArray());
        }
        if (Request.Form[hdnSelectValue.UniqueID] != "")
        {
            selectedValues = Request.Form[hdnSelectValue.UniqueID].Remove(System.Convert.ToInt32(Request.Form[hdnSelectValue.UniqueID].Length - 1), 1).Split(";".ToCharArray());
        }
        _customPropertyDataList = _customProperty.GetList(Ektron.Cms.Common.EkEnumeration.CustomPropertyObjectType.TaxonomyNode, m_refApi.ContentLanguage, pageInfo);
        for (i = 0; i <= listData.Count - 1; i++)
        {
            cpo.Delete(TaxonomyId, m_refApi.ContentLanguage, EkEnumeration.CustomPropertyObjectType.TaxonomyNode, listData[i].PropertyId);
        }
        if ((selectedIds != null) || (selectedValues != null))
        {
            for (i = 0; i <= selectedIds.Length - 1; i++)
            {
                //var customPropertyData = cp.GetItem(selectedIds[i], m_refApi.ContentLanguage);
                //CustomPropertyObjectData data = new CustomPropertyObjectData(TaxonomyId, m_refApi.ContentLanguage, selectedIds[i], EkEnumeration.CustomPropertyObjectType.TaxonomyNode);
                Ektron.Cms.Common.CustomPropertyData customPropertyData = cp.GetItem(Convert.ToInt64(selectedIds[i].ToString()), m_refApi.ContentLanguage);
                CustomPropertyObjectData data = new CustomPropertyObjectData(TaxonomyId, m_refApi.ContentLanguage, Convert.ToInt64(selectedIds[i].ToString()), EkEnumeration.CustomPropertyObjectType.TaxonomyNode);
                if ((customPropertyData != null) && (data != null))
                {
                    string inputValue = HttpUtility.UrlDecode((string)(selectedValues[i].ToString()));
                    switch (customPropertyData.PropertyDataType)
                    {
                        case EkEnumeration.CustomPropertyItemDataType.Boolean:
                            bool booleanValue;
                            if (bool.TryParse(inputValue, out booleanValue))
                            {
                                data.AddItem(booleanValue);
                            }
                            break;

                        case EkEnumeration.CustomPropertyItemDataType.DateTime:
                            DateTime dateTimeValue;
                            if (DateTime.TryParse(inputValue, out dateTimeValue))
                            {
                                data.AddItem(dateTimeValue);
                            }
                            break;
                        default:
                            data.AddItem(inputValue);
                            break;
                    }
                    cpo.Add(data);
                }
            }
        }
    }
Esempio n. 2
0
    private void AddCustomProperties()
    {
        int i = 0;
            CustomProperty cp = new CustomProperty();
            CustomPropertyObject cpo = new CustomPropertyObject();
            string[] selectedIds = null;
            string[] selectedValues = null;

            if (Request.Form[hdnSelectedIDS.UniqueID] != "")
            {
                selectedIds = Request.Form[hdnSelectedIDS.UniqueID].Remove(System.Convert.ToInt32(Request.Form[hdnSelectedIDS.UniqueID].Length - 1), 1).Split(";".ToCharArray());
            }
            if (Request.Form[hdnSelectValue.UniqueID] != "")
            {
                selectedValues = Request.Form[hdnSelectValue.UniqueID].Remove(System.Convert.ToInt32(Request.Form[hdnSelectValue.UniqueID].Length - 1), 1).Split(";".ToCharArray());
            }

            if ((selectedIds != null)&& (selectedValues != null))
            {
                if (selectedIds.Length == selectedValues.Length)
                {
                    for (i = 0; i <= selectedIds.Length - 1; i++)
                    {
                        CustomPropertyData  customPropertyData = cp.GetItem(Convert.ToInt64 (selectedIds[i]), m_refApi.ContentLanguage);
                        CustomPropertyObjectData data = new CustomPropertyObjectData(TaxonomyId, m_refApi.ContentLanguage,Convert.ToInt64 ( selectedIds[i]), EkEnumeration.CustomPropertyObjectType.TaxonomyNode);

                        if ((customPropertyData != null) && (data != null))
                        {

                            string inputValue = HttpUtility.UrlDecode((string) (selectedValues[i].ToString()));

                            switch (customPropertyData.PropertyDataType)
                            {
                                case EkEnumeration.CustomPropertyItemDataType.Boolean:
                                    bool booleanValue;
                                    if (bool.TryParse(inputValue, out booleanValue))
                                    {
                                        data.AddItem(booleanValue);
                                    }
                                    break;

                                case EkEnumeration.CustomPropertyItemDataType.DateTime:
                                    DateTime dateTimeValue;
                                    if (DateTime.TryParse(inputValue, out dateTimeValue))
                                    {
                                        data.AddItem(dateTimeValue);
                                    }
                                    break;
                                default:
                                    data.AddItem(inputValue);
                                    break;
                            }
                            cpo.Add(data);
                        }
                    }
                }
            }
    }