Example #1
0
        public virtual Recordset FetchRecordset(DbService dbService, bool addFields)
        {
            if (dbService == null)
            {
                throw new ArgumentNullException("dbService");
            }
            var source = dbService.Source as DbSource;

            if (source != null)
            {
                switch (source.ServerType)
                {
                case enSourceType.SqlDatabase:
                {
                    var broker            = CreateDatabaseBroker();
                    var outputDescription = broker.TestService(dbService);

                    if (outputDescription == null || outputDescription.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                    {
                        throw new Exception("Error retrieving shape from service output.");
                    }

                    dbService.Recordset.Name = dbService.Recordset.Name.Replace(".", "_");
                    dbService.Recordset.Fields.Clear();

                    ServiceMappingHelper smh = new ServiceMappingHelper();

                    smh.MapDbOutputs(outputDescription, ref dbService, addFields);

                    return(dbService.Recordset);
                }

                case enSourceType.MySqlDatabase:
                {
                    var broker            = new MySqlDatabaseBroker();
                    var outputDescription = broker.TestService(dbService);

                    if (outputDescription == null || outputDescription.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                    {
                        throw new Exception("Error retrieving shape from service output.");
                    }

                    dbService.Recordset.Name = dbService.Recordset.Name.Replace(".", "_");
                    dbService.Recordset.Fields.Clear();

                    ServiceMappingHelper smh = new ServiceMappingHelper();

                    smh.MySqlMapDbOutputs(outputDescription, ref dbService, addFields);

                    return(dbService.Recordset);
                }

                default: return(null);
                }
            }
            return(null);


            // Clear out the Recordset.Fields list because the sequence and
            // number of fields may have changed since the last invocation.
            //
            // Create a copy of the Recordset.Fields list before clearing it
            // so that we don't lose the user-defined aliases.
            //
        }
Example #2
0
        private Recordset FetchDbSourceRecordset(ref DbService dbService, bool addFields, DbSource source)
        {
            switch (source.ServerType)
            {
            case enSourceType.SqlDatabase:
            {
                var broker            = CreateDatabaseBroker();
                var outputDescription = broker.TestService(dbService);

                if (outputDescription?.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                {
                    throw new Exception(ErrorResource.ErrorRetrievingShapeFromServiceOutput);
                }
                if (dbService.Recordset != null)
                {
                    dbService.Recordset.Name = dbService.Method.ExecuteAction;
                    if (dbService.Recordset.Name != null)
                    {
                        dbService.Recordset.Name = dbService.Recordset.Name.Replace(".", "_");
                    }
                    dbService.Recordset.Fields.Clear();

                    var smh = new ServiceMappingHelper();
                    smh.MapDbOutputs(outputDescription, ref dbService, addFields);
                }
                return(dbService.Recordset);
            }

            case enSourceType.MySqlDatabase:
            {
                var broker            = new MySqlDatabaseBroker();
                var outputDescription = broker.TestService(dbService);

                if (outputDescription?.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                {
                    throw new Exception(ErrorResource.ErrorRetrievingShapeFromServiceOutput);
                }

                dbService.Recordset.Fields.Clear();

                var smh = new ServiceMappingHelper();

                smh.MySqlMapDbOutputs(outputDescription, ref dbService, addFields);

                return(dbService.Recordset);
            }

            case enSourceType.SQLiteDatabase:
            {
                var broker            = new SqliteDatabaseBroker();
                var outputDescription = broker.TestService(dbService);

                if (outputDescription?.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                {
                    throw new Exception(ErrorResource.ErrorRetrievingShapeFromServiceOutput);
                }

                dbService.Recordset.Fields.Clear();

                var smh = new ServiceMappingHelper();

                smh.MySqlMapDbOutputs(outputDescription, ref dbService, addFields);

                return(dbService.Recordset);
            }

            case enSourceType.PostgreSQL:
            {
                var broker            = new PostgreSqlDataBaseBroker();
                var outputDescription = broker.TestService(dbService);

                if (outputDescription?.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                {
                    throw new Exception(ErrorResource.ErrorRetrievingShapeFromServiceOutput);
                }

                dbService.Recordset.Fields.Clear();

                var smh = new ServiceMappingHelper();

                smh.MySqlMapDbOutputs(outputDescription, ref dbService, addFields);

                return(dbService.Recordset);
            }

            case enSourceType.Oracle:
            {
                var broker            = new OracleDatabaseBroker();
                var outputDescription = broker.TestService(dbService);

                if (outputDescription?.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                {
                    throw new Exception(ErrorResource.ErrorRetrievingShapeFromServiceOutput);
                }

                dbService.Recordset.Fields.Clear();

                var smh = new ServiceMappingHelper();

                smh.MapDbOutputs(outputDescription, ref dbService, addFields);

                return(dbService.Recordset);
            }

            case enSourceType.ODBC:
            {
                var broker            = new ODBCDatabaseBroker();
                var outputDescription = broker.TestService(dbService);

                if (outputDescription?.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                {
                    throw new Exception(ErrorResource.ErrorRetrievingShapeFromServiceOutput);
                }

                dbService.Recordset.Fields.Clear();

                var smh = new ServiceMappingHelper();

                smh.MapDbOutputs(outputDescription, ref dbService, addFields);
                dbService.Recordset.Name = @"Unnamed";
                return(dbService.Recordset);
            }

            default: return(null);
            }
        }
        public virtual Recordset FetchRecordset(DbService dbService, bool addFields)
        {

            if(dbService == null)
            {
                throw new ArgumentNullException("dbService");
            }
                        var  source = dbService.Source as DbSource;
            if(source != null)
            {
                switch(source.ServerType)
                {
                    case enSourceType.SqlDatabase:
                        {
                            var broker = CreateDatabaseBroker();
                            var outputDescription = broker.TestService(dbService);

                            if (outputDescription == null || outputDescription.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                            {
                                throw new Exception("Error retrieving shape from service output.");
                            }

                            dbService.Recordset.Name = dbService.Recordset.Name.Replace(".", "_");
                            dbService.Recordset.Fields.Clear();

                            ServiceMappingHelper smh = new ServiceMappingHelper();

                            smh.MapDbOutputs(outputDescription, ref dbService, addFields);

                            return dbService.Recordset;
                        }

                    case enSourceType.MySqlDatabase:
                    {
                        
                            var broker = new MySqlDatabaseBroker();
                            var outputDescription = broker.TestService(dbService);

                            if (outputDescription == null || outputDescription.DataSourceShapes == null || outputDescription.DataSourceShapes.Count == 0)
                            {
                                throw new Exception("Error retrieving shape from service output.");
                            }

                            dbService.Recordset.Name = dbService.Recordset.Name.Replace(".", "_");
                            dbService.Recordset.Fields.Clear();

                            ServiceMappingHelper smh = new ServiceMappingHelper();

                            smh.MySqlMapDbOutputs(outputDescription, ref dbService, addFields);

                            return dbService.Recordset;
                        
                    }
                    default: return null;

                }
            }
            return null;
           

            // Clear out the Recordset.Fields list because the sequence and
            // number of fields may have changed since the last invocation.
            //
            // Create a copy of the Recordset.Fields list before clearing it
            // so that we don't lose the user-defined aliases.
            //

        }