public ActionResult CreateRepeated(RepeatedShowTime model) { DateTime endDate = model.EndDate; DateTime startDate = model.StartDate; Show show = showRepository.Get(model.ShowId); Salon salon = salonRepository.Get(model.SalonId); if (endDate > startDate) { DateTime showDate = startDate; while (showDate <= endDate) { ShowTime newShowTime = new ShowTime(); newShowTime.Show = show; newShowTime.Salon = salon; newShowTime.ShowDateTime = new DateTime(showDate.Year, showDate.Month, showDate.Day, model.Time.Hour, model.Time.Minute, model.Time.Second); newShowTime.ShowDateSh = showDate.ToPersian(); this.showTimeRepository.Save(newShowTime); showDate = showDate.AddDays(1); } return RedirectToAction("List", new { Id = model.ShowId }); } else throw new Exception("Invalid Date Range"); }
public ActionResult CreateSingle(SingleShowTime model) { DateTime showDate = model.Date; ShowTime newShowTime = new ShowTime(); newShowTime.Show = showRepository.Get(model.ShowId); newShowTime.Salon = salonRepository.Get(model.SalonId); newShowTime.ShowDateTime = new DateTime(showDate.Year, showDate.Month, showDate.Day, model.Time.Hour, model.Time.Minute, model.Time.Second); newShowTime.ShowDateSh = showDate.ToPersian(); this.showTimeRepository.Save(newShowTime); return RedirectToAction("List", new { Id = model.ShowId }); }
public void Create(ShowTime entity) { showTimeRepository.Create(entity); }
public IActionResult Edit(ShowTime showTime) { _dbcontext.ShowTime.Update(showTime); _dbcontext.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public IActionResult Delete(ShowTime Showtimes) { _dbcontext.ShowTime.Remove(Showtimes); _dbcontext.SaveChanges(); return(RedirectToAction(actionName: nameof(Index))); }
public void Timekeeping(DateTime input) { bool reset = false; ResetTime(input); timer = new Timer(new TimerCallback(param => { if (reset) { ResetTime(input); reset = false; return; } if (IsSecondSound) { ThreadPool.QueueUserWorkItem(stateInfo => { secondSoundService.Play(); }); } inputCountdownTime = inputCountdownTime.AddSeconds(-1); page.Dispatcher.BeginInvoke(new Action(() => { ShowTime = inputCountdownTime.ToString("HH:mm:ss"); })); if (ShowTime.Equals("00:00:01") || ShowTime.Equals("00:00:00")) { if (IsRepeat) { ThreadPool.QueueUserWorkItem(stateInfo => { repeatTimeOutService.Play(); Thread.Sleep(1000); repeatTimeOutService.Stop(); }); reset = true; } else { Stop(); page.Dispatcher.BeginInvoke(new Action(() => { if (page.NavigationService.CanGoBack) { page.NavigationService.GoBack(); } //时间到,取消订阅。 if (TimeOut != null) { TimeOut(); } UnSubscribe(); })); if (ScheduledActionService.Find("alarm") != null) { ScheduledActionService.Remove("alarm"); } } } })); timer.Change(1000, 1000); }
public IActionResult Create(ShowTime showTime) { _dbcontext.Add(showTime); _dbcontext.SaveChanges(); return(RedirectToAction(nameof(Index))); }
private static bool MovieAlreadySent(ShowTime showTime, User user) { return(user.Notifications.Any(n => n.ShowTime == showTime)); }
public static string GetCurrentTime(string[] exactPostTime, string[] showPostTime) { for (int i = 0; i < exactPostTime.Length - 1; i++) { for (int j = i + 1; j < exactPostTime.Length; j++) { if (exactPostTime[i] == exactPostTime[j]) { if (showPostTime[i] != showPostTime[j]) { return("impossible"); } } } } DateTime x, ct, min = DateTime.Parse("00:00:00"), max = DateTime.Parse("23:59:59"); string ShowTime; for (int i = 0; i < exactPostTime.Length; i++) { x = DateTime.Parse(exactPostTime[i]); ShowTime = showPostTime[i]; string[] st = ShowTime.Split(' '); if (st[1].Equals("seconds")) { ct = x; if (DateTime.Compare(DateTime.Parse(ct.ToLongTimeString()), DateTime.Parse(min.ToLongTimeString())) == 1) { min = ct; } if (DateTime.Compare(DateTime.Parse(ct.AddSeconds(59).ToLongTimeString()), DateTime.Parse(max.ToLongTimeString())) == -1) { max = ct.AddSeconds(59); } } else if (st[1].Equals("minutes")) { ct = x.AddMinutes(double.Parse(st[0])); if (DateTime.Compare(DateTime.Parse(ct.ToLongTimeString()), DateTime.Parse(min.ToLongTimeString())) == 1) { min = ct; } if (DateTime.Compare(DateTime.Parse(ct.AddSeconds(59).ToLongTimeString()), DateTime.Parse(max.ToLongTimeString())) == -1) { max = ct.AddSeconds(59); } } else if (st[1].Equals("hours")) { ct = x.AddHours(double.Parse(st[0])); if (DateTime.Compare(DateTime.Parse(ct.ToLongTimeString()), DateTime.Parse(min.ToLongTimeString())) == 1) { min = ct; } if (DateTime.Compare(DateTime.Parse(ct.AddMinutes(59).ToLongTimeString()), DateTime.Parse(max.ToLongTimeString())) == -1) { max = ct.AddMinutes(59); } } } return(min.ToLongTimeString()); }
public void ReserveThreeSeatsNonPattern() { using (IWebDriver driver = new FirefoxDriver()) { driver.Navigate().GoToUrl(new Uri(this.url)); IWebElement searchFilm = driver.FindElement(By.CssSelector(".searchfield")); searchFilm.SendKeys(Resources.FilmName); IWebElement film = driver.FindElement(By.CssSelector("a.ng-scope:nth-child(1) > img:nth-child(1)")); film.Click(); Thread.Sleep(TimeSpan.FromSeconds(3)); SelectElement function = new SelectElement(driver.FindElement(By.Id("showTime"))); function.SelectByValue("2"); SelectElement seats = new SelectElement(driver.FindElement(By.Name("seats"))); seats.SelectByValue("3"); IWebElement continueOption = driver.FindElement(By.CssSelector("input.btn")); continueOption.Click(); Thread.Sleep(TimeSpan.FromSeconds(3)); IWebElement firstSeat = driver.FindElement(By.CssSelector("label[for='4,12']")); firstSeat.Click(); IWebElement secondSeat = driver.FindElement(By.CssSelector("label[for='4,13']")); secondSeat.Click(); IWebElement thirdSeat = driver.FindElement(By.CssSelector("label[for=\'4,14']")); thirdSeat.Click(); IWebElement continueOption2 = driver.FindElement(By.CssSelector("button.btn:nth-child(2)")); continueOption2.Click(); IWebElement finilize = driver.FindElement(By.CssSelector(".btn")); finilize.Click(); } List <Seat> bookedSeats = new List <Seat>(); using (WebClient request = new WebClient()) { string response = request.DownloadString("http://localhost:8080/rest/showtime/2"); ShowTime showTime = JsonConvert.DeserializeObject <ShowTime>(response); showTime.Seats.ForEach(block => bookedSeats.AddRange(block.Where(seat => seat.Booked))); } List <Seat> expectedResult = new List <Seat>() { new Seat() { Booked = true, Column = 12, Row = 4 }, new Seat() { Booked = true, Column = 13, Row = 4 }, new Seat() { Booked = true, Column = 14, Row = 4 } }; CollectionAssert.AreEquivalent(expectedResult, bookedSeats); }
protected override void Render(HtmlTextWriter writer) { try { DateTime tmpDate; try { tmpDate = this.SelectedDate == "" ? DateTime.Now : Convert.ToDateTime(SelectedDate); } catch (Exception ex) { tmpDate = DateTime.Now; } string temp = CssClass; CssClass = ""; if (temp == "") { temp = "ampicker"; } writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Width, Width.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (Text != "") { writer.AddAttribute(HtmlTextWriterAttribute.Style, "white-space:nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(Text); writer.RenderEndTag(); } writer.AddAttribute(HtmlTextWriterAttribute.Width, Width.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute("class", temp); writer.AddAttribute("id", ClientID); writer.AddAttribute("name", ClientID); writer.AddAttribute("onblur", "return window." + ClientID + ".onblur(this);"); writer.AddAttribute("onkeypress", "return window." + ClientID + ".onlyDateChars(event);"); //writer.AddAttribute("onkeydown", "return window." & Me.ClientID & ".KeyPress(event);") //writer.AddAttribute("onclick", "return window." & Me.ClientID & ".Click(event);showalert();") if (Enabled == false) { writer.AddAttribute("disabled", "disabled"); } if (ShowDateBox) { writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); } dtFI = Thread.CurrentThread.CurrentCulture.DateTimeFormat; if (!(string.IsNullOrEmpty(SelectedDate))) { DateTime dte = DateTime.Parse(SelectedDate); SelectedDate = dte.ToString(dtFI.ShortDatePattern + " " + dtFI.ShortTimePattern); } writer.AddAttribute("type", "hidden"); writer.AddAttribute("id", "hid_" + ClientID); writer.AddAttribute("name", "hid_" + ClientID); writer.AddAttribute("value", SelectedDate); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute("id", "cal_" + ClientID); writer.AddAttribute("style", "display:none;position:absolute;"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Td); if (ImageUrl == string.Empty) { ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), "DotNetNuke.Modules.ActiveForums.CustomControls.Resources.calendar.gif"); } if (Enabled) { writer.AddAttribute("src", ImageUrl); writer.AddAttribute("onclick", "window." + ClientID + ".Toggle(event);"); writer.AddAttribute("id", "img_" + ClientID); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); var str = new StringBuilder(); str.Append("<script type=\"text/javascript\">"); cal = new System.Globalization.GregorianCalendar(); if (Thread.CurrentThread.CurrentCulture != null) { cal = Thread.CurrentThread.CurrentCulture.Calendar; } DateFormat = dtFI.ShortDatePattern; TimeFormat = dtFI.ShortTimePattern; str.Append("window." + ClientID + "=new asDatePicker('" + ClientID + "');"); str.Append("window." + ClientID + ".Locale='" + Context.Request.UserLanguages[0].Substring(0, 2).ToUpper() + "';"); str.Append("window." + ClientID + ".SelectedDate='" + SelectedDate + "';"); str.Append("window." + ClientID + ".Width='" + CalendarWidth + "';"); str.Append("window." + ClientID + ".Height='" + CalendarHeight + "';"); str.Append("window." + ClientID + ".DateFormat='" + dtFI.ShortDatePattern + "';"); str.Append("window." + ClientID + ".TimeFormat='" + dtFI.ShortTimePattern + "';"); str.Append("window." + ClientID + ".Year=" + tmpDate.Year + ";"); str.Append("window." + ClientID + ".Month=" + (tmpDate.Month - 1) + ";"); str.Append("window." + ClientID + ".Day=" + tmpDate.Day + ";"); str.Append("window." + ClientID + ".SelectedYear=" + tmpDate.Year + ";"); str.Append("window." + ClientID + ".SelectedMonth=" + (tmpDate.Month - 1) + ";"); str.Append("window." + ClientID + ".SelectedDay=" + tmpDate.Day + ";"); str.Append("window." + ClientID + ".ShowTime=" + ShowTime.ToString().ToLower() + ";"); str.Append("window." + ClientID + ".DefaultTime='" + DefaultTime + "';"); str.Append("window." + ClientID + ".CallbackFlag='" + CallbackFlag + "';"); if (!(string.IsNullOrEmpty(RelatedControl))) { Control ctl = Parent.FindControl(RelatedControl); if (ctl == null) { ctl = Page.FindControl(RelatedControl); } if (ctl == null) { RelatedControl = string.Empty; } else { RelatedControl = ctl.ClientID; } } str.Append("window." + ClientID + ".linkedControl='" + RelatedControl + "';"); if (IsEndDate) { str.Append("window." + ClientID + ".isEndDate=true;"); } else { str.Append("window." + ClientID + ".isEndDate=false;"); } string sTime = string.Empty; SelectedTime = tmpDate.ToString(TimeFormat); if (ShowTime) { if (SelectedTime != "12:00 AM") { sTime = SelectedTime; } if (TimeRequired) { str.Append("window." + ClientID + ".RequireTime=true;"); } else { str.Append("window." + ClientID + ".RequireTime=false;"); } } else { str.Append("window." + ClientID + ".RequireTime=false;"); } str.Append("window." + ClientID + ".SelectedTime='" + sTime + "';"); if (string.IsNullOrEmpty(ImgNext)) { str.Append("window." + ClientID + ".ImgNext='" + Page.ClientScript.GetWebResourceUrl(GetType(), "DotNetNuke.Modules.ActiveForums.CustomControls.Resources.cal_nextMonth.gif") + "';"); } else { str.Append("window." + ClientID + ".ImgNext='" + Page.ResolveUrl(ImgNext) + "';"); } if (string.IsNullOrEmpty(ImgPrev)) { str.Append("window." + ClientID + ".ImgPrev='" + Page.ClientScript.GetWebResourceUrl(GetType(), "DotNetNuke.Modules.ActiveForums.CustomControls.Resources.cal_prevMonth.gif") + "';"); } else { str.Append("window." + ClientID + ".ImgPrev='" + Page.ResolveUrl(ImgPrev) + "';"); } if (SelectedDate != "") { try { if (ShowTime == false && sTime == string.Empty) { str.Append("window." + ClientID + ".textbox.value=new Date(" + tmpDate.Year + "," + (tmpDate.Month - 1) + "," + tmpDate.Day + ").formatDP('" + DateFormat + "','" + ClientID + "');"); str.Append("window." + ClientID + ".dateSel = new Date(" + tmpDate.Year + "," + (tmpDate.Month - 1) + "," + tmpDate.Day + ",0,0,0,0);"); } else { str.Append("window." + ClientID + ".textbox.value=new Date(" + tmpDate.Year + "," + (tmpDate.Month - 1) + "," + tmpDate.Day + "," + tmpDate.Hour + "," + tmpDate.Minute + ",0).formatDP('" + DateFormat + " " + TimeFormat + "','" + ClientID + "');"); str.Append("window." + ClientID + ".dateSel = new Date(" + tmpDate.Year + "," + (tmpDate.Month - 1) + "," + tmpDate.Day + "," + tmpDate.Hour + "," + tmpDate.Minute + ",0);"); } } catch (Exception ex) { } } int xMonths = cal.GetMonthsInYear(cal.GetYear(tmpDate), cal.GetEra(tmpDate)); int currMonth = cal.GetMonth(tmpDate); int currYear = cal.GetYear(tmpDate); int currDay = cal.GetDayOfMonth(tmpDate); str.Append("window." + ClientID + ".MonthDays = new Array("); for (int i = 0; i < xMonths; i++) { str.Append(cal.GetDaysInMonth(currYear, i + 1)); if (i < (xMonths - 1)) { str.Append(","); } } str.Append(");"); str.AppendLine(); string[] mNames = dtFI.MonthNames; str.Append("window." + ClientID + ".MonthNames = new Array("); for (int i = 0; i < xMonths; i++) { str.Append("'" + mNames[i] + "'"); if (i < (xMonths - 1)) { str.Append(","); } } str.Append(");"); str.AppendLine(); str.Append("window." + ClientID + ".ShortMonthNames = new Array("); string[] mAbbr = dtFI.AbbreviatedMonthNames; for (int i = 0; i < xMonths; i++) { str.Append("'" + mAbbr[i] + "'"); if (i < (xMonths - 1)) { str.Append(","); } } str.Append(");"); str.AppendLine(); str.Append("window." + ClientID + ".ShortDayNames = new Array("); string[] dAbbr = dtFI.AbbreviatedDayNames; for (int i = 0; i <= 6; i++) { str.Append("'" + dAbbr[i] + "'"); if (i < 6) { str.Append(","); } } str.Append(");"); str.AppendLine(); str.Append("window." + ClientID + ".Class={"); str.Append("CssCalendarStyle:'" + CssCalendarStyle + "',"); str.Append("CssMonthStyle:'" + CssMonthStyle + "',"); str.Append("CssWeekendStyle:'" + CssWeekendStyle + "',"); str.Append("CssWeekdayStyle:'" + CssWeekdayStyle + "',"); str.Append("CssSelectedDayStyle:'" + CssSelectedDayStyle + "',"); str.Append("CssCurrentMonthDayStyle:'" + CssCurrentMonthDayStyle + "',"); str.Append("CssOtherMonthDayStyle:'" + CssOtherMonthDayStyle + "',"); str.Append("CssDayHeaderStyle:'" + CssDayHeaderStyle + "',"); str.Append("CssCurrentDayStyle:'" + CssCurrentDayStyle + "'};"); str.Append("window." + ClientID + ".selectedDate=window." + ClientID + ".textbox.value;"); str.Append("window." + ClientID + ".timeLabel='[RESX:Time]';"); str.Append("</script>"); writer.Write(str); } catch (Exception ex) { } }
public static async Task ExecuteShowTimesParcing() { try { var response = await _client.GetAsync(@"https://planetakino.ua/showtimes/xml"); var responseString = await response.Content.ReadAsStringAsync(); var xmlDoc = XDocument.Parse(responseString); var showtimes = xmlDoc.Descendants("showtimes").Descendants("day").Descendants("show"); using (BookingBreakerContext db = new BookingBreakerContext()) { var cinema = GetParcingCinema(db); db.ShowTimes.RemoveRange(db.ShowTimes.Where(p => p.CinemaHall.Cinema.Title == cinema.Title)); foreach (var show in showtimes) { var movieId = show.Attribute("movie-id").Value; var startTime = DateTime.Parse(show.Attribute("full-date").Value); var url = show.Attribute("order-url").Value; var hallId = show.Attribute("hall-id").Value; var technology = show.Attribute("technology").Value; if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(movieId)) { continue; } var hallIdInt = Int32.Parse(hallId); var cinemaHall = db.CinemaHalls.FirstOrDefault(p => p.LocalCinemaHallId == hallIdInt); if (cinemaHall == null) { cinemaHall = new CinemaHall(); cinemaHall.LocalCinemaHallId = Int32.Parse(hallId); cinemaHall.PlacesRepresentationTech = PlacesRepresentationTechEnum.SeatCharts; cinemaHall.Cinema = cinema; db.CinemaHalls.Add(cinemaHall); } var showtimeId = url.Substring(url.IndexOf("show_id=") + 8, url.IndexOf(@"&theatre_id") - url.IndexOf("show_id") - 8); var showresponse = await _client.GetAsync(@"https://cabinet.planetakino.ua" + "/Hall/HallScheme?" + "showtimeId=" + showtimeId + "&theaterId=imax-kiev&hallId=" + hallId + "&attrTechnology=" + technology + "&transactionId="); var placesContent = await showresponse.Content.ReadAsStringAsync(); var showPlaces = ParseShowTime(placesContent, cinemaHall); if (showPlaces == null) { continue; } var showTimeTech = TechnologyEnum.TwoD; if (technology.ToLower().Contains("3d")) { showTimeTech = TechnologyEnum.ThreeD; } if (technology.ToLower().Contains("imax")) { showTimeTech = TechnologyEnum.IMAX; } var showtimeEntity = new ShowTime { CinemaHall = cinemaHall, Movie = db.LocalMovieIdentities.Include(c => c.Movie).First(p => p.LocalIdentifier == movieId).Movie, StartTime = startTime, Link = url, ShowTimePlaces = showPlaces, Technology = showTimeTech }; showPlaces.ForEach(p => p.ShowTime = showtimeEntity); db.ShowTimes.Add(showtimeEntity); } ; db.SaveChanges(); } } catch (Exception ex) { _logger.Warn("Exception: " + ex.Message); _logger.Warn("Exception Trace: " + ex.StackTrace); } }