Defend
8 years ago
3 changed files with 247 additions and 212 deletions
@ -0,0 +1,13 @@ |
|||
package ru.defend.defdevteam.tstu; |
|||
|
|||
/** |
|||
* Created by itsmy on 11.02.2017. |
|||
*/ |
|||
|
|||
public class GroupList { |
|||
public String name, rate; |
|||
public GroupList(String name, String rate){ |
|||
this.name = name; |
|||
this.rate = rate; |
|||
} |
|||
} |
@ -0,0 +1,199 @@ |
|||
package ru.defend.defdevteam.tstu; |
|||
|
|||
import android.app.Activity; |
|||
import android.util.Log; |
|||
import android.widget.ArrayAdapter; |
|||
import android.widget.ListView; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* Created by itsmy on 11.02.2017. |
|||
*/ |
|||
|
|||
public class OldCabinetController { |
|||
boolean authBegin, taskFinished = false; |
|||
static public String AuthURL, MainURL, AdditionalURL ,JournalURL, RateValueURL, GroupRateURL, |
|||
FacultyRateURL, siteBuf; |
|||
static public String MainHTML, AdditionalHTML, JournalHTML, RateValueHTML, GroupRateHTML, |
|||
FacultyRateHTML; |
|||
public CabinetActivity cabinetActivity; |
|||
|
|||
public OldCabinetController(CabinetActivity cabinet){ |
|||
this.cabinetActivity = cabinet; |
|||
} |
|||
|
|||
public byte sessionState () { |
|||
OldParser parser = new OldParser(); |
|||
if(taskFinished) return 127; |
|||
Log.i("sessionActive","Checking session"); |
|||
String a = parser.cutLine("http://web-iais.admin.tstu.ru:7777/zion/f?p=503:",":",cabinetActivity.getURL()); |
|||
switch (a){ |
|||
case "LOGIN_DESKTOP": |
|||
Log.i("sessionActive","Окно авторизации"); |
|||
cabinetActivity.cabinetClosing(0, "Конец сессии авторизации"); |
|||
return 0; |
|||
case "er": |
|||
Log.i("sessionActive","Окно авторизации"); |
|||
cabinetActivity.cabinetClosing(1, "Ошибка авторизации"); |
|||
return 1; |
|||
case "1": |
|||
Log.i("sessionActive","Страница студента"); |
|||
MainURL = cabinetActivity.getURL(); |
|||
taskGenerator(2); |
|||
return 2; |
|||
case "40": |
|||
Log.i("sessionActive","Страница - Успеваемость"); |
|||
taskGenerator(3); |
|||
return 3; |
|||
case "41": |
|||
Log.i("sessionActive","Страница - Журналы|Главная"); |
|||
taskGenerator(4); |
|||
return 4; |
|||
case "43": |
|||
Log.i("sessionActive","Страница - Рейтинг|Главная"); |
|||
String s = parser.cutLine("","503:",MainURL) + "503:43:" + parser.cutLine(":1:","",MainURL)+":"; |
|||
if(parser.cutLine(s,":NO:", cabinetActivity.getURL()).equals("RATE_GROUP")) { |
|||
taskGenerator(6); |
|||
return 6; |
|||
} |
|||
if(parser.cutLine(s,":NO:", cabinetActivity.getURL()).equals("RATE_INST")) { |
|||
taskGenerator(7); |
|||
return 7; |
|||
} |
|||
taskGenerator(5); |
|||
return 5; |
|||
|
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
public void taskGenerator(int state){ |
|||
OldParser parser = new OldParser(); |
|||
if (!taskFinished) |
|||
switch (state){ |
|||
case 2: |
|||
MainHTML = siteBuf; |
|||
String studNameGroup = parser.cutLine("<span id=\\\"P1_STUD\\\" class=\\\"display_only\\\" style=\\\"font-size: 120%; font-family:Verdana, Arial, Helvetica, sans-serif; color: #0000FF; font-weight:bold\\\">", |
|||
"</span>", MainHTML); |
|||
cabinetActivity.setStudentName(parser.cutLine(""," /",studNameGroup)); |
|||
cabinetActivity.setStudentGroup(parser.cutLine("/ ","",studNameGroup)); |
|||
cabinetActivity.loadSite("javascript:apex.submit('T_ЗАНЯТИЯ/ОЦЕНКИ');"); |
|||
break; |
|||
case 3: |
|||
AdditionalHTML = siteBuf; |
|||
JournalURL = "http://web-iais.admin.tstu.ru:7777/zion/" + |
|||
parser.cutLine("<td headers=\\\"BRS\\\"><a href=\\\"","\" title=\\\"Просмотр журналов\\\">",AdditionalHTML); |
|||
RateValueURL = "http://web-iais.admin.tstu.ru:7777/zion/" + |
|||
parser.cutLine("<td headers=\\\"RTG\\\"><a href=\\\"","\\\" title=\\\"Просмотр успеваемости\\\">",AdditionalHTML); |
|||
cabinetActivity.loadSite(JournalURL); |
|||
break; |
|||
case 4: |
|||
JournalHTML = siteBuf; |
|||
cabinetActivity.loadSite(RateValueURL); |
|||
break; |
|||
case 5: |
|||
RateValueHTML = siteBuf; |
|||
String rate = parser.cutLine("<td align=\\\"center\\\" headers=\\\"STUDRATE\\\">","</td>",RateValueHTML); |
|||
cabinetActivity.setStudentRate(rate); |
|||
GroupRateURL = "http://web-iais.admin.tstu.ru:7777/zion/" + parser.cutLine("><td headers=\\\"GROUP_NAME\\\"><a href=\\\"","\\\">",RateValueHTML); |
|||
FacultyRateURL = "http://web-iais.admin.tstu.ru:7777/zion/" + parser.cutLine("<td headers=\\\"INST\\\"><a href=\\\"","\\\">", RateValueHTML); |
|||
cabinetActivity.loadSite(GroupRateURL); |
|||
break; |
|||
case 6: |
|||
GroupRateHTML = siteBuf; |
|||
fillGroup(); |
|||
cabinetActivity.loadSite(FacultyRateURL); |
|||
break; |
|||
case 7: |
|||
FacultyRateHTML = siteBuf; |
|||
fillFaculty(); |
|||
fillRates(); |
|||
taskFinished = true; |
|||
cabinetActivity.setProgressVisibility(false); |
|||
break; |
|||
} |
|||
|
|||
} |
|||
|
|||
public String getSiteBuffer(){ |
|||
return this.siteBuf; |
|||
} |
|||
|
|||
public void setSiteBuffer(String siteBuf) { |
|||
this.siteBuf = siteBuf; |
|||
} |
|||
|
|||
public void fillRates(){ |
|||
OldParser parser = new OldParser(); |
|||
String s; |
|||
String s2 = GroupRateHTML; |
|||
s = parser.cutLine("<tr>","</tr>",GroupRateHTML); |
|||
s = parser.cutLine("<font","</font>",s); |
|||
while (s.equals("")) { |
|||
s2 = parser.cutLine("</tr>","",s2); |
|||
s = parser.cutLine("<tr>","</tr>",s2); |
|||
s = parser.cutLine("<font","</font>",s); |
|||
} |
|||
s2 = parser.cutLine("<td align=\\\"center\\\" headers=\\\"ROWNUM\\\">","</td>",s2); |
|||
cabinetActivity.setGroupPosition(s2); |
|||
s = ""; |
|||
s2 = FacultyRateHTML; |
|||
s = parser.cutLine("<tr>","</tr>",FacultyRateHTML); |
|||
s = parser.cutLine("<font","</font>",s); |
|||
while (s.equals("")) { |
|||
s2 = parser.cutLine("</tr>","",s2); |
|||
s = parser.cutLine("<tr>","</tr>",s2); |
|||
s = parser.cutLine("<font","</font>",s); |
|||
} |
|||
s2 = parser.cutLine("<td align=\\\"center\\\" headers=\\\"ROWNUM\\\">","</td>",s2); |
|||
cabinetActivity.setFacultyPosition(s2); |
|||
} |
|||
|
|||
public void fillGroup(){ |
|||
cabinetActivity.group = new ArrayList<GroupList>(); |
|||
OldParser parser = new OldParser(); |
|||
String n,r; |
|||
String gr = getSiteBuffer(); |
|||
gr = parser.cutLine("<h1>Рейтинг в группе</h1>", "", gr); |
|||
int i = 0; |
|||
while ( !(parser.cutLine("<tr><td align=\\\"center\\\" headers=\\\"ROWNUM\\\">","</tr>",gr,true) == "")){ |
|||
Integer s = Integer.valueOf(parser.cutLine("<td align=\\\"center\\\" headers=\\\"ROWNUM\\\">","</td>",gr)); |
|||
if(s == (i+1)) { |
|||
n = parser.cutLine("<td headers=\\\"STUDNAME\\\">", "</td>", gr); |
|||
if (!(parser.cutLine("<font color=\\\"red\\\"><b>", "</b></font>", n) == "")) |
|||
n = parser.cutLine("<font color=\\\"red\\\"><b>", "</b></font>",n); |
|||
r = parser.cutLine("<td align=\\\"center\\\" headers=\\\"STUDRATE\\\">", "</td>", gr); |
|||
r += " | Группа: " + parser.cutLine("<td headers=\\\"GROUP_NAME\\\">","</td>", gr, true); |
|||
cabinetActivity.group.add(new GroupList(n,"Общий балл: " + r)); |
|||
i++; |
|||
} |
|||
gr = parser.cutLine("</td></tr>\\n", "", gr); |
|||
} |
|||
cabinetActivity.fillGroup(); |
|||
} |
|||
|
|||
public void fillFaculty(){ |
|||
OldParser parser = new OldParser(); |
|||
cabinetActivity.faculty = new ArrayList<GroupList>(); |
|||
String n,r; |
|||
String fr = getSiteBuffer(); |
|||
fr = parser.cutLine("<h1>Рейтинг в институте/факультете</h1>", "", fr); |
|||
int i = 0; |
|||
while ( !(parser.cutLine("<tr><td align=\\\"center\\\" headers=\\\"ROWNUM\\\">","</tr>",fr,true) == "")){ |
|||
Integer s = Integer.valueOf(parser.cutLine("<td align=\\\"center\\\" headers=\\\"ROWNUM\\\">","</td>",fr)); |
|||
if(s == (i+1)) { |
|||
n = parser.cutLine("<td headers=\\\"STUDNAME\\\">", "</td>", fr); |
|||
if (!(parser.cutLine("<font color=\\\"red\\\"><b>", "</b></font>", n) == "")) |
|||
n = parser.cutLine("<font color=\\\"red\\\"><b>", "</b></font>",n); |
|||
r = parser.cutLine("<td align=\\\"center\\\" headers=\\\"STUDRATE\\\">", "</td>", fr); |
|||
r += " | Группа: " + parser.cutLine("<td headers=\\\"GROUP_NAME\\\">","</td>", fr, true); |
|||
cabinetActivity.faculty.add(new GroupList(n,"Общий балл: " + r)); |
|||
i++; |
|||
} |
|||
fr = parser.cutLine("</td></tr>\\n", "", fr); |
|||
} |
|||
cabinetActivity.fillFaculty(); |
|||
} |
|||
} |
Loading…
Reference in new issue