Beispiel #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);
                    }
                }
            }
        }
        public static void BuildClientOrderCollection(SqlDataReader dr, YellowstonePathology.Business.ClientOrder.Model.ClientOrderCollection clientOrderCollection)
        {
            int clientOrderIdCount = 0;
            while (dr.Read())
            {
                if (dr["ClientOrderIdCount"] != DBNull.Value)
                {
                    clientOrderIdCount = Convert.ToInt32(dr["ClientOrderIdCount"].ToString());
                }
            }

            for (int i = 0; i < clientOrderIdCount; i++)
            {
                dr.NextResult();
                YellowstonePathology.Business.ClientOrder.Model.ClientOrder clientOrder = BuildClientOrder(dr);
                dr.NextResult();
                BuildClientOrderDetailCollection(clientOrder.ClientOrderDetailCollection, dr);

                if (clientOrder.ClientOrderId != null)
                {
                    clientOrderCollection.Add(clientOrder);
                }
            }
        }
        public static void BuildClientOrderDetailCollection(YellowstonePathology.Business.ClientOrder.Model.ClientOrderDetailCollection clientOrderDetailCollection, SqlDataReader dr)
        {
            int clientOrderDetailCount = 0;
            while (dr.Read())
            {
                clientOrderDetailCount = Convert.ToInt32(dr["ClientOrderDetailCount"].ToString());
            }

            if (clientOrderDetailCount > 0)
            {
                for (int i = 0; i < clientOrderDetailCount; i++)
                {
                    dr.NextResult();

                    string orderTypeCode = null;
                    while (dr.Read())
                    {
                        orderTypeCode = dr["OrderTypeCode"].ToString();
                    }

                    dr.NextResult();

                    YellowstonePathology.Business.ClientOrder.Model.ClientOrderDetail clientOrderDetail = YellowstonePathology.Business.ClientOrder.Model.ClientOrderDetailFactory.GetClientOrderDetail(orderTypeCode, Persistence.PersistenceModeEnum.UpdateChangedProperties);
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter propertyWriter = new Persistence.SqlDataReaderPropertyWriter(clientOrderDetail, dr);
                        propertyWriter.WriteProperties();
                        clientOrderDetailCollection.Add(clientOrderDetail);
                    }
                }
            }
            else
            {
                dr.NextResult();
                dr.NextResult();
            }
        }