Exemplo n.º 1
0
        public void CreateReport(Zetbox.App.SchemaMigration.MigrationProject obj)
        {
            this._obj = obj;

            NewHeading1("Summary");
            foreach (var s in obj.StagingDatabases)
            {
                RenderTableMappings(s);
            }

            foreach (var s in obj.StagingDatabases)
            {
                foreach (var tbl in s.SourceTables.Where(i => i.DestinationObjectClass != null).OrderBy(i => i.Name))
                {
                    var r = new SourceTableMappingReport(Section);
                    r.CreateReport(tbl);
                }

                foreach (var tbl in s.SourceTables.Where(i => i.DestinationObjectClass == null && i.Status != MappingStatus.Ignored).OrderBy(i => i.Name))
                {
                    var r = new SourceTableMappingReport(Section);
                    r.CreateReport(tbl);
                }
            }
        }
Exemplo n.º 2
0
        public void CreateReport(Zetbox.App.SchemaMigration.MigrationProject obj)
        {
            this._obj = obj;

            NewHeading1("Summary");
            foreach (var s in obj.StagingDatabases)
            {
                RenderTableMappings(s);
            }

            foreach (var s in obj.StagingDatabases)
            {
                foreach (var tbl in s.SourceTables.Where(i => i.DestinationObjectClass != null).OrderBy(i => i.Name))
                {
                    var r = new SourceTableMappingReport(Section);
                    r.CreateReport(tbl);
                }

                foreach (var tbl in s.SourceTables.Where(i => i.DestinationObjectClass == null && i.Status != MappingStatus.Ignored).OrderBy(i => i.Name))
                {
                    var r = new SourceTableMappingReport(Section);
                    r.CreateReport(tbl);
                }
            }
        }
Exemplo n.º 3
0
        public static void UpdateFromSourceSchema(Zetbox.App.SchemaMigration.MigrationProject obj)
        {
            foreach (var s in obj.StagingDatabases)
            {
                using (Log.InfoTraceMethodCall("UpdateFromSourceSchema", s.Description))
                {
                    var connectionString = _cfg.Server.GetConnectionString(s.ConnectionStringKey);
                    if (string.IsNullOrEmpty(connectionString.ConnectionString))
                    {
                        throw new InvalidOperationException("Source ConnectionString is empty");
                    }
                    if (string.IsNullOrEmpty(connectionString.SchemaProvider))
                    {
                        throw new InvalidOperationException("Source Provider is empty");
                    }
                    ISchemaProvider src = _scope.ResolveNamed <ISchemaProvider>(connectionString.SchemaProvider);
                    src.Open(connectionString.ConnectionString);

                    var destTbls = s.SourceTables
                                   .ToDictionary(k => k.Name);

                    // foreach table in src
                    // TODO: And views!!
                    foreach (var tbl in src.GetTableNames().ToList().Union(src.GetViewNames().ToList()))
                    {
                        if (tbl.Schema != s.Schema)
                        {
                            continue;
                        }

                        Log.InfoFormat("reading table {0}", tbl);
                        SourceTable destTbl;
                        if (!destTbls.ContainsKey(tbl.Name))
                        {
                            destTbl      = obj.Context.Create <SourceTable>();
                            destTbl.Name = tbl.Name;
                            s.SourceTables.Add(destTbl);
                        }
                        else
                        {
                            destTbl = destTbls[tbl.Name];
                        }

                        var cols     = src.GetTableColumns(tbl);
                        var destCols = obj.Context.GetQuery <SourceColumn>()
                                       .Where(i => i.SourceTable == destTbl)
                                       .ToDictionary(k => k.Name);

                        foreach (var col in cols)
                        {
                            SourceColumn destCol;
                            if (!destCols.ContainsKey(col.Name))
                            {
                                destCol      = obj.Context.Create <SourceColumn>();
                                destCol.Name = col.Name;
                                destTbl.SourceColumn.Add(destCol);
                            }
                            else
                            {
                                destCol = destCols[col.Name];
                            }
                            destCol.DbType     = (ColumnType)col.Type;
                            destCol.IsNullable = col.IsNullable;
                            destCol.Size       = col.Size;
                        }
                    }
                }
            }

            // TODO: For now, submit changes
            // Later, implement InvokeOnServer correctly
            obj.Context.SubmitChanges();
        }