Beispiel #1
0
        /// <summary>
        /// Create custom db command.
        /// </summary>
        /// <param name="databaseName">Configured database name.</param>
        /// <param name="commandText">Command text.</param>
        /// <returns>Db command.</returns>
        public IDataCommand CreateCustomDBCommand(string databaseName, string commandText)
        {
            DataCommand result = null;

            if (string.IsNullOrWhiteSpace(commandText))
            {
                throw new ArgumentNullException("Custom command text is null or empty.");
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(databaseName))
                {
                    var databaseUnit = this._dBConfigRepository.GetDataBase(databaseName);
                    if (databaseUnit != null)
                    {
                        var commandUnit = new DataCommandUnit();
                        commandUnit.CommandType = "Text";
                        commandUnit.CommandText = commandText;
                        result = new DataCommand(databaseUnit, commandUnit);
                    }
                    else
                    {
                        throw new ArgumentNullException($"Database \"{databaseName}\" not found.");
                    }
                }
                else
                {
                    throw new ArgumentNullException("The database name is null or empty.");
                }
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Get data command.
        /// </summary>
        /// <param name="dataCommandName">Data command name.</param>
        /// <returns>Data command descriptor.</returns>
        public DataCommandUnit GetDataCommand(string dataCommandName)
        {
            DataCommandUnit result          = null;
            var             dataCommandList = this.GetDataCommandConfigList();

            if (!dataCommandList.IsNullOrEmpty())
            {
                foreach (var dataCommand in dataCommandList)
                {
                    var dataCommandConfig = this._configManager.GetConfiguration <DataCommandsConfig>("Data/" + dataCommand);
                    if (dataCommandConfig != null && !dataCommandConfig.DataCommandCollection.IsNullOrEmpty())
                    {
                        result = dataCommandConfig.DataCommandCollection.Find(command => command.Name.Equals(dataCommandName, StringComparison.OrdinalIgnoreCase));
                        if (result != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Get data command.
        /// </summary>
        /// <param name="dataCommandName">Data command name.</param>
        /// <returns>Data command descriptor.</returns>
        public DataCommandUnit GetDataCommand(string dataCommandName)
        {
            DataCommandUnit result          = null;
            var             dataCommandList = this.GetDataCommandConfigList();

            if (!dataCommandList.IsNullOrEmpty())
            {
                var systemName = this.GetSystemName();
                foreach (var dataCommand in dataCommandList)
                {
                    var dataCommandConfig = this._configManager.GetConfigFromService <DataCommandsConfig>(dataCommand, systemName, NodeDataType.Xml);
                    if (dataCommandConfig != null && !dataCommandConfig.DataCommandCollection.IsNullOrEmpty())
                    {
                        result = dataCommandConfig.DataCommandCollection.Find(command => command.Name.Equals(dataCommandName, StringComparison.OrdinalIgnoreCase));
                        if (result != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the DataCommand class.
 /// </summary>
 /// <param name="database">Database descriptor.</param>
 /// <param name="dataCommand">Data command descriptor.</param>
 public DataCommand(DataBaseUnit database, DataCommandUnit dataCommand)
 {
     this.databaseConfig    = database;
     this.dataCommandConfig = dataCommand;
 }