public override void Run(object context)
        {
            String schemaName = DbHelper.GetRandomString(10);

            try
            {
                DbDefault.CreateDB(schemaName, DbCreateType.Basic);

                try
                {
                    Command.CommandText = "DROP SCHEMA " + schemaName + " RESTRICT";
                    Command.ExecuteNonQuery();

                    Fail("Expected exception when schema is dropped");
                }
                catch (GFXDException e)
                {
                    Log(e);
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                DbDefault.DropDB(schemaName);
                Command.CommandText = "DROP SCHEMA " + schemaName + " RESTRICT";
                base.Run(context);
            }
        }
        private static IList <Appointment> buildAppointmentList(MySqlCommand cmd)
        {
            var appointments = new List <Appointment>();

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                int apptIDOrdinal   = reader.GetOrdinal("apptID");
                int datetimeOrdinal = reader.GetOrdinal("datetime");
                int reasonsOrdinal  = reader.GetOrdinal("reasons");
                int doctorIDOrdinal = reader.GetOrdinal("doctorID");
                int fnameOrdinal    = reader.GetOrdinal("fname");
                int lnameOrdinal    = reader.GetOrdinal("lname");
                int initialOrdinal  = reader.GetOrdinal("initialDiagnosis");
                int finalOrdinal    = reader.GetOrdinal("finalDiagnosis");

                while (reader.Read())
                {
                    Appointment appointment = new Appointment();

                    appointment.ID                         = DbDefault.GetInt(reader, apptIDOrdinal);
                    appointment.Date                       = DbDefault.GetDatetime(reader, datetimeOrdinal);
                    appointment.Reasons                    = DbDefault.GetString(reader, reasonsOrdinal);
                    appointment.Doctor.ID                  = DbDefault.GetInt(reader, doctorIDOrdinal);
                    appointment.Doctor.Bio.FirstName       = DbDefault.GetString(reader, fnameOrdinal);
                    appointment.Doctor.Bio.LastName        = DbDefault.GetString(reader, lnameOrdinal);
                    appointment.Diagnosis.InitialDiagnosis = DbDefault.GetString(reader, initialOrdinal);
                    appointment.Diagnosis.FinalDiagnosis   = DbDefault.GetString(reader, finalOrdinal);

                    appointments.Add(appointment);
                }

                return(appointments);
            }
        }
        public override void Run(object context)
        {
            DataTable table = new DataTable();

            Command.CommandText = DbDefault.GetOrderDetailQuery();

            try
            {
                DataAdapter.Fill(table);

                if (table.Columns.Count <= 0)
                {
                    Fail(String.Format("Table [{0}] has {1} columns",
                                       table.TableName, table.Columns.Count));
                }
                if (table.Rows.Count <= 0)
                {
                    Fail(String.Format("Table [{0}] has {1} rows",
                                       table.TableName, table.Rows.Count));
                }

                ParseDataTable(table);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        private static RoutineCheck buildRoutineCheck(MySqlCommand cmd)
        {
            var routineCheck = new RoutineCheck();

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                int nurseIDOrdinal = reader.GetOrdinal("nurseID");
                int fnameOrdinal   = reader.GetOrdinal("fname");
                int lnameOrdinal   = reader.GetOrdinal("lname");
                int bloodPressureSystolicOrdinal  = reader.GetOrdinal("bloodPressureSystolic");
                int bloodPressureDiastolicOrdinal = reader.GetOrdinal("bloodPressureDiastolic");
                int bodyTempOrdinal = reader.GetOrdinal("bodyTemp");
                int pulseOrdinal    = reader.GetOrdinal("pulse");
                int weightOrdinal   = reader.GetOrdinal("weight");
                int symptomsOrdinal = reader.GetOrdinal("symptoms");

                while (reader.Read())
                {
                    routineCheck.Nurse.ID               = DbDefault.GetInt(reader, nurseIDOrdinal);
                    routineCheck.Nurse.Bio.FirstName    = DbDefault.GetString(reader, fnameOrdinal);
                    routineCheck.Nurse.Bio.LastName     = DbDefault.GetString(reader, lnameOrdinal);
                    routineCheck.BloodPressureSystolic  = DbDefault.GetInt(reader, bloodPressureSystolicOrdinal);
                    routineCheck.BloodPressureDiastolic = DbDefault.GetInt(reader, bloodPressureDiastolicOrdinal);
                    routineCheck.BodyTemp               = DbDefault.GetDouble(reader, bodyTempOrdinal);
                    routineCheck.Pulse    = DbDefault.GetInt(reader, pulseOrdinal);
                    routineCheck.Weight   = DbDefault.GetDouble(reader, weightOrdinal);
                    routineCheck.Symptoms = DbDefault.GetString(reader, symptomsOrdinal);
                }

                return(routineCheck);
            }
        }
Ejemplo n.º 5
0
        public Customer SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.CUSTOMER, 1)), QueryTypes.DATAROW);

            return(new Customer(row));
        }
Ejemplo n.º 6
0
        public override void Run(object context)
        {
            DbController dbc = null;

            try
            {
                Log(DbDefault.GetCreateViewStatement(Relation.CUSTOMER_ADDRESS));

                dbc = new DbController(Connection);
                dbc.CreateView(Relation.CUSTOMER_ADDRESS);

                DataTable table = Connection.GetSchema("Views");

                if (table.Rows.Count <= 0)
                {
                    Fail("GetSchema('Views') did not return information.");
                }


                table.Clear();
                Command.CommandText = "SELECT * FROM " + Relation.CUSTOMER_ADDRESS.ToString();
                DataAdapter.Fill(table);

                ParseDataTable(table);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                dbc.DropView(Relation.CUSTOMER_ADDRESS.ToString());
                base.Run(context);
            }
        }
Ejemplo n.º 7
0
        public Product SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.PRODUCT, 1)), QueryTypes.DATAROW);

            return(new Product(row));
        }
Ejemplo n.º 8
0
        private static IList <LabTest> buildLabTestList(MySqlCommand cmd)
        {
            var labTests = new List <LabTest>();

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                var apptIdOrdinal       = reader.GetOrdinal("apptID");
                var testTypeCodeOrdinal = reader.GetOrdinal("testTypeCode");
                var resultsOrdinal      = reader.GetOrdinal("results");
                var abnormalityOrdinal  = reader.GetOrdinal("abnormality");
                var datetimeOrdinal     = reader.GetOrdinal("testDatetime");
                var testTypeNameOrdinal = reader.GetOrdinal("name");

                while (reader.Read())
                {
                    var labTest = new LabTest();

                    var testType = new TestType
                    {
                        Code = DbDefault.GetInt(reader, testTypeCodeOrdinal),
                        Name = DbDefault.GetString(reader, testTypeNameOrdinal)
                    };
                    labTest.TestType = testType;

                    labTest.AppointmentID = DbDefault.GetInt(reader, apptIdOrdinal);
                    labTest.Results       = DbDefault.GetString(reader, resultsOrdinal);
                    labTest.Abnormality   = DbDefault.GetString(reader, abnormalityOrdinal);
                    labTest.Date          = DbDefault.GetDatetime(reader, datetimeOrdinal);

                    labTests.Add(labTest);
                }

                return(labTests);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Category category = dbc.GetRandomCategory();

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.PRODUCT_CATEGORY, new long[] { category.CategoryId });

                DataReader = Command.ExecuteReader();

                if (DataReader.FieldCount != (DbDefault.GetTableStructure(TableName.PRODUCT).Columns.Count
                                              + DbDefault.GetTableStructure(TableName.CATEGORY).Columns.Count))
                {
                    Fail("Number of data fields returned is incorrect");
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
Ejemplo n.º 10
0
        public Supplier SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.SUPPLIER, 1)), QueryTypes.DATAROW);

            return(new Supplier(row));
        }
Ejemplo n.º 11
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Product   product = dbc.GetRandomProduct();
                DataTable table   = new DataTable();

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.PRODUCT_CATEGORY, new long[] { product.ProductId });

                DataAdapter.Fill(table);

                if (table.Columns.Count != (DbDefault.GetTableStructure(TableName.PRODUCT).Columns.Count
                                            + DbDefault.GetTableStructure(TableName.CATEGORY).Columns.Count))
                {
                    Fail("Number of returned columns is incorrect");
                }

                ParseDataTable(table);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
Ejemplo n.º 12
0
        public OrderDetail SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.ORDERDETAIL, 1)), QueryTypes.DATAROW);

            return(new OrderDetail(row));
        }
Ejemplo n.º 13
0
        public Address SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.ADDRESS, 1)), QueryTypes.DATAROW);

            return(new Address(row));
        }
Ejemplo n.º 14
0
        public override void Run(object context)
        {
            GFXDCommand command;
            String      cmdString = "SELECT * FROM " + DbDefault.GetAddressQuery();

            try
            {
                command = new GFXDCommand(cmdString, Connection);

                if (command.CommandText != cmdString)
                {
                    Fail(String.Format(
                             "CommandText property is not initialized with specified "
                             + " command string. Expected {0}; Actual {1}",
                             cmdString, command.CommandText));
                }
                if (command.Connection != Connection)
                {
                    Fail(String.Format(
                             "Connection property is not initialized with the specified "
                             + "GFXDConnection object"));
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                String schemaName = DbHelper.GetRandomString(10);
                DbDefault.CreateDB(schemaName, DbCreateType.PKPartition);

                foreach (TableName tname in Enum.GetValues(typeof(TableName)))
                {
                    Command.CommandText = DbDefault.GetSelectCountStatement(schemaName, tname);
                    if (Convert.ToInt32(Command.ExecuteScalar()) < 1)
                    {
                        Fail(String.Format("Failed to create table {0}.{1}", schemaName, tname.ToString()));
                    }
                }

                DbDefault.DropDB(schemaName);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
Ejemplo n.º 16
0
        public IList <Order> SelectByCustomer(long customerId)
        {
            String statement = QualifyTableName(DbDefault.GetSelectStatement(
                                                    TableName.ORDERS, String.Format("customer_id = {0}", customerId)));

            DataTable table = null;

            if (Connection != null)
            {
                table = (DataTable)GFXDDbi.Select(Connection, statement, QueryTypes.DATATABLE);
            }
            else
            {
                table = (DataTable)GFXDDbi.Select(statement, QueryTypes.DATATABLE);
            }

            IList <Order> orders = new List <Order>();

            foreach (DataRow row in table.Rows)
            {
                orders.Add(new Order(row));
            }

            return(orders);
        }
Ejemplo n.º 17
0
        public IList <OrderDetail> Select(long orderId)
        {
            String statement = QualifyTableName(DbDefault.GetSelectStatement(
                                                    TableName.ORDERDETAIL, new long[] { orderId }));

            DataTable table = null;

            if (Connection != null)
            {
                table = (DataTable)GFXDDbi.Select(Connection, statement, QueryTypes.DATATABLE);
            }
            else
            {
                table = (DataTable)GFXDDbi.Select(statement, QueryTypes.DATATABLE);
            }

            IList <OrderDetail> orderdetails = new List <OrderDetail>();

            foreach (DataRow row in table.Rows)
            {
                orderdetails.Add(new OrderDetail(row));
            }

            return(orderdetails);
        }
Ejemplo n.º 18
0
        public Category SelectRandom()
        {
            DataRow row = (DataRow)GFXDDbi.Select(QualifyTableName(
                                                      DbDefault.GetSelectRandomStatement(TableName.CATEGORY, 1)), QueryTypes.DATAROW);

            return(new Category(row));
        }
        public override void Run(object context)
        {
            DataSet dataset   = new DataSet();
            String  tableName = TableName.PRODUCT.ToString();

            Command.CommandText = DbDefault.GetAddressQuery();
            int count = 0;

            try
            {
                DataAdapter = Command.CreateDataAdapter();
                dataset     = new DataSet();

                // fill product table
                DataAdapter.SelectCommand.CommandText = DbDefault.GetProductQuery();
                DataAdapter.Fill(dataset, tableName);

                if (dataset.Tables.Count != 1)
                {
                    Fail(String.Format("Tables.Count is incorrect. "
                                       + "Expected [{0}]; Actual [{1}]",
                                       count, dataset.Tables.Count));
                }
                if (dataset.Tables[0].TableName != tableName)
                {
                    Fail(String.Format("TableName is incorrect. "
                                       + "Expected [{0}]; Actual [{1}]",
                                       tableName, dataset.Tables[0].TableName));
                }
                if (dataset.Tables[0].Columns.Count <= 0)
                {
                    Fail(String.Format("Table has {0} columns",
                                       dataset.Tables[0].Columns.Count));
                }
                if (dataset.Tables[0].Rows.Count <= 0)
                {
                    Fail(String.Format("Table has {0} rows",
                                       dataset.Tables[0].Rows.Count));
                }

                ParseDataSet(dataset);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
Ejemplo n.º 20
0
        public IList <OrderDetail> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.ORDERDETAIL, numRecords)), QueryTypes.DATATABLE);

            IList <OrderDetail> orderdetails = new List <OrderDetail>();

            foreach (DataRow row in table.Rows)
            {
                orderdetails.Add(new OrderDetail(row));
            }

            return(orderdetails);
        }
Ejemplo n.º 21
0
        public int Delete(long orderId, long productId)
        {
            String statement = QualifyTableName(DbDefault.GetDeleteStatement(
                                                    TableName.ORDERDETAIL, new long[] { orderId, productId }));

            if (Connection != null)
            {
                return(GFXDDbi.Delete(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Delete(statement));
            }
        }
Ejemplo n.º 22
0
        public int Update(Product product)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.PRODUCT, new long[] { product.ProductId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, product)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, product)));
            }
        }
Ejemplo n.º 23
0
        public int Delete(long addressId)
        {
            String statement = DbDefault.GetDeleteStatement(
                TableName.ADDRESS, new long[] { addressId });

            if (Connection != null)
            {
                return(GFXDDbi.Delete(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Delete(statement));
            }
        }
Ejemplo n.º 24
0
        public IList <Address> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.ADDRESS, numRecords)), QueryTypes.DATATABLE);

            IList <Address> addresses = new List <Address>();

            foreach (DataRow row in table.Rows)
            {
                addresses.Add(new Address(row));
            }

            return(addresses);
        }
Ejemplo n.º 25
0
        public int Update(Supplier supplier)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.SUPPLIER, new long[] { supplier.SupplierId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, supplier)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, supplier)));
            }
        }
Ejemplo n.º 26
0
        public IList <Supplier> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.SUPPLIER, numRecords)), QueryTypes.DATATABLE);

            IList <Supplier> suppliers = new List <Supplier>();

            foreach (DataRow row in table.Rows)
            {
                suppliers.Add(new Supplier(row));
            }

            return(suppliers);
        }
Ejemplo n.º 27
0
        public int Update(Address address)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.ADDRESS, new long[] { address.AddressId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, address)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, address)));
            }
        }
Ejemplo n.º 28
0
        public int Update(OrderDetail ordDetail)
        {
            String statement = QualifyTableName(DbDefault.GetUpdateStatement(
                                                    TableName.ORDERDETAIL, new long[] { ordDetail.OrderId, ordDetail.ProductId }));

            if (Connection != null)
            {
                return(GFXDDbi.Update(Connection, BuildQuery(statement, ordDetail)));
            }
            else
            {
                return(GFXDDbi.Update(BuildQuery(statement, ordDetail)));
            }
        }
Ejemplo n.º 29
0
        public int Delete(long supplierId)
        {
            String statement = QualifyTableName(DbDefault.GetDeleteStatement(
                                                    TableName.SUPPLIER, new long[] { supplierId }));

            if (Connection != null)
            {
                return(GFXDDbi.Delete(Connection, statement));
            }
            else
            {
                return(GFXDDbi.Delete(statement));
            }
        }
Ejemplo n.º 30
0
        public IList <Product> SelectRandom(int numRecords)
        {
            DataTable table = (DataTable)GFXDDbi.Select(QualifyTableName(
                                                            DbDefault.GetSelectRandomStatement(TableName.PRODUCT, numRecords)), QueryTypes.DATATABLE);

            IList <Product> products = new List <Product>();

            foreach (DataRow row in table.Rows)
            {
                products.Add(new Product(row));
            }

            return(products);
        }