コード例 #1
0
 static function makeHtml($notification = null)
 {
     if ($notification == null) {
         return "";
     }
     $auth_id = $notification->info;
     if ($auth_id == null) {
         return "";
     }
     $auth = ConnectionAuth::findOne($auth_id);
     if (!$auth) {
         return "";
     }
     $connection = Connection::findOne($auth->connection_id);
     $source = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => 0])->domain;
     $path_order = ConnectionPath::find()->where(['conn_id' => $connection->id])->count() - 1;
     $destination = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => $path_order])->domain;
     $reservation = Reservation::findOne($connection->reservation_id);
     $title = Yii::t("notify", 'Pending authorization');
     $msg = Yii::t("notify", 'The connection is from') . " <b>" . $source . "</b> " . Yii::t("notify", 'to') . " <b>" . $destination . "</b>";
     $msg .= ". " . Yii::t("notify", 'The request bandwidth is') . " " . $reservation->bandwidth . " Mbps.";
     $date = Yii::$app->formatter->asDatetime($notification->date);
     $link = '/circuits/authorization/answer?id=' . $reservation->id . '&domain=' . $auth->domain;
     $html = Notification::makeHtml('pending_authorization.png', $date, $title, $msg, $link);
     if ($notification->viewed == true) {
         return '<li>' . $html . '</li>';
     }
     return '<li class="notification_new">' . $html . '</li>';
 }
コード例 #2
0
 public function __construct($reservation, $connection_id, $domain)
 {
     $this->reservation_id = $reservation->id;
     $this->reservation_name = $reservation->name;
     $path = ConnectionPath::findOne(['conn_id' => $connection_id, 'path_order' => 0]);
     if ($path) {
         $this->source_domain = $path->domain;
     } else {
         $this->source_domain = Yii::t('circuits', 'deleted');
     }
     $path = ConnectionPath::find()->where(['conn_id' => $connection_id])->orderBy("path_order DESC")->one();
     if ($path) {
         $this->destination_domain = $path->domain;
     } else {
         $this->destination_domain = Yii::t('circuits', 'deleted');
     }
     $user = User::findOne(['id' => $reservation->request_user_id]);
     if ($user) {
         $this->requester = $user->name;
     }
     $this->bandwidth = $reservation->bandwidth . " Mbps";
     $paths_domain = ConnectionPath::find()->where(['conn_id' => $connection_id, 'domain' => $domain])->orderBy("path_order ASC")->all();
     $this->port_in = $paths_domain[0]->port_urn;
     $this->port_out = $paths_domain[count($paths_domain) - 1]->port_urn;
 }
コード例 #3
0
 static function makeHtml($notification = null)
 {
     if ($notification == null) {
         return "";
     }
     $reservation = Reservation::findOne($notification->info);
     if (!$reservation) {
         return "";
     }
     $connection = Connection::find()->where(['reservation_id' => $reservation->id])->one();
     $source = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => 0])->domain;
     $path_order = ConnectionPath::find()->where(['conn_id' => $connection->id])->count() - 1;
     $destination = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => $path_order])->domain;
     $title = Yii::t("notify", 'Reservation') . " (" . $reservation->name . ")";
     $connections = Connection::find()->where(['reservation_id' => $reservation->id])->all();
     //Se possui apenas uma conexão, então pode informar diretamente se foi aceito ou negado
     if (count($connections) < 2) {
         $msg = Yii::t("notify", 'The connection between') . " <b>" . $source . " </b>" . Yii::t("notify", 'and') . " <b>" . $destination . "</b> ";
         $date = Yii::$app->formatter->asDatetime($notification->date);
         $link = '/circuits/reservation/view?id=' . $reservation->id;
         if ($connections[0]->status == Connection::STATUS_FAILED_CREATE || $connections[0]->status == Connection::STATUS_FAILED_CONFIRM || $connections[0]->status == Connection::STATUS_FAILED_SUBMIT || $connections[0]->status == Connection::STATUS_FAILED_PROVISION || $connections[0]->status == Connection::STATUS_CANCELLED || $connections[0]->status == Connection::STATUS_CANCEL_REQ || $connections[0]->auth_status == Connection::AUTH_STATUS_REJECTED || $connections[0]->auth_status == Connection::AUTH_STATUS_EXPIRED) {
             $msg .= " " . Yii::t("notify", 'can not be provisioned.');
             $html = Notification::makeHtml('circuit_reject.png', $date, $title, $msg, $link);
         } else {
             $msg .= " " . Yii::t("notify", 'was provisioned.');
             $html = Notification::makeHtml('circuit_accept.png', $date, $title, $msg, $link);
         }
     } else {
         //Conta o número de provisionadas, rejeitadas (aglomera todos estados em que não vai ser gerado o circuito)
         //e pendentes (aglomera todos estados de processamento intermediário)
         $provisioned = 0;
         $reject = 0;
         $pending = 0;
         foreach ($connections as $conn) {
             if ($conn->status == Connection::STATUS_PROVISIONED) {
                 $provisioned++;
             } else {
                 if ($conn->status == Connection::STATUS_FAILED_CREATE || $conn->status == Connection::STATUS_FAILED_CONFIRM || $conn->status == Connection::STATUS_FAILED_SUBMIT || $conn->status == Connection::STATUS_FAILED_PROVISION || $conn->status == Connection::STATUS_CANCELLED || $conn->status == Connection::STATUS_CANCEL_REQ || $conn->auth_status == Connection::AUTH_STATUS_REJECTED || $conn->auth_status == Connection::AUTH_STATUS_EXPIRED) {
                     $reject++;
                 } else {
                     $pending++;
                 }
             }
         }
         $msg = Yii::t("notify", 'The status of connections changed:') . "<br />";
         $msg .= Yii::t("notify", 'Provisioned:') . " " . $provisioned . ", ";
         $msg .= Yii::t("notify", 'Rejected:') . " " . $reject . ", ";
         $msg .= Yii::t("notify", 'Pending:') . " " . $pending;
         $date = Yii::$app->formatter->asDatetime($notification->date);
         $link = '/circuits/reservation/view?id=' . $reservation->id;
         $html = Notification::makeHtml('circuit_changed.png', $date, $title, $msg, $link);
     }
     if ($notification->viewed == true) {
         return '<li>' . $html . '</li>';
     }
     return '<li class="notification_new">' . $html . '</li>';
 }
コード例 #4
0
ファイル: BpmFlow.php プロジェクト: ufrgs-hyman/meican
 public function checkDomain($flow, $connection)
 {
     Yii::trace("Testando Domain");
     switch ($flow->operator) {
         case 'source':
             $domain = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => 0])->domain;
             break;
         case 'previous':
             $cp = ConnectionPath::findOne(['conn_id' => $connection->id, 'domain' => $flow->domain]);
             if (!isset($cp)) {
                 //Se dominio deletado
                 $flow->status = self::STATUS_YES;
                 return;
             }
             $domain = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => $cp->path_order - 1]);
             if (!isset($domain)) {
                 //Se dominio deletado
                 $flow->status = self::STATUS_YES;
                 return;
             }
             $domain = $domain->domain;
             break;
         case 'next':
             $cp = ConnectionPath::findOne(['conn_id' => $connection->id, 'domain' => $flow->domain]);
             if (!isset($cp)) {
                 //Se dominio deletado
                 $flow->status = self::STATUS_YES;
                 return;
             }
             $domain = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => $cp->path_order + 1]);
             if (!isset($domain)) {
                 //Se dominio deletado
                 $flow->status = self::STATUS_YES;
                 return;
             }
             $domain = $domain->domain;
             break;
         case 'destination':
             $path_order = ConnectionPath::find()->where(['conn_id' => $connection->id])->count() - 1;
             $domain = ConnectionPath::findOne(['conn_id' => $connection->id, 'path_order' => $path_order])->domain;
             break;
     }
     if (isset($domain) && $flow->value == $domain) {
         $flow->status = self::STATUS_YES;
     } else {
         Yii::trace("Não passou em DOMAIN");
         $flow->status = self::STATUS_NO;
     }
 }