-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWalkers.cs
More file actions
122 lines (105 loc) · 3.88 KB
/
Walkers.cs
File metadata and controls
122 lines (105 loc) · 3.88 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Turniket_OOP;
using System.IO;
namespace OOP_Turniket
{
class Walkers
{
private static Walkers walkers = null;
private Walkers()
{
string[] file_Present = File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Present.txt");
string[] file_Late = File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Late.txt");
try
{
countPresent = Convert.ToInt32(file_Present[file_Present.Length - 1].Split('.')[0]);
}
catch (Exception e)
{
countPresent = 0;
}
try
{
countLate = Convert.ToInt32(file_Late[file_Late.Length - 1].Split('.')[0]);
}
catch (Exception e)
{
countLate = 0;
}
}
public static Walkers GetWalkers()
{
if (walkers == null)
{
walkers = new Walkers();
}
return walkers;
}
public Walkers(string Name, string Surname, int Quantity)
{
name = Name;
surname = Surname;
quantity = Quantity;
}
private string name;
private string surname;
private int quantity;
public string Name { get => name; }
public string Surname { get => surname; }
public int Quantity { get => quantity; }
int countPresent = 1;
int countLate = 1;
public void Inform(Student student, bool Islate, int walk)
{
// Clear text file, if a new day
// Number_lessons ++
// Cheak in 6 pm hours- cheak student in text file
if (Islate) //pars
{
try
{
string[] file_Missing = File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Present.txt");
countPresent = Convert.ToInt32(file_Missing[file_Missing.Length - 1].Split('.')[0]);
}
catch (Exception ex)
{
}
string presentText = File.ReadAllText("D:\\Turniket_OOP/Turniket_OOP/Present.txt", encoding: Encoding.GetEncoding(1251));
if (presentText.Contains(student.ToString()))
{
return;
}
using (StreamWriter fstream = new StreamWriter("D:\\Turniket_OOP/Turniket_OOP/Present.txt", true, Encoding.GetEncoding(1251)))
{
countPresent++;
fstream.WriteLine(countPresent + ". " + student + " - " + DateTime.Now);
}
}
else
{
try
{
string[] file_Missing = File.ReadAllLines("D:\\Turniket_OOP/Turniket_OOP/Late.txt");
countLate = Convert.ToInt32(file_Missing[file_Missing.Length - 1].Split('.')[0]);
}
catch (Exception ex)
{
}
string lateText = File.ReadAllText("D:\\Turniket_OOP/Turniket_OOP/Late.txt", encoding: Encoding.GetEncoding(1251));
if (lateText.Contains(student.ToString()))
{
return;
}
using (StreamWriter fstream = new StreamWriter("D:\\Turniket_OOP/Turniket_OOP/Late.txt", true, Encoding.GetEncoding(1251)))
{
countLate++;
fstream.WriteLine(countLate + ". " + student + " " + walk + " - " + "пропусків" + " " + DateTime.Now.ToShortDateString());
}
}
}
}
}