Esempio n. 1
0
        internal async Task <Projection> BuildAsync()
        {
            var session         = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
            var readCatalogTask = _catalogReader.ReadAsync();
            var mapping         = await _mappingReader.ReadAsync();

            var catalog = await readCatalogTask;

            var ixProcedureFullNames = new HashSet <string>(
                from schema in catalog.Schema
                where schema.Procedure != null
                from sp in schema.Procedure
                select sp.FullName
                , StringComparer.OrdinalIgnoreCase);

            if (_diagnosticsCallbackScope.ErrorsCount > 0)
            {
                throw new NotImplementedException();
            }

            var context    = new Context(mapping);
            var projection = new Projection();
            var tasks      = context.SelectedSpFullNames
                             .Where(spFullName => ixProcedureFullNames.Contains(spFullName))
                             .Select(spFullName => _catalogReader.ReadSpInfoAsync(spFullName, context, session))
                             .ToList();

            foreach (var sp in mapping.Procedures
                     .Where(sp => false == ixProcedureFullNames.Contains(sp.FullName)))
            {
                var message = new StringBuilder($"{sp.FullName} stored procedure specified in the maping xml-file could not be found.")
                              .Append($" Make sure that every database object specified in the given mapping does exist in the target database.");

                _diagnosticsCallbackScope.Error(message.ToString());
            }

            foreach (var task in tasks)
            {
                try
                {
                    var spInfo = await task;
                    projection.AddProcedure(spInfo);
                }
                catch (SqlException ex)
                {
                    Debug.Write(ex.Message);
                    throw;
                }
            }


            return(projection);
        }
Esempio n. 2
0
        public async virtual void GoBack()
        {
            StartBusiness();

            var treeCatalog = CatalogReader as ITreeCatalogReader;

            if (treeCatalog == null)
            {
                StopBusiness();
                return;
            }

            treeCatalog.GoBack();
            IEnumerable <CatalogItemModel> items;

            try
            {
                items = await CatalogReader.ReadAsync();
            }
            catch (ReadCatalogException)
            {
                ShowReadCatalogError();
                return;
            }
            catch (TaskCanceledException)
            {
                //skip taks cancelled exception
                return;
            }
            finally
            {
                StopBusiness();
            }

            FolderItems = new ObservableCollection <CatalogItemModel>(items);
            OnCatalogNavigated(false);
        }