Ignore:
Timestamp:
Jan 5, 2021, 10:30:31 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Further improved models initialization system.
Location:
trunk/Modules/NetworkShare
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkShare/NetworkShare.php

    r887 r894  
    1818  }
    1919
    20   function DoInstall(): void
     20  function GetModels(): array
    2121  {
    22   }
    23 
    24   function DoUnInstall(): void
    25   {
     22    return array(NetworkShareItem::GetClassName(), NetworkShareError::GetClassName());
    2623  }
    2724
     
    3128  }
    3229}
     30
     31class NetworkShareItem extends Model
     32{
     33  static function GetDesc(): ModelDesc
     34  {
     35    $Desc = new ModelDesc('NetworkShareItem');
     36    $Desc->AddString('Name');
     37    $Desc->AddReference('Parent', NetworkShareItem::GetClassName());
     38    $Desc->AddReference('Host', NetworkDevice::GetClassName());
     39    $Desc->AddBigInt('Size');
     40    $Desc->AddString('Ext');
     41    $Desc->AddDate('Date');
     42    $Desc->AddInteger('Type');
     43    return $Desc;
     44  }
     45}
     46
     47class NetworkShareError extends Model
     48{
     49  static function GetDesc(): ModelDesc
     50  {
     51    $Desc = new ModelDesc(self::GetClassName());
     52    $Desc->AddString('Host');
     53    $Desc->AddString('Message');
     54    return $Desc;
     55  }
     56}
  • trunk/Modules/NetworkShare/update.php

    r873 r894  
    88  $Hosts = array();
    99  $StartTime = GetMicrotime();
    10   $DbResult = $Database->query("SELECT * FROM NetworkDevice WHERE Online=1 AND (Block=0 OR Name='centrala') AND (Name!='GATE') AND User>0");
     10  $DbResult = $Database->query("SELECT * FROM `NetworkDevice` WHERE `Online`=1 AND (`Block`=0 OR `Name`='centrala') AND (`Name` != 'GATE') AND (`User` > 0)");
    1111  while ($Row = $DbResult->fetch_array())
    1212  {
     
    1616    $HostID = 100;
    1717    $StartTime2 = GetMicrotime();
    18     if ($Dnes != $Row['last_share_check'])
     18    if ($Dnes != $Row['LastShareCheck'])
    1919    {
    2020      echo("Kontroluji ".$Row['Name']."...\n");
     
    2323    else echo("Vynechavam ".$Row['Name']."...\n");
    2424    // Aktualizuj datum prochazeni
    25     $Database->update('Hosts', "name='".$Row['name']."'",array('last_share_check' => $Dnes));
     25    $Database->update('NetworkDevice', "Id='".$Row['Id']."'", array('LastShareCheck' => $Dnes));
    2626  }
    27   $Rozdil = GetMicrotime()-$StartTime+10;
     27  $Rozdil = GetMicrotime() - $StartTime + 10;
    2828
    2929  // Oprav a zoptimalizuj tabulku
Note: See TracChangeset for help on using the changeset viewer.