Revize 9547fd4a
Přidáno uživatelem Eliška Mourycová před téměř 4 roky(ů)
Server/ServerApp/DataDownload/DataDownloader.cs | ||
---|---|---|
31 | 31 |
/// <summary> |
32 | 32 |
/// This class takes care of downloading of data. Download happens from http://openstore.zcu.cz/. |
33 | 33 |
/// </summary> |
34 |
public class DataDownloader |
|
34 |
public class DataDownloader : IDataDownloader
|
|
35 | 35 |
{ |
36 | 36 |
/// <summary> |
37 | 37 |
/// The root directory containing all downloaded data |
... | ... | |
332 | 332 |
/// <param name="format">The data format</param> |
333 | 333 |
/// <param name="startDate">The start date</param> |
334 | 334 |
/// <param name="endDate">The end date</param> |
335 |
/// <returns></returns> |
|
336 |
public List<string> DownloadData(DataType type, DataFormat format, Date startDate, Date endDate/*int startYear, int endYear, int startMonth, int endMonth*/)
|
|
335 |
/// <returns>A list of full paths to all saved files</returns>
|
|
336 |
public List<string> DownloadData(DataType type, DataFormat format, Date startDate, Date endDate) |
|
337 | 337 |
{ |
338 | 338 |
if (startDate > endDate) |
339 | 339 |
throw new ArgumentException("startDate must be the same as or before the endDate."); |
... | ... | |
394 | 394 |
/// <summary> |
395 | 395 |
/// Retrieves all data files with dates falling within the specified range. If not all data for the specified range is found |
396 | 396 |
/// then returns also file/s with month 0 if exists. |
397 |
/// If startDate and/or endDate are null, then returns all files from the given subdirectory. |
|
397 | 398 |
/// </summary> |
398 | 399 |
/// <param name="subDirectory">The subdirectory to search</param> |
399 | 400 |
/// <param name="startDate">The start date</param> |
400 | 401 |
/// <param name="endDate">The end date</param> |
401 |
/// <returns></returns> |
|
402 |
/// <returns>A list of all retrieved data files from the requested time span</returns>
|
|
402 | 403 |
public List<string> GetData(string subDirectory, Date startDate, Date endDate) |
403 | 404 |
{ |
404 | 405 |
if (startDate == null || endDate == null) |
... | ... | |
489 | 490 |
|
490 | 491 |
return relevantFiles; |
491 | 492 |
} |
492 |
|
|
493 |
|
|
494 |
#region UNUSED |
|
495 |
//public string GetDirectoryListingRegexForUrl(string url) |
|
496 |
//{ |
|
497 |
// if (url.Equals(site)) |
|
498 |
// { |
|
499 |
// //return "\\\"([^\"]*)\\\""; |
|
500 |
// return @"\bOD_ZCU_\w*\b"; |
|
501 |
// //return @"\A[OD_ZCU_]"; |
|
502 |
// } |
|
503 |
// else return null; |
|
504 |
//} |
|
505 |
//public void ListDirectory() |
|
506 |
//{ |
|
507 |
// string url = site; |
|
508 |
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); |
|
509 |
// using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) |
|
510 |
// { |
|
511 |
// using (StreamReader reader = new StreamReader(response.GetResponseStream())) |
|
512 |
// { |
|
513 |
// string html = reader.ReadToEnd(); |
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
// Regex regex = new Regex(GetDirectoryListingRegexForUrl(url)); |
|
518 |
// MatchCollection matches = regex.Matches(html); |
|
519 |
// Console.WriteLine(matches.Count); |
|
520 |
|
|
521 |
// if (matches.Count > 0) |
|
522 |
// { |
|
523 |
// foreach (Match match in matches) |
|
524 |
// { |
|
525 |
// //if (match.Success) |
|
526 |
// //{ |
|
527 |
// Console.WriteLine(match.ToString()); |
|
528 |
// //} |
|
529 |
// } |
|
530 |
// } |
|
531 |
// } |
|
532 |
// Console.ReadLine(); |
|
533 |
// } |
|
534 |
//} |
|
535 |
|
|
536 |
#endregion |
|
537 | 493 |
} |
538 | 494 |
} |
Také k dispozici: Unified diff
Refs #9008, #8919. Data directory path should now be ok on linux + added interface for DataDownloader + changed time span of default downloaded data.