/**
  * Migrates the existing distributors
  */
 public function run()
 {
     $count = 0;
     $skipped = 0;
     $r = mysql_query("SELECT * FROM suppliers");
     while ($supplier = mysql_fetch_assoc($r)) {
         $name = PartDBMigration::convertText($supplier["name"]);
         try {
             $distributor = DistributorManager::getInstance()->getDistributorByName($name);
             $skipped++;
         } catch (\Exception $e) {
             $distributor = new Distributor();
             $distributor->setName($name);
             $this->entityManager->persist($distributor);
             $count++;
         }
     }
     $this->entityManager->flush();
     $this->logMessage(sprintf("Migrated %d distributors, skipped %d because they already exist", $count, $skipped));
 }
 /**
  * Migrates the storage locations
  */
 public function run()
 {
     $count = 0;
     $skipped = 0;
     $r = mysql_query("SELECT * FROM storeloc");
     while ($store = mysql_fetch_assoc($r)) {
         $name = PartDBMigration::convertText($store["name"]);
         try {
             $storageLocation = StorageLocationManager::getInstance()->getStorageLocationByName($name);
             $skipped++;
         } catch (\Exception $e) {
             $oStorageLocation = new StorageLocation();
             $oStorageLocation->setName($name);
             $this->entityManager->persist($oStorageLocation);
             $count++;
         }
     }
     $this->entityManager->flush();
     $this->logMessage(sprintf("Migrated %d storage locations, skipped %d because they already exist", $count, $skipped));
 }
Exemplo n.º 3
0
 /**
  * Migrates the existing footprints
  */
 public function run()
 {
     $count = 0;
     $skipped = 0;
     // Get or create node for the imported footprints
     $footprintCategory = FootprintSetup::addFootprintPath(explode("/", "Imported Footprints"), FootprintCategoryManager::getInstance()->getRootNode());
     $r = mysql_query("SELECT * FROM footprints");
     while ($sFootprint = mysql_fetch_assoc($r)) {
         $name = PartDBMigration::convertText($sFootprint["name"]);
         try {
             FootprintManager::getInstance()->getFootprintByName($name);
             $skipped++;
         } catch (\Exception $e) {
             $footprint = new Footprint();
             $footprint->setName($name);
             $footprint->setCategory($footprintCategory->getNode());
             $this->entityManager->persist($footprint);
             $count++;
         }
     }
     $this->entityManager->flush();
     $this->logMessage(sprintf("Migrated %d footprints, skipped %d because they already exist", $count, $skipped));
 }
Exemplo n.º 4
0
if ($ask) {
    echo "If you are sure you want to do this, type YES and hit return.\n";
    $fp = fopen('php://stdin', 'r');
    $data = fgets($fp, 1024);
    if ($data !== "YES\n") {
        echo "Aborting.\n";
        die;
    }
}
echo "Performing actions...\n";
$setup = new Setup();
$setup->setConsole();
$setup->runCLIChecks();
$setup->run();
if ($migration) {
    if (Configuration::getOption("partkeepr.migration.partdb.hostname", false) === false || Configuration::getOption("partkeepr.migration.partdb.username", false) === false || Configuration::getOption("partkeepr.migration.partdb.password", false) === false || Configuration::getOption("partkeepr.migration.partdb.dbname", false) === false) {
        echo "Error migrating from partdb: One or more configuration settings are missing.\n";
        echo "Please make sure that you define the partkeepr.migration.partdb.* keys, as shown in config.php.template\n\n";
        echo "After adjusting the keys, you can safely re-run the setup, even if you already have worked with PartKeepr.\n";
        exit;
    }
    mysql_connect(Configuration::getOption("partkeepr.migration.partdb.hostname"), Configuration::getOption("partkeepr.migration.partdb.username"), Configuration::getOption("partkeepr.migration.partdb.password"));
    mysql_query("SET CHARACTER SET UTF8");
    mysql_query("SET NAMES UTF8");
    mysql_select_db(Configuration::getOption("partkeepr.migration.partdb.dbname"));
    $migration = new PartDBMigration();
    $migration->setConsole();
    $migration->run();
}
echo "All done.\n\n";
echo "Use the user 'admin' with password 'admin' to login. Access the frontend using the `frontend` directory.\n";