public void SetConnection(IAsyncConnection conn) { _conn = conn; _currUserKeyedName = conn.ItemById("User", conn.UserId).KeyedName().Value; txtModifiedBy.Text = _currUserKeyedName; this.Icon = (this.Owner ?? Application.OpenForms[0]).Icon; }
/// <summary> /// Construct a new <see cref="ExportProcessor"/> from a connection to Aras /// </summary> /// <param name="conn"></param> public ExportProcessor(IAsyncConnection conn) { _conn = conn; _metadata = ArasMetadataProvider.Cached(conn); _metadata.Reset(); _dependAnalyzer = new DependencyAnalyzer(_metadata); }
public static void HandleEvent(RecoverableErrorEventArgs args, IAsyncConnection conn) { using (var dialog = new ErrorWindow()) { dialog._conn = conn; dialog.txtMessage.Text = args.Message ?? args.Exception.Message; dialog.txtErrorDetails.Text = Utils.IndentXml(args.Exception.ToAml()); dialog.txtQuery.Text = Utils.IndentXml(args.Exception.Query); dialog.TopMost = true; switch (dialog.ShowDialog()) { case DialogResult.Ignore: args.RecoveryOption = RecoveryOption.Skip; break; case DialogResult.Retry: args.RecoveryOption = RecoveryOption.Retry; var doc = new XmlDocument(); doc.LoadXml(dialog.txtQuery.Text); args.NewQuery = doc.DocumentElement; break; default: args.RecoveryOption = RecoveryOption.Abort; break; } } }
private async Task<string> ExecuteAsync(IAsyncConnection conn) { var whereUsed = await GetWhereUsed(conn, this.Type, this.OrigId); var finalSql = new StringBuilder(); string sql; string props; IReadOnlyResult res; foreach (var item in whereUsed) { props = item.Properties.Select(p => p + " = '" + this.ReplaceId + "'").GroupConcat(", "); sql = "update innovator.[" + item.MainType.Replace(' ', '_') + "] set " + props + " where id ='" + item.MainId + "';"; if (this.GenerateSql) { finalSql.AppendLine(sql); } else { res = await conn.ApplySql(sql, true).ToTask(); res.AssertNoError(); } } if (this.GenerateSql) return finalSql.ToString(); return "Complete."; }
private async Task<IEnumerable<WhereUsedItem>> GetWhereUsed(IAsyncConnection conn, string type, string id) { var whereUsed = await conn.ApplyAsync(@"<AML> <Item type='SQL' action='SQL Process'> <name>WhereUsed_General</name> <PROCESS>CALL</PROCESS> <ARG1>@0</ARG1> <ARG2>@1</ARG2> </Item> </AML>", true, false, type, id).ToTask(); return ( from i in whereUsed.Items() where string.IsNullOrEmpty(type) || i.Property("parent_type").Value == type select new WhereUsedItem() { Type = i.Property("parent_type").Value, Id = i.Property("parent_id").Value, Icon = i.Property("icon").Value, MainType = i.Property("main_type").Value, MainId = i.Property("main_id").Value, Properties = i.Elements().OfType<IReadOnlyProperty>() .Where(p => p.Name.Length == 2 && p.Name[0] == 'p' && char.IsNumber(p.Name[1])) .Select(p => p.Value), Generation = i.Generation().AsInt(1), KeyedName = i.KeyedName().Value, MajorRev = i.MajorRev().Value }).ToList(); }
private async Task <string> ExecuteAsync(IAsyncConnection conn) { var whereUsed = await GetWhereUsed(conn, this.Type, this.OrigId); var finalSql = new StringBuilder(); string sql; string props; IReadOnlyResult res; foreach (var item in whereUsed) { props = item.Properties.Select(p => p + " = '" + this.ReplaceId + "'").GroupConcat(", "); sql = "update innovator.[" + item.MainType.Replace(' ', '_') + "] set " + props + " where id ='" + item.MainId + "';"; if (this.GenerateSql) { finalSql.AppendLine(sql); } else { res = await conn.ApplySql(sql, true).ToTask(); res.AssertNoError(); } } if (this.GenerateSql) { return(finalSql.ToString()); } return("Complete."); }
public static async Task <ArasProperty> NewProp(IReadOnlyItem item, IAsyncConnection conn) { var prop = NewProp(item.Id()); await prop.Initialize(item, conn); return(prop); }
public void SetConnection(IAsyncConnection conn) { _conn = conn; _currUserKeyedName = conn.ItemById("User", conn.UserId).KeyedName().Value; txtModifiedBy.Text = _currUserKeyedName; this.Icon = (this.Owner ?? Application.OpenForms[0]).Icon; }
private async Task <IEnumerable <WhereUsedItem> > GetWhereUsed(IAsyncConnection conn, string type, string id) { var whereUsed = await conn.ApplyAsync(@"<AML> <Item type='SQL' action='SQL Process'> <name>WhereUsed_General</name> <PROCESS>CALL</PROCESS> <ARG1>@0</ARG1> <ARG2>@1</ARG2> </Item> </AML>", true, false, type, id).ToTask(); return(( from i in whereUsed.Items() where string.IsNullOrEmpty(type) || i.Property("parent_type").Value == type select new WhereUsedItem() { Type = i.Property("parent_type").Value, Id = i.Property("parent_id").Value, Icon = i.Property("icon").Value, MainType = i.Property("main_type").Value, MainId = i.Property("main_id").Value, Properties = i.Elements().OfType <IReadOnlyProperty>() .Where(p => p.Name.Length == 2 && p.Name[0] == 'p' && char.IsNumber(p.Name[1])) .Select(p => p.Value), Generation = i.Generation().AsInt(1), KeyedName = i.KeyedName().Value, MajorRev = i.MajorRev().Value }).ToList()); }
/// <summary> /// Get the result of executing the specified SQL query /// </summary> /// <param name="conn">Connection to execute the query on</param> /// <param name="sql">SQL query to be performed. If parameters are specified, they will be substituted into the query</param> /// <param name="ct">A <see cref="CancellationToken"/> used to cancel the asynchronous operation</param> /// <returns>A read-only result</returns> public static IPromise <IReadOnlyResult> ApplySql(this IAsyncConnection conn, Command sql, CancellationToken ct) { if (!sql.Aml.TrimStart().StartsWith("<")) { sql.Aml = "<sql>" + ServerContext.XmlEscape(sql.Aml) + "</sql>"; } return(ApplyAsyncInt(conn, sql.WithAction(CommandAction.ApplySQL), ct)); }
/// <summary> /// Get the result of executing the specified AML query /// </summary> /// <param name="conn">Connection to execute the query on</param> /// <param name="query">Query to be performed. If parameters are specified, they will be substituted into the query</param> /// <param name="async">Whether to perform the query asynchronously</param> /// <param name="noItemsIsError">Whether a 'No items found' exception should be signaled to the <see cref="IPromise"/> as an exception</param> /// <param name="parameters">Parameters to be injected into the query</param> /// <returns>A read-only result</returns> public static IPromise <IReadOnlyResult> ApplyAsync(this IAsyncConnection conn, Command query, bool async, bool noItemsIsError, params object[] parameters) { if (async) { return(ApplyAsyncInt(conn, query, default(CancellationToken), parameters)); } return(Promises.Resolved(Apply(conn, query, parameters))); }
public void Configure(IWizard wizard) { _wizard = wizard; _wizard.NextEnabled = _selectedRefs.Any(); _wizard.NextLabel = "&Export"; _wizard.Message = "Select the items you would like to include in the package."; _conn = _wizard.Connection; }
public void Configure(IWizard wizard) { _wizard = wizard; _wizard.NextEnabled = _selectedRefs.Any(); _wizard.NextLabel = "&Export"; _wizard.Message = "Select the items you would like to include in the package."; _conn = _wizard.Connection; }
private static async Task <AsyncSavepoint> ConstructAsync(IAsyncConnection parent, int id) { if (id == 0) { await parent.ExecuteAsync("START TRANSACTION"); } await parent.ExecuteAsync("SAVEPOINT `" + id + "`"); return(new AsyncSavepoint(parent, id)); }
protected virtual async Task <IAsyncConnection> CreateAsyncDbConnection(IEnumerable <IBaseRepository> repos = null) { IAsyncConnection uow = _unitOfWorkProvider.GetAsyncUnitOfWork(repos); if (uow.NumberOfRepos > 1) { await uow.BeginTransactionAsync(); } return(uow); }
/// <summary> /// Transforms the vault URL replacing any <c>$[]</c>-style parameters. /// </summary> /// <param name="conn">The connection.</param> /// <param name="async">Whether to perform this action asynchronously</param> /// <returns>A promise to return the transformed URL</returns> public IPromise <string> TransformUrl(IAsyncConnection conn, bool async) { return(Url.IndexOf("$[") < 0 ? Promises.Resolved(Url) : conn.Process(new Command("<url>@0</url>", Url) .WithAction(CommandAction.TransformVaultServerURL), async) .Convert(s => { Url = s.AsString(); return Url; })); }
/// <summary> /// Return a cached metadata object for a given connection /// </summary> public static ArasMetadataProvider Cached(IAsyncConnection conn) { ArasMetadataProvider result; var key = conn.Database + "|" + conn.UserId; var remote = conn as IRemoteConnection; if (remote != null) { key += "|" + remote.Url; } if (!_cache.TryGetValue(key, out result) || string.IsNullOrEmpty(result._conn.UserId)) { result = new ArasMetadataProvider(conn); _cache[key] = result; } return(result); }
/// <summary> /// Fetches the version from the database if it is not already known. /// </summary> /// <param name="conn">The connection to fetch the version for</param> /// <param name="async">Whether to fetch the version asynchronously</param> /// <returns>A promise to return the version of the Aras installation.</returns> public static IPromise <Version> FetchVersion(this IAsyncConnection conn, bool async) { var version = (conn as Connection.IArasConnection)?.Version; if (version != default(Version) && version.Major > 0) { return(Promises.Resolved(version)); } return(conn.ApplyAsync(@"<Item type='Variable' action='get' select='name,value'> <name condition='like'>Version*</name> </Item>", async, false) .Convert(res => { var dict = res.Items() .GroupBy(i => i.Property("name").AsString("")) .ToDictionary(g => g.Key, g => g.First().Property("value").Value); string majorStr; int major; string minorStr; int minor; string servicePackStr; int servicePack; string buildStr; int build; if (dict.TryGetValue("VersionMajor", out majorStr) && int.TryParse(majorStr, out major) && dict.TryGetValue("VersionMinor", out minorStr) && int.TryParse(minorStr, out minor) && dict.TryGetValue("VersionServicePack", out servicePackStr)) { if (!dict.TryGetValue("VersionBuild", out buildStr) || !int.TryParse(buildStr, out build)) { build = 0; } if (!int.TryParse(servicePackStr.TrimStart('S', 'P'), out servicePack)) { servicePack = 0; } return new Version(major, minor, servicePack, build); } return default(Version); })); }
protected virtual async Task <T> DoWorkAsync <T>(Func <IAsyncConnection, Task <T> > work) { try { T result; if (AsyncUnitOfWork != null && !AsyncUnitOfWork.Disposed) { if (!AsyncUnitOfWork.IsOpen) { throw new Exception("Connection not open. Please call BeginTransaction() to open the connection."); } result = await work(AsyncUnitOfWork); } else { // not passing in any repos to the UOW creation allows multiple repository operations // to each independantly do their DB work on separate connections using (IAsyncConnection tempUnitOfWork = await CreateAsyncDbConnection()) { // since there isn't a transaction, the UOW needs to be opened. await tempUnitOfWork.OpenAsync(); result = await work(tempUnitOfWork); } } _tryCount = 0; return(result); } catch (SqlException ex) when(ex.Number == DEADLOCK_ERROR_NBR) { if (_tryCount < 3) { _tryCount++; Thread.Sleep(_random.Next(100, 200)); return(await DoWorkAsync(work)); } throw; } }
public static string Transform(string xslt, string xml, IAsyncConnection conn) { var xal = new XsltArgumentList(); xal.AddExtensionObject(Namespace, new ArasXsltExtensions(conn)); var xsl = new MvpXslTransform(); xsl.SupportedFunctions = Mvp.Xml.Exslt.ExsltFunctionNamespace.All; using (var reader = new StringReader(xslt)) { using (var xmlReader = XmlReader.Create(reader)) { xsl.Load(xmlReader); } } using (var writer = new System.IO.StringWriter()) { xsl.Transform(new XmlInput(new StringReader(xml)), xal, new XmlOutput(writer)); return writer.ToString(); } }
/// <summary> /// Fetches the version from the database if it is not already known. /// </summary> /// <param name="conn">The connection to fetch the version for</param> /// <param name="async">Whether to fetch the version asynchronously</param> /// <returns>A promise to return the version of the Aras installation.</returns> public static IPromise <Version> FetchVersion(this IAsyncConnection conn, bool async) { if (!(conn is Connection.IArasConnection arasConn)) { return(Promises.Resolved(default(Version))); } var version = arasConn.Version; if (version != default(Version)) { return(Promises.Resolved(version)); } return(conn.ApplyAsync(@"<Item type='Variable' action='get' select='name,value'> <name condition='like'>Version*</name> </Item>", async, false) .Convert(res => { var dict = res.Items() .GroupBy(i => i.Property("name").AsString("")) .ToDictionary(g => g.Key, g => g.First().Property("value").Value); var major = 0; var minor = 0; var servicePack = 0; var build = 0; // int.TryParse will default to 0 on a failure // Always set a version with the pieces even if the version doesn't make sense so that we don't repeat retrieval var _ = dict.TryGetValue("VersionMajor", out string majorStr) && int.TryParse(majorStr, out major); _ = dict.TryGetValue("VersionMinor", out string minorStr) && int.TryParse(minorStr, out minor); _ = dict.TryGetValue("VersionServicePack", out string servicePackStr) && int.TryParse(servicePackStr.TrimStart('S', 'P'), out servicePack); _ = dict.TryGetValue("VersionBuild", out string buildStr) && int.TryParse(buildStr, out build); version = new Version(major, minor, servicePack, build); arasConn.Version = version; return version; })); }
private static IPromise <IReadOnlyResult> ApplyAsyncInt(this IAsyncConnection conn, Command query, CancellationToken ct, params object[] parameters) { var result = new Promise <IReadOnlyResult>(); query.WithAml(query.Aml, parameters); ct.Register(() => result.Cancel()); result.CancelTarget( conn.Process(query, true) .Progress((p, m) => result.Notify(p, m)) .Done(r => { try { if (query.Action == CommandAction.ApplySQL) { var res = ElementFactory.Utc.FromXml(r, query, conn); result.Resolve(res); } else { var res = conn.AmlContext.FromXml(r, query, conn); result.Resolve(res); } } catch (Exception ex) { result.Reject(ex); } }).Fail(ex => { result.Reject(ex); })); return(result); }
public void Initialize(IAsyncConnection conn) { _conn = conn; }
internal static void EnsureSystemData(IAsyncConnection _conn, ref Dictionary<string, ItemType> _itemTypes) { if (_itemTypes == null) { _itemTypes = new Dictionary<string, ItemType>(); var itemTypes = _conn.Apply(@"<Item type='ItemType' action='get' select='is_versionable,is_dependent,implementation_type,core,name'></Item>").Items(); ItemType result; foreach (var itemTypeData in itemTypes) { result = new ItemType(); result.Id = itemTypeData.Id(); result.IsCore = itemTypeData.Property("core").AsBoolean(false); result.IsDependent = itemTypeData.Property("is_dependent").AsBoolean(false); result.IsFederated = itemTypeData.Property("implementation_type").Value == "federated"; result.IsPolymorphic = itemTypeData.Property("implementation_type").Value == "polymorphic"; result.IsVersionable = itemTypeData.Property("is_versionable").AsBoolean(false); result.Name = itemTypeData.Property("name").Value; result.Reference = ItemReference.FromFullItem(itemTypeData, true); _itemTypes[result.Name.ToLowerInvariant()] = result; } var relationships = _conn.Apply(@"<Item action='get' type='RelationshipType' related_expand='0' select='related_id,source_id,relationship_id,name' />").Items(); ItemType relType; foreach (var rel in relationships) { if (rel.SourceId().Attribute("name").HasValue() && _itemTypes.TryGetValue(rel.SourceId().Attribute("name").Value.ToLowerInvariant(), out result) && rel.Property("relationship_id").Attribute("name").HasValue() && _itemTypes.TryGetValue(rel.Property("relationship_id").Attribute("name").Value.ToLowerInvariant(), out relType)) { result.Relationships.Add(relType); } } var floatProps = _conn.Apply(@"<Item type='Property' action='get' select='source_id,item_behavior,name' related_expand='0'> <data_type>item</data_type> <data_source> <Item type='ItemType' action='get'> <is_versionable>1</is_versionable> </Item> </data_source> <item_behavior>float</item_behavior> <name condition='not in'>'config_id','id'</name> </Item>").Items(); foreach (var floatProp in floatProps) { if (_itemTypes.TryGetValue(floatProp.SourceId().Attribute("name").Value.ToLowerInvariant(), out result)) { result.FloatProperties.Add(floatProp.Property("name").AsString("")); } } } }
public static IEnumerable<InstallItem> SortByDependencies(IEnumerable<InstallItem> items, IAsyncConnection conn) { int loops = 0; var state = CycleState.ResolvedCycle; var results = items; var metadata = ArasMetadataProvider.Cached(conn); metadata.Wait(); var analyzer = new DependencyAnalyzer(metadata); while (loops < 10 && state == CycleState.ResolvedCycle) { foreach (var newInstallItem in items) { analyzer.GatherDependencies(newInstallItem.Script, newInstallItem.Reference, newInstallItem.CoreDependencies); } analyzer.CleanDependencies(); results = GetDependencyList(analyzer, items, out state).ToList(); loops++; } return results; }
public IPromise <string> Execute(IAsyncConnection conn) { return(ExecuteAsync(conn).ToPromise()); }
public ResultObject(TestSuite suite, IAsyncConnection conn) { var rope = new Rope<char>(); using (var writer = new Editor.RopeWriter(rope)) { suite.Write(writer); } _amlLength = rope.Length; _count = suite.Tests.Count; _conn = conn; _text = new RopeTextSource(rope); _dataSet = new DataSet(); }
public TestContext(IAsyncConnection conn) { _conns.Push(conn); }
public ArasXsltExtensions(IAsyncConnection conn) { _conn = conn; }
public async Task <IEnumerable <InstallItem> > SortByDependencies(IEnumerable <InstallItem> items, IAsyncConnection conn) { var metadata = ArasMetadataProvider.Cached(conn); await metadata.ReloadTask().ConfigureAwait(false); return(SortByDependencies(items, metadata)); }
private static async Task <AsyncSavepoint> ConstructAsync(IAsyncConnection parent, int id) { await parent.ExecuteAsync("SAVEPOINT '" + id + "'"); return(new AsyncSavepoint(parent, id)); }
public async Task<string> ExecuteAsync(IAsyncConnection conn) { var defaultProps = new List<string>() { "classification", "config_id", "created_by_id", "created_on", "css", "current_state", "effective_date", "generation", "id", "is_current", "is_released", "keyed_name", "locked_by_id", "major_rev", "managed_by_id", "minor_rev", "modified_by_id", "modified_on", "new_version", "not_lockable", "owned_by_id", "permission_id", "release_date", "state", "superseded_date", "team_id", "related_id", "source_id", "behavior", "itemtype" }; if (!this.IncludeSortOrder) defaultProps.Add("sort_order"); var info = await conn.ApplyAsync(@"<AML> <Item type='ItemType' action='get'> <name>@0</name> <Relationships> <Item action='get' type='Property' 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> </Relationships> </Item> </AML>", true, true, this.ItemType).ToTask(); var itemTypeInfo = info.AssertItem(); var itemProps = new List<ArasProperty>(); var classBuilder = new StringBuilder(); var polyItem = itemTypeInfo.Property("implementation_type").AsString("") == "polymorphic"; if (!this.IsBase) classBuilder.AppendLine("Imports Gentex.ComponentTracker.Model"); classBuilder.AppendLine("Imports Gentex.Data.Aras.Model"); classBuilder.AppendLine("Imports Gentex.Data.Base.Model"); classBuilder.AppendLine(); if (this.IsBase) classBuilder.AppendLine("Namespace Aras.Model"); else classBuilder.AppendLine("Namespace Model"); classBuilder.AppendFormat(@" <SourceName(""{0}"")> _", this.ItemType).AppendLine(); if (itemTypeInfo.Property("is_relationship").AsBoolean(false)) { classBuilder.AppendFormat(" Public Class {0}", Strings.StrConv(this.ItemType, VbStrConv.ProperCase).Replace(" ", "")).AppendLine(); var rel = await conn.ApplyAsync(@"<AML> <Item type='RelationshipType' action='get' select='source_id,related_id' related_expand='0'> <relationship_id>@0</relationship_id> </Item> </AML>", true, true, itemTypeInfo.Id()).ToTask(); var relTypeInfo = rel.AssertItem(); if (!relTypeInfo.RelatedId().KeyedName().HasValue()) classBuilder.AppendFormat(" Inherits NullRelationship(Of {0})", Strings.StrConv(relTypeInfo.SourceId().Attribute("name").Value, VbStrConv.ProperCase).Replace(" ", "")) .AppendLine(); else classBuilder.AppendFormat(" Inherits Relationship(Of {0}, {1})", Strings.StrConv(relTypeInfo.SourceId().Attribute("name").Value, VbStrConv.ProperCase).Replace(" ", ""), Strings.StrConv(relTypeInfo.RelatedId().Attribute("name").Value, VbStrConv.ProperCase).Replace(" ", "")) .AppendLine(); } else if (polyItem) { classBuilder.AppendFormat(" Public Interface I{0}", Strings.StrConv(this.ItemType, VbStrConv.ProperCase).Replace(" ", "")).AppendLine(); if (itemTypeInfo.Property("is_versionable").AsBoolean(false)) classBuilder.AppendLine(" Inherits IVersionableItem"); else classBuilder.AppendLine(" Inherits IItem"); } else { classBuilder.AppendFormat(" Public Class {0}", Strings.StrConv(this.ItemType, VbStrConv.ProperCase).Replace(" ", "")).AppendLine(); if (itemTypeInfo.Property("is_versionable").AsBoolean(false)) classBuilder.AppendLine(" Inherits VersionableItem"); else classBuilder.AppendLine(" Inherits Item"); } classBuilder.AppendLine(); ArasProperty arasProp; foreach (var prop in itemTypeInfo.Relationships("Property")) { if (!defaultProps.Contains(prop.Property("name").AsString(""))) { arasProp = await ArasProperty.NewProp(prop, conn); itemProps.Add(arasProp); } } if (!polyItem) { itemProps.Sort(SortVariable); foreach (var prop in itemProps) { if (prop.PropType == ArasProperty.PropTypes.ReadOnly) { classBuilder.AppendFormat(@" Private {0} As New ReadOnlyPropertyValue(Of {1})(""{2}"", Me)", prop.VarName, prop.DataType, prop.Name).AppendLine(); } else if (prop.PropType == ArasProperty.PropTypes.Normal) { classBuilder.AppendFormat(@" Private {0} As New PropertyValue(Of {1})(""{2}"", Me, {3})", prop.VarName, prop.DataType, prop.Name, prop.Required).AppendLine(); } } classBuilder.AppendLine(); var foreignProps = itemProps.Where(p => p.PropType == ArasProperty.PropTypes.Foreign); if (foreignProps.Any()) { foreach (var prop in foreignProps) { classBuilder.AppendFormat(@" Private {0} As New ForeignPropertyValue(Of {1}, {2})(""{3}"", Me, {4}, Function(item) item.{5})" , prop.VarName, prop.ForeignLinkProp.DataType, prop.DataType, prop.Name, prop.ForeignLinkProp.VarName, prop.ForeignProp.PropName) .AppendLine(); } classBuilder.AppendLine(); } } itemProps.Sort(SortProperty); foreach (var prop in itemProps) { classBuilder.AppendLine(" ''' <summary>"); classBuilder.AppendFormat(" ''' Gets the {0}.", prop.Label.ToLower().Replace("&", "&")).AppendLine(); classBuilder.AppendLine(" ''' </summary>"); classBuilder.AppendFormat(@" <DisplayName(""{0}""), SourceName(""{1}"")", prop.Label, prop.Name); if (!String.IsNullOrEmpty(prop.List)) { classBuilder.AppendFormat(@", List(""{0}""", prop.List); if (!String.IsNullOrEmpty(prop.ListFilter)) { classBuilder.AppendFormat(@", ""{0}""", prop.ListFilter); } if (prop.EbsList) { if (String.IsNullOrEmpty(prop.ListFilter)) classBuilder.Append(", "); classBuilder.Append(", True"); } classBuilder.Append(")"); } if (prop.StringLength > 0) classBuilder.AppendFormat(", StringField({0})", prop.StringLength); classBuilder.Append(">"); classBuilder.AppendLine(); classBuilder.Append(" "); if (!polyItem) classBuilder.Append("Public "); switch (prop.PropType) { case ArasProperty.PropTypes.ReadOnly: classBuilder.AppendFormat("ReadOnly Property {0} As ReadOnlyPropertyValue(Of {1})", prop.PropName, prop.DataType).AppendLine(); break; case ArasProperty.PropTypes.Foreign: classBuilder.AppendFormat("ReadOnly Property {0} As IPropertyValue(Of {1})", prop.PropName, prop.DataType).AppendLine(); break; default: classBuilder.AppendFormat("ReadOnly Property {0} As PropertyValue(Of {1})", prop.PropName, prop.DataType).AppendLine(); break; } if (!polyItem) { classBuilder.AppendLine(" Get"); classBuilder.AppendFormat(" Return {0}", prop.VarName).AppendLine(); classBuilder.AppendLine(" End Get"); classBuilder.AppendLine(" End Property"); } } classBuilder.AppendLine(); if (polyItem) { classBuilder.AppendLine(" End Interface"); } else { if (this.IsBase) classBuilder.AppendLine(" Public Sub New(ByVal builder As Base.Model.IModelBuilder)"); else classBuilder.AppendLine(" Public Sub New(ByVal builder As IModelBuilder)"); classBuilder.AppendLine(" MyBase.New(builder)"); classBuilder.AppendLine(" End Sub"); if (this.GetProperties) { classBuilder.AppendLine(); classBuilder.AppendLine(" Private _getter As New PropGetter(Me)"); classBuilder.AppendLine(" Protected Overrides Function GetPropertyGetter() As Gentex.Data.Base.Model.IModelPropertyGetter"); classBuilder.AppendLine(" Return _getter"); classBuilder.AppendLine(" End Function"); classBuilder.AppendLine(); classBuilder.AppendLine(" Private Class PropGetter"); classBuilder.AppendLine(" Implements IModelPropertyGetter"); classBuilder.AppendLine(); classBuilder.AppendFormat(" Private _parent As {0}", Strings.StrConv(this.ItemType, VbStrConv.ProperCase).Replace(" ", "")).AppendLine(); classBuilder.AppendLine(); classBuilder.AppendLine(" Public ReadOnly Property SupportsByName As Boolean Implements IModelPropertyGetter.SupportsByName"); classBuilder.AppendLine(" Get"); classBuilder.AppendLine(" Return True"); classBuilder.AppendLine(" End Get"); classBuilder.AppendLine(" End Property"); classBuilder.AppendLine(); classBuilder.AppendFormat(" Public Sub New(parent as {0})", Strings.StrConv(this.ItemType, VbStrConv.ProperCase).Replace(" ", "")).AppendLine(); classBuilder.AppendLine(" _parent = parent"); classBuilder.AppendLine(" End Sub"); classBuilder.AppendLine(); classBuilder.AppendLine(" Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of PropertyValueInfo) Implements System.Collections.Generic.IEnumerable(Of Gentex.Data.Base.Model.PropertyValueInfo).GetEnumerator"); classBuilder.AppendLine(" Dim props As New List(Of Data.Base.Model.PropertyValueInfo)"); itemProps.Sort((x, y) => x.VarName.CompareTo(y.VarName)); foreach (var prop in itemProps) { classBuilder.AppendLine(String.Format(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent.{0}, Nothing))", prop.VarName)); } classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._configId, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._generation, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._isCurrent, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._isReleased, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._majorRev, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._minorRev, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._releaseDate, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._supersededDate, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._classification, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._createdBy, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._createdOn, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._currentState, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._effectiveDate, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._lockedBy, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._managedBy, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._modifiedBy, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._modifiedOn, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._notLockable, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._ownedBy, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._permission, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._state, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._team, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._id, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._keyedName, Nothing))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._canDelete, New LazyLoadAttribute(True, False)))"); classBuilder.AppendLine(" props.Add(New Data.Base.Model.PropertyValueInfo(_parent._canUpdate, New LazyLoadAttribute(True, False)))"); classBuilder.AppendLine(" Return props"); classBuilder.AppendLine(" End Function"); classBuilder.AppendLine(); classBuilder.AppendLine(" Public Function ByName(name As String) As Base.Model.PropertyValueInfo Implements Gentex.Data.Base.Model.IModelPropertyGetter.ByName"); classBuilder.AppendLine(" Select Case name"); foreach (var prop in itemProps) { classBuilder.AppendLine(String.Format(@" Case ""{0}""", prop.Name)); classBuilder.AppendLine(String.Format(" Return New Data.Base.Model.PropertyValueInfo(_parent.{0}, Nothing)", prop.VarName)); } classBuilder.AppendLine(" Case Field_ConfigId"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._configId, Nothing)"); classBuilder.AppendLine(" Case Field_Generation"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._generation, Nothing)"); classBuilder.AppendLine(" Case \"is_current\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._isCurrent, Nothing)"); classBuilder.AppendLine(" Case \"is_released\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._isReleased, Nothing)"); classBuilder.AppendLine(" Case Field_MajorRev"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._majorRev, Nothing)"); classBuilder.AppendLine(" Case Field_MinorRev"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._minorRev, Nothing)"); classBuilder.AppendLine(" Case \"release_date\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._releaseDate, Nothing)"); classBuilder.AppendLine(" Case \"superseded_date\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._supersededDate, Nothing)"); classBuilder.AppendLine(" Case Field_Classification"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._classification, Nothing)"); classBuilder.AppendLine(" Case \"created_by_id\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._createdBy, Nothing)"); classBuilder.AppendLine(" Case \"created_on\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._createdOn, Nothing)"); classBuilder.AppendLine(" Case \"current_state\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._currentState, Nothing)"); classBuilder.AppendLine(" Case \"effective_date\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._effectiveDate, Nothing)"); classBuilder.AppendLine(" Case \"locked_by_id\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._lockedBy, Nothing)"); classBuilder.AppendLine(" Case \"managed_by_id\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._managedBy, Nothing)"); classBuilder.AppendLine(" Case \"modified_by_id\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._modifiedBy, Nothing)"); classBuilder.AppendLine(" Case \"modified_on\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._modifiedOn, Nothing)"); classBuilder.AppendLine(" Case \"not_lockable\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._notLockable, Nothing)"); classBuilder.AppendLine(" Case \"owned_by_id\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._ownedBy, Nothing)"); classBuilder.AppendLine(" Case \"permission_id\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._permission, Nothing)"); classBuilder.AppendLine(" Case Field_State"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._state, Nothing)"); classBuilder.AppendLine(" Case \"team_id\""); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._team, Nothing)"); classBuilder.AppendLine(" Case Field_PermissionCanDelete"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._canDelete, New LazyLoadAttribute(True, False))"); classBuilder.AppendLine(" Case Field_PermissionCanUpdate"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._canUpdate, New LazyLoadAttribute(True, False))"); classBuilder.AppendLine(" Case Field_Id"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._id, Nothing)"); classBuilder.AppendLine(" Case Field_KeyedName"); classBuilder.AppendLine(" Return New Data.Base.Model.PropertyValueInfo(_parent._keyedName, Nothing)"); classBuilder.AppendLine(" Case Else"); classBuilder.AppendLine(" Return Nothing"); classBuilder.AppendLine(" End Select"); classBuilder.AppendLine(" End Function"); classBuilder.AppendLine(); classBuilder.AppendLine(" Private Function GetEnumeratorCore() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator"); classBuilder.AppendLine(" Return GetEnumerator()"); classBuilder.AppendLine(" End Function"); classBuilder.AppendLine(" End Class"); } classBuilder.AppendLine(" End Class"); } classBuilder.AppendLine("End Namespace"); return classBuilder.ToString(); }
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 TestContext(IAsyncConnection conn) { _conns.Push(conn); }
public static EditorScript ItemTypeAddScript(IAsyncConnection conn, ItemType itemType) { return new EditorScript() { Name = "New " + (itemType.Label ?? itemType.Name), Action = "ApplyItem", ScriptGetter = () => { var builder = new StringBuilder(); builder.AppendFormat("<Item type='{0}' action='add'>", itemType.Name).AppendLine(); foreach (var prop in ArasMetadataProvider.Cached(conn).GetProperties(itemType).Wait() .Where(p => p.DefaultValue != null)) { builder.Append(" <").Append(prop.Name).Append(">"); builder.Append(conn.AmlContext.LocalizationContext.Format(prop.DefaultValue)); builder.Append("</").Append(prop.Name).Append(">").AppendLine(); } builder.Append("</Item>"); return builder.ToString(); } }; }
private AsyncSavepoint(IAsyncConnection parent, int id) { _id = id; _connection = parent; }
/// <summary> /// Return a cached metadata object for a given connection /// </summary> public static ArasMetadataProvider Cached(IAsyncConnection conn) { ArasMetadataProvider result; if (!_cache.TryGetValue(conn, out result)) { result = new ArasMetadataProvider(conn); _cache[conn] = result; } return result; }
public DatabasePackage(IAsyncConnection conn) { _conn = conn; }
public void Initialize(IAsyncConnection conn) { _child.Initialize(conn); }
public void PushConnection(IAsyncConnection conn) { _conns.Push(conn); }
public AsyncThreadSafeConnection(IAsyncConnection asyncConnectionImplementation) { _asyncConnectionImplementation = asyncConnectionImplementation; }
public DatabasePackage(IAsyncConnection conn) { _conn = conn; }
public SqlSettings(IAsyncConnection conn) { _conn = conn; }
public ArasEditorProxy(IAsyncConnection conn, string name) { _conn = conn; _helper = new Editor.AmlEditorHelper(); _helper.InitializeConnection(_conn); _name = name; var arasConn = _conn as Innovator.Client.Connection.IArasConnection; _actions = GetActions(arasConn == null ? -1 : arasConn.Version).OrderBy(a => a).ToArray(); }
public InstallProcessor(IAsyncConnection conn) { _conn = conn; _exportTools = new ExportProcessor(conn); _currLine = -1; }
/// <summary> /// Constructor for the ArasMetadataProvider class /// </summary> private ArasMetadataProvider(IAsyncConnection conn) { _conn = conn; Reset(); }
public void SetConnection(IAsyncConnection conn, string name = null) { if (conn == null) throw new ArgumentNullException("conn"); exploreButton.Visible = true; mniLocale.Visible = true; mniTimeZone.Visible = true; SetProxy(new ArasEditorProxy(conn, name ?? conn.Database)); _disposeProxy = false; }
public IPromise<string> Execute(IAsyncConnection conn) { return ExecuteAsync(conn).ToPromise(); }
public static IEnumerable<ItemReference> GetItems(IAsyncConnection conn, string query, int offset) { return GetItems(d => { d.SetConnection(conn); d.Script = query; d.inputEditor.Editor.CaretOffset = offset; }); }
public void PushConnection(IAsyncConnection conn) { _conns.Push(conn); }
public ResultObject(Stream aml, IAsyncConnection conn) { System.Diagnostics.Debug.Print("{0:hh:MM:ss} Document loaded", DateTime.Now); var rope = new Rope<char>(); using (var reader = new StreamReader(aml)) using (var writer = new Editor.RopeWriter(rope)) { IndentXml(reader, writer, out _count); } _amlLength = rope.Length; _conn = conn; _text = new RopeTextSource(rope); System.Diagnostics.Debug.Print("{0:hh:MM:ss} Document rendered", DateTime.Now); }
/// <summary> /// Initializes the stategy object with the specified connection and vault factory /// </summary> /// <param name="conn">The connection.</param> /// <param name="factory">The vault factory.</param> public void Initialize(IAsyncConnection conn, IVaultFactory factory) { _conn = conn; _factory = factory; }
public static async Task <AsyncSavepoint> ConstructAsync(IAsyncConnection parent) => await ConstructAsync(parent, 0);
/// <summary> /// Get the result of executing the specified AML query /// </summary> /// <param name="conn">Connection to execute the query on</param> /// <param name="query">Query to be performed. If parameters are specified, they will be substituted into the query</param> /// <param name="ct">A <see cref="CancellationToken"/> used to cancel the asynchronous operation</param> /// <param name="parameters">Parameters to be injected into the query</param> /// <returns>A read-only result</returns> public static IPromise <IReadOnlyResult> ApplyAsync(this IAsyncConnection conn, Command query, CancellationToken ct, params object[] parameters) { return(ApplyAsyncInt(conn, query, ct, parameters)); }
public void SetConnection(IAsyncConnection conn, string name = null) { if (conn == null) throw new ArgumentNullException("conn"); exploreButton.Visible = true; SetProxy(new ArasEditorProxy(conn, name ?? conn.Database)); _disposeProxy = false; _oldConnType = ConnectionType.Innovator; }
public OutputModelClasses(IAsyncConnection conn) { _conn = conn; }
public TestContext(IAsyncConnection conn) { _conn = conn; }
public virtual void InitializeConnection(IAsyncConnection conn) { _itemTypes.Clear(); if (conn != null) { _conn = conn; _conn.ApplyAsync("<AML><Item action=\"get\" type=\"ItemType\" select=\"name\" /><Item action=\"get\" type=\"RelationshipType\" related_expand=\"0\" select=\"related_id,source_id,relationship_id,name\" /></AML>" , true, false) .Done(r => LoadItemTypes(r.Items())); } }
/// <summary> /// Constructor for the ArasMetadataProvider class /// </summary> private ArasMetadataProvider(IAsyncConnection conn) { _conn = conn; Reset(); }