//------------------------------------------ // EXECUTION //----------------------------------------- #region Execution /// <summary> /// Executes this instance with result. /// </summary> /// <param name="resultString">The result to get.</param> /// <param name="appScope">The application scope to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <param name="runtimeMode">The runtime mode to consider.</param> /// <returns>The log of execution log.</returns> public override ILog ExecuteWithResult( out string resultString, IAppScope appScope = null, IScriptVariableSet scriptVariableSet = null, RuntimeMode runtimeMode = RuntimeMode.Normal) { resultString = ""; ILog log = appScope.Check(true); if (this.Reference == null) { log.AddWarning( title: "Reference missing", description: "No reference defined in command '" + this.Key() + "'."); } else if (!log.HasErrorsOrExceptions() && this.Reference != null) { scriptVariableSet.SetValue("currentItem", this.Reference.SourceElement.GetObject()); scriptVariableSet.SetValue("currentElement", this.Reference.SourceElement); resultString = this.Reference.Get(appScope, scriptVariableSet, log)?.ToString(); } return(log); }
/// <summary> /// Evaluate this instance. /// </summary> /// <param name="condition">The condition to consider.</param> /// <param name="scriptInterpreter">Script interpreter.</param> /// <param name="scriptVariableSet">The script variable set used to evaluate.</param> /// <returns>True if this instance is true.</returns> private static bool Evaluate( this AdvancedCondition condition, IBdoScriptInterpreter scriptInterpreter, IScriptVariableSet scriptVariableSet) { if (condition == null) { return(false); } bool isAllConditionSatisfied = true; foreach (Condition subCondition in condition.Conditions) { switch (condition.Kind) { case AdvancedConditionKind.And: isAllConditionSatisfied &= subCondition.Evaluate(scriptInterpreter, scriptVariableSet); break; case AdvancedConditionKind.Or: isAllConditionSatisfied |= subCondition.Evaluate(scriptInterpreter, scriptVariableSet); break; default: break; } } return(isAllConditionSatisfied == condition.TrueValue); }
// ------------------------------------------ // ACCESSORS // ------------------------------------------ #region Accessors // SQL commands /// <summary> /// Gets the SQL text of the specified query. /// </summary> /// <param name="query">The query to consider.</param> /// <param name="parameterMode">Indicates whether parameters are replaced.</param> /// <param name="parameterSet">The parameter set to consider.</param> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <param name="log">The log to consider.</param> /// <returns>Returns the SQL text of the specified query.</returns> public string CreateCommandText( IDbQuery query, DbQueryParameterMode parameterMode = DbQueryParameterMode.ValueInjected, IDataElementSet parameterSet = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { string sqlText = ""; if (QueryBuilder == null) { log?.AddError("Data builder missing"); } else { var subLog = new BdoLog(); sqlText = QueryBuilder.BuildQuery(query, parameterMode, parameterSet, scriptVariableSet, subLog); log?.AddEvents(subLog); if (subLog.HasErrorsOrExceptions()) { return(StringHelper.__NoneString); } } return(sqlText); }
/// <summary> /// Creates the instance of the specified definition. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="configuration">The configuration to consider.</param> /// <param name="name">The name to consider.</param> /// <param name="log">The log to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <typeparam name="T">The connector class to return.</typeparam> /// <returns>Returns the created connector.</returns> public static T CreateDbConnector <T>( this IBdoScope scope, IBdoConnectorConfiguration configuration, string name = null, IBdoLog log = null, IScriptVariableSet scriptVariableSet = null) where T : class, IBdoDbConnector, new() => scope.CreateConnector <T>(configuration, name, log, scriptVariableSet).WithScope(scope) as T;
// -------------------------------------------------- // EXECUTION // -------------------------------------------------- #region Execution /// <summary> /// Executes customly this instance. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <param name="item">The item to use.</param> /// <param name="dataElement">The element to use.</param> /// <param name="objects">The objects to use.</param> /// <returns>The log of check log.</returns> protected override IBdoLog CustomExecute( IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, Object item = null, IDataElement dataElement = null, params object[] objects) { var log = new BdoLog(); //if (item!=null && ParameterDetail!=null) //{ // String aFormat = (ParameterDetail.GetElementItem() as string ?? string.Empty); // String aString = ((item as string) ?? string.Empty); // if (!string.IsNullOrEmpty(aFormat)) // { // if (!String.Format(aString, aFormat).KeyEquals(aString)) // { // log.AddError("Bad format").ResultCode = "ERROR_FORMAT:" + (dataElement != null ? dataElement.Key() : string.Empty); // } // } //} return(log); }
// Load ------------------------------------------------ /// <summary> /// Creates the instance of the specified definition. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="xmlstring">The XML string to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The log to consider.</param> public static ITBdoExtensionItemConfiguration <T> LoadConfiguration <T>( this IBdoScope scope, string xmlstring, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) where T : IBdoExtensionItemDefinition { BdoExtensionItemKind extensionItemKind = typeof(T).GetExtensionItemKind(); ITBdoExtensionItemConfiguration <T> configuration = default; switch (extensionItemKind) { case BdoExtensionItemKind.Carrier: configuration = XmlHelper.LoadFromString <BdoCarrierConfiguration>(xmlstring, scope, scriptVariableSet, log) as ITBdoExtensionItemConfiguration <T>; break; case BdoExtensionItemKind.Connector: configuration = XmlHelper.LoadFromString <BdoConnectorConfiguration>(xmlstring, scope, scriptVariableSet, log) as ITBdoExtensionItemConfiguration <T>; break; case BdoExtensionItemKind.Entity: configuration = XmlHelper.LoadFromString <BdoEntityConfiguration>(xmlstring, scope, scriptVariableSet, log) as ITBdoExtensionItemConfiguration <T>; break; case BdoExtensionItemKind.Format: configuration = XmlHelper.LoadFromString <BdoFormatConfiguration>(xmlstring, scope, scriptVariableSet, log) as ITBdoExtensionItemConfiguration <T>; break; case BdoExtensionItemKind.Task: configuration = XmlHelper.LoadFromString <BdoTaskConfiguration>(xmlstring, scope, scriptVariableSet, log) as ITBdoExtensionItemConfiguration <T>; break; } return(configuration); }
// ------------------------------------------ // EVALUATION // ------------------------------------------ #region Evaluation // Expression /// <summary> /// Evaluates the specified data expression. /// </summary> /// <param name="expression">The data expression to consider.</param> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <param name="log">The log to consider.</param> /// <returns>Literal or script value according to the specified default mode.</returns> public object Evaluate( IDataExpression expression, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { int index; int scriptwordBeginIndex; var script = expression?.Text ?? string.Empty; switch (expression?.Kind) { case DataExpressionKind.Auto: if (!string.IsNullOrEmpty(script)) { var resultScript = script; scriptwordBeginIndex = script.IndexOf("{{"); while (scriptwordBeginIndex > -1) { index = script.IndexOfNextString("}}", scriptwordBeginIndex + 1); if ((scriptwordBeginIndex > -1) && (index > -1)) { var subScript = script.Substring(2)[0..^ 2];
/// <summary> /// Instantiates a new instance of Configuration class from a xml file. /// </summary> /// <param name="filePath">The file path to consider.</param> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The log to consider.</param> /// <param name="xmlSchemaSet">The XML schema set to consider for checking.</param> /// <param name="mustFileExist">Indicates whether the file must exist.</param> /// <param name="isRuntimeUpdated">Indicates whether the runtime is updated.</param> /// <returns>The Xml operation project defined in the Xml file.</returns> public static T Load <T>( string filePath, IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null, XmlSchemaSet xmlSchemaSet = null, bool mustFileExist = true, bool isRuntimeUpdated = true) where T : class, IBdoBaseConfiguration, new() { T unionConfiguration = new T(); if (XmlHelper.Load <T>(filePath, scope, scriptVariableSet, log, xmlSchemaSet, mustFileExist, isRuntimeUpdated) is T topConfiguration) { unionConfiguration.Update(topConfiguration); if (topConfiguration is BdoUsableConfiguration topUsableConfiguration) { foreach (string usingFilePath in topUsableConfiguration.UsingFilePaths) { string completeUsingFilePath = (usingFilePath.Contains(":") ? usingFilePath : Path.GetDirectoryName(filePath).EndingWith(@"\") + usingFilePath).ToPath(); if (Load <T>(completeUsingFilePath, scope, scriptVariableSet, log, xmlSchemaSet, mustFileExist) is T usingConfiguration) { unionConfiguration.Update(usingConfiguration); } } } } unionConfiguration.CurrentFilePath = filePath; return(unionConfiguration); }
/// <summary> /// Creates the instance of the specified definition. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="configuration">The configuration to consider.</param> /// <param name="name">The name to consider.</param> /// <param name="log">The log to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <returns>Returns the created connector.</returns> public static BdoDbConnector CreateDbConnector( this IBdoScope scope, IBdoConnectorConfiguration configuration = null, string name = null, IBdoLog log = null, IScriptVariableSet scriptVariableSet = null) => scope.CreateConnector(configuration, name, log, scriptVariableSet).WithScope(scope) as BdoDbConnector;
//------------------------------------------ // EXECUTION //----------------------------------------- #region Execution /// <summary> /// Executes this instance with result. /// </summary> /// <param name="resultString">The result to get.</param> /// <param name="appScope">The application scope to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <param name="runtimeMode">The runtime mode to consider.</param> /// <returns>The log of execution log.</returns> public override ILog ExecuteWithResult( out string resultString, IAppScope appScope = null, IScriptVariableSet scriptVariableSet = null, RuntimeMode runtimeMode = RuntimeMode.Normal) { resultString = ""; ILog log = appScope.Check(false); if (!log.HasErrorsOrExceptions()) { if (string.IsNullOrEmpty(this._script)) { log.AddWarning( title: "Script missing", description: "No script defined in command '" + this.Key() + "'."); } else { appScope.ScriptInterpreter.Evaluate(this._script, out resultString, scriptVariableSet, log); } } return(log); }
// GroupBy ------------------------------------- private string GetSqlText_GroupByClause( IDbQueryGroupByClause clause, IDbSingleQuery query = null, IDataElementSet parameterSet = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { string queryString = ""; if (clause != null) { if (clause?.Expression != null) { string expression = Scope?.Interpreter.Evaluate(clause.Expression, scriptVariableSet, log)?.ToString() ?? ""; queryString += expression; } else if (clause.Fields?.Count > 0) { foreach (DbField field in clause.Fields) { if (!string.IsNullOrEmpty(queryString)) { queryString += ", "; } queryString += GetSqlText_Field( field, query, parameterSet, DbQueryFieldMode.CompleteNameOrValueAsAlias, query.DataModule, query.Schema, query.DataTable, scriptVariableSet: scriptVariableSet, log: log); } } queryString = queryString.If(!string.IsNullOrEmpty(queryString), " group by " + queryString); } return(queryString); }
/// <summary> /// Sets the database query builder in the specified script variable set. /// </summary> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <param name="queryBuilder">The query builder to consider.</param> /// <returns></returns> public static IScriptVariableSet SetDbBuilder( this IScriptVariableSet scriptVariableSet, DbQueryBuilder queryBuilder) { scriptVariableSet?.SetValue(__DbBuilder, queryBuilder); return(scriptVariableSet); }
// Deserialiaze ---------------------------- /// <summary> /// Loads a data item from the specified file path. /// </summary> /// <param name="filePath">The path of the Xml file to load.</param> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The output log of the method.</param> /// <param name="xmlSchemaSet">The XML schema set to consider for checking.</param> /// <param name="mustFileExist">Indicates whether the file must exist.</param> /// <param name="isRuntimeUpdated">Indicates whether it is updated in runtime.</param> /// <returns>The loaded log.</returns> /// <remarks>If the XML schema set is null then the schema is not checked.</remarks> public static T Load <T>( String filePath, IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null, XmlSchemaSet xmlSchemaSet = null, bool mustFileExist = true, bool isRuntimeUpdated = true) where T : class, IDataItem { T dataItem = default; StreamReader streamReader = null; if (!File.Exists(filePath)) { if (mustFileExist) { log?.AddError("File not found ('" + filePath + "'). Could not load '" + typeof(T).Name + "' object"); } } else { try { IBdoLog checkLog = new BdoLog(); if (xmlSchemaSet != null) { XDocument xDocument = XDocument.Load(filePath); xDocument.Validate(xmlSchemaSet, (o, e) => checkLog.AddError("File not valid ('" + filePath + "'). Could not load '" + typeof(T).Name + "' object")); log?.AddEvents(checkLog); } if (!checkLog.HasErrorsOrExceptions()) { // then we load XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); streamReader = new StreamReader(filePath); dataItem = xmlSerializer.Deserialize(XmlReader.Create(streamReader)) as T; if (isRuntimeUpdated) { dataItem?.UpdateRuntimeInfo(scope, scriptVariableSet, log); } } } catch (Exception ex) { log?.AddException(ex); } finally { streamReader?.Close(); } } return(dataItem); }
/// <summary> /// Initializes a new instance of the BdoScriptwordFunctionScope class. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <param name="scriptword">The script word to consider.</param> public BdoScriptwordFunctionScope( IBdoScope scope, IScriptVariableSet scriptVariableSet, IBdoScriptword scriptword) { Scope = scope; ScriptVariableSet = scriptVariableSet; Scriptword = scriptword; }
/// <summary> /// Creates the instance of the specified definition. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="configuration">The configuration to consider.</param> /// <param name="name">The name to consider.</param> /// <param name="log">The log to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <typeparam name="T">The connector class to return.</typeparam> /// <returns>Returns the created connector.</returns> public static T CreateConnector <T>( this IBdoScope scope, IBdoConnectorConfiguration configuration, string name = null, IBdoLog log = null, IScriptVariableSet scriptVariableSet = null) where T : class, IBdoConnector, new() { return(scope.CreateConnector(configuration, name, log, scriptVariableSet) as T); }
// Carriers ------------------------------------------------ /// <summary> /// Creates the instance of the specified definition. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="configuration">The configuration to consider.</param> /// <param name="name">The name to consider.</param> /// <param name="log">The log to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <typeparam name="T">The carrier class to return.</typeparam> /// <returns>Returns the created carrier.</returns> public static T CreateCarrier <T>( this IBdoScope scope, IBdoCarrierConfiguration configuration = null, string name = null, IBdoLog log = null, IScriptVariableSet scriptVariableSet = null) where T : BdoCarrier { return(scope.CreateCarrier(configuration, name, log, scriptVariableSet) as T); }
/// <summary> /// Returns the item object of this instance. /// </summary> /// <param name="elementKey">The element key to consider.</param> /// <param name="log">The log to populate.</param> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <returns>Returns the items of this instance.</returns> public virtual T GetValue <T>( string elementKey, IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { var aObject = GetValue(elementKey, scope, scriptVariableSet, log) ?? default(T); return((T)aObject); }
/// <summary> /// Updates information for runtime. /// </summary> /// <param name="scope"></param> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <param name="log"></param> public override void UpdateRuntimeInfo(IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { WithItems(Carriers?.Select(p => { p.UpdateRuntimeInfo(scope, scriptVariableSet, log); return(p); }).ToArray()); base.UpdateRuntimeInfo(scope, scriptVariableSet, log); }
// OrderBy ------------------------------------- private string GetSqlText_OrderByClause( IDbQueryOrderByClause clause, IDbSingleQuery query = null, IDataElementSet parameterSet = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { string queryString = ""; if (clause != null) { if (clause?.Expression != null) { string expression = Scope?.Interpreter.Evaluate(clause.Expression, scriptVariableSet, log)?.ToString() ?? ""; queryString += expression; } else if (clause.Statements?.Count > 0) { foreach (var statement in clause.Statements) { if (!string.IsNullOrEmpty(queryString)) { queryString += ", "; } if (statement.Sorting == DataSortingModes.Random) { queryString += "newid()"; } else { queryString += GetSqlText_Field( statement.Field, query, parameterSet, DbQueryFieldMode.OnlyName, scriptVariableSet: scriptVariableSet, log: log); switch (statement.Sorting) { case DataSortingModes.Ascending: queryString += " asc"; break; case DataSortingModes.Descending: queryString += " desc"; break; } } } } queryString = queryString.If(!string.IsNullOrEmpty(queryString), " order by " + queryString); } return(queryString); }
/// <summary> /// Posts the selected targets to the source. /// </summary> /// <param name="targetObject">The target object to consider.</param> /// <param name="sourceDataElement">The source data element to consider.</param> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <param name="log">The log to consider.</param> /// <returns>Returns the source object.</returns> public static List <object> Post( object targetObject, ref DataElement sourceDataElement, IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { List <object> objects = new List <object>(); return(objects); }
/// <summary> /// Updates information for runtime. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The log to update.</param> public override void UpdateRuntimeInfo(IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { if (Configurations != null) { foreach (IBdoConnectorConfiguration configuration in Configurations) { configuration.UpdateRuntimeInfo(scope, scriptVariableSet, log); } } base.UpdateRuntimeInfo(scope, scriptVariableSet, log); }
private string GetSqlText_Table( string tableDataModule, string tableSchema, string tableName, string tableAlias, IDbQuery query = null, IDataElementSet parameterSet = null, DbQueryFieldMode viewMode = DbQueryFieldMode.CompleteName, string defaultDataModule = null, string defaultSchema = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { string queryString = ""; if ((viewMode == DbQueryFieldMode.CompleteName) && (!string.IsNullOrEmpty(tableAlias))) { queryString += GetSqlText_Table(tableAlias); } else if (!string.IsNullOrEmpty(tableName)) { if ((viewMode == DbQueryFieldMode.CompleteName) || (viewMode == DbQueryFieldMode.CompleteNameOrValueAsAlias)) { if (string.IsNullOrEmpty(tableDataModule)) { tableDataModule = defaultDataModule; } if (!string.IsNullOrEmpty(tableDataModule)) { tableDataModule = GetDatabaseName(tableDataModule); } if (string.IsNullOrEmpty(tableSchema)) { tableSchema = defaultSchema; } string script = DbFluent.Table(tableName, tableSchema, tableDataModule); queryString += Scope?.Interpreter.Evaluate(script, DataExpressionKind.Script, scriptVariableSet, log) ?? String.Empty; } else { queryString += GetSqlText_Table(tableName); } if (viewMode == DbQueryFieldMode.CompleteNameOrValueAsAlias) { queryString = queryString.ConcatenateIf(!string.IsNullOrEmpty(tableAlias), " as " + GetSqlText_Table(tableAlias)); } } return(queryString); }
/// <summary> /// Updates information for runtime. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The log to update.</param> public override void UpdateRuntimeInfo(IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { foreach (ApplicationCredential applicationCredential in Credentials) { applicationCredential.UpdateRuntimeInfo(scope, scriptVariableSet, log); } foreach (Datasource dataSource in Datasources) { dataSource.UpdateRuntimeInfo(scope, scriptVariableSet, log); } base.UpdateRuntimeInfo(scope, scriptVariableSet, log); }
/// <summary> /// Loads the data item from the specified file path. /// </summary> /// <typeparam name="T">The data item class to consider.</typeparam> /// <param name="xmlString">The Xml string to load.</param> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The output log of the load method.</param> /// <param name="xmlSchemaSet">The XML schema set to consider for checking.</param> /// <returns>The loaded log.</returns> /// <remarks>If the XML schema set is null then the schema is not checked.</remarks> public static T LoadFromString <T>( String xmlString, IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null, XmlSchemaSet xmlSchemaSet = null) where T : DataItem { T dataItem = null; if (xmlString != null) { StreamReader streamReader = null; try { IBdoLog checkLog = new BdoLog(); if (xmlSchemaSet != null) { XDocument xDocument = XDocument.Parse(xmlString); xDocument.Validate(xmlSchemaSet, (o, e) => { log?.AddError( title: "Xml string not valid", description: e.Message); }); log?.AddEvents(checkLog); } if (!checkLog.HasErrorsOrExceptions()) { // then we load XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); StringReader stringReader = new StringReader(xmlString); dataItem = xmlSerializer.Deserialize(XmlReader.Create(stringReader)) as T; dataItem?.UpdateRuntimeInfo(scope, scriptVariableSet, log); } } catch (Exception ex) { log?.AddException(ex); } finally { streamReader?.Close(); } } return(dataItem); }
/// <summary> /// Updates information for runtime. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The log to update.</param> public override void UpdateRuntimeInfo( IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { if (PathDetail != null) { foreach (DataElement dataElement in PathDetail.Items) { dataElement.UpdateRuntimeInfo(scope, scriptVariableSet, log); } } SourceElement?.UpdateRuntimeInfo(scope, scriptVariableSet, log); }
// Element items ------------------------ /// <summary> /// Returns the item object of this instance. /// </summary> /// <param name="elementKey">The element key to consider.</param> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The script variable set to use.</param> /// <param name="log">The log to populate.</param> /// <returns>Returns the items of this instance.</returns> public virtual object GetValue( string elementKey, IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { IDataElement element = Get(elementKey); if (element != null) { return(element.GetValue(scope, scriptVariableSet, log)); } return(null); }
private string GetSqlText_Table( string tableDataModule, string tableSchema, string tableName, string tableAlias, DbQueryTableMode mode = DbQueryTableMode.CompleteName, string defaultDataModule = null, string defaultSchema = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { return(GetSqlText_Table( DbFluent.Table(tableName, tableSchema, tableDataModule).WithAlias(tableAlias), null, null, mode, defaultDataModule, defaultSchema, scriptVariableSet, log)); }
// -------------------------------------------------- // ACCESSORS // -------------------------------------------------- #region Accessors /// <summary> /// Gets the value of this instance. /// </summary> /// <param name="scriptInterpreter">The script interpreter to consider.</param> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <returns>Returns the value of this instance.</returns> public bool GetValue(IBdoScriptInterpreter scriptInterpreter = null, IScriptVariableSet scriptVariableSet = null) { string valueString = ValueScript?.Trim(); if (valueString?.Trim().Equals("true", StringComparison.OrdinalIgnoreCase) == true) { return(true); } if (scriptInterpreter != null) { return(scriptInterpreter.Evaluate(valueString, DataExpressionKind.Script, scriptVariableSet) as bool? == true); } return(false); }
/// <summary> /// Updates information for runtime. /// </summary> /// <param name="scope">The scope to consider.</param> /// <param name="scriptVariableSet">The set of script variables to consider.</param> /// <param name="log">The log to update.</param> public override void UpdateRuntimeInfo(IBdoScope scope = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { foreach (DataElementSet elementSet in Objects) { AssemblyHelper.CreateInstance(ClassFullName, out object item).AddEventsTo(log); if (!log.HasErrorsOrExceptions() && (item is DataItem)) { elementSet.UpdateRuntimeInfo(scope, scriptVariableSet, log); item.UpdateFromElementSet <DetailPropertyAttribute>(elementSet, scope, scriptVariableSet); } Add(item); } base.UpdateRuntimeInfo(scope, scriptVariableSet, log); }
/// <summary> /// Builds the SQL text of the specified merge query. /// </summary> /// <param name="query">The query to consider.</param> /// <param name="parameterSet">The parameter set to consider.</param> /// <param name="scriptVariableSet">The script variable set to consider.</param> /// <param name="log">The log to consider.</param> /// <returns>Returns the built query text.</returns> protected override string GetSqlText_Query( IDbCompositeQuery query, IDataElementSet parameterSet = null, IScriptVariableSet scriptVariableSet = null, IBdoLog log = null) { var queryString = ""; // we build the query switch (query.Kind) { case DbQueryKind.Insert: break; // Upsert case DbQueryKind.Upsert: { //queryString = "merge "; //queryString += GetSqlText_Table( // query.DataModule, query.Schema, query.DataTable, query.DataTableAlias, // DbFieldViewMode.CompleteNameAsAlias, query.DataModule, query.Schema, // scriptVariableSet: scriptVariableSet, log: log); //if (query.SelectJoinStatement != null) //{ // query.SelectJoinStatement.Kind = DbQueryJoinKind.Left; // var subQueryString = GetSqlText_Join(query.SelectJoinStatement, query, parameterSet, scriptVariableSet, log); // subQueryString = subQueryString.Substring("left join ".Length); // queryString += subQueryString; //} //queryString += " when matched "; //queryString += BuildQuery(query.MatchedQuery, DbQueryParameterMode.Scripted, parameterSet, scriptVariableSet, log); //UpdateParameterSet(query.ParameterSet, query.MatchedQuery); //queryString += " when not matched "; //queryString += BuildQuery(query.NotMatchedQuery, DbQueryParameterMode.Scripted, parameterSet, scriptVariableSet, log); //queryString += ";"; //UpdateParameterSet(query.ParameterSet, query.NotMatchedQuery); } break; } return(queryString); }