コード例 #1
0
        /// <summary>
        /// Saves the value.
        /// </summary>
        /// <param name="cUid">The c uid.</param>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        public override void SaveValue(string cUid, string key, object value)
        {
            string uid = GetKey(cUid, key);

            if (value == null)
            {
                Security.CurrentUser.Properties[uid] = null;
            }
            else if (value is string && string.Empty == ((string)value))
            {
                Security.CurrentUser.Properties[uid] = string.Empty;
            }
            else
            {
                // Step 1. Object to XmlSerializedItem
                string typeName = null;

                if (value.GetType().IsGenericType)
                    typeName = AssemblyUtil.GetTypeString(value.GetType().FullName, value.GetType().Assembly.GetName().Name);
                else
                    typeName = AssemblyUtil.GetTypeString(value.GetType().ToString(), value.GetType().Assembly.GetName().Name);

                XmlSerializedItem item = new XmlSerializedItem(typeName, McXmlSerializer.GetString(value.GetType(), value));

                // Step 2. XmlSerializedItem to string
                Security.CurrentUser.Properties[uid] = McXmlSerializer.GetString<XmlSerializedItem>(item);
            }
        }
コード例 #2
0
        /// <summary>
        /// Saves the value.
        /// </summary>
        /// <param name="cUid">The c uid.</param>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        public override void SaveValue(string cUid, string key, object value)
        {
            string uid = GetKey(cUid, key);

            if (value == null)
            {
                Security.CurrentUser.Properties[uid] = null;
            }
            else if (value is string && string.Empty == ((string)value))
            {
                Security.CurrentUser.Properties[uid] = string.Empty;
            }
            else
            {
                // Step 1. Object to XmlSerializedItem
                string typeName = null;

                if (value.GetType().IsGenericType)
                {
                    typeName = AssemblyUtil.GetTypeString(value.GetType().FullName, value.GetType().Assembly.GetName().Name);
                }
                else
                {
                    typeName = AssemblyUtil.GetTypeString(value.GetType().ToString(), value.GetType().Assembly.GetName().Name);
                }

                XmlSerializedItem item = new XmlSerializedItem(typeName, McXmlSerializer.GetString(value.GetType(), value));

                // Step 2. XmlSerializedItem to string
                Security.CurrentUser.Properties[uid] = McXmlSerializer.GetString <XmlSerializedItem>(item);
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <param name="cUid">The c uid.</param>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public override object GetValue(string cUid, string key)
        {
            string uid = GetKey(cUid, key);

            UserLightPropertyCollection pc = Security.CurrentUser.Properties;

            string value = pc[uid];

            if (string.IsNullOrEmpty(value))
            {
                //dvs: load default setting for all users if available
                value = PortalConfig.GetValue(uid);

                if (string.IsNullOrEmpty(value))
                {
                    return(value);
                }
            }

            // Step 1. String to XmlSerializedItem
            XmlSerializedItem item = McXmlSerializer.GetObject <XmlSerializedItem>(value);

            // Step 2. XmlSerializedItem to object
            return(McXmlSerializer.GetObject(item.Type, item.Data));
        }
コード例 #4
0
        public override object GetValue(string cUid, string key)
        {
            string           uid = GetKey(cUid, key);
            CustomPageEntity cpe = Mediachase.IBN.Business.WidgetEngine.CustomPageManager.GetCustomPage(pageUid, profileId, userId);

            if (cpe == null)
            {
                throw new ArgumentException(string.Format("Page not found for pageUid: {0} profileId: {1} userId: {2}", pageUid, profileId, userId));
            }

            XmlDocument doc = new XmlDocument();

            if (String.IsNullOrEmpty(cpe.PropertyJsonData))
            {
                doc.AppendChild(doc.CreateElement("ControlProperties"));
                cpe.PropertyJsonData = doc.OuterXml;
            }
            else
            {
                doc.LoadXml(cpe.PropertyJsonData);
            }

            string value = string.Empty;

            XmlNode valNode = doc.DocumentElement.SelectSingleNode(string.Format("{0}/{1}", cUid, key));

            if (valNode != null)
            {
                value = valNode.InnerText;
            }
            //else
            //{
            //    value = PortalConfig.GetValue(uid);
            //}

            if (String.IsNullOrEmpty(value))
            {
                return(null);
            }

            // Step 1. String to XmlSerializedItem
            value = value.Trim();
            XmlSerializedItem item = McXmlSerializer.GetObject <XmlSerializedItem>(value);

            // Step 2. XmlSerializedItem to object
            return(McXmlSerializer.GetObject(item.Type, item.Data));
        }
コード例 #5
0
        public override void SaveValue(string cUid, string key, object value)
        {
            string uid = GetKey(cUid, key);

            CustomPageEntity cpe = Mediachase.IBN.Business.WidgetEngine.CustomPageManager.GetCustomPage(pageUid, profileId, userId);

            if (cpe == null)
            {
                throw new ArgumentException(string.Format("Page not found for pageUid: {0} profileId: {1} userId: {2}", pageUid, profileId, userId));
            }

            XmlDocument doc = new XmlDocument();

            if (String.IsNullOrEmpty(cpe.PropertyJsonData))
            {
                doc.AppendChild(doc.CreateElement("ControlProperties"));
                cpe.PropertyJsonData = doc.OuterXml;
            }
            else
            {
                doc.LoadXml(cpe.PropertyJsonData);
            }

            XmlNode controlNode = doc.DocumentElement.SelectSingleNode(cUid);

            if (controlNode == null)
            {
                controlNode = doc.CreateElement(cUid);
                doc.DocumentElement.AppendChild(controlNode);
            }

            XmlNode keyNode = controlNode.SelectSingleNode(key);

            if (keyNode == null)
            {
                keyNode = doc.CreateElement(key);
                controlNode.AppendChild(keyNode);
            }

            if (value == null)
            {
                keyNode.InnerText = ControlProperties._nullValueKey;
            }
            else if (value is string && string.Empty == ((string)value))
            {
                keyNode.InnerText = string.Empty;
            }
            else
            {
                // Step 1. Object to XmlSerializedItem
                string typeName = null;

                if (value.GetType().IsGenericType)
                {
                    typeName = AssemblyUtil.GetTypeString(value.GetType().FullName, value.GetType().Assembly.GetName().Name);
                }
                else
                {
                    typeName = AssemblyUtil.GetTypeString(value.GetType().ToString(), value.GetType().Assembly.GetName().Name);
                }

                XmlSerializedItem item = new XmlSerializedItem(typeName, McXmlSerializer.GetString(value.GetType(), value));

                // Step 2. XmlSerializedItem to string
                keyNode.InnerText = McXmlSerializer.GetString <XmlSerializedItem>(item);
            }

            //todo: to debug
            Mediachase.IBN.Business.WidgetEngine.CustomPageManager.UpdateCustomPageProperty(pageUid, doc.OuterXml, profileId, userId);
        }