public void Inititalize()
 {
     warehouseEngine = new WarehouseEngine(warehouse_username, warehouse_password, warehouse_host, warehouse_port, warehouse_database);
 }
        static void DoWork()
        {
            switch (applicationConfig.Action.ToLower())
            {
                case "makewarehousesales":
                    log.Info("Calling makewarehousesales");

                    Init();

                    BiotrackEngine reporting = new BiotrackEngine(programConfig.username, programConfig.password, programConfig.host, programConfig.port, programConfig.database);
                    WarehouseEngine warehouse = new WarehouseEngine(programConfig.warehouse_username, programConfig.warehouse_password, programConfig.warehouse_host, programConfig.warehouse_port);
                    warehouse = WarehouseEngine.GetWarehouse(warehouse, true);

                    SyncFoundation();

                    var inputStartTime = applicationConfig.Options[0].Split('=')[1];                    
                    var inputEndTime = applicationConfig.Options[1].Split('=')[1];

                    log.Info(string.Format("starttime => {0}, endtime => {1}", inputStartTime, inputEndTime));
                    var data = reporting.MakeSalesWarehouse(inputStartTime, inputEndTime);
                    var syncedrows = warehouse.InsertSalesWarehouseData((List<SalesWarehouseRow>)data);

                    var syncrow = new SyncRow { Success = true, Tablename = "saleswarehouse", Timestamp = DateTime.UtcNow, RowsSynced = syncedrows };
                    warehouse.InsertSyncRow(syncrow);

                    break;
                case "makewarehouseinventory":
                    log.Info("Calling makewarehouseinventory");

                    Init();
                    reporting = new BiotrackEngine(programConfig.username, programConfig.password, programConfig.host, programConfig.port, programConfig.database);
                    warehouse = new WarehouseEngine(programConfig.warehouse_username, programConfig.warehouse_password, programConfig.warehouse_host, programConfig.warehouse_port);

                    break;
                case "deletedatabase":
                    log.Info("Calling deletedatabase");

                    Init();
                    warehouse = new WarehouseEngine(programConfig.warehouse_username, programConfig.warehouse_password, programConfig.warehouse_host, programConfig.warehouse_port);
                    warehouse.DropWarehouseDatabase();

                    break;
                case "applyconfig":
                    log.Info("Calling config");
                    ApplyConfiguration(applicationConfig);
                    break;
                default:
                    ShowHelp();
                    break;
            }
        }
 public void TestInitialize()
 {
     biotrackEngine = new BiotrackEngine(username, password, host, port, database);
     warehouseEngine = new WarehouseEngine(warehouse_username, warehouse_password, warehouse_host, warehouse_port, warehouse_database);
 }
        private static void SyncFoundation()
        {
            var warehouse = new WarehouseEngine(programConfig.warehouse_username, programConfig.warehouse_password, programConfig.warehouse_host, programConfig.warehouse_port);
            var database = new DatabaseEngine(programConfig.username, programConfig.password, programConfig.host, programConfig.port, programConfig.database);

            using (var wh_session = warehouse.GetSession())
            {
                // products            
                var products = database.GetProducts();
                foreach (var product in products)
                {
                    var wh_product = (wh_products)product;
                    wh_session.Replicate(wh_product, replicationMode: NHibernate.ReplicationMode.Overwrite);
                }
                wh_session.Flush();

                // product categories
                var productCategories = database.GetProductCategories();
                foreach (var category in productCategories)
                {
                    var wh_productcategory = (wh_productcategory)category;
                    wh_session.Replicate(wh_productcategory, replicationMode: NHibernate.ReplicationMode.Overwrite);
                }
                wh_session.Flush();

                // locations
                var locations = database.GetLocations();
                foreach (var location in locations)
                {
                    var wh_location = (wh_location)location;
                    wh_session.Replicate(wh_location, replicationMode: NHibernate.ReplicationMode.Overwrite);
                }

                wh_session.Flush();

                // vendors
                var vendors = database.GetVendors();
                foreach (var vendor in vendors)
                {
                    var wh_vendor = (wh_Vendors)vendor;
                    wh_session.Replicate(wh_vendor, replicationMode: NHibernate.ReplicationMode.Overwrite);
                }

                wh_session.Flush();

                // customers
                var customers = database.GetCustomers();
                foreach (var customer in customers)
                {
                    var wh_customer = (wh_customers)customer;
                    wh_session.Replicate(wh_customer, replicationMode: NHibernate.ReplicationMode.Overwrite);
                }

                wh_session.Flush();
            }
        }