Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 085453be

Přidáno uživatelem Eliška Mourycová před téměř 4 roky(ů)

Re #8691. Working on retrieving data in time span from a directory.

Zobrazit rozdíly:

Server/ServerApp/DataDownload/DataDownloader.cs
185 185
			return nameZip;
186 186
		}
187 187

  
188

  
189
		private void ExtractDateFromFileName(string fileName, ref int month, ref int year)
190
		{
191

  
192
		}
193

  
188 194
		/// <summary>
189 195
		/// Downloads a specific archive.
190 196
		/// </summary>
......
222 228
				foreach (ZipArchiveEntry entry in zipArchive.Entries)
223 229
				{
224 230
					// get the relative path to the file:
225
					string extractedFile = nameFolder + entry.Name;
231
					string newFileName = $"{month}-{year}.{format}";
232
					string extractedFile = nameFolder + newFileName; //+ entry.Name;
226 233

  
227 234
					// add full path to the list:
228 235
					extractedFiles.Add(Path.GetFullPath(extractedFile));
......
236 243
					else
237 244
					{
238 245
						// if overwrite is not desired, check if the file exists first:
239
						if(File.Exists(nameFolder + entry.Name))
246
						if(File.Exists(extractedFile/*nameFolder + entry.Name*/))
240 247
						{
241 248
							continue;
242 249
						}
......
335 342
			throw new NotImplementedException();
336 343
		}
337 344

  
345

  
346

  
338 347
		public List<string> GetData(string subDirectory, Date startDate, Date endDate)
339 348
		{
340 349
			string[] files = Directory.GetFiles(subDirectory);
341 350
			for(int i = 0; i < files.Length; i++)
342 351
			{
352
				string currFileName = Path.GetFileName(files[i]);
353
				Console.WriteLine("curr file: " + currFileName);
354
				string[] splits = currFileName.Split(new char[] { '-', '.' });
355

  
356
				int month = int.Parse(splits[0]);
357
				int year = int.Parse(splits[1]);
358

  
359

  
360
				Date d = new Date((uint)month, (uint)year);
361

  
343 362

  
344 363
			}
345 364

  
Server/ServerApp/Program.cs
52 52
			DataDownloader dd = new DataDownloader(config.DataRootDir, config.DataWebsite, config.DownloadedFilesNaming);
53 53
			dd.OverwriteExisting = false;
54 54
			List<string> savedFiles = new List<string>();
55
			savedFiles.AddRange(dd.DownloadData(DataType.JIS, DataFormat.CSV, new Date(1, 2017), new Date(12, 2020)));
56
			savedFiles.AddRange(dd.DownloadData(DataType.STROJE, DataFormat.CSV, new Date(1, 2017), new Date(12, 2020)));
57
			savedFiles.AddRange(dd.DownloadData(DataType.POCASI, DataFormat.CSV, new Date(1, 2017), new Date(12, 2020)));
55
			savedFiles.AddRange(dd.DownloadData(DataType.JIS, DataFormat.CSV, new Date(1, 2019), new Date(12, 2020)));
56
			//savedFiles.AddRange(dd.DownloadData(DataType.STROJE, DataFormat.CSV, new Date(1, 2017), new Date(12, 2020)));
57
			//savedFiles.AddRange(dd.DownloadData(DataType.POCASI, DataFormat.CSV, new Date(1, 2017), new Date(12, 2020)));
58 58

  
59 59

  
60 60

  
......
70 70
				Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
71 71
			}
72 72

  
73
			dd.GetData(dd.DataSubDirectories[DataType.JIS], new Date(1, 2019), new Date(12, 2020));
74

  
75

  
76

  
77

  
73 78

  
74 79

  
75 80
			// date testing

Také k dispozici: Unified diff