private void MigrateRecords(ColumnInfo deleteOn, string deleteValue)
        {
            var deleteOnColumnName = GetRAWColumnNameFullyQualified(deleteOn);

            using (var con = _raw.Server.GetConnection())
            {
                con.Open();

                //if we are deleting on a child table we need to look up the primary table primary key (e.g. StudyInstanceUID) we should then migrate that data instead (for all tables)
                if (!deleteOn.Equals(_primaryTablePk))
                {
                    var oldValue = deleteValue;

                    deleteValue        = GetPrimaryKeyValueFor(deleteOn, deleteValue, con);
                    deleteOnColumnName = GetRAWColumnNameFullyQualified(_primaryTablePk);

                    if (deleteValue == null)
                    {
                        throw new Exception("Primary key value not found for " + oldValue);
                    }

                    _job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Corresponding primary key is '" + deleteValue + "' ('" + deleteOnColumnName + "')"));
                }

                //pull all records that we must isolate in all joined tables
                Dictionary <TableInfo, DataTable> toPush = new Dictionary <TableInfo, DataTable>();

                foreach (TableInfo tableInfo in TablesToIsolate)
                {
                    toPush.Add(tableInfo, PullTable(tableInfo, con, deleteOnColumnName, deleteValue));
                }

                //push the results to isolation
                foreach (KeyValuePair <TableInfo, DataTable> kvp in toPush)
                {
                    var toDatabase = IsolationDatabase.Discover(DataAccessContext.DataLoad);
                    var toTable    = toDatabase.ExpectTable(GetIsolationTableName(kvp.Key));

                    using (var bulkInsert = toTable.BeginBulkInsert())
                        bulkInsert.Upload(kvp.Value);
                }

                foreach (TableInfo t in TablesToIsolate.Reverse())
                {
                    DeleteRows(t, deleteOnColumnName, deleteValue, con);
                }
            }
        }
Ejemplo n.º 2
0
        private void MigrateRecords(ColumnInfo deleteOn, object[] deleteValues)
        {
            var deleteOnColumnName = GetRAWColumnNameFullyQualified(deleteOn);

            using (var con = _raw.Server.GetConnection())
            {
                con.Open();

                //if we are deleting on a child table we need to look up the primary table primary key (e.g. StudyInstanceUID) we should then migrate that data instead (for all tables)
                if (!deleteOn.Equals(_primaryTablePk))
                {
                    deleteValues       = GetPrimaryKeyValuesFor(deleteOn, deleteValues, con);
                    deleteOnColumnName = GetRAWColumnNameFullyQualified(_primaryTablePk);
                }

                //pull all records that we must isolate in all joined tables
                Dictionary <TableInfo, DataTable> toPush = new Dictionary <TableInfo, DataTable>();

                foreach (TableInfo tableInfo in TablesToIsolate)
                {
                    toPush.Add(tableInfo, PullTable(tableInfo, con, deleteOnColumnName, deleteValues));
                }

                //push the results to isolation
                foreach (KeyValuePair <TableInfo, DataTable> kvp in toPush)
                {
                    var toDatabase = IsolationDatabase.Discover(DataAccessContext.DataLoad);
                    var toTable    = toDatabase.ExpectTable(GetIsolationTableName(kvp.Key));

                    using (var bulkInsert = toTable.BeginBulkInsert())
                        bulkInsert.Upload(kvp.Value);
                }

                foreach (TableInfo t in TablesToIsolate.Reverse())
                {
                    DeleteRows(t, deleteOnColumnName, deleteValues, con);
                }

                con.Close();
            }
        }
Ejemplo n.º 3
0
        public void TestEquality()
        {
            Tuple<string, string, string, string, string>[] tests =
                {
                    Tuple.Create("", "", "", "", ""),
                    Tuple.Create("name","", "","", ""),
                    Tuple.Create("name","db", "", "", ""),
                    Tuple.Create("name","db", "table", "", ""),
                    Tuple.Create("name","db", "table", "column", ""),
                    Tuple.Create("name","db", "table", "column", "Variant"),
                };

            Assert.False(new ColumnInfo("", "", "", "", "").Equals(null));
            Assert.False(new ColumnInfo("", "", "", "", "").Equals(new Object()));

            for (int i = 0; i < tests.Length; i++)
            {
                for (int j = 0; j < tests.Length; j++)
                {
                    var fst = new ColumnInfo(tests[i].Item1, tests[i].Item2, tests[i].Item3, tests[i].Item4, tests[i].Item5);
                    var snd = new ColumnInfo(tests[j].Item1, tests[j].Item2, tests[j].Item3, tests[j].Item4, tests[j].Item5);

                    if (i == j)
                    {
                        Assert.True(fst.Equals(fst));
                        Assert.True(snd.Equals(snd));
                        Assert.Equal(fst, snd);
                        Assert.True(fst == snd);
                        Assert.False(fst != snd);
                    }
                    else
                    {
                        Assert.NotEqual(fst, snd);
                        Assert.False(fst == snd);
                        Assert.True(fst != snd);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void TestEquality()
        {
            Tuple <string, string, string, string, string>[] tests =
            {
                Tuple.Create("",     "",   "",      "",       ""),
                Tuple.Create("name", "",   "",      "",       ""),
                Tuple.Create("name", "db", "",      "",       ""),
                Tuple.Create("name", "db", "table", "",       ""),
                Tuple.Create("name", "db", "table", "column", ""),
                Tuple.Create("name", "db", "table", "column", "Variant"),
            };

            Assert.False(new ColumnInfo("", "", "", "", "").Equals(null));
            Assert.False(new ColumnInfo("", "", "", "", "").Equals(new object()));

            for (int i = 0; i < tests.Length; i++)
            {
                for (int j = 0; j < tests.Length; j++)
                {
                    var fst = new ColumnInfo(tests[i].Item1, tests[i].Item2, tests[i].Item3, tests[i].Item4, tests[i].Item5);
                    var snd = new ColumnInfo(tests[j].Item1, tests[j].Item2, tests[j].Item3, tests[j].Item4, tests[j].Item5);

                    if (i == j)
                    {
                        Assert.True(fst.Equals(fst));
                        Assert.True(snd.Equals(snd));
                        Assert.Equal(snd, fst);
                        Assert.True(fst == snd);
                        Assert.False(fst != snd);
                    }
                    else
                    {
                        Assert.NotEqual(fst, snd);
                        Assert.False(fst == snd);
                        Assert.True(fst != snd);
                    }
                }
            }
        }