Example #1
0
        public static void AddAllSQLTables(YellowstonePathology.Business.Mongo.TransferCollection transferCollection)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "SELECT Table_Name, Column_Name " +
                "FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE " +
                "WHERE OBJECTPROPERTY(OBJECT_ID(constraint_name), 'IsPrimaryKey') = 1 " +
                "AND table_name like 'tbl%'";
            cmd.CommandType = CommandType.Text;

            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename);

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Mongo.Transfer transfer = new Transfer();
                        transfer.ObjectId = BsonObjectId.GenerateNewId().ToString();
                        transfer.TableName = dr.GetString(0);
                        transfer.PrimaryKeyName = dr.GetString(1);
                        transferCollection.Add(transfer);
                    }
                }
            }
        }
Example #2
0
        public static TransferCollection GetTransferCollection()
        {
            TransferCollection result = new TransferCollection();

            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename);
            MongoCollection collection = server.Database.GetCollection<BsonDocument>("Transfer");
            MongoCursor cursor = collection.FindAllAs(typeof(BsonDocument)).SetSortOrder(SortBy.Ascending("TableName"));

            foreach (BsonDocument bsonDocument in cursor)
            {
                Transfer transfer = new Transfer();
                YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, transfer);
                result.Add(transfer);
            }

            return result;
        }
Example #3
0
 public static long GetExtendedDocumentCount(Transfer transfer)
 {
     YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename);
     MongoCollection collection = server.Database.GetCollection<BsonDocument>(transfer.TableName);
     long count = collection.Count(Query.And(Query.EQ("HasBeenExtended", true), Query.EQ("ExtendedFrom", transfer.TableName)));
     return count;
 }
Example #4
0
        public static void ExtendDocuments(Transfer transfer)
        {
            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.LISDatabaseName);
            MongoCollection mongoCollection = server.Database.GetCollection<BsonDocument>(transfer.BaseTableName.Substring(3));

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Select * from " + transfer.BaseTableName + " btn join " + transfer.TableName + " dtn on btn." + transfer.PrimaryKeyName + " = dtn." + transfer.PrimaryKeyName;
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        BsonDocument bsonDocument = YellowstonePathology.Business.Mongo.BSONDRBuilder.Build(dr);
                        bsonDocument.Add("ExtendedFrom", transfer.TableName);
                        bsonDocument.Add("HasBeenExtended", true);
                        mongoCollection.Save(bsonDocument);
                    }
                }
            }
        }
Example #5
0
 public static Transfer New(string tableName, string className)
 {
     MongoDB.Bson.BsonObjectId bsonObjectId = MongoDB.Bson.BsonObjectId.GenerateNewId();
     Transfer transfer = new Transfer();
     transfer.m_ObjectId = bsonObjectId.ToString();
     transfer.m_TableName = tableName;
     transfer.m_HasCLSObjectId = false;
     transfer.m_HasSQLObjectId = false;
     transfer.m_HasSQLTimestamp = false;
     transfer.m_TimestampColumnName = null;
     transfer.m_HasTransferDBTSAttribute = false;
     transfer.m_TransferDBTS = null;
     transfer.m_HasSQLDeleteTrigger = false;
     transfer.m_SQLRowCount = 0;
     transfer.m_MongoDocumentCount = 0;
     transfer.m_SQLNullObjectIdCount = 0;
     transfer.m_OutOfSyncCount = 0;
     transfer.m_SQLIndexCount = 0;
     transfer.m_MongoIndexCount = 0;
     transfer.m_HasBaseClass = false;
     transfer.m_BaseTableName = null;
     transfer.m_ExtendedDocumentCount = 0;
     transfer.m_HasTransferStraightAcrossAttribute = false;
     transfer.m_TransferStraightAcross = false;
     return transfer;
 }