Add support to cancelled trains
This commit is contained in:
		
							parent
							
								
									b0cec37bd7
								
							
						
					
					
						commit
						a9ade801ac
					
				
					 3 changed files with 30 additions and 21 deletions
				
			
		| 
						 | 
					@ -38,6 +38,7 @@ namespace InfoferScraper.Models.Station {
 | 
				
			||||||
	public interface IStationStatus : IStatus {
 | 
						public interface IStationStatus : IStatus {
 | 
				
			||||||
		new int Delay { get; }
 | 
							new int Delay { get; }
 | 
				
			||||||
		new bool Real { get; }
 | 
							new bool Real { get; }
 | 
				
			||||||
 | 
							public bool Cancelled { get; }
 | 
				
			||||||
		public string? Platform { get; }
 | 
							public string? Platform { get; }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					@ -102,6 +103,7 @@ namespace InfoferScraper.Models.Station {
 | 
				
			||||||
	internal record StationStatus : IStationStatus {
 | 
						internal record StationStatus : IStationStatus {
 | 
				
			||||||
		public int Delay { get; internal set; }
 | 
							public int Delay { get; internal set; }
 | 
				
			||||||
		public bool Real { get; internal set; }
 | 
							public bool Real { get; internal set; }
 | 
				
			||||||
 | 
							public bool Cancelled { get; internal set; }
 | 
				
			||||||
		public string? Platform { get; internal set; }
 | 
							public string? Platform { get; internal set; }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -170,8 +170,16 @@ namespace InfoferScraper.Scrapers {
 | 
				
			||||||
								.Text()
 | 
													.Text()
 | 
				
			||||||
								.WithCollapsedSpaces()
 | 
													.WithCollapsedSpaces()
 | 
				
			||||||
						).Groups as IEnumerable<Group>).Skip(1).Select(group => group.Value);
 | 
											).Groups as IEnumerable<Group>).Skip(1).Select(group => group.Value);
 | 
				
			||||||
 | 
											if (delayMin is null && delayDiv.Text().WithCollapsedSpaces() == "anulat") {
 | 
				
			||||||
 | 
												arrDep.ModifyableStatus.Cancelled = true;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											else if (delayMin is null) {
 | 
				
			||||||
 | 
												throw new Exception($"Unexpected delayDiv value: {delayDiv.Text().WithCollapsedSpaces()}");
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											else {
 | 
				
			||||||
							arrDep.ModifyableStatus.Real = string.IsNullOrEmpty(approx);
 | 
												arrDep.ModifyableStatus.Real = string.IsNullOrEmpty(approx);
 | 
				
			||||||
							arrDep.ModifyableStatus.Delay = delayMin.Length == 0 ? 0 : int.Parse(delayMin);
 | 
												arrDep.ModifyableStatus.Delay = delayMin.Length == 0 ? 0 : int.Parse(delayMin);
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						if (statusDivComponents.Length < 2) return;
 | 
											if (statusDivComponents.Length < 2) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Runtime.InteropServices.ComTypes;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace InfoferScraper {
 | 
					namespace InfoferScraper;
 | 
				
			||||||
	public static partial class Utils {
 | 
					
 | 
				
			||||||
 | 
					public static partial class Utils {
 | 
				
			||||||
	private static readonly Dictionary<char, char> RoToEn = new() {
 | 
						private static readonly Dictionary<char, char> RoToEn = new() {
 | 
				
			||||||
		{ 'ă', 'a' },
 | 
							{ 'ă', 'a' },
 | 
				
			||||||
		{ 'Ă', 'A' },
 | 
							{ 'Ă', 'A' },
 | 
				
			||||||
| 
						 | 
					@ -20,5 +20,4 @@ namespace InfoferScraper {
 | 
				
			||||||
	public static string RoLettersToEn(this string str) {
 | 
						public static string RoLettersToEn(this string str) {
 | 
				
			||||||
		return string.Concat(str.Select(letter => RoToEn.GetValueOrDefault(letter, letter)));
 | 
							return string.Concat(str.Select(letter => RoToEn.GetValueOrDefault(letter, letter)));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue