-
Notifications
You must be signed in to change notification settings - Fork 0
/
controlFile.cs
106 lines (99 loc) · 3.07 KB
/
controlFile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace cseNoticeBoard
{
class controlFile
{
public static string currentText;
// return number of line without the first line (only actual data line)
public static void setTextAsCurrent()
{
// read the text in the control file
currentText = System.IO.File.ReadAllText(variables.controlFilePath);
}
public static string getLine(int lineNumber)
{
try
{
string[] token = currentText.Split('\n');
return token[lineNumber];
}
catch (IndexOutOfRangeException)
{
return "";
}
}
public static string getItem(int lineNumber, int itemNumber)
{
try
{
string currentLine = getLine(lineNumber);
string[] token = currentLine.Split('$');
return token[itemNumber];
}
catch (IndexOutOfRangeException)
{
return "";
}
}
public static string getFileName (int lineNumber)
{
return getItem(lineNumber, 0);
}
public static int getNumberOfLineInControlFile()
{
int numberOfLinesInControlFile;
string[] token = currentText.Split('\n');
// - 1 because first line is description of elements and not part of data
numberOfLinesInControlFile = token.Length - 1;
// - 1 last item with split will be an empty line
return numberOfLinesInControlFile - 1;
}
public static string getDirectoryName(int lineNumber)
{
return getItem(lineNumber, 0);
}
public static string getFileDescriptionMainWindow (int lineNumber)
{
return getItem(lineNumber, 1);
}
public static string getSessionNumberTimeTablesWindow (int lineNumber)
{
return getItem(lineNumber, 1);
}
public static string getTeacherNameTeachersInfoWindow(int lineNumber)
{
return getItem(lineNumber, 1);
}
public static int getLineNumberTeacherWindow (string teacherName)
{
for (int i=1 ; i<= getNumberOfLineInControlFile(); ++i)
{
if (teacherName == getTeacherNameTeachersInfoWindow(i))
{
return i;
}
}
return 0;
}
public static string getTeacherPositionTeacherWindow(int lineNumber)
{
return getItem(lineNumber, 2);
}
public static string getTabTitle(int lineNumber)
{
return getItem(lineNumber, 1);
}
public static bool checkIfChairman (int lineNumber)
{
if (getItem(lineNumber, 3) == "yes")
return true;
else
return false;
}
}
}