地理所隊列操作功能的添加記錄:
將各項功能做成子功能表,總體思路:
../csm/conf.php中配置所有的操作命令:
// Command to handle the queue opration
$execute_to_reconfig = $shell_cgi." ".escapeshellarg("$QUEUES_BIN/badmin reconfig");
$prepare_to_setenv = $shell_cgi." ".escapeshellarg("export LSF_ENVDIR");
$list_all_queues_command = $shell_cgi." ".escapeshellarg("source /etc/profile;$QUEUES_BIN/bqueues | $ROOT_BIN/awk '{if (NR>1)print $1}'"); // 這一句如果不加 source /etc/profile 會提示某些環境變數未設定的錯誤
$get_user_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s");
$add_user_to_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s -a %s");
$del_user_from_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s -d %s");
$change_user_to_queue = $shell_cgi." ".escapeshellarg("$USR_YPBIN/bqueueadm -u %s -d %s -a %s");
在相應的tpl檔案中定義顯示的視圖,注意僅僅是視圖,不包括顯示的資料。
類似:../csm/addusertoqueue.php 是實際給tpl傳遞資料的,需要的使用者資料,隊列資料
都是從這裡傳入的。
類似:js/addusertoqueue.js 是利用ajax非同步將請求發送給處理頁面,並接收處理頁面傳
遞迴來的值。
類似:../csm/addusertoqueue-ajax.php 是接收ajax傳來的參數,實際進行命令的執行
的。
特別注意:$list_all_queues_command這條命令,其中限制性了source /etc/profile 把環境變數讀進去,
不然返回的數組裡面沒有值,會報錯。
Js檔案中的例子:
$().ready(function(){
$('#submit_change_user_to_queue').click(function(){
$.ajax({
url: '../csm/changeusertoqueue-ajax.php',
type: 'GET',
data: 'username='+$('#usernamelist option:selected').text()+'&beforqueue='+$('#queueslist_befor option:selected').text()+'&nowqueue='+$('#queueslist_now option:selected').text(),
dataType: 'text',
success: function(data){
alert(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);
}
});
});
});
Changeusertoqueue-ajax.php中的例子:
<?php
include_once "../conf.php";
include_once "../functions.php";
include_once "../csm/conf.php";
$username = $_GET["username"];
$beforqueue = $_GET["beforqueue"];
$nowqueue = $_GET["nowqueue"];
$change_user_to_queue = $change_user_to_queue ;
$execute_to_reconf = $execute_to_reconfig ;
$change_user_to_queue_cmd = sprintf($change_user_to_queue,$username,$beforqueue,$nowqueue);
$change_user_to_queue_cmd = ConstructShellCommand($change_user_to_queue_cmd);
$execute_to_reconf_cmd = ConstructShellCommand($execute_to_reconf);
//echo $execute_to_reconf_cmd ;
ExecuteCommand($change_user_to_queue_cmd, $output, $return);
if($return==0){
ExecuteCommand($execute_to_reconf_cmd, $output, $return);
if($return==0){
echo "使用者".$username."已成功從隊列".$beforqueue."更改到隊列".$nowqueue."中!";
}else{
echo "使配置生效的命令執行失敗!";
}
}else{
echo "執行將使用者添加到指定隊列出錯,請聯絡管理員!";
}
?>