예제 #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>
        /// 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);
        }
예제 #3
0
 internal static void CreateFix()
 {
     foreach (EntityObject obj in BusinessManager.List(CustomPageEntity.ClassName, new FilterElement[] {}))
     {
         string xml = McXmlSerializer.GetString <EntityObject>(obj);
     }
 }
예제 #4
0
        static void Test()
        {
            SchemaMaster master = new SchemaMaster();

            master.TypeName                     = AssemblyUtil.GetTypeString(typeof(SequentialWorkflowInstanceFactory));
            master.InstanceFactory              = new SequentialWorkflowInstanceFactory();
            master.Description.Id               = Guid.NewGuid();
            master.Description.Name             = "Agreement";
            master.Description.Creator          = "Mediachase";
            master.Description.Icon             = string.Empty;
            master.Description.Comment          = string.Empty;
            master.Description.UI.CreateControl = string.Empty;
            master.Description.UI.EditControl   = string.Empty;
            master.Description.UI.ViewControl   = string.Empty;

            ActivityMaster create = new ActivityMaster();

            create.TypeName = AssemblyUtil.GetTypeString(typeof(CreateAssignmentAndWaitResultActivityInstanceFactory));
            CreateAssignmentAndWaitResultActivityInstanceFactory ifact = new CreateAssignmentAndWaitResultActivityInstanceFactory();

            ifact.AssignmentProperties = new PropertyValueCollection();
            ifact.AssignmentProperties.Add(new PropertyValue("Subject", "Test Subject"));
            ifact.AssignmentProperties.Add(new PropertyValue("UserId", 12));

            create.InstanceFactory = ifact;

            create.Description.Name             = "AgreeWith";
            create.Description.Icon             = string.Empty;
            create.Description.Comment          = string.Empty;
            create.Description.UI.CreateControl = string.Empty;
            create.Description.UI.EditControl   = string.Empty;
            create.Description.UI.ViewControl   = string.Empty;


            ActivityMaster block = new ActivityMaster();

            block.TypeName                     = AssemblyUtil.GetTypeString(typeof(BlockActivityInstanceFactory));
            block.InstanceFactory              = new BlockActivityInstanceFactory();
            block.Description.Name             = "AgreementBlock";
            block.Description.Icon             = string.Empty;
            block.Description.Comment          = string.Empty;
            block.Description.UI.CreateControl = string.Empty;
            block.Description.UI.EditControl   = string.Empty;
            block.Description.UI.ViewControl   = string.Empty;

            master.Description.Activities.Add(create);
            master.Description.Activities.Add(block);

            master.Description.SupportedIbnObjectTypes.Add(16);

            string xml = McXmlSerializer.GetString <SchemaMaster>(master, typeof(SequentialWorkflowInstanceFactory),
                                                                  typeof(CreateAssignmentAndWaitResultActivityInstanceFactory),
                                                                  typeof(BlockActivityInstanceFactory));
        }
        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);
        }
예제 #6
0
        /// <summary>
        /// Saves to XML.
        /// </summary>
        /// <param name="mapDoc">The map doc.</param>
        /// <returns></returns>
        public static string GetXml(MappingDocument mapDoc)
        {
            String retVal = McXmlSerializer.GetString <MappingDocument>(mapDoc);

            return(retVal);
        }