Beispiel #1
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);
                        }
                    }
                }
            }
    }