· 6 years ago · Oct 23, 2019, 11:16 PM
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
8namespace adatbazisfeltoltes
9{
10 class Program
11 {
12 class Felhasznalok
13 {
14 //public int Felhasznalo_id { get; set; }
15 //public string Nev { get; set; }
16 //public string Lakcim { get; set; }
17 //public int Telefonszam { get; set; }
18 //public string Email { get; set; }
19
20 public string[] vezeteknevek = {"Nagy","Kovács","Tóth",
21 "Szabó","Kiss","Molnár",
22 "Juhász","Fekete","Fehér",
23 "Török","Katona","Balogh",
24 "Varga","Fülöp","Gál" };
25 string[] keresztnevek = {"László","András","Balázs",
26 "Dávid","Zoltán","Gábor",
27 "Péter","Tamás","Zsolt",
28 "Katalin","Zsuzsanna","Krisztina",
29 "Anita","Eszter","Anikó",
30 "Viktória","Zsófia","Nóra"};
31
32 string[] iranyitoszam = { "1016","1029","1039","1044","1054",
33 "1061","1072","1081","1097","1108",
34 "1116","1122","1135","1141","1151",
35 "1162","1172","1183","1192","1201",
36 "1213","1221","1238"};
37 string[] cimek = { "Ady Endre utca 12","Arany János utca 38",
38 "Bem utca 21","Ecetfa utca 42","Kör utca 72","Gabona utca 98",
39 "Liliom utca 16","Márton utca 65","Napfény utca 89","Nádasdy utca 76",
40 "Álmos utca 14","Cukrász utca 55","Gomb utca 53","Madách utca 29",
41 "Bodnár utca 84","Bölény utca 2","Darázs utca 5","Harangvirág utca 9",
42 "Hegyi utca 8","Kökény utca 6"};
43
44 //string[] domain = { "gmail.com", "hotmail.com", "outlook.com", "freemail.com", "citromail.com" };
45
46 private string Telszam()
47 {
48 string telszam = "+36";
49 for (int i = 0; i < 9; i++)
50 {
51 telszam += rnd.Next(0, 10).ToString();
52 }
53 return telszam;
54 }
55 static Random rnd = new Random();
56
57 public List<string> Feltoltes()
58 {
59 List<string> Felhasznalok = new List<string>();
60 for (int i = 0; i < 20; i++)
61 {
62 string vnev = vezeteknevek[rnd.Next(0, vezeteknevek.Length)];
63 string knev = keresztnevek[rnd.Next(0, keresztnevek.Length)];
64 string rekord = "insert into Felhasznalok values(" + (i + 1) + "," + "'" + vnev + " " + knev + "'" +
65 "," + "'" + iranyitoszam[rnd.Next(0, iranyitoszam.Length)] + " " + cimek[rnd.Next(0, cimek.Length)] + "'" + ","
66 + Telszam() + "," + "'" + GenerateEmail(vnev, knev) + "'" + ");";
67 Felhasznalok.Add(rekord);
68 }
69 return Felhasznalok;
70 }
71
72 public static string ToASCII(string accentedStr)
73 {
74
75 byte[] tempBytes;
76 tempBytes = System.Text.Encoding.GetEncoding("ISO-8859-8").GetBytes(accentedStr);
77 return System.Text.Encoding.UTF8.GetString(tempBytes);
78 }
79 public static string GenerateEmail(string vnev, string knev)
80 {
81
82 string vezetek = ToASCII(vnev);
83 string kereszt = ToASCII(knev);
84 string[] mail = { "gmail.com", "freemail.hu", "hotmail.com", "uni-obuda.hu", "citromail.hu", "icloud.com", "outlook.com" };
85
86
87
88 return vezetek.ToLower() + "." + kereszt.ToLower() + "@" + mail[rnd.Next(mail.Length)];
89
90 }
91 public void Kiiras(string txtpath, List<string> lista)
92 {
93 StreamWriter sw = new StreamWriter(txtpath);
94 for (int i = 0; i < lista.Count; i++)
95 {
96 sw.WriteLine(lista[i]);
97 }
98 sw.Close();
99 }
100 }
101
102 //----------------------------------------------------------------------------------------------------
103 class Futar
104 {
105 static Random rnd = new Random();
106 public List<string> FutarFeltoltes()
107 {
108 List<string> lista = new List<string>();
109 for (int i = 0; i < 3; i++)
110 {
111 string rekord = "";
112 rekord += "insert into Futar values(" + (i + 1) + "," + rnd.Next(1, 21) + "," + rnd.Next(80000, 120000) + ");";
113 lista.Add(rekord);
114 }
115 return lista;
116 }
117 public void Kiiras(string txtpath, List<string> lista)
118 {
119 StreamWriter sw = new StreamWriter(txtpath);
120 for (int i = 0; i < lista.Count; i++)
121 {
122 sw.WriteLine(lista[i]);
123 }
124 sw.Close();
125 }
126 }
127 //----------------------------------------------------------------------------------------------------------------
128 class Rendelesek
129 {
130 static Random rnd = new Random();
131 public List<string> RendelesFeltoltes()
132 {
133 List<string> lista = new List<string>();
134 List<string> datumok = GenerateDates(40);
135 for (int i = 0; i < 40; i++)
136 {
137 string rekord = "";
138 string rendelesIdopontja = datumok[rnd.Next(datumok.Count())];
139 string kezbesitesIdeje = KezbesitesEllenorzes(rendelesIdopontja);
140 rekord += "insert into Rendelesek values(" + (i + 1) + "," + rnd.Next(1, 21) + "," + rnd.Next(1, 4) + ","+
141 "to_date(" + "'" + rendelesIdopontja + "'"+"," + "'YYYY-MM-DD HH24:MI:SS')" + "," + "to_date('" + kezbesitesIdeje + "','YYYY-MM-DD HH24:MI:SS'));";
142 lista.Add(rekord);
143 }
144 return lista;
145 }
146 private string KezbesitesEllenorzes(string rendelesidopontja)
147 {
148 string kezbesitve;
149 return kezbesitve = (DateTime.Parse(rendelesidopontja).AddMinutes(rnd.Next(30, 61))).ToString();
150 }
151 static List<string> GenerateDates(int db)
152 {
153 int i = 0;
154 List<string> datumok = new List<string>();
155 while (i < db)
156 {
157 string start = "";
158
159 do
160 {
161
162 int starthour = rnd.Next(24);
163 int startminute = rnd.Next(60);
164 string starth = "";
165 string startm = "";
166 if (starthour < 10) starth = "0" + starthour.ToString();
167 else starth = starthour.ToString();
168 if (startminute < 10) startm = "0" + startminute.ToString();
169 else startm = startminute.ToString();
170
171
172 string startday = rnd.Next(1, 24).ToString();
173 start = "2019. 10. " + startday + ". " + starth + ":" + startm + ":" + "00";
174
175
176 }
177 while (datumok.Contains(start));
178 datumok.Add(start);
179 i++;
180 }
181 return datumok;
182
183
184 }
185 public void Kiiras(string txtpath, List<string> lista)
186 {
187 StreamWriter sw = new StreamWriter(txtpath);
188 for (int i = 0; i < lista.Count; i++)
189 {
190 sw.WriteLine(lista[i]);
191 }
192 sw.Close();
193 }
194 }
195
196
197 static void Main(string[] args)
198 {
199 Felhasznalok f = new Felhasznalok();
200 f.Kiiras("Felhasznalok.txt", f.Feltoltes());
201
202 Futar fu = new Futar();
203 fu.Kiiras("Futar.txt", fu.FutarFeltoltes());
204
205 Rendelesek r = new Rendelesek();
206 r.Kiiras("Rendelesek.txt", r.RendelesFeltoltes());
207 }
208 }
209}