Exemplo n.º 1
0
 /// <summary>
 /// Gets all stored procedures (no arguments, for Oracle no packages)
 /// </summary>
 public IList <DatabaseStoredProcedure> StoredProcedureList()
 {
     using (_readerAdapter.CreateConnection())
     {
         return(_readerAdapter.StoredProcedures(null));
     }
 }
        public void Execute(CancellationToken ct)
        {
            if (ct.IsCancellationRequested)
            {
                return;
            }

            RaiseReadingProgress(SchemaObjectType.StoredProcedure);
            var sprocs = _readerAdapter.StoredProcedures(null).ToList();

            if (ct.IsCancellationRequested)
            {
                return;
            }
            RaiseReadingProgress(SchemaObjectType.Functions);
            var functions = _readerAdapter.Functions(null).ToList();

            //before we split sprocs and functions into packages, add arguments and sources
            if (ct.IsCancellationRequested)
            {
                return;
            }
            RaiseReadingProgress(SchemaObjectType.ProcedureArguments);
            var args = _readerAdapter.ProcedureArguments(null).ToList();

            AddArguments(sprocs, functions, args);

            //exclusions
            var procFilter = _exclusions.StoredProcedureFilter;

            if (procFilter != null)
            {
                sprocs.RemoveAll(p => procFilter.Exclude(p.Name));
                functions.RemoveAll(p => procFilter.Exclude(p.Name));
            }

            //packages
            var packFilter = _exclusions.PackageFilter;

            if (packFilter == null)
            {
                packFilter = new Filter();
            }
            var packs = _readerAdapter.Packages(null).ToList();

            packs.RemoveAll(p => packFilter.Exclude(p.Name));

            //move sprocs into packages
            MoveStoredProceduresIntoPackages(packs, sprocs, packFilter);
            //move funcs into packages
            MoveFunctionsIntoPackages(packs, functions, packFilter);

            //add to schema
            if (ct.IsCancellationRequested)
            {
                return;
            }
            _databaseSchema.StoredProcedures.Clear();
            _databaseSchema.StoredProcedures.AddRange(sprocs);
            _databaseSchema.Functions.Clear();
            _databaseSchema.Functions.AddRange(functions);
            _databaseSchema.Packages.Clear();
            _databaseSchema.Packages.AddRange(packs);

            if (ct.IsCancellationRequested)
            {
                return;
            }
            RaiseReadingProgress(SchemaObjectType.ProcedureSource);
            AddSources();
        }