Exemplo n.º 1
0
        public override void Execute()
        {
            base.Execute();

            // Get the template for diff
            var file = Activator.SelectFile("Template File", "Imaging Template", "*.it");

            if (file == null)
            {
                return;
            }

            var templateCollection = ImageTableTemplateCollection.LoadFrom(File.ReadAllText(file.FullName));

            var comparer = new LiveVsTemplateComparer(_tableInfo, templateCollection);

            var viewer = new SQLBeforeAndAfterViewer(comparer.LiveSql, comparer.TemplateSql, "Your Database", "Template", "Differences between live table and image template", MessageBoxButtons.OK); // lgtm[cs/local-not-disposed]

            viewer.Show();
        }
Exemplo n.º 2
0
        public void TestImageTemplates(DatabaseType type)
        {
            var db = GetCleanedServer(type);

            // Create a nice template with lots of columns
            var template = new ImageTableTemplate();

            template.TableName = "Fish";
            template.Columns   = new[]
            {
                new ImageColumnTemplate {
                    IsPrimaryKey = true, AllowNulls = true, ColumnName = "RelativeFileArchiveURI"
                },
                new ImageColumnTemplate {
                    IsPrimaryKey = false, AllowNulls = true, ColumnName = "SeriesInstanceUID"
                },
                new ImageColumnTemplate {
                    IsPrimaryKey = false, AllowNulls = true, ColumnName = "StudyDate"
                },
                new ImageColumnTemplate {
                    IsPrimaryKey = false, AllowNulls = true, ColumnName = "StudyInstanceUID"
                },
                new ImageColumnTemplate {
                    IsPrimaryKey = false, AllowNulls = true, ColumnName = "StudyDescription"
                },
                new ImageColumnTemplate {
                    IsPrimaryKey = false, AllowNulls = true, ColumnName = "EchoTime"
                },
                new ImageColumnTemplate {
                    IsPrimaryKey = false, AllowNulls = true, ColumnName = "RepetitionTime"
                },
                new ImageColumnTemplate {
                    IsPrimaryKey = false, AllowNulls = true, ColumnName = "PatientAge"
                },
            };

            // use it to create a table
            var tbl = db.ExpectTable(template.TableName);
            var cmd = new ExecuteCommandCreateNewImagingDataset(RepositoryLocator, tbl, template);

            Assert.IsFalse(cmd.IsImpossible);
            cmd.Execute();

            Assert.IsTrue(tbl.Exists());

            // import RDMP reference to the table
            var importer = new TableInfoImporter(CatalogueRepository, tbl);

            importer.DoImport(out TableInfo ti, out _);

            // compare the live with the template
            var comparer = new LiveVsTemplateComparer(ti, new ImageTableTemplateCollection()
            {
                DatabaseType = type, Tables = new List <ImageTableTemplate> {
                    template
                }
            });

            // should be no differences
            Assert.AreEqual(comparer.TemplateSql, comparer.LiveSql);

            // make a difference
            tbl.DropColumn(tbl.DiscoverColumn("EchoTime"));

            //now comparer should see a difference
            comparer = new LiveVsTemplateComparer(ti, new ImageTableTemplateCollection()
            {
                DatabaseType = type, Tables = new List <ImageTableTemplate> {
                    template
                }
            });
            Assert.AreNotEqual(comparer.TemplateSql, comparer.LiveSql);

            tbl.Drop();
        }