Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="srcXml">The SRC XML.</param>
        /// <returns></returns>
        public static MappingDocument LoadFromXml(string srcXml)
        {
            MappingDocument retVal = (MappingDocument)
                                     McXmlSerializer.GetObject <MappingDocument>(srcXml);

            return(retVal);
        }
Exemplo n.º 3
0
        public override void DataBind()
        {
            object bindObject = DataBinder.GetDataItem(this.Parent);
            string retVal     = "";

            if (bindObject != null && bindObject is MetaObject)
            {
                string argumentType = ((MetaObject)bindObject).Properties["ArgumentType"].Value.ToString();
                string argumentData = ((MetaObject)bindObject).Properties["ArgumentData"].Value.ToString();

                Type   objType = Mediachase.Ibn.Data.AssemblyUtil.LoadType(argumentType);
                object obj     = McXmlSerializer.GetObject(objType, argumentData);
                if (obj != null)
                {
                    PropertyInfo pinfo = objType.GetProperty("CurrentState");
                    if (pinfo != null)
                    {
                        object curState = pinfo.GetValue(obj, null);
                        if (curState is State)
                        {
                            retVal = String.Format("<b>{0}:</b>&nbsp;{1}",
                                                   CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_State}"),
                                                   CHelper.GetResFileString(StateMachineManager.GetState("TimeTrackingBlock", ((State)curState).Name).Properties["FriendlyName"].Value.ToString()));
                        }
                    }
                }
                if (String.IsNullOrEmpty(retVal))
                {
                    retVal = CHelper.GetEventResourceString((MetaObject)bindObject);
                }

                lblStateValue.Text = retVal;
            }
            base.DataBind();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets the value.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        public static void SetValue(EntityObject entity, string key, object value)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (!entity.Properties.Contains(WorkflowInstanceEntity.FieldXSParameters))
            {
                throw new ArgumentException("Couldn't find XSParameters property", "entity");
            }

            AttributeCollection attr = McXmlSerializer.GetObject <AttributeCollection>((string)entity[WorkflowInstanceEntity.FieldXSParameters]);

            if (attr == null)
            {
                attr = new AttributeCollection();
            }

            attr.Set(key, value);

            entity[WorkflowInstanceEntity.FieldXSParameters] = McXmlSerializer.GetString <AttributeCollection>(attr);
        }
        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));
        }
Exemplo n.º 6
0
        public static DynamicCategoryInfo[] Load()
        {
            List <DynamicCategoryInfo> list = new List <DynamicCategoryInfo>();

            //string structureVirtualPath
            //string structurePath = HostingEnvironment.MapPath(structureVirtualPath);
            FileDescriptor[] files = FileResolver.GetFiles(ControlsDir + Path.DirectorySeparatorChar + ConfigDir, "*.xml");
            foreach (FileDescriptor file in files)
            {
                string controlDir = Path.GetDirectoryName(file.FilePath);

                if (!string.IsNullOrEmpty(controlDir))
                {
                    string configsDir           = Path.DirectorySeparatorChar + ConfigDir;
                    string tempControlDirString = controlDir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)) ? controlDir.Substring(0, controlDir.Length - 1) : controlDir;
                    if (controlDir.EndsWith(configsDir, StringComparison.OrdinalIgnoreCase))
                    {
                        controlDir = controlDir.Substring(0, controlDir.LastIndexOf(configsDir));
                    }
                }

                XmlDocument doc = new XmlDocument();
                doc.Load(file.FilePath);

                foreach (XmlNode node in doc.DocumentElement.SelectNodes("DynamicCategoryInfo"))
                {
                    DynamicCategoryInfo dci = McXmlSerializer.GetObject <DynamicCategoryInfo>(node.OuterXml);                    //McXmlSerializer.GetObjectFromFile<DynamicCategoryInfo>(file.FilePath);

                    if (string.IsNullOrEmpty(dci.Uid) || list.Contains(dci))
                    {
                        throw new ArgumentNullException("DynamicCategoryInfo must have unique <Uid>");
                    }

                    list.Add(dci);
                }

                list.Sort(DynamicCategoryInfoComparasion);
            }

            return(list.ToArray());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the event resource string.
        /// </summary>
        /// <param name="eventObject">The event object.</param>
        /// <returns></returns>
        public static string GetEventResourceString(MetaObject eventObject)
        {
            string retVal = GetResFileString(eventObject.Properties["EventTitle"].Value.ToString());
            //{event:...}
            MatchCollection coll = Regex.Matches(retVal, "{event:(?<EventProp>[^}]*)}");

            foreach (Match match in coll)
            {
                string sArg = match.Groups["EventProp"].Value;
                retVal = retVal.Replace(match.ToString(), GetResFileString(eventObject.Properties[sArg].Value.ToString()));
            }
            //{args:...}
            if (eventObject.Properties["ArgumentType"].Value != null &&
                eventObject.Properties["ArgumentData"].Value != null)
            {
                string          argumentType = eventObject.Properties["ArgumentType"].Value.ToString();
                string          argumentData = eventObject.Properties["ArgumentData"].Value.ToString();
                MatchCollection argscoll     = Regex.Matches(retVal, "{args:(?<EventArg>[^}]*)}");
                if (argscoll.Count > 0)
                {
                    Type   objType = Mediachase.Ibn.Data.AssemblyUtil.LoadType(argumentType);
                    object obj     = McXmlSerializer.GetObject(objType, argumentData);
                    if (obj != null)
                    {
                        foreach (Match match in argscoll)
                        {
                            string       p_name = match.Groups["EventArg"].Value;
                            PropertyInfo pinfo  = objType.GetProperty(p_name);
                            if (pinfo != null)
                            {
                                string sTemp = pinfo.GetValue(obj, null).ToString();

                                retVal = retVal.Replace(match.ToString(), GetResFileString(sTemp));
                            }
                        }
                    }
                }
            }
            return(retVal);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public static object GetValue(EntityObject entity, string key)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (entity.Properties.Contains(WorkflowInstanceEntity.FieldXSParameters))
            {
                AttributeCollection attr = McXmlSerializer.GetObject <AttributeCollection>((string)entity[WorkflowInstanceEntity.FieldXSParameters]);

                if (attr != null)
                {
                    return(attr.GetValue(key));
                }
            }

            return(AssignmentOverdueAction.NoAction);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Starts the workflow.
        /// </summary>
        /// <param name="worflowDef">The worflow def.</param>
        /// <returns></returns>
        public static Guid StartWorkflow(WorkflowDefinitionEntity worflowDef)
        {
            WorkflowSchema schema = McXmlSerializer.GetObject <WorkflowSchema>(worflowDef.Xaml);

            return(schema.InstanceId);
        }