public function getServerHistory() { $bSave = false; $mapping = ['envId' => 'envId', 'farmId' => 'farmId', 'farmRoleId' => 'farmRoleId', 'serverIndex' => 'index', 'cloudLocation' => 'cloudLocation']; if (!isset($this->serverHistory)) { $entity = Entity\Server\History::findPk($this->serverId); if (!$entity) { $this->serverHistory = new Entity\Server\History(); $this->serverHistory->clientId = $this->clientId; $this->serverHistory->serverId = $this->serverId; $this->serverHistory->platform = $this->platform; $this->serverHistory->cloudLocation = $this->cloudLocation; $this->serverHistory->instanceTypeName = $this->instanceTypeName; $this->serverHistory->roleId = $this->GetProperty(SERVER_PROPERTIES::ROLE_ID); $this->serverHistory->farmCreatedById = $this->GetProperty(SERVER_PROPERTIES::FARM_CREATED_BY_ID); $this->serverHistory->osType = $this->osType; $this->serverHistory->type = $this->type; $bSave = true; } else { $this->serverHistory = $entity; } if ($this->GetEnvironmentObject()->analytics->enabled) { $this->serverHistory->projectId = $this->GetProperty(SERVER_PROPERTIES::FARM_PROJECT_ID); $this->serverHistory->ccId = $this->GetProperty(SERVER_PROPERTIES::ENV_CC_ID); $bSave = true; } } foreach ($mapping as $prop => $key) { if ($this->serverHistory->{$prop} != $this->{$key}) { $this->serverHistory->{$prop} = $this->{$key}; $bSave = true; } } if (!empty($bSave)) { $this->serverHistory->save(); } return $this->serverHistory; }
public function __construct(DBServer $DBServer, $reasonId = 0, $reasonMsg = "") { parent::__construct(); $this->DBServer = $DBServer; try { $history = $this->DBServer->getServerHistory(); $this->launchReasonId = $history->launchReasonId; $this->launchReason = $history->launchReason; } catch (Exception $e) { } }