Пример #1
0
        public async Task <object> ExecuteCommand(DataCommand dataCommand, List <ScreenDataCommandParameter> parameters, string commandText)
        {
            object retVal = null;


            try
            {
                DataCommandPreProcessorArgs preArgs = ProcessDataCommandPreProcessor(dataCommand, parameters);
                bool SkipExecution = false;

                if (preArgs != null)
                {
                    SkipExecution = preArgs.SkipExecution;

                    if (preArgs.Data != null)
                    {
                        retVal = preArgs.Data;
                    }
                }

                if (!SkipExecution)
                {
                    DataConnection connection = dataCommand.GetDataConnection();
                    if (connection == null)
                    {
                        throw new Exception(String.Format("Data Connection could not be found in configuration - {0}", dataCommand.DataConnection));
                    }
                    IDataCommandProvider dataSource = GetProvider(connection);
                    retVal = await dataSource.ExecuteCommand(
                        connection,
                        dataCommand,
                        parameters,
                        commandText,
                        success =>
                    {
                        DataCommandPostProcessorArgs postArgs = ProcessDataCommandPostProcessor(dataCommand, parameters, retVal);
                        if (postArgs != null)
                        {
                            retVal = postArgs.Data;
                        }
                    },
                        error => {
                        throw error;
                    });
                }
            }
            catch (Exception ex)
            {
                Common.LogException(ex);
                throw ex;
            }

            return(retVal);
        }
Пример #2
0
        public async Task <XDocument> GetXmlData(DataCommand dataCommand, List <ScreenDataCommandParameter> parameters, string commandText)
        {
            XDocument retVal = null;

            DataCommandPreProcessorArgs preArgs = ProcessDataCommandPreProcessor(dataCommand, parameters);
            bool SkipExecution = false;

            if (preArgs != null)
            {
                SkipExecution = preArgs.SkipExecution;

                if (preArgs.Data != null)
                {
                    if (preArgs.Data is XDocument)
                    {
                        retVal = (XDocument)preArgs.Data;
                    }
                }
            }

            if (!SkipExecution)
            {
                DataConnection connection = dataCommand.GetDataConnection();
                if (connection == null)
                {
                    throw new Exception(String.Format("Data Connection could not be found in configuration - {0}", dataCommand.DataConnection));
                }
                IDataCommandProvider DataSource = GetProvider(connection);
                retVal = await DataSource.GetXmlData(
                    connection,
                    dataCommand,
                    parameters,
                    commandText,
                    success =>
                {
                    DataCommandPostProcessorArgs postArgs = ProcessDataCommandPostProcessor(dataCommand, parameters, retVal);
                    if (postArgs != null)
                    {
                        if (postArgs.Data is XDocument)
                        {
                            retVal = (XDocument)postArgs.Data;
                        }
                    }
                },
                    error => {
                    throw error;
                });
            }



            return(retVal);
        }
Пример #3
0
        public object ExecuteCommand(DbTransaction tran, DataCommand dataCommand, List <ScreenDataCommandParameter> parameters, string commandText)
        {
            DataConnection connection = dataCommand.GetDataConnection();

            return(ExecuteCommand(tran, connection, dataCommand, parameters, commandText));
        }
Пример #4
0
        public XmlDocument GetXmlData(DbTransaction tran, DataCommand dataCommand, List <ScreenDataCommandParameter> parameters, string commandText)
        {
            DataConnection connection = dataCommand.GetDataConnection();

            return(GetXmlData(tran, connection, dataCommand, parameters, commandText));
        }
Пример #5
0
        public Task <DataTable> GetData(DataCommand dataCommand, List <ScreenDataCommandParameter> parameters, string commandText)
        {
            TaskCompletionSource <DataTable> taskDT = new TaskCompletionSource <DataTable>();



            DataCommandPreProcessorArgs preArgs = ProcessDataCommandPreProcessor(dataCommand, parameters);
            bool SkipExecution = false;

            if (preArgs != null)
            {
                SkipExecution = preArgs.SkipExecution;
            }

            if (SkipExecution)
            {
                if (preArgs.Data != null)
                {
                    if (preArgs.Data is DataTable)
                    {
                        taskDT.SetResult((DataTable)preArgs.Data);
                    }
                }
            }
            else
            {
                DataConnection connection = dataCommand.GetDataConnection();
                if (connection == null)
                {
                    taskDT.SetException(new Exception(String.Format("Data Connection could not be found in configuration - {0}", dataCommand.DataConnection)));
                }
                IDataCommandProvider dataSource = GetProvider(connection);

                var result = dataSource.GetData(
                    connection,
                    dataCommand,
                    parameters,
                    commandText,
                    success =>
                {
                    DataCommandPostProcessorArgs postArgs = ProcessDataCommandPostProcessor(dataCommand, parameters, success);
                    if (postArgs != null)
                    {
                        if (postArgs.Data is DataTable)
                        {
                            taskDT.SetResult((DataTable)postArgs.Data);
                        }
                        else
                        {
                            taskDT.SetResult(success);
                        }
                    }
                    else
                    {
                        taskDT.SetResult(success);
                    }
                },
                    error => {
                    taskDT.SetException(error);
                });
            }

            return(taskDT.Task);
        }