public static ItemReference FromFullItem(IReadOnlyItem elem, bool getKeyedName) { var result = new ItemReference(); FillItemRef(result, elem, getKeyedName); return(result); }
private void EnsureContext() { if (!_contextLoaded) { _contextLoaded = true; var aml = Conn.AmlContext; var query = aml.Item(aml.Type("Workflow"), aml.Action("get"), aml.Select("source_type,source_id"), aml.RelatedExpand(false), aml.RelatedId( aml.Item(aml.Type("Workflow Process"), aml.Action("get"), aml.Relationships( aml.Item(aml.Type("Workflow Process Activity"), aml.Action("get"), aml.RelatedId(Activity.Id()) ) ) ) ) ); QueryDefaults?.Invoke(query); var workflow = Conn.ItemByQuery(query.ToAml()); query = aml.Item(aml.TypeId(workflow.Property("source_type").Value), aml.Id(workflow.SourceId().Value), aml.Action("get")); QueryDefaults?.Invoke(query); _context = Conn.ItemByQuery(query.ToAml()); _result.ErrorContext(_context); } }
private void EnsureExisting() { if (!_existingLoaded) { _existingLoaded = true; if (!string.IsNullOrEmpty(Item.Id())) { var aml = Conn.AmlContext; var query = aml.Item(Item.Type(), aml.Id(Item.Id()), aml.Action("get")); if (QueryDefaults != null) { QueryDefaults.Invoke(query); } var items = query.Apply(Conn).Items(); if (items.Any()) { _existing = items.Single(); } else { _existing = Client.Item.GetNullItem <IReadOnlyItem>(); } } else { _existing = Client.Item.GetNullItem <IReadOnlyItem>(); } } }
/// <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 async Task <ArasProperty> NewProp(IReadOnlyItem item, IAsyncConnection conn) { var prop = NewProp(item.Id()); await prop.Initialize(item, conn); return(prop); }
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 Method FromFullItem(IReadOnlyItem elem, bool getKeyedName) { var result = new Method(); FillItemRef(result, elem, getKeyedName); return(result); }
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; }
private Vault GetReadVaultForFile(IReadOnlyItem file, IEnumerable <Vault> readPriority) { var located = file.Relationships("Located").ToList(); if (located.Count < 1) { return(null); } else if (located.Count == 1) { return(_factory.GetVault(located[0].RelatedId().AsItem())); } else { // The maximum file version var maxVersion = located.Select(l => l.Property("file_version").AsInt(-1)).Max(); if (maxVersion < 0) { return(_factory.GetVault(located[0].RelatedId().AsItem())); } located = located.Where(l => l.Property("file_version").AsInt(-1) == maxVersion).ToList(); if (located.Count == 1) { return(_factory.GetVault(located[0].RelatedId().AsItem())); } // The vault sortOrders var vaultSort = new Dictionary <string, int>(); var vaultList = readPriority.ToList(); // Looping in reverse order to ensure that the minimum number is stored for (int i = vaultList.Count - 1; i >= 0; i--) { vaultSort[vaultList[i].Id] = i; } // Sort based on the vault priorities located.Sort((x, y) => { int xSort, ySort; if (!vaultSort.TryGetValue(x.RelatedId().Value, out xSort)) { xSort = 999999; } if (!vaultSort.TryGetValue(y.RelatedId().Value, out ySort)) { ySort = 999999; } int compare = xSort.CompareTo(ySort); if (compare == 0) { compare = x.Id().CompareTo(y.Id()); } return(compare); }); return(_factory.GetVault(located.First(l => l.Property("file_version").AsInt(-1) == maxVersion).RelatedId().AsItem())); } }
internal Vault(IReadOnlyItem i) { this.Id = i.Id(); this.Url = i.Property("vault_url").Value; this.Authentication = AuthenticationSchemes.None; HttpClient = (SyncHttpClient)Factory.DefaultService(); }
internal Item(IConnection conn, IReadOnlyItem result) { _conn = conn; _content = new List <IReadOnlyItem>() { result }; }
internal Vault(IReadOnlyItem i, HttpClient client) { this.Id = i.Id(); this.Url = i.Property("vault_url").Value; this.Authentication = AuthenticationSchemes.None; HttpClient = client; }
public Method(IReadOnlyItem elem, bool isCore = false) { FillItemRef(this, elem, false); this.KeyedName = elem.Property("name").AsString(""); this.IsCore = elem.Property("core").AsBoolean(isCore); this.Documentation = AmlDocumentation.Parse(this.KeyedName, elem.Property("method_code").AsString("")); this.Documentation.Summary = this.Documentation.Summary ?? elem.Property("comments").AsString(null); }
/// <summary> /// Initializes a new instance of the <see cref="VoteContext"/> class. /// </summary> /// <param name="conn">The connection.</param> /// <param name="item">The item.</param> public VoteContext(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) ); }
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; }
/// <summary>Retrieve the value of the <c>source_id</c> property as an Item</summary> public static IReadOnlyItem SourceItem(this IReadOnlyItem parent) { var par = parent.Parent; // Relationships if (par != null && par is Relationships) { return(par.Parent as IReadOnlyItem); } return(parent.Property("source_id").AsItem()); }
public ItemType WithScripts(IReadOnlyItem itemType) { foreach (var prop in itemType.Relationships("Property") .Select(p => Property.FromItem(p, this))) { _properties[prop.Name] = prop; } WithExtra(itemType); return(this); }
internal static void FillItemRef(ItemReference result, IReadOnlyItem elem, bool getKeyedName) { result.Type = elem.Type().Value; if (elem.Attribute("id").Exists) { result.Unique = elem.Attribute("id").Value; } else if (elem.Attribute("where").Exists) { result.Unique = elem.Attribute("where").Value; } if (getKeyedName) { if (result.Type == "FileType" && elem.Property("mimetype").HasValue()) { result.KeyedName = elem.Property("extension").AsString("") + ", " + elem.Property("mimetype").AsString(""); } else { IReadOnlyProperty_Base node = elem.Property("id"); if (node.Exists && node.KeyedName().Exists) { result.KeyedName = node.KeyedName().Value; } else { result.KeyedName = node.Attribute("_keyed_name").Value ?? elem.KeyedName().AsString(null) ?? elem.Property("name").AsString(null); } node = elem.SourceId(); if (node.Exists && node.KeyedName().Exists) { if (result.KeyedName.IsGuid()) { var related = elem.RelatedId(); if (related.Exists && related.KeyedName().Exists) { result.KeyedName = node.Attribute("keyed_name").Value + " > " + related.Attribute("keyed_name").Value; } else { result.KeyedName = node.Attribute("keyed_name").Value + ": " + result.KeyedName; } } else if (!string.IsNullOrEmpty(node.Attribute("keyed_name").Value)) { result.KeyedName += " {" + node.Attribute("keyed_name").Value + "}"; } } } } }
internal void AddReadOnly(IReadOnlyItem content) { var list = _content as IList <IReadOnlyItem>; if (list == null) { list = new List <IReadOnlyItem>(); _content = list; } list.Add(content); }
/// <summary> /// Loads the property metadata for the current type into the schema. /// </summary> /// <param name="type">The type.</param> /// <param name="itemTypeMeta">The properties.</param> private void LoadProperties(ItemType type, IReadOnlyItem itemTypeMeta) { var props = itemTypeMeta.Relationships("Property") .Concat(itemTypeMeta.Relationships("ItemType_xPropertyDefinition").Select(i => i.RelatedItem())); foreach (var prop in props) { var newProp = Property.FromItem(prop, type); type.Properties[newProp.Name] = newProp; } }
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 void NullItemForInterface() { var nullItem = Item.GetNullItem <IReadOnlyItem>(); Assert.AreNotEqual(null, nullItem); nullItem = Item.GetNullItem <IItem>(); Assert.AreNotEqual(null, nullItem); nullItem = new IReadOnlyItem[] { }.FirstOrNullItem(); Assert.AreNotEqual(null, nullItem); nullItem = new IItem[] { }.FirstOrNullItem(); Assert.AreNotEqual(null, nullItem); }
public ServerEvent(IReadOnlyItem serverEvent) { Event = serverEvent.Property("server_event").Value; var related = serverEvent.RelatedId(); Method = related.AsItem().Exists ? ItemReference.FromFullItem(related.AsItem(), true) : new ItemReference(related.Type().Value, related.Value) { KeyedName = related.KeyedName().Value }; SortOrder = serverEvent.Property("sort_order").AsInt(0); }
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 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(); }
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; }
/// <summary> /// Initializes a new instance of the <see cref="WorkflowContext"/> class. /// </summary> /// <param name="conn">The connection.</param> /// <param name="item">The item.</param> public WorkflowContext(IServerConnection conn, IReadOnlyItem item) { Conn = conn; Activity = item as Activity; _result = conn.AmlContext.Result(); switch (item.Property("WorkflowEvent").Value) { case "on_activate": WorkflowEvent = WorkflowEvent.OnActivate; break; case "on_assign": WorkflowEvent = WorkflowEvent.OnAssign; break; case "on_close": WorkflowEvent = WorkflowEvent.OnClose; break; case "on_delegate": WorkflowEvent = WorkflowEvent.OnDelegate; break; case "on_due": WorkflowEvent = WorkflowEvent.OnDue; break; case "on_escalate": WorkflowEvent = WorkflowEvent.OnEscalate; break; case "on_refuse": WorkflowEvent = WorkflowEvent.OnRefuse; break; case "on_remind": WorkflowEvent = WorkflowEvent.OnRemind; break; case "on_vote": WorkflowEvent = WorkflowEvent.OnVote; break; default: WorkflowEvent = WorkflowEvent.Other; break; } }
/// <summary> /// Specify an item to be used for parameter substitution /// </summary> /// <param name="item">Parameter item</param> public Command WithParamItem(IReadOnlyItem item) { foreach (var prop in item.Elements() .OfType <IReadOnlyProperty_Base>() .Where(p => p.HasValue())) { _sub.AddParameter(prop.Name, prop.Value); } foreach (var attr in item.Attributes() .Where(a => a.HasValue())) { _sub.AddParameter("@" + attr.Name, attr.Value); } return(this); }
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); }
public Method(IReadOnlyItem elem, bool isCore = false) { FillItemRef(this, elem, false); this.KeyedName = elem.Property("name").AsString(""); this.IsCore = elem.Property("core").AsBoolean(isCore); this.Documentation = OperationElement.Parse(this.KeyedName, elem.Property("method_code").AsString("")); if (this.Documentation.Summary.Count < 1 && elem.Property("comments").HasValue()) { this.Documentation.Summary.Add(new TextRun(elem.Property("comments").Value)); } var execution = elem.Property("execution_allowed_to"); ExecutionAllowedTo = execution.KeyedName().Value ?? execution.AsItem().KeyedName().Value ?? execution.AsItem().Property("name").Value; IsServerMethod = elem.Property("method_type").Value != "JavaScript"; }
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; }
private Vault GetReadVaultForFile(IReadOnlyItem file, IEnumerable<Vault> readPriority) { var located = file.Relationships("Located").ToList(); if (located.Count < 1) { return null; } else if (located.Count == 1) { return Vault.GetVault(located[0].RelatedId().AsItem()); } else { // The maximum file version var maxVersion = located.Select(l => l.Property("file_version").AsInt(-1)).Max(); if (maxVersion < 0) return Vault.GetVault(located[0].RelatedId().AsItem()); located = located.Where(l => l.Property("file_version").AsInt(-1) == maxVersion).ToList(); if (located.Count == 1) return Vault.GetVault(located[0].RelatedId().AsItem()); // The vault sortOrders var vaultSort = new Dictionary<string, int>(); var vaultList = readPriority.ToList(); // Looping in reverse order to ensure that the minimum number is stored for (int i = vaultList.Count - 1; i >= 0; i--) { vaultSort[vaultList[i].Id] = i; } // Sort based on the vault priorities located.Sort((x, y) => { int xSort, ySort; if (!vaultSort.TryGetValue(x.RelatedId().Value, out xSort)) xSort = 999999; if (!vaultSort.TryGetValue(y.RelatedId().Value, out ySort)) ySort = 999999; int compare = xSort.CompareTo(ySort); if (compare == 0) compare = x.Id().CompareTo(y.Id()); return compare; }); return Vault.GetVault(located.First(l => l.Property("file_version").AsInt(-1) == maxVersion).RelatedId().AsItem()); } }
/// <summary> /// Loads the property metadata for the current type into the schema. /// </summary> /// <param name="type">The type.</param> /// <param name="itemTypeMeta">The properties.</param> private void LoadProperties(ItemType type, IReadOnlyItem itemTypeMeta) { var props = itemTypeMeta.Relationships("Property"); Property newProp = null; foreach (var prop in props) { newProp = new Property(prop.Property("name").Value); newProp.Id = prop.Id(); newProp.Label = prop.Property("label").Value; newProp.SetType(prop.Property("data_type").Value); newProp.Precision = prop.Property("prec").AsInt(-1); newProp.Scale = prop.Property("scale").AsInt(-1); newProp.StoredLength = prop.Property("stored_length").AsInt(-1); 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); //default_value,column_width,is_required,readonly type.Properties.Add(newProp.Name, newProp); } }
private void EnsureNewVersion() { if (!_newLoaded) { _newLoaded = true; var props = _oldVersion.LazyMap(_conn, i => new { ConfigId = i.ConfigId().Value, Generation = i.Generation().AsInt() }); var aml = Conn.AmlContext; var query = aml.Item(_oldVersion.Type(), aml.Action("get"), aml.ConfigId(props.ConfigId), aml.Generation(props.Generation + 1) ); if (QueryDefaults != null) QueryDefaults.Invoke(query); _newVersion = query.Apply(Conn).AssertItem(); } }
public WorkflowContext(IServerConnection conn, IReadOnlyItem item) { _conn = conn; _activity = new Activity(item); _result = conn.AmlContext.Result(); switch (item.Property("WorkflowEvent").Value) { case "on_activate": _event = WorkflowEvent.OnActivate; break; case "on_assign": _event = WorkflowEvent.OnAssign; break; case "on_close": _event = WorkflowEvent.OnClose; break; case "on_delegate": _event = WorkflowEvent.OnDelegate; break; case "on_due": _event = WorkflowEvent.OnDue; break; case "on_escalate": _event = WorkflowEvent.OnEscalate; break; case "on_refuse": _event = WorkflowEvent.OnRefuse; break; case "on_remind": _event = WorkflowEvent.OnRemind; break; case "on_vote": _event = WorkflowEvent.OnVote; break; default: _event = WorkflowEvent.Other; break; } }
public LifeCycleState(IReadOnlyItem item) : base(item) { }
public SingleItemContext(IServerConnection conn, IReadOnlyItem item) { _conn = conn; _item = item; }
public ItemWrapper(IReadOnlyItem item) { _item = item; }
/// <summary> /// Loads the property metadata for the current type into the schema. /// </summary> /// <param name="type">The type.</param> /// <param name="itemTypeMeta">The properties.</param> private void LoadProperties(ItemType type, IReadOnlyItem itemTypeMeta) { var props = itemTypeMeta.Relationships("Property"); Property newProp = null; foreach (var prop in props) { newProp = new Property(prop.Property("name").Value); newProp.Label = prop.Property("label").Value; newProp.SetType(prop.Property("data_type").Value); newProp.Precision = prop.Property("prec").AsInt(-1); newProp.Scale = prop.Property("scale").AsInt(-1); newProp.StoredLength = prop.Property("stored_length").AsInt(-1); 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 && 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); //default_value,column_width,is_required,readonly type.Properties.Add(newProp.Name, newProp); } }
public static async Task<ArasProperty> NewProp(IReadOnlyItem item, IAsyncConnection conn) { var prop = NewProp(item.Id()); await prop.Initialize(item, conn); return prop; }
public PromotionContext(IServerConnection conn, IReadOnlyItem item) { _conn = conn; _item = item; }
public ValidationException ValidationException(string message, Exception innerException, IReadOnlyItem item, params string[] properties) { return new ValidationException(this, message, innerException, item, properties); }
public LifeCycleTransition(IReadOnlyItem item) : base(item) { }
private void EnsureExisting() { if (!_existingLoaded) { _existingLoaded = true; if (!string.IsNullOrEmpty(_changes.Id())) { var aml = Conn.AmlContext; var query = aml.Item(Changes.Type(), aml.Id(Changes.Id()), aml.Action("get")); if (QueryDefaults != null) QueryDefaults.Invoke(query); var items = query.Apply(Conn).Items(); if (items.Any()) _existing = items.Single(); } } }
public IErrorBuilder ErrorContext(IReadOnlyItem item) { _errorContext = item; return this; }
private Vault(IReadOnlyItem i) { this.Id = i.Id(); this.Url = i.Property("vault_url").Value; this.Authentication = AuthenticationSchemes.None; }
private IEditorTreeNode ProcessTreeNode(IReadOnlyItem item) { switch (item.Classification().Value.ToLowerInvariant()) { case "tree node/savedsearchintoc": return new EditorTreeNode() { Name = item.Property("label").Value, Description = "Saved Search", ImageKey = "xml-tag-16", HasChildren = item.Relationships("Tree Node Child").Any(), Children = item.Relationships().Select(r => ProcessTreeNode(r.RelatedItem())), ScriptGetter = () => Enumerable.Repeat( new EditorScript() { Name = item.Property("label").Value, Action = "ApplyItem", Script = _conn.Apply("<Item type='SavedSearch' action='get' select='criteria' id='@0' />", item.Property("saved_search_id").Value) .AssertItem().Property("criteria").Value }, 1) }; case "tree node/itemtypeintoc": return new EditorTreeNode() { Name = item.Property("label").Value, ImageKey = "class-16", Description = "ItemType: " + item.Property("name").Value, HasChildren = true, ScriptGetter = () => ItemTypeScripts(ArasMetadataProvider.Cached(_conn).TypeById(item.Property("itemtype_id").Value)), Children = ItemTypeChildren(item.Property("itemtype_id").Value) .Concat(item.Relationships().Select(r => ProcessTreeNode(r.RelatedItem()))) }; default: return new EditorTreeNode() { Name = item.Property("label").Value, ImageKey = "folder-16", HasChildren = item.Relationships("Tree Node Child").Any(), Children = item.Relationships().Select(r => ProcessTreeNode(r.RelatedItem())) }; } }
public static Sql FromFullItem(IReadOnlyItem elem, bool getKeyedName) { var result = new Sql(); FillItemRef(result, elem, getKeyedName); return result; }
public WorkflowProcess(IReadOnlyItem item) : base(item) { }
public VersionContext(IServerConnection conn, IReadOnlyItem item) { _conn = conn; _oldVersion = item; }
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); }); }
private void EnsureContext() { if (!_contextLoaded) { _contextLoaded = true; var aml = Conn.AmlContext; var query = aml.Item(aml.Type("Workflow"), aml.Action("get"), aml.Select("source_type", "source_id"), aml.RelatedExpand(false), aml.RelatedId( aml.Item(aml.Type("Workflow Process"), aml.Action("get"), aml.Relationships( aml.Item(aml.Type("Workflow Process Activity"), aml.Action("get"), aml.RelatedId(_activity.Id()) ) ) ) ) ); if (QueryDefaults != null) QueryDefaults(query); var workflow = Conn.ItemByQuery(query.ToAml()); query = aml.Item(aml.TypeId(workflow.Property("source_type").Value), aml.Id(workflow.SourceId().Value), aml.Action("get")); if (QueryDefaults != null) QueryDefaults(query); _context = Conn.ItemByQuery(query.ToAml()); } }
public ValidationReportException ValidationException(string message, Exception innerException, IReadOnlyItem item, string report) { return new ValidationReportException(this, message, innerException, item, report); }
internal ValidationReportException(ElementFactory factory, string message, Exception innerException , IReadOnlyItem item, string report) : base(factory, message, 1001, innerException) { CreateDetailElement(item, report); }
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 Activity(IReadOnlyItem item) : base(item) { }
/// <summary> /// Loads the property metadata for the current type into the schema. /// </summary> /// <param name="type">The type.</param> /// <param name="itemTypeMeta">The properties.</param> private void LoadProperties(ItemType type, IReadOnlyItem itemTypeMeta) { var props = itemTypeMeta.Relationships("Property"); Property newProp = null; foreach (var prop in props) { newProp = new Property(prop.Property("name").Value); newProp.SetType(prop.Property("data_type").Value); if (newProp.Type == PropertyType.item && prop.Property("data_source").Attribute("name").HasValue()) { newProp.Restrictions.Add(prop.Property("data_source").Attribute("name").Value); } type.Properties.Add(newProp); } }
internal ValidationException(ElementFactory factory, string message, Exception innerException , IReadOnlyItem item, params string[] properties) : base(factory, message, properties.Any() ? 1001 : 1, innerException) { CreateDetailElement(item, properties); }