|
|
@ -1,10 +1,10 @@
|
|
|
|
# encoding: utf-8
|
|
|
|
# encoding: utf-8
|
|
|
|
class MyshixunsController < ApplicationController
|
|
|
|
class MyshixunsController < ApplicationController
|
|
|
|
layout 'base_myshixun'
|
|
|
|
layout 'base_myshixun'
|
|
|
|
skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh]
|
|
|
|
skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message]
|
|
|
|
before_filter :require_login, :except => [:training_task_status, :close_webssh]
|
|
|
|
before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message]
|
|
|
|
before_filter :check_authentication, :except => [:training_task_status, :close_webssh, :mul_test_home, :mul_test_user,
|
|
|
|
before_filter :check_authentication, :except => [:training_task_status, :close_webssh, :mul_test_home, :mul_test_user,
|
|
|
|
:mul_test_myshixun, :mul_test_shixun, :mul_test_start]
|
|
|
|
:mul_test_myshixun, :mul_test_shixun, :mul_test_start, :code_runinng_message]
|
|
|
|
before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh, :sync_reset_time, :destroy, :search_file_list, :vnc]
|
|
|
|
before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh, :sync_reset_time, :destroy, :search_file_list, :vnc]
|
|
|
|
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
|
|
|
|
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
|
|
|
|
|
|
|
|
|
|
|
@ -435,6 +435,39 @@ class MyshixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 代码运行中的信息接口
|
|
|
|
|
|
|
|
def code_runinng_message
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
logger.info("######################params: #{params}")
|
|
|
|
|
|
|
|
jsonTestDetails = JSON.parse(params[:jsonTestDetails])
|
|
|
|
|
|
|
|
game_id = jsonTestDetails['buildID']
|
|
|
|
|
|
|
|
message = jsonTestDetails['textMsg']
|
|
|
|
|
|
|
|
logger.info("##################code_runinng_message:#{jsonTestDetails}")
|
|
|
|
|
|
|
|
logger.info("##################buildID: #{game_id}")
|
|
|
|
|
|
|
|
logger.info("##################textMsg: #{message}")
|
|
|
|
|
|
|
|
if game_id.present? && message.present?
|
|
|
|
|
|
|
|
game = Game.find game_id
|
|
|
|
|
|
|
|
msg = game.run_code_message
|
|
|
|
|
|
|
|
# 只有评测中的game才会创建和更新代码评测中的信息
|
|
|
|
|
|
|
|
logger.info("##################game: #{game.status}")
|
|
|
|
|
|
|
|
logger.info("##################retry_status: #{game.retry_status}")
|
|
|
|
|
|
|
|
if game.status == 1 || game.status == 2 && game.retry_status == 1
|
|
|
|
|
|
|
|
if msg.blank?
|
|
|
|
|
|
|
|
RunCodeMessage.create!(:game_id => game_id, :status => 1, :message => message)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
msg.update_attributes(:status => (msg.status + 1), :message => message)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# 评测完成,初始化评测信息的状态
|
|
|
|
|
|
|
|
msg.update_attributes(:status => 0, :message => nil) if msg.present?
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
render :json => {:data => "success"}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
render :json => {:data => "failed"}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# taskId 即返回的game id
|
|
|
|
# taskId 即返回的game id
|
|
|
|
# 返回结果:params [:stauts] 0 表示成功,其它则失败
|
|
|
|
# 返回结果:params [:stauts] 0 表示成功,其它则失败
|
|
|
|
# msg 错误信息
|
|
|
|
# msg 错误信息
|
|
|
@ -540,7 +573,7 @@ class MyshixunsController < ApplicationController
|
|
|
|
logger.info("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
logger.info("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
|
|
|
|
render :json => {:data => "success"}
|
|
|
|
render :json => {:data => "success"}
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
render :json => {:data => "failed"}
|
|
|
|
render :json => {:data => "failed, errer_message:#{e}"}
|
|
|
|
logger.error("training_task_status error: #{e}")
|
|
|
|
logger.error("training_task_status error: #{e}")
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
end
|
|
|
|
end
|
|
|
|