예제 #1
0
        // --------------------------------------------------
        // 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);
        }
예제 #2
0
        // Create -------------------------------------

        /// <summary>
        /// Creates a connector.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="dataSource">The data source to consider.</param>
        /// <param name="connectorDefinitionUniqueId">The connector definition name to consider.</param>
        /// <param name="log">The log of execution to consider.</param>
        /// <returns>Returns True if the connector has been opened. False otherwise.</returns>
        public static T Open <T>(
            this IBdoScope scope,
            IDatasource dataSource,
            string connectorDefinitionUniqueId,
            IBdoLog log = null)
            where T : class, IBdoConnection
        {
            if (log == null)
            {
                log = new BdoLog();
            }

            if (dataSource == null)
            {
                log.AddError("Data source missing");
            }
            else if (!string.IsNullOrEmpty(connectorDefinitionUniqueId) && dataSource.HasConfiguration(connectorDefinitionUniqueId))
            {
                log.AddError("Connection not defined in data source", description: "No connector is defined in the specified data source.");
            }
            else if (!string.IsNullOrEmpty(connectorDefinitionUniqueId))
            {
                return(scope.Open <T>(dataSource.GetConfiguration(connectorDefinitionUniqueId), log));
            }
            else if (dataSource.Configurations.Count > 0)
            {
                return(scope.Open <T>(dataSource.Configurations[0], log));
            }

            return(default);
예제 #3
0
        // Open -------------------------------------

        /// <summary>
        /// Creates a connector.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="depot">The data source depot to consider.</param>
        /// <param name="dataSourceName">The data source name to consider.</param>
        /// <param name="connectorDefinitionUniqueId">The connector definition name to consider.</param>
        /// <param name="log">The log of execution to consider.</param>
        /// <returns>Returns True if the connector has been opened. False otherwise.</returns>
        public static T Open <T>(
            this IBdoScope scope,
            IBdoDatasourceDepot depot,
            string dataSourceName,
            string connectorDefinitionUniqueId,
            IBdoLog log = null)
            where T : class, IBdoConnection
        {
            if (log == null)
            {
                log = new BdoLog();
            }

            if (depot == null)
            {
                depot = scope?.DataStore?.Get <IBdoDatasourceDepot>();
            }

            if (depot == null)
            {
                log.AddError("Data source depot missing");
            }
            else if (!depot.HasItem(dataSourceName))
            {
                log.AddError("Data source '" + dataSourceName + "' missing in depot");
            }
            else
            {
                return(scope.Open <T>(depot.Get(dataSourceName), connectorDefinitionUniqueId, log));
            }

            return(default);
        // 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);
        }
예제 #5
0
 /// <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;
예제 #6
0
 /// <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;
        /// <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);
        }
예제 #8
0
        // 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);
        }
예제 #9
0
        /// <summary>
        /// Creates a new database query builder.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <typeparam name="T">The query builder type to consider.</typeparam>
        /// <returns>Returns the created query builder.</returns>
        public static T CreateQueryBuilder <T>(IBdoScope scope) where T : DbQueryBuilder, new()
        {
            var builder = new T
            {
                Scope = scope
            };

            return(builder);
        }
 /// <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;
 }
예제 #11
0
 /// <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);
 }
예제 #12
0
        // 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);
        }
예제 #13
0
        /// <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);
        }
예제 #14
0
        /// <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);
        }
예제 #15
0
        /// <summary>
        /// Creates a new service.
        /// </summary>
        /// <param name="scope"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns>Returns the log of the operation.</returns>
        public static T CreateService <T>(
            this IBdoScope scope)
            where T : IBdoConnectedService, new()
        {
            var service = new T();

            service.WithScope(scope);

            return(service);
        }
예제 #16
0
        /// <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);
        }
예제 #17
0
        /// <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);
        }
예제 #18
0
        // Connectors ------------------------------------------------

        /// <summary>
        /// Creates the instance of the specified definition.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="name">The name to consider.</param>
        /// <typeparam name="T">The connector class to return.</typeparam>
        /// <returns>Returns the created connector.</returns>
        public static T CreateConnector <T>(
            this IBdoScope scope,
            string name = null) where T : class, IBdoConnector, new()
        {
            T connector = new T
            {
                Name = name
            };

            connector.WithScope(scope);

            return(connector);
        }
예제 #19
0
        /// <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);
        }
예제 #20
0
        /// <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);
        }
예제 #21
0
        /// <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);
        }
예제 #22
0
        // 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);
        }
예제 #23
0
        /// <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);
        }
예제 #24
0
        /// <summary>
        /// Creates a new connected service.
        /// </summary>
        /// <param name="scope"></param>
        /// <param name="connector"></param>
        /// <param name="log"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns>Returns the log of the operation.</returns>
        public static T CreateConnected <T>(
            this IBdoScope scope,
            IBdoConnector connector,
            IBdoLog log = null)
            where T : IBdoConnectedService, new()
        {
            var service = scope.CreateService <T>();

            var subLog = new BdoLog();

            service.WithConnector(connector);
            subLog.AddEventsTo(log);


            if (subLog.HasErrorsOrExceptions())
            {
                return(default);
        // Entities ------------------------------------------------

        /// <summary>
        /// Creates the instance of the specified definition.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="definitionUniqueId">The unique ID of the definition to consider.</param>
        /// <param name="log">The log to consider.</param>
        public static IBdoEntityConfiguration CreateEntityConfiguration(
            this IBdoScope scope,
            string definitionUniqueId,
            IBdoLog log = null)
        {
            IBdoEntityConfiguration configuration = null;

            IBdoEntityDefinition definition = scope.ExtensionStore.GetItemDefinitionWithUniqueId <BdoEntityDefinition>(definitionUniqueId);

            if (definition == null)
            {
                log?.AddError("Could not retrieve the extension item '" + definitionUniqueId + "' of kind '" + BdoExtensionItemKind.Entity.ToString() + "'");
            }
            else
            {
                configuration = BdoExtensionFactory.CreateEntityConfiguration(definitionUniqueId);
                configuration.Update(definition);
            }

            return(configuration);
        }
예제 #26
0
        /// <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 task.</returns>
        public static BdoTask CreateTask(
            this IBdoScope scope,
            IBdoTaskConfiguration configuration = null,
            string name = null,
            IBdoLog log = null,
            IScriptVariableSet scriptVariableSet = null)
        {
            BdoTask task = null;

            if (scope?.Check(true).HasErrorsOrExceptions() == false)
            {
                if (configuration != null)
                {
                    // we get the task class reference

                    IBdoTaskDefinition definition = scope.ExtensionStore.GetItemDefinitionWithUniqueId <IBdoTaskDefinition>(configuration?.DefinitionUniqueId);
                    if (definition == null)
                    {
                        log?.AddError("Could not retrieve the extension task '" + configuration.DefinitionUniqueId + "' definition");
                    }
                    else
                    {
                        // we intantiate the task

                        AssemblyHelper.CreateInstance(definition.RuntimeType, out object item).AddEventsTo(log);

                        if (!log.HasErrorsOrExceptions())
                        {
                            task      = item as BdoTask;
                            task.Name = name ?? configuration?.Name;
                            task.UpdateFromElementSet <TaskInputAttribute>(configuration, scope, scriptVariableSet);
                            task.UpdateFromElementSet <TaskOutputAttribute>(configuration, scope, scriptVariableSet);
                        }
                    }
                }
            }

            return(task);
        }
예제 #27
0
        /// <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 carrier.</returns>
        public static BdoCarrier CreateCarrier(
            this IBdoScope scope,
            IBdoCarrierConfiguration configuration = null,
            string name = null,
            IBdoLog log = null,
            IScriptVariableSet scriptVariableSet = null)
        {
            BdoCarrier carrier = null;

            if (scope?.Check(true).HasErrorsOrExceptions() == false)
            {
                if (configuration != null)
                {
                    // we get the carrier class reference

                    IBdoCarrierDefinition definition = scope.ExtensionStore.GetItemDefinitionWithUniqueId <IBdoCarrierDefinition>(configuration.DefinitionUniqueId);
                    if (definition == null)
                    {
                        log?.AddError("Could not retrieve the extension carrier '" + configuration.DefinitionUniqueId + "' definition");
                    }
                    else
                    {
                        // we intantiate the carrier

                        AssemblyHelper.CreateInstance(definition.RuntimeType, out object item).AddEventsTo(log);

                        if (item != null)
                        {
                            carrier      = item as BdoCarrier;
                            carrier.Name = name ?? configuration?.Name;
                            carrier.UpdateFromElementSet <DetailPropertyAttribute>(configuration, scope, scriptVariableSet);
                        }
                    }
                }
            }

            return(carrier);
        }
예제 #28
0
        /// <summary>
        /// Gets the target objects from the specified source.
        /// </summary>
        /// <param name="sourceElement">The source element to consider.</param>
        /// <param name="pathDetail">The path detail 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 target objects.</returns>
        public static List <object> Get(
            DataElement sourceElement            = null,
            DataElementSet pathDetail            = null,
            IBdoScope scope                      = null,
            IScriptVariableSet scriptVariableSet = null,
            IBdoLog log = null)
        {
            List <object> objects = new List <object>();

            if (sourceElement == null)
            {
                log?.AddError("Source element missing");
            }
            else
            {
                if (!(sourceElement.Items[0] is RepositoryFile file))
                {
                    log?.AddError("Source file missing");
                }
            }

            return(objects);
        }
예제 #29
0
        // --------------------------------------------------
        // ACCESSORS
        // --------------------------------------------------

        #region Accessors

        /// <summary>
        /// Gets the items from the source of this instance and update the target items.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="scriptVariableSet">The script variable set to use.</param>
        /// <param name="log">The log to consider.</param>
        /// <returns>Returns the retrieved items.</returns>
        public object Get(
            IBdoScope scope = null,
            IScriptVariableSet scriptVariableSet = null,
            IBdoLog log = null)
        {
            //SetDefinition((scope== null ? null : scope.BdoExtension));
            //log.AddEvents(Check());

            List <object> dataItems = new List <object>();

            //parameterDetail = (parameterDetail ?? new DataElementSet());

            //if (!log.HasErrorsOrExceptions())
            //    if (Definition == null)
            //        log.AddError(title: "Definition not found");
            //    else if (Definition.RuntimeFunction_Get == null)
            //        log.AddError(title: "Calling function missing");
            //    else if (aSourceElement == null)
            //        log.AddError(title: "Source element missing");
            //    else
            //        dataItems.AddRange(Definition.RuntimeFunction_Get(aSourceElement, parameterDetail, scope, scriptVariableSet, log));

            return(dataItems);
        }
예제 #30
0
        // --------------------------------------------------
        // 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 (dataElement == null)
            {
                log.AddError("Element missing");
            }
            else if (dataElement.Items.Count == 0 || dataElement.Items[0] == null)
            {
                log.AddError("Item required").ResultCode = "ERROR_ITEMREQUIRED:" + dataElement.Key();
            }
            else if (dataElement.ValueType.IsScalar() && dataElement.Items.Count == 1 && string.IsNullOrEmpty(dataElement.GetValue().ToNotNullString()))
            {
                log.AddError("Item required").ResultCode = "ERROR_ITEMREQUIRED:" + dataElement.Key();
            }

            return(log);
        }