ntu coph member plugin data sync

This commit is contained in:
Spen 2013-12-20 10:41:43 +08:00 committed by Manson Wang
parent 2ef59530a5
commit e4aea37b00
2 changed files with 54 additions and 37 deletions

View File

@ -76,10 +76,13 @@ class Admin::ImportDataController < OrbitBackendController
teachers = User.all teachers = User.all
teachers.each do |hash| teachers.each do |hash|
if hash.ntu_seq.present? # if hash.ntu_seq.present?
ntu_seq = hash.ntu_seq if hash.user_id.present?
# ntu_seq = hash.ntu_seq
u_account = hash.user_id
books_xml = Nokogiri::XML( \ books_xml = Nokogiri::XML( \
open("http://ann.cc.ntu.edu.tw/Achv/xmlBook.asp?Seq=#{ntu_seq}")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlBook.asp?Seq=#{ntu_seq}"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=Book&account=#{u_account}"))
@books = books_xml.xpath("//Book").map do |book_node| @books = books_xml.xpath("//Book").map do |book_node|
{ {
author: (book_node>"Authors").text, author: (book_node>"Authors").text,
@ -125,10 +128,13 @@ class Admin::ImportDataController < OrbitBackendController
teachers = User.all teachers = User.all
teachers.each do |hash| teachers.each do |hash|
if hash.ntu_seq.present? # if hash.ntu_seq.present?
ntu_seq = hash.ntu_seq if hash.user_id.present?
# ntu_seq = hash.ntu_seq
u_account = hash.user_id
conference_xml = Nokogiri::XML( \ conference_xml = Nokogiri::XML( \
open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=C")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=C"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=paper&account=#{u_account}&type=C"))
#open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml")) #open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml"))
@conference_papers = conference_xml.xpath("//Paper").map do |cp_node| @conference_papers = conference_xml.xpath("//Paper").map do |cp_node|
{ {
@ -196,11 +202,14 @@ class Admin::ImportDataController < OrbitBackendController
teachers = User.all teachers = User.all
teachers.each do |hash| teachers.each do |hash|
if hash.ntu_seq.present? # if hash.ntu_seq.present?
ntu_seq = hash.ntu_seq if hash.user_id.present?
# ntu_seq = hash.ntu_seq
u_account = hash.user_id
paper_xml = Nokogiri::XML( \ paper_xml = Nokogiri::XML( \
#open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml")) #open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=paper&account=#{u_account}&type=J"))
@journal_papers = paper_xml.xpath("//Paper").map do |paper_node| @journal_papers = paper_xml.xpath("//Paper").map do |paper_node|
{ {
author: (paper_node>"Authors").text, author: (paper_node>"Authors").text,
@ -265,10 +274,13 @@ def sync_conference_data
@user = User.find("#{params[:user_id]}") @user = User.find("#{params[:user_id]}")
# teachers.each do |hash| # teachers.each do |hash|
if @user.sid.present? # if @user.sid.present?
ntu_seq = @user.sid if @user.user_id.present?
# ntu_seq = @user.sid
u_account = @user.user_id
conference_xml = Nokogiri::XML( \ conference_xml = Nokogiri::XML( \
open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=C")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=C"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=paper&account=#{u_account}&type=C"))
#open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml")) #open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml"))
@conference_papers = conference_xml.xpath("//Paper").map do |cp_node| @conference_papers = conference_xml.xpath("//Paper").map do |cp_node|
{ {
@ -339,11 +351,14 @@ def sync_conference_data
@user = User.find("#{params[:user_id]}") @user = User.find("#{params[:user_id]}")
# teachers.each do |hash| # teachers.each do |hash|
if @user.sid.present? # if @user.sid.present?
ntu_seq = @user.sid if @user.user_id.present?
# ntu_seq = @user.sid
u_account = @user.user_id
paper_xml = Nokogiri::XML( \ paper_xml = Nokogiri::XML( \
#open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml")) #open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=paper&account=#{u_account}&type=J"))
@journal_papers = paper_xml.xpath("//Paper").map do |paper_node| @journal_papers = paper_xml.xpath("//Paper").map do |paper_node|
{ {
author: (paper_node>"Authors").text, author: (paper_node>"Authors").text,
@ -417,10 +432,13 @@ def sync_book_data
@user = User.find("#{params[:user_id]}") @user = User.find("#{params[:user_id]}")
# teachers.each do |hash| # teachers.each do |hash|
if @user.sid.present? # if @user.sid.present?
ntu_seq = @user.sid if @user.user_id.present?
# ntu_seq = @user.sid
u_account = @user.user_id
books_xml = Nokogiri::XML( \ books_xml = Nokogiri::XML( \
open("http://ann.cc.ntu.edu.tw/Achv/xmlBook.asp?Seq=#{ntu_seq}")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlBook.asp?Seq=#{ntu_seq}"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=Book&account=#{u_account}"))
@books = books_xml.xpath("//Book").map do |book_node| @books = books_xml.xpath("//Book").map do |book_node|
{ {
author: (book_node>"Authors").text, author: (book_node>"Authors").text,
@ -470,10 +488,13 @@ end
# @user = User.find("#{params[:user_id]}") # @user = User.find("#{params[:user_id]}")
# teachers.each do |hash| # teachers.each do |hash|
if user.sid.present? # if user.sid.present?
ntu_seq = user.sid if user.user_id.present?
# ntu_seq = user.sid
u_account = user.user_id
conference_xml = Nokogiri::XML( \ conference_xml = Nokogiri::XML( \
open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=C")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=C"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=paper&account=#{u_account}&type=C"))
#open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml")) #open("http://versatile.management.ntu.edu.tw/publication1/conference/#{ntuseq}.xml"))
@conference_papers = conference_xml.xpath("//Paper").map do |cp_node| @conference_papers = conference_xml.xpath("//Paper").map do |cp_node|
{ {
@ -547,11 +568,14 @@ def sync_journal_paper_data_auto
# @user = User.find("#{params[:user_id]}") # @user = User.find("#{params[:user_id]}")
# teachers.each do |hash| # teachers.each do |hash|
if user.sid.present? # if user.sid.present?
ntu_seq = user.sid if user.user_id.present?
# ntu_seq = user.sid
u_account = user.user_id
paper_xml = Nokogiri::XML( \ paper_xml = Nokogiri::XML( \
#open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml")) #open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=paper&account=#{u_account}&type=J"))
@journal_papers = paper_xml.xpath("//Paper").map do |paper_node| @journal_papers = paper_xml.xpath("//Paper").map do |paper_node|
{ {
author: (paper_node>"Authors").text, author: (paper_node>"Authors").text,
@ -621,10 +645,13 @@ def sync_book_data_auto
# @user = User.find("#{params[:user_id]}") # @user = User.find("#{params[:user_id]}")
# teachers.each do |hash| # teachers.each do |hash|
if user.sid.present? # if user.sid.present?
ntu_seq = user.sid if user.user_id.present?
# ntu_seq = user.sid
u_account = user.user_id
books_xml = Nokogiri::XML( \ books_xml = Nokogiri::XML( \
open("http://ann.cc.ntu.edu.tw/Achv/xmlBook.asp?Seq=#{ntu_seq}")) # open("http://ann.cc.ntu.edu.tw/Achv/xmlBook.asp?Seq=#{ntu_seq}"))
open("http://ann.cc.ntu.edu.tw/Achv/xmlData_useMail.asp?item=Book&account=#{u_account}"))
@books = books_xml.xpath("//Book").map do |book_node| @books = books_xml.xpath("//Book").map do |book_node|
{ {
author: (book_node>"Authors").text, author: (book_node>"Authors").text,

View File

@ -232,16 +232,6 @@ Orbit::Application.routes.draw do
get "import_data/sync_journal_paper_data_auto" get "import_data/sync_journal_paper_data_auto"
get "import_data/sync_conference_data_auto" get "import_data/sync_conference_data_auto"
get "import_data/get_teacher_data"
get "import_data/get_book_data"
get "import_data/get_conference_data"
get "import_data/get_journal_paper_data"
get "import_data/get_announcement_data"
get "import_data/get_page_data"
get "import_data/sync_book_data"
get "import_data/sync_journal_paper_data"
get "import_data/sync_conference_data"
resources :tags do resources :tags do
collection do collection do
post 'add_to_default' post 'add_to_default'