示例#1
0
        public static async Task <List <WriteStoredProcedure> > GetAllStoredProceduresAsync(IConnectionFactory connFactory)
        {
            var storedProcedures = new List <WriteStoredProcedure>();
            var conn             = connFactory.GetConnection();

            try
            {
                await conn.OpenAsync();

                var cmd    = connFactory.GetCommand(GetAllStoredProceduresQuery, conn);
                var reader = await cmd.ExecuteReaderAsync();

                while (await reader.ReadAsync())
                {
                    var storedProcedure = new WriteStoredProcedure
                    {
                        SchemaName   = reader.GetValueById(SchemaName).ToString(),
                        RoutineName  = reader.GetValueById(RoutineName).ToString(),
                        SpecificName = reader.GetValueById(SpecificName).ToString()
                    };

                    storedProcedures.Add(storedProcedure);
                }

                return(storedProcedures);
            }
            finally
            {
                await conn.CloseAsync();
            }
        }
示例#2
0
        public static async Task <Schema> GetSchemaForStoredProcedureAsync(IClientFactory clientFactory,
                                                                           WriteStoredProcedure storedProcedure)
        {
            var schema = new Schema
            {
                Id                = storedProcedure.GetId(),
                Name              = storedProcedure.GetId(),
                Description       = "",
                DataFlowDirection = Schema.Types.DataFlowDirection.Write,
                Query             = storedProcedure.GetId()
            };

            var client = clientFactory.GetClient();

            var query = string.Format(GetStoredProcedureParamsQuery, "testdata", storedProcedure.SchemaName,
                                      storedProcedure.SpecificName);
            var results = await client.ExecuteReaderAsync(query);

            foreach (var row in results)
            {
                var property = new Property()
                {
                    Id           = row[ParamName].ToString(),
                    Name         = row[ParamName].ToString(),
                    Description  = "",
                    Type         = Discover.Discover.GetType(row[DataType].ToString()),
                    TypeAtSource = row[DataType].ToString()
                };

                schema.Properties.Add(property);
            }

            return(schema);
        }
示例#3
0
        public static async Task <List <WriteStoredProcedure> > GetAllStoredProceduresAsync(IClientFactory clientFactory)
        {
            var storedProcedures = new List <WriteStoredProcedure>();
            var client           = clientFactory.GetClient();

            try
            {
                var results = await client.ExecuteReaderAsync(String.Format(GetAllStoredProceduresQuery,
                                                                            client.GetDefaultDatabase()));


                foreach (var row in results)
                {
                    var storedProcedure = new WriteStoredProcedure()
                    {
                        SchemaName   = row[SchemaName].ToString(),
                        RoutineName  = row[RoutineName].ToString(),
                        SpecificName = row[SpecificName].ToString()
                    };

                    storedProcedures.Add(storedProcedure);
                }
            }
            catch
            {
            }

            return(storedProcedures);
        }
示例#4
0
        public static async Task <Schema> GetSchemaForStoredProcedureAsync(IConnectionFactory connFactory,
                                                                           WriteStoredProcedure storedProcedure, string goldenRecordIdParm)
        {
            var schema = new Schema
            {
                Id                = storedProcedure.GetId(),
                Name              = storedProcedure.GetId(),
                Description       = "",
                DataFlowDirection = Schema.Types.DataFlowDirection.Write,
                Query             = storedProcedure.GetId()
            };

            var conn = connFactory.GetConnection();
            await conn.OpenAsync();

            var cmd = connFactory.GetCommand(
                string.Format(GetStoredProcedureParamsQuery, storedProcedure.SchemaName, storedProcedure.SpecificName),
                conn);
            var reader = await cmd.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                var property = new Property
                {
                    Id           = reader.GetValueById(ParamName).ToString(),
                    Name         = reader.GetValueById(ParamName).ToString(),
                    Description  = "",
                    Type         = Discover.Discover.GetType(reader.GetValueById(DataType).ToString()),
                    TypeAtSource = reader.GetValueById(DataType).ToString(),
                };

                // mark as key if the property is to map the golden record id
                if (!string.IsNullOrWhiteSpace(goldenRecordIdParm))
                {
                    if (property.Id == goldenRecordIdParm)
                    {
                        property.IsKey = true;
                    }
                }

                schema.Properties.Add(property);
            }

            await conn.CloseAsync();

            return(schema);
        }
示例#5
0
 public static async Task <Schema> GetSchemaForStoredProcedureAsync(ISessionFactory connFactory,
                                                                    WriteStoredProcedure storedProcedure)
 {
     throw new NotImplementedException();
     // var schema = new Schema
     // {
     //     Id = storedProcedure.GetId(),
     //     Name = storedProcedure.GetId(),
     //     Description = "",
     //     DataFlowDirection = Schema.Types.DataFlowDirection.Write,
     //     Query = storedProcedure.GetId()
     // };
     //
     // var conn = connFactory.GetConnection();
     // await conn.OpenAsync();
     //
     // var cmd = connFactory.GetCommand(
     //     string.Format(GetStoredProcedureParamsQuery, storedProcedure.SchemaName, storedProcedure.SpecificName),
     //     conn);
     // var reader = await cmd.ExecuteReaderAsync();
     //
     // while (await reader.ReadAsync())
     // {
     //     var property = new Property
     //     {
     //         Id = reader.GetValueById(ParamName).ToString(),
     //         Name = reader.GetValueById(ParamName).ToString(),
     //         Description = "",
     //         Type = Discover.Discover.GetType(reader.GetValueById(DataType).ToString()),
     //         TypeAtSource = reader.GetValueById(DataType).ToString()
     //     };
     //
     //     schema.Properties.Add(property);
     // }
     //
     // await conn.CloseAsync();
     //
     // return schema;
 }
示例#6
0
        public static async Task <Schema> GetSchemaForStoredProcedureAsync(IConnectionFactory connFactory,
                                                                           WriteStoredProcedure storedProcedure)
        {
            var schema = new Schema
            {
                Id                = storedProcedure.GetId(),
                Name              = storedProcedure.GetId(),
                Description       = "",
                DataFlowDirection = Schema.Types.DataFlowDirection.Write,
                Query             = storedProcedure.GetId()
            };

            var conn = connFactory.GetConnection();
            await conn.OpenAsync();

            var cmd = connFactory.GetCommand(
                string.Format(GetStoredProcedureParamsQuery, storedProcedure.SchemaName, storedProcedure.SpecificName),
                conn);
            var reader = await cmd.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                var property = new Property
                {
                    Id           = reader.GetValueById(ParamName).ToString(),
                    Name         = reader.GetValueById(ParamName).ToString(),
                    Description  = "",
                    Type         = Discover.Discover.GetType(reader.GetValueById(DataType).ToString()),
                    TypeAtSource = reader.GetValueById(DataType).ToString()
                };

                schema.Properties.Add(property);
            }

            await conn.CloseAsync();

            return(schema);
        }