internal static void CreateFix() { foreach (EntityObject obj in BusinessManager.List(CustomPageEntity.ClassName, new FilterElement[] {})) { string xml = McXmlSerializer.GetString <EntityObject>(obj); } }
/// <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); } }
/// <summary> /// Loads all controls from given directory and its subdirectories. /// </summary> /// <param name="structureVirtualPath">The structure virtual path.</param> /// <returns></returns> public static WorkspaceTemplateInfo[] Load(string structureVirtualPath) { List <WorkspaceTemplateInfo> list = new List <WorkspaceTemplateInfo>(); string structurePath = HostingEnvironment.MapPath(structureVirtualPath); IList <Mediachase.Ibn.Web.UI.WebControls.FileResolverItem> files = Mediachase.Ibn.Web.UI.WebControls.FileResolver.GetFilesSingleSelector(structurePath, ControlsDir + Path.DirectorySeparatorChar + "Configs", "*.xml", new string[] { }); foreach (Mediachase.Ibn.Web.UI.WebControls.FileResolverItem 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, true, CultureInfo.InvariantCulture)) { controlDir = controlDir.Substring(0, controlDir.LastIndexOf(configsDir)); } } WorkspaceTemplateInfo wti = McXmlSerializer.GetObjectFromFile <WorkspaceTemplateInfo>(file.FilePath); if (string.IsNullOrEmpty(wti.Uid)) { wti.Uid = Path.GetFileNameWithoutExtension(file.FilePath); } //wti.Path = wti.Path; //MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.Path); list.Add(wti); } return(list.ToArray()); }
/// <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)); }
/// <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); }
/// <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 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> {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(); }
static void UpdateMetaModel(string commandsFilePath) { LogFile.WriteLine("Updating metamodel..."); SchemaDocument schema = new SchemaDocument(); schema.Load(Path.Combine(Settings.InstallDir, @"Code\_Source\Tools\metamodelSchema.xml")); SyncCommand[] commands = McXmlSerializer.GetObjectFromFile <SyncCommand[]>(commandsFilePath); using (DataContext dataContext = new DataContext(string.Empty)) { DataContext.Current = dataContext; dataContext.SqlContext.CommandTimeout = CommandTimeout; SqlTransaction previousTransaction = DataContext.Current.SqlContext.Transaction; using (DBTransaction tran = DBHelper2.DBHelper.BeginTransaction()) { DataContext.Current.SqlContext.Transaction = tran.SqlTran; try { MetaModelSync.Execute(schema, commands); tran.Commit(); LogWriteOk(); } finally { DataContext.Current.SqlContext.Transaction = previousTransaction; } } } }
/// <summary> /// Loads from file. /// </summary> /// <param name="path">The path.</param> /// <returns></returns> public static MappingDocument LoadFromFile(String path) { MappingDocument retVal = (MappingDocument) McXmlSerializer.GetObjectFromFile <MappingDocument>(path); return(retVal); }
/// <summary> /// Loads all controls from given directory and its subdirectories. /// </summary> /// <returns></returns> public static WorkspaceTemplateInfo[] Load() { List <WorkspaceTemplateInfo> list = new List <WorkspaceTemplateInfo>(); FileDescriptor[] files = FileResolver.GetFiles(ControlsDir + Path.DirectorySeparatorChar + "Configs", "*.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, true, CultureInfo.InvariantCulture)) { controlDir = controlDir.Substring(0, controlDir.LastIndexOf(configsDir)); } } WorkspaceTemplateInfo wti = McXmlSerializer.GetObjectFromFile <WorkspaceTemplateInfo>(file.FilePath); if (string.IsNullOrEmpty(wti.Uid)) { wti.Uid = Path.GetFileNameWithoutExtension(file.FilePath); } list.Add(wti); } return(list.ToArray()); }
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)); }
/// <summary> /// Loads the entity objects. /// </summary> /// <param name="metaClassName">Name of the meta class.</param> /// <returns></returns> private static EntityObject[] LoadEntityObjects(string metaClassName) { if (metaClassName == null) { throw new ArgumentNullException("metaClassName"); } if (!entityObjectHash.ContainsKey(metaClassName)) { lock (typeof(LocalDiskEntityObjectPlugin)) { if (!entityObjectHash.ContainsKey(metaClassName)) { FileDescriptor[] files = FileResolver.GetFiles(EntityObjectsDirs + Path.DirectorySeparatorChar + metaClassName, "*.xml"); List <EntityObject> items = new List <EntityObject>(); // Load EntityObject From File foreach (FileDescriptor file in files) { PrimaryKeyId pk; if (PrimaryKeyId.TryParse(Path.GetFileNameWithoutExtension(file.FilePath), out pk)) { // Load EntityObject From File EntityObject tmpItem = McXmlSerializer.GetObjectFromFile <EntityObject>(file.FilePath); // Create TEntityObject EntityObject item = BusinessManager.InitializeEntity(metaClassName); // Copy Fields From tmpItem To item foreach (EntityObjectProperty property in tmpItem.Properties) { item[property.Name] = property.Value; } // item.PrimaryKeyId = pk; // Add Abstract Property item[IsLoadDiskEntityPropertyName] = true; items.Add(item); } } entityObjectHash[metaClassName] = items.ToArray(); } } } return(entityObjectHash[metaClassName]); }
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)); }
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()); }
private static SchemaMasterCollection LoadDefaultMasterts() { SchemaMasterCollection retVal = new SchemaMasterCollection(); //string path = HostingEnvironment.MapPath("~/Apps/BusinessProcess/Config/Schemas"); //if (Directory.Exists(path)) //{ // foreach (string filePath in Directory.GetFiles(path, "*.xml")) // { // SchemaMaster master = McXmlSerializer.GetObjectFromFile<SchemaMaster>(filePath, // typeof(SequentialWorkflowInstanceFactory), // typeof(CreateAssignmentAndWaitResultActivityInstanceFactory), // typeof(BlockActivityInstanceFactory)); // retVal.Add(master); // } //} // O.R. [2009-07-28]: Use subdirectories to find schemas string rootPath = HostingEnvironment.MapPath("~/Apps/BusinessProcess"); if (Directory.Exists(rootPath)) { foreach (string filePath in Directory.GetFiles(rootPath, "*.xml", SearchOption.AllDirectories)) { if (filePath.ToLowerInvariant().Contains("\\config\\schemas\\")) { SchemaMaster master = McXmlSerializer.GetObjectFromFile <SchemaMaster>(filePath, typeof(SequentialWorkflowInstanceFactory), typeof(CreateAssignmentAndWaitResultActivityInstanceFactory), typeof(BlockActivityInstanceFactory)); retVal.Add(master); } } } return(retVal); }
/// <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); }
/// <summary> /// Loads all controls from given directory and its subdirectories. /// </summary> /// <returns></returns> public static DynamicControlInfo[] Load() { List <DynamicControlInfo> list = new List <DynamicControlInfo>(); //string structureVirtualPath //string structurePath = HostingEnvironment.MapPath(structureVirtualPath); FileDescriptor[] files = FileResolver.GetFiles(ControlsDir + Path.DirectorySeparatorChar + "Configs", "*.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)); } } DynamicControlInfo dci = McXmlSerializer.GetObjectFromFile <DynamicControlInfo>(file.FilePath); if (string.IsNullOrEmpty(dci.Uid)) { dci.Uid = Path.GetFileNameWithoutExtension(file.FilePath); } dci.AdapterPath = MakeVirtualPath(controlDir, dci.AdapterPath); dci.IconPath = dci.IconPath; dci.Path = dci.Path; //MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.Path); dci.PropertyPagePath = dci.PropertyPagePath; //MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.PropertyPagePath); dci.LargeThumbnail = dci.LargeThumbnail; dci.SmallThumbnail = dci.SmallThumbnail; list.Add(dci); } return(list.ToArray()); }
/// <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); }
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); }
/// <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); }
/// <summary> /// Saves to file. /// </summary> /// <param name="path">The path.</param> /// <param name="mapDoc">The map doc.</param> public static void SaveToFile(String path, MappingDocument mapDoc) { McXmlSerializer.SaveObjectToFile <MappingDocument>(path, mapDoc); }
/// <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); }