public override int GetHashCode() { unchecked { var hashCode = HintNumber.GetHashCode(); hashCode = (hashCode * 397) ^ (int)Character; hashCode = (hashCode * 397) ^ Offset; hashCode = (hashCode * 397) ^ ShowDuration.GetHashCode(); hashCode = (hashCode * 397) ^ NextHint.GetHashCode(); return(hashCode); } }
public string GetTimeProperties() { StringBuilder json = new StringBuilder(); //json.AppendFormat(@"{{""minTime"": ""{0}"", ""maxTime"": ""{1}"", ""showDuration"": {2}, ""step"": ""{3}"", ""timeFormat"": ""{4}""}}", "00:00", _maxTime, ShowDuration.ToString().ToLower(), Step, TimeFormat); json.AppendFormat(@"[""{0}"", ""{1}"", {2}, {3}, ""{4}""]", "00:00", _maxTime, ShowDuration.ToString().ToLower(), Step, TimeFormat); return(json.ToString()); }
public static async Task ExecuteMovieParcing() { _logger.Info("Start Movie Parcing"); try { var response = await _client.GetAsync(@"https://planetakino.ua/showtimes/xml"); var responseString = await response.Content.ReadAsStringAsync(); var xmlDoc = XDocument.Parse(responseString); var films = xmlDoc.Descendants("movies").Descendants("movie"); var showtimes = xmlDoc.Descendants("showtimes").Descendants("day").Descendants("show"); using (BookingBreakerContext db = new BookingBreakerContext()) { var cinema = GetParcingCinema(db); foreach (var film in films) { var filmTitle = film.Descendants("title").First().Value; var startDate = film.Descendants("dt-start").First().Value; var endDate = film.Descendants("dt-end").First().Value; var cinemaMovieId = film.Attribute("id").Value; var cinemaMovieLink = film.Attribute("url").Value; var movie = db.Movies.FirstOrDefault(p => p.Title == filmTitle); if (movie == null) { movie = new Movie { Title = filmTitle }; db.Movies.Add(movie); } var showDuration = db.ShowDurations.FirstOrDefault(p => p.Movie.Title == movie.Title && p.Cinema.Title == cinema.Title); if (startDate.Contains("0000")) { continue; } if (endDate.Contains("0000")) { endDate = DateTime.Now.AddYears(1).ToShortDateString(); } if (showDuration == null) { showDuration = new ShowDuration(); db.ShowDurations.Add(showDuration); } showDuration.StartShowDate = DateTime.Parse(startDate); showDuration.EndShowDate = DateTime.Parse(endDate); showDuration.Cinema = cinema; showDuration.Movie = movie; var localMovieIdentity = db.LocalMovieIdentities.FirstOrDefault(p => p.Movie.Title == movie.Title && p.Cinema.Title == cinema.Title); if (localMovieIdentity == null) { localMovieIdentity = new LocalMovieIdentity(); db.LocalMovieIdentities.Add(localMovieIdentity); } localMovieIdentity.LocalMovieLink = cinemaMovieLink; localMovieIdentity.LocalIdentifier = cinemaMovieId; localMovieIdentity.Cinema = cinema; localMovieIdentity.Movie = movie; } db.SaveChanges(); } } catch (Exception ex) { _logger.Warn("Exception: " + ex.Message); _logger.Warn("Exception Trace: " + ex.StackTrace); } _logger.Info("End Movie Parcing"); }