/// <summary> /// Gets the <see cref="Vault" /> object from AML data. /// </summary> /// <param name="item">The AML item.</param> /// <returns>The <see cref="Vault" /> object from AML data.</returns> public Vault GetVault(IReadOnlyItem item) { if (item == null || !item.Exists) { return(null); } var vault = LinkedListOps.Find(_last, item.Id()); if (vault == null) { lock (_lock) { vault = LinkedListOps.Find(_last, item.Id()); if (vault == null) { vault = new Vault(item, _client); LinkedListOps.Add(ref _last, vault); } } } return(vault); }
public static Vault GetVault(IReadOnlyItem i) { if (i == null || !i.Exists) return null; Vault result; if (!_vaults.TryGetValue(i.Id(), out result)) { result = new Vault(i); _vaults[i.Id()] = result; } return result; }
private IPromise <IHttpResponse> DownloadFileFromVault(IReadOnlyItem fileItem, Vault vault, bool async, Command request) { var url = vault.Url; if (string.IsNullOrEmpty(url)) { return(null); } var urlPromise = url.IndexOf("$[") < 0 ? Promises.Resolved(url) : _conn.Process(new Command("<url>@0</url>", url) .WithAction(CommandAction.TransformVaultServerURL), async) .Convert(s => s.AsString()); return(urlPromise.Continue(u => { if (u != vault.Url) { vault.Url = u; } var uri = new Uri(string.Format("{0}?dbName={1}&fileId={2}&fileName={3}&vaultId={4}", u, _conn.Database, fileItem.Id(), Uri.EscapeDataString(fileItem.Property("filename").Value), vault.Id)); var req = new HttpRequest(); _conn.SetDefaultHeaders(req.SetHeader); req.SetHeader("VAULTID", vault.Id); foreach (var a in _conn.DefaultSettings) { a.Invoke(req); } request.Settings?.Invoke(req); var trace = new LogData(4 , "Innovator: Download file from vault" , request.LogListener ?? Factory.LogListener , request.Parameters) { { "aras_url", _conn.MapClientUrl("../../Server") }, { "database", _conn.Database }, { "file_id", fileItem.Id() }, { "filename", fileItem.Property("filename").Value }, { "query", request.Aml }, { "url", uri }, { "user_id", _conn.UserId }, { "vault_id", vault.Id }, { "version", _conn.Version } }; return vault.HttpClient.GetPromise(uri, async, trace, req).Always(trace.Dispose); })); }
public DelegateContext(IServerConnection conn, IReadOnlyItem item) : base(conn, item) { var aml = conn.AmlContext; _assignment = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("AssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("AssignmentId").Value) ); _delegate = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("ToAssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("ToAssignmentId").Value) ); }
public ItemType(IReadOnlyItem itemType, HashSet <string> coreIds = null) { Id = itemType.Id(); IsCore = itemType.Property("core").AsBoolean(coreIds?.Contains(itemType.Id()) == true); IsDependent = itemType.Property("is_dependent").AsBoolean(false); IsFederated = itemType.Property("implementation_type").Value == "federated"; IsPolymorphic = itemType.Property("implementation_type").Value == "polymorphic"; IsVersionable = itemType.Property("is_versionable").AsBoolean(false); Label = itemType.Property("label").Value; Name = itemType.Property("name").Value ?? itemType.KeyedName().Value ?? itemType.IdProp().KeyedName().Value; Reference = ItemReference.FromFullItem(itemType, true); Description = itemType.Property("description").Value; }
public StateLink(IReadOnlyItem item, Dictionary <string, StateNode> nodes) { Id = item.Id(); Label = item.Property("label").Value; Name = item.Property("name").Value ?? item.Property("role").KeyedName().Value; if (item.Property("segments").HasValue()) { Segments.AddRange(item.Property("segments").Value .Split('|') .Select(p => p.Split(',')) .Select(p => new Point(int.Parse(p[0]), int.Parse(p[1])))); } if (nodes.TryGetValue(item.Property("from_state").Value ?? item.SourceItem().Id() ?? "", out var sourceNode)) { Source = sourceNode; } if (nodes.TryGetValue(item.Property("to_state").Value ?? item.RelatedId().Value ?? "", out var relatedNode)) { Related = relatedNode; } IsDefault = item.Property("is_default").AsBoolean(false); IsOverride = item.Property("is_override").AsBoolean(false); }
public static async Task <ArasProperty> NewProp(IReadOnlyItem item, IAsyncConnection conn) { var prop = NewProp(item.Id()); await prop.Initialize(item, conn); return(prop); }
public MapElement(IReadOnlyItem item) { Type = item.TypeName(); Id = item.Id(); IsRelative = item.Property("segments").Exists; Position = new Point() { X = item.Property("x").AsInt(0), Y = item.Property("y").AsInt(0) }; if (item.Property("segments").HasValue()) { Segments = item.Property("segments").Value .Split('|') .Select(p => p.Split(',')) .Select(p => new Point() { X = int.Parse(p[0]), Y = int.Parse(p[1]) }) .ToArray(); } else { Segments = Enumerable.Empty <Point>(); } _context = item.AmlContext.LocalizationContext; }
internal Vault(IReadOnlyItem i) { this.Id = i.Id(); this.Url = i.Property("vault_url").Value; this.Authentication = AuthenticationSchemes.None; HttpClient = (SyncHttpClient)Factory.DefaultService(); }
internal Vault(IReadOnlyItem i, HttpClient client) { this.Id = i.Id(); this.Url = i.Property("vault_url").Value; this.Authentication = AuthenticationSchemes.None; HttpClient = client; }
private XmlElement CreateDetailElement(IReadOnlyItem item, string report) { var detail = _faultNode.Elem("detail"); if (item != null) { detail.Elem("item").Attr("type", item.Type().Value).Attr("id", item.Id()); } detail.Elem("error_resolution_report", report); return detail; }
public void Add(IReadOnlyItem item) { if (item.Attribute(XmlFlags.Attr_ScriptType).HasValue()) { return; } switch (item.TypeName().ToLowerInvariant()) { case "method": _methods.Add(new Method(item, _coreIds.Contains(item.ConfigId().Value ?? item.Id()))); break; case "relationshiptype": if (item.Property("relationship_id").HasValue()) { Add(item.Property("relationship_id").AsItem()); } break; case "itemtype": var itemType = new ItemType(item); if (string.IsNullOrEmpty(itemType.Name)) { return; } _itemTypesByName[itemType.Name] = itemType; Add(item.Relationships("Property")); break; case "sql": var sql = Sql.FromFullItem(item, false); sql.KeyedName = item.Property("name").Value ?? item.KeyedName().Value ?? item.IdProp().KeyedName().Value ?? ""; sql.Type = item.Property("type").AsString(""); if (string.IsNullOrEmpty(sql.KeyedName)) { return; } _sql[sql.KeyedName.ToLowerInvariant()] = sql; break; case "property": _propertyNames[item.Id()] = item.Property("name").Value ?? item.KeyedName().Value ?? item.IdProp().KeyedName().Value; break; } }
public DatabaseList(IReadOnlyItem list) { Id = list.Id(); Name = list.Property("name").Value; Label = list.Property("label").Value; Description = list.Property("description").Value; Values = list.Relationships() .Select(i => new ListValue() { Label = i.Property("label").Value, Value = i.Property("value").Value, Filter = i.Property("filter").Value }).ToList(); }
private IElement CreateDetailElement(IReadOnlyItem item, string report) { var detail = _fault.ElementByName("detail"); if (item != null) { detail.Add(new AmlElement(_fault.AmlContext, "item" , new Attribute("type", item.Type().Value) , new Attribute("id", item.Id()))); } detail.Add(new AmlElement(_fault.AmlContext, "error_resolution_report", report)); if (!detail.Exists) { _fault.Add(detail); } return(detail); }
private XmlElement CreateDetailElement(IReadOnlyItem item, params string[] properties) { if (item != null) { var detail = _faultNode.Elem("detail"); detail.Elem("item").Attr("type", item.Type().Value).Attr("id", item.Id()); if (properties.Any()) { var props = detail.Elem("properties"); foreach (var prop in properties) { props.Elem("property", prop); } } return detail; } return null; }
public StateNode(IReadOnlyItem item) { Id = item.Id(); Name = item.Property("name").Value; Label = item.Property("label").Value; Location = new Point(item.Property("x").AsInt(0), item.Property("y").AsInt(0)); if (item.Property("is_start").AsBoolean(false)) { Type = NodeType.Start; } else if (item.Property("is_end").AsBoolean(false)) { Type = NodeType.End; } else { Type = NodeType.General; } IsAutomatic = item.Property("is_auto").AsBoolean(false); Image = item.Property("image").Value; }
internal static Property FromItem(IReadOnlyItem prop, ItemType type) { var newProp = new Property(prop.Property("name").Value) { Id = prop.Id(), Label = prop.Property("label").Value, Precision = prop.Property("prec").AsInt(-1), Scale = prop.Property("scale").AsInt(-1), StoredLength = prop.Property("stored_length").AsInt(-1), Description = prop.Property("help_text").AsString(null) ?? prop.Property("help_tooltip").AsString(null) }; newProp.SetType(prop.Property("data_type").Value); var foreign = prop.Property("foreign_property").AsItem(); if (foreign.Exists) { newProp.ForeignLinkPropName = prop.Property("data_source").KeyedName().Value; newProp.ForeignPropName = foreign.Property("name").Value; newProp.ForeignTypeName = foreign.SourceId().KeyedName().Value; } newProp.DataSource = prop.Property("data_source").Value; if (newProp.Type == PropertyType.item && newProp.Name == "data_source" && type.Name == "Property") { newProp.Restrictions.AddRange(new string[] { "ItemType", "List", "Property" }); } else if (newProp.Type == PropertyType.item && prop.Property("data_source").Attribute("name").HasValue()) { newProp.Restrictions.Add(prop.Property("data_source").Attribute("name").Value); } newProp.Visibility = (prop.Property("is_hidden").AsBoolean(false) ? PropertyVisibility.None : PropertyVisibility.MainGrid) | (prop.Property("is_hidden2").AsBoolean(false) ? PropertyVisibility.None : PropertyVisibility.RelationshipGrid); newProp.SortOrder = prop.Property("sort_order").AsInt(int.MaxValue); newProp.ColumnWidth = prop.Property("column_width").AsInt(100); newProp.IsRequired = prop.Property("is_required").AsBoolean(false); newProp.ReadOnly = prop.Property("readonly").AsBoolean(false); return(newProp); }
private IElement CreateDetailElement(IReadOnlyItem item, params string[] properties) { var detail = _fault.ElementByName("detail"); detail.Add(new AmlElement(_fault.AmlContext, "item" , new Attribute("type", item.Type().Value) , new Attribute("id", item.Id()))); if (properties.Any()) { var props = new AmlElement(_fault.AmlContext, "properties"); foreach (var prop in properties) { props.Add(new AmlElement(_fault.AmlContext, "property", prop)); } detail.Add(props); } if (!detail.Exists) { _fault.Add(detail); } return(detail); }
public StateDiagram(IReadOnlyItem item) { Id = item.Id(); Type = item.TypeName(); Name = item.Property("name").Value ?? item.KeyedName().Value; Label = item.Property("label").Value; Nodes = item.Relationships("Life Cycle State") .Concat(item.Relationships("Workflow Map Activity") .Select(i => i.RelatedItem())) .Select(i => new StateNode(i)) .ToDictionary(n => n.Id); if (item.Property("start_state").HasValue() && Nodes.TryGetValue(item.Property("start_state").Value, out var startState)) { startState.Type = NodeType.Start; } Links = item.Relationships("Life Cycle Transition") .Concat(item.Relationships("Workflow Map Activity") .SelectMany(i => i.RelatedItem().Relationships("Workflow Map Path"))) .Select(i => new StateLink(i, Nodes)) .ToList(); }
public ItemType(IReadOnlyItem itemType, HashSet <string> coreIds = null, bool defaultProperties = false, Func <string, string> getName = null) { var relType = itemType.Property("relationship_id").AsItem(); var sourceProp = itemType.SourceId(); SourceTypeName = sourceProp.Attribute("name").Value ?? sourceProp.KeyedName().Value; var relatedProp = itemType.RelatedId(); RelatedTypeName = relatedProp.Attribute("name").Value ?? relatedProp.KeyedName().Value; if (relType.Exists) { RelationshipTypeId = itemType.Id(); TabLabel = itemType.Property("label").Value; RelationshipView = itemType.Relationships("Relationship View") .FirstOrNullItem(i => i.Property("start_page").HasValue()) .Property("start_page").Value; itemType = relType; } Id = itemType.Id(); IsCore = itemType.Property("core").AsBoolean(coreIds?.Contains(itemType.Id()) == true); IsDependent = itemType.Property("is_dependent").AsBoolean(false); IsFederated = itemType.Property("implementation_type").Value == "federated"; IsRelationship = itemType.Property("is_relationship").AsBoolean(false); IsPolymorphic = itemType.Property("implementation_type").Value == "polymorphic"; IsVersionable = itemType.Property("is_versionable").AsBoolean(false); Label = itemType.Property("label").Value; Name = itemType.Property("name").Value ?? itemType.KeyedName().Value ?? itemType.IdProp().KeyedName().Value; Reference = ItemReference.FromFullItem(itemType, true); Description = itemType.Property("description").Value; if (itemType.Property("class_structure").HasValue()) { ClassStructure = new ClassStructure(itemType.Property("class_structure").Value); } DefaultPageSize = itemType.Property("default_page_size").AsInt(); MaxRecords = itemType.Property("maxrecords").AsInt(); HasLifeCycle = itemType.Relationships("ItemType Life Cycle").Any(); _properties = itemType.Relationships("Property") .Select(p => Property.FromItem(p, this, getName)) .ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase); if (_properties.Count > 0 || defaultProperties) { if (!_properties.ContainsKey("id")) { foreach (var property in ElementFactory.Local.FromXml(string.Format(_coreProperties, Id)) .Items() .Select(p => Property.FromItem(p, this)) .Where(p => !_properties.ContainsKey(p.Name))) { _properties[property.Name] = property; } } var propAml = @"<Item type='Property'> <column_alignment>left</column_alignment> <data_source keyed_name='{0}' type='ItemType' name='{0}'>{1}</data_source> <data_type>item</data_type> <is_hidden>{3}</is_hidden> <is_hidden2>1</is_hidden2> <is_indexed>1</is_indexed> <is_keyed>0</is_keyed> <is_multi_valued>0</is_multi_valued> <is_required>0</is_required> <item_behavior>float</item_behavior> <readonly>0</readonly> <sort_order>2944</sort_order> <name>{2}</name> </Item>"; if (sourceProp.Exists && !_properties.ContainsKey("source_id")) { _properties["source_id"] = Property.FromItem(ElementFactory.Local.FromXml(string.Format(propAml , SourceTypeName , sourceProp.Value , "source_id" , "1")).AssertItem(), this); } if (relatedProp.Exists && !_properties.ContainsKey("related_id")) { _properties["related_id"] = Property.FromItem(ElementFactory.Local.FromXml(string.Format(propAml , RelatedTypeName , relatedProp.Value , "related_id" , "0")).AssertItem(), this); } } WithExtra(itemType); }
public async Task Initialize(IReadOnlyItem item, IAsyncConnection conn) { this.Label = item.Property("label").AsString(""); this.Name = item.Property("name").AsString(""); this.Required = item.Property("is_required").AsBoolean(false) || item.Property("is_class_required").AsBoolean(false); this.PropName = LabelToProp(this.Label); this.VarName = NameToVar(this.Name); if (string.IsNullOrEmpty(this.PropName)) { this.PropName = LabelToProp(this.Name); } if (string.IsNullOrEmpty(this.Label)) { this.Label = Strings.StrConv(this.Name.Replace('_', ' '), VbStrConv.ProperCase); } if (item.Property("data_type").Value == "foreign") { this.PropType = PropTypes.Foreign; if (!item.Property("foreign_property").HasValue()) { var result = await conn.ApplyAsync(@"<AML> <Item type='Property' action='get' id='@0' select='label,name,is_required,is_class_required,data_type,data_source,readonly,pattern,stored_length,foreign_property(label,name,is_required,is_class_required,data_type,data_source,readonly,pattern,stored_length)'> </Item> </AML>", true, true, item.Id()).ToTask(); item = result.AssertItem(); } ForeignProp = await NewProp(item.Property("foreign_property").AsItem(), conn); ForeignLinkProp = NewProp(item.Property("data_source").Value); } else if (item.Property("readonly").AsBoolean(false)) { PropType = PropTypes.ReadOnly; } else { PropType = PropTypes.Normal; } if (this.ForeignProp != null) { this.DataType = ForeignProp.DataType; } else { switch (item.Property("data_type").AsString("").ToLowerInvariant()) { case "decimal": case "float": DataType = "Double"; break; case "date": DataType = "Date"; break; case "item": DataType = Strings.StrConv(item.Property("data_source").KeyedName().Value, VbStrConv.ProperCase) .Replace(" ", ""); if (item.Property("data_source").Value == "0C8A70AE86AF49AD873F817593F893D4") { this.List = item.Property("pattern").AsString(""); this.EbsList = true; } break; case "integer": DataType = "Integer"; break; case "boolean": DataType = "Boolean"; break; case "list": case "filter list": case "mv_list": DataType = "String"; this.List = item.Property("data_source").AsString(""); this.ListFilter = item.Property("pattern").AsString(""); break; case "image": DataType = "Gentex.Drawing.WebLazyImage"; break; default: //"list", "string", "text" this.StringLength = item.Property("stored_length").AsInt(-1); this.DataType = "String"; break; } } }
private Vault(IReadOnlyItem i) { this.Id = i.Id(); this.Url = i.Property("vault_url").Value; this.Authentication = AuthenticationSchemes.None; }
private IPromise<WebResponse> DownloadFileFromVault(IReadOnlyItem fileItem, Vault vault, bool async, Command request) { var url = vault.Url; if (string.IsNullOrEmpty(url)) return null; var urlPromise = url.IndexOf("$[") < 0 ? Promises.Resolved(url) : _conn.Process(new Command("<url>@0</url>", url) .WithAction(CommandAction.TransformVaultServerURL), async) .Convert(s => s.AsString()); return urlPromise.Continue<string, WebResponse>(u => { if (u != vault.Url) vault.Url = u; var uri = new Uri(string.Format("{0}?dbName={1}&fileId={2}&fileName={3}&vaultId={4}", u, _conn.Database, fileItem.Id(), HttpUtility.UrlEncode(fileItem.Property("filename").Value), vault.Id)); var req = (HttpWebRequest)System.Net.WebRequest.Create(uri); req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); req.Credentials = CredentialCache.DefaultCredentials; req.Method = "GET"; req.Proxy.Credentials = CredentialCache.DefaultCredentials; req.Timeout = -1; _conn.SetDefaultHeaders((k, v) => { req.Headers.Set(k, v); }); req.Headers.Set("VAULTID", vault.Id); var result = new WebRequest(req, _conn.Compression); foreach (var a in _conn.DefaultSettings) { a.Invoke(result); } if (request.Settings != null) request.Settings.Invoke(result); return result.Execute(async); }); }
/// <summary> /// Initializes a new instance of the <see cref="DelegateContext"/> class. /// </summary> /// <param name="conn">The connection.</param> /// <param name="item">The item.</param> public DelegateContext(IServerConnection conn, IReadOnlyItem item) : base(conn, item) { var aml = conn.AmlContext; Assignment = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("AssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("AssignmentId").Value) ); DelegateTo = aml.Item(aml.Type("Activity Assignment"), aml.Id(item.Property("ToAssignmentId").Value), aml.SourceId(aml.KeyedName(item.KeyedName()), aml.Type(item.Type().Value), item.Id()), aml.Property("id", item.Property("ToAssignmentId").Value) ); }
internal static Property FromItem(IReadOnlyItem prop, ItemType type, Func <string, string> getName = null) { var newProp = new Property() { Applicable = true, Name = prop.Property("name").Value, Id = prop.Id(), Label = prop.Property("label").Value, Precision = prop.Property("prec").AsInt(-1), Scale = prop.Property("scale").AsInt(-1), StoredLength = prop.Property("stored_length").AsInt(-1), Description = prop.Property("help_text").AsString(null) ?? prop.Property("help_tooltip").AsString(null), ClassPath = prop.Property("class_path").Value, DefaultSearch = prop.Property("default_search").Value, Pattern = prop.Property("pattern").Value, KeyedNameOrder = prop.Property("keyed_name_order").AsInt(), OrderBy = prop.Property("order_by").AsInt(), }; if (_propertyHelp.TryGetValue(newProp.Name, out var stdDescription)) { newProp.Core = true; newProp.Description = newProp.Description ?? stdDescription; } if (prop.Property("default_value").HasValue()) { newProp.DefaultValue = prop.Property("default_value").Value; } newProp.SetType(prop.Property("data_type").Value); var foreign = prop.Property("foreign_property").AsItem(); if (foreign.Exists) { newProp.ForeignLinkPropName = prop.Property("data_source").KeyedName().Value ?? prop.Property("data_source").AsItem().Property("name").Value; newProp.ForeignPropName = foreign.Property("name").Value ?? foreign.Property("keyed_name").Value; newProp.ForeignTypeName = foreign.SourceId().KeyedName().Value ?? foreign.SourceId().AsItem().Property("name").Value; } newProp.DataSource = prop.Property("data_source").Value; if (newProp.Type == PropertyType.item && newProp.Name == "data_source" && type.Name == "Property") { newProp.Restrictions.AddRange(new string[] { "ItemType", "List", "Property" }); } else if (prop.Property("data_source").Attribute("name").HasValue() || prop.Property("data_source").KeyedName().HasValue()) { newProp.Restrictions.Add(prop.Property("data_source").Attribute("name").Value ?? prop.Property("data_source").KeyedName().Value); } else if (prop.Property("data_source").HasValue() && !string.IsNullOrEmpty(prop.Property("data_source").Value)) { var name = getName?.Invoke(prop.Property("data_source").Value); if (!string.IsNullOrEmpty(name)) { newProp.Restrictions.Add(name); } } newProp.Visibility = (prop.Property("is_hidden").AsBoolean(false) ? PropertyVisibility.None : PropertyVisibility.MainGrid) | (prop.Property("is_hidden2").AsBoolean(false) ? PropertyVisibility.None : PropertyVisibility.RelationshipGrid); newProp.SortOrder = prop.Property("sort_order").AsInt(int.MaxValue); newProp.ColumnWidth = prop.Property("column_width").AsInt(100); newProp.IsRequired = prop.Property("is_required").AsBoolean(false); newProp.ReadOnly = prop.Property("readonly").AsBoolean(false); switch (newProp.Name) { case "classification": newProp.Applicable = type.ClassPaths.Any() || type.IsPolymorphic || type.IsFederated; break; case "config_id": case "generation": case "is_current": case "major_rev": case "minor_rev": case "new_version": case "release_date": newProp.Applicable = type.IsVersionable || type.IsPolymorphic || type.IsFederated; break; case "current_state": case "is_released": case "state": newProp.Applicable = type.HasLifeCycle || type.IsPolymorphic || type.IsFederated; break; case "related_id": newProp.Applicable = prop.Property("data_source").HasValue(); break; } return(newProp); }
public void Add(IReadOnlyItem item) { if (item.Attribute(XmlFlags.Attr_ScriptType).HasValue()) { return; } switch (item.TypeName().ToLowerInvariant()) { case "method": _methods.Add(new Method(item, _coreIds.Contains(item.ConfigId().Value ?? item.Id()))); break; case "relationshiptype": if (item.Property("relationship_id").HasValue()) { var relType = new ItemType(item, null, true); if (string.IsNullOrEmpty(relType.Name)) { return; } _itemTypesByName[relType.Name] = relType; var source = _itemTypesByName.Values .FirstOrDefault(i => i.Id == item.SourceId().Value); if (source != null) { source.Relationships.Add(relType); } } break; case "itemtype": var itemType = new ItemType(item, null, item.Property("name").HasValue(), GetName); if (!string.IsNullOrEmpty(itemType.Name) && !_itemTypesByName.ContainsKey(itemType.Name)) { _itemTypesByName[itemType.Name] = itemType; AddRange(item.Relationships("Property")); } else if (!string.IsNullOrEmpty(itemType.Id)) { _itemTypesByName.Values .FirstOrDefault(i => i.Id == itemType.Id) ?.WithScripts(item); } break; case "sql": var sql = Sql.FromFullItem(item, false); sql.KeyedName = item.Property("name").Value ?? item.KeyedName().Value ?? item.IdProp().KeyedName().Value ?? ""; sql.Type = item.Property("type").AsString(""); if (string.IsNullOrEmpty(sql.KeyedName)) { return; } _sqlByName[sql.KeyedName.ToLowerInvariant()] = sql; break; case "property": _propertyNames[item.Id()] = item.Property("name").Value ?? item.KeyedName().Value ?? item.IdProp().KeyedName().Value; break; case "list": _listsById[item.Id()] = new DatabaseList(item); break; case "life cycle map": case "workflow map": if (item.Action().Value != "edit") { Diagrams.Add(new StateDiagram(item)); } break; } }
public async Task Initialize(IReadOnlyItem item, IAsyncConnection conn) { this.Label = item.Property("label").AsString(""); this.Name = item.Property("name").AsString(""); this.Required = item.Property("is_required").AsBoolean(false) || item.Property("is_class_required").AsBoolean(false); this.PropName = LabelToProp(this.Label); this.VarName = NameToVar(this.Name); if (string.IsNullOrEmpty(this.PropName)) this.PropName = LabelToProp(this.Name); if (string.IsNullOrEmpty(this.Label)) this.Label = Strings.StrConv(this.Name.Replace('_', ' '), VbStrConv.ProperCase); if (item.Property("data_type").Value == "foreign") { this.PropType = PropTypes.Foreign; if (!item.Property("foreign_property").HasValue()) { var result = await conn.ApplyAsync(@"<AML> <Item type='Property' action='get' id='@0' select='label,name,is_required,is_class_required,data_type,data_source,readonly,pattern,stored_length,foreign_property(label,name,is_required,is_class_required,data_type,data_source,readonly,pattern,stored_length)'> </Item> </AML>", true, true, item.Id()).ToTask(); item = result.AssertItem(); } ForeignProp = await NewProp(item.Property("foreign_property").AsItem(), conn); ForeignLinkProp = NewProp(item.Property("data_source").Value); } else if (item.Property("readonly").AsBoolean(false)) { PropType = PropTypes.ReadOnly; } else { PropType = PropTypes.Normal; } if (this.ForeignProp != null) { this.DataType = ForeignProp.DataType; } else { switch (item.Property("data_type").AsString("").ToLowerInvariant()) { case "decimal": case "float": DataType = "Double"; break; case "date": DataType = "Date"; break; case "item": DataType = Strings.StrConv(item.Property("data_source").KeyedName().Value, VbStrConv.ProperCase) .Replace(" ", ""); if (item.Property("data_source").Value == "0C8A70AE86AF49AD873F817593F893D4") { this.List = item.Property("pattern").AsString(""); this.EbsList = true; } break; case "integer": DataType = "Integer"; break; case "boolean": DataType = "Boolean"; break; case "list": case "filter list": case "mv_list": DataType = "String"; this.List = item.Property("data_source").AsString(""); this.ListFilter = item.Property("pattern").AsString(""); break; case "image": DataType = "Gentex.Drawing.WebLazyImage"; break; default: //"list", "string", "text" this.StringLength = item.Property("stored_length").AsInt(-1); this.DataType = "String"; break; } } }
public static async Task<ArasProperty> NewProp(IReadOnlyItem item, IAsyncConnection conn) { var prop = NewProp(item.Id()); await prop.Initialize(item, conn); return prop; }
public void Add(IReadOnlyItem item) { if (item.Attribute(XmlFlags.Attr_ScriptType).HasValue()) { return; } switch (item.TypeName().ToLowerInvariant()) { case "method": var method = Method.FromFullItem(item, false); method.KeyedName = item.Property("name").AsString(""); method.IsCore = item.Property("core") .AsBoolean(_coreIds.Contains(item.ConfigId().Value ?? item.Id())); _methods.Add(method); break; case "itemtype": var itemType = new ItemType() { Id = item.Id(), IsCore = item.Property("core") .AsBoolean(_coreIds.Contains(item.Id())), IsDependent = item.Property("is_dependent").AsBoolean(false), IsFederated = item.Property("implementation_type").Value == "federated", IsPolymorphic = item.Property("implementation_type").Value == "polymorphic", IsVersionable = item.Property("is_versionable").AsBoolean(false), Label = item.Property("label").Value, Name = item.Property("name").Value ?? item.KeyedName().Value ?? item.IdProp().KeyedName().Value, Reference = ItemReference.FromFullItem(item, true) }; if (string.IsNullOrEmpty(itemType.Name)) { return; } _itemTypesByName[itemType.Name] = itemType; Add(item.Relationships("Property")); break; case "sql": var sql = Sql.FromFullItem(item, false); sql.KeyedName = item.Property("name").Value ?? item.KeyedName().Value ?? item.IdProp().KeyedName().Value ?? ""; sql.Type = item.Property("type").AsString(""); if (string.IsNullOrEmpty(sql.KeyedName)) { return; } _sql[sql.KeyedName.ToLowerInvariant()] = sql; break; case "property": _propertyNames[item.Id()] = item.Property("name").Value ?? item.KeyedName().Value ?? item.IdProp().KeyedName().Value; break; } }