protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            this.SpinAndWait(true);

            TMDBService tmdb = new TMDBService();

            if (App.TMDBConfig == null)
            {
                App.TMDBConfig = await tmdb.GetConfig();
            }

            Person p = await tmdb.GetPersonDetails(castinfo.ID);

            this.LoadPersonDetails(p);

            this.SpinAndWait(false);
        }
Ejemplo n.º 2
0
        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("CineDataWorkerRole entry point called", "Information");

            TMDBService tmdb = new TMDBService();

            dtNextFullRun = DateTime.MinValue;
            DateTime dtLastRun = DateTime.MinValue; //GetLastModified();

            if (dtLastRun.Date < DateTime.UtcNow.Date)
            {
                dtNextFullRun = DateTime.UtcNow;
            }
            else
            {
                dtNextFullRun = DateTime.UtcNow.Date.AddHours(26);
            }

            int tenMinSleepDuration = (int)TimeSpan.FromMinutes(10).TotalMilliseconds;

            LoadLocationData();

            while (true)
            {
                Trace.WriteLine("Working", "Information");

                if (DateTime.UtcNow >= dtNextFullRun)
                {
                    // execute a full run

                    dtNextFullRun = DateTime.UtcNow.Date.AddHours(26);

                    Cineworld.Configuration        conf  = null;
                    Task <Cineworld.Configuration> tConf = tmdb.GetConfig();
                    tConf.Wait();

                    if (!tConf.IsFaulted && tConf.Result != null)
                    {
                        conf = tConf.Result;
                    }
                    else
                    {
                        continue;
                    }

                    dictionaryCinemaFilms.Clear();

                    FilmsUK.Clear();
                    FilmsIE.Clear();

                    CinemasUK.Clear();
                    CinemasIE.Clear();

                    cinemaFilmsUK.Clear();
                    filmCinemasUK.Clear();

                    cinemaFilmsIE.Clear();
                    filmCinemasIE.Clear();

                    bool          processedUKFilms     = false;
                    bool          processedUKCinemas   = false;
                    bool          processedIEFilms     = false;
                    bool          processedIECinemas   = false;
                    bool          cinemafilmSaved      = false;
                    HashSet <int> ukCinemaPerformances = new HashSet <int>();
                    HashSet <int> ieCinemaPerformances = new HashSet <int>();

                    while (true)
                    {
                        try
                        {
                            if (!processedUKFilms)
                            {
                                ProcessFilmInfo(conf, FilmsUK, filmCinemasUK, RegionDef.GB);
                                processedUKFilms = true;
                            }

                            if (!processedUKCinemas)
                            {
                                ProcessCinemaInfo(CinemasUK, cinemaFilmsUK, FilmsUK, RegionDef.GB);
                                processedUKCinemas = true;
                            }

                            if (!processedIEFilms)
                            {
                                ProcessFilmInfo(conf, FilmsIE, filmCinemasIE, RegionDef.IE, true);
                                processedIEFilms = true;
                            }

                            if (!processedIECinemas)
                            {
                                ProcessCinemaInfo(CinemasIE, cinemaFilmsIE, FilmsIE, RegionDef.IE);
                                processedIECinemas = true;
                            }

                            if (!cinemafilmSaved)
                            {
                                ProcessData();
                                cinemafilmSaved = true;
                            }

                            ProcessPerformances(ukCinemaPerformances, ieCinemaPerformances);

                            break;
                        }
                        catch (Exception ex)
                        {
                            LogError(ex, null);
                            Thread.Sleep(tenMinSleepDuration);
                        }
                    }
                }

#if DEBUG
                return;
#else
                Thread.Sleep(tenMinSleepDuration);
#endif
            }
        }
Ejemplo n.º 3
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.PersonDetailsSegment.Enabled = false;

            this.BusyIndicator.StartAnimating();

            this.NavigationItem.Title = this.Cast.Name;

            Person person = null;

            try
            {
                TMDBService tmdbService = new TMDBService();

                if (Application.TMDBConfig == null)
                {
                    Application.TMDBConfig = await tmdbService.GetConfig();
                }

                person = await tmdbService.GetPersonDetails(this.Cast.ID);
            }
            catch
            {
                UIAlertView alert = new UIAlertView("Cineworld", "Error downloading data. Please try again later", null, "OK", null);
                alert.Show();

                return;
            }
            finally
            {
                this.BioView.Hidden = false;
                this.BusyIndicator.StopAnimating();
            }

            var height = 0;

            string url   = Cast.ProfilePicture == null ? null : Cast.ProfilePicture.OriginalString;
            var    image = ImageManager.Instance.GetImage(url);

            if (image == null)
            {
                image = UIImage.FromFile("Images/PlaceHolder.png");
            }

            this.Poster.Image = image;
            this.Poster.Image = image;
            this.Poster.Layer.CornerRadius       = 10f;
            this.Poster.Layer.MasksToBounds      = true;
            this.Poster.Layer.RasterizationScale = UIScreen.MainScreen.Scale;
            this.Poster.Layer.Opaque             = true;

            DateTime dtBirthDay;

            if (DateTime.TryParseExact(person.Birthday, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dtBirthDay))
            {
                UILabel birthday = new UILabel(new CGRect(0, height, 166, 20));
                birthday.Font = UIFont.FromName("HelveticaNeue", 12f);
                birthday.Text = String.Format("Born: {0}", dtBirthDay.ToString("dd MMM yyyy"));

                this.MiscView.AddSubview(birthday);
                height += 30;
            }

            if (!String.IsNullOrWhiteSpace(person.PlaceOfBirth))
            {
                UILabel birthplace = new UILabel(new CGRect(0, height, 166, 20));
                birthplace.Font = UIFont.FromName("HelveticaNeue", 12f);
                birthplace.Text = person.PlaceOfBirth;

                this.MiscView.AddSubview(birthplace);
                height += 30;
            }

            DateTime dtDeathDay;

            if (DateTime.TryParseExact(person.Deathday, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dtDeathDay))
            {
                UILabel deathDay = new UILabel(new CGRect(0, height, 166, 20));
                deathDay.Font = UIFont.FromName("HelveticaNeue", 12f);
                deathDay.Text = String.Format("Died: {0}", dtBirthDay.ToString("dd MMM yyyy"));

                this.MiscView.AddSubview(deathDay);
                height += 30;
            }

            if (!String.IsNullOrWhiteSpace(person.Biography))
            {
                UILabel biography = new UILabel(new CGRect(15, 0, 290, 1));
                biography.Font  = UIFont.FromName("HelveticaNeue", 12f);
                biography.Lines = 0;
                biography.Text  = person.Biography;
                biography.SizeToFit();

                UIScrollView scrollviewer = new UIScrollView(new CGRect(0, 183, 320, 207));
                scrollviewer.ContentSize = biography.Bounds.Size;
                scrollviewer.AddSubview(biography);

                this.BioView.AddSubview(scrollviewer);
            }

            if (person.Credits != null && person.Credits.Cast != null && person.Credits.Cast.Length > 0)
            {
                List <MovieCastInfo> movieRoles = new List <MovieCastInfo>();

                foreach (var movieRole in person.Credits.Cast.OrderByDescending(p => p.ReleaseDate))
                {
                    movieRoles.Add(new MovieCastInfo(Application.TMDBConfig.Images.BaseUrl, "w185", movieRole));
                }

                CastFilmTableSource castFilmSource = new CastFilmTableSource(movieRoles);
                this.FilmsView.Source = castFilmSource;
                this.FilmsView.ReloadData();
            }

            this.PersonDetailsSegment.ValueChanged += (sender, e) =>
            {
                switch (this.PersonDetailsSegment.SelectedSegment)
                {
                case 0:
                    this.BioView.Hidden   = false;
                    this.FilmsView.Hidden = true;
                    break;

                case 1:
                    this.FilmsView.Hidden = false;
                    this.BioView.Hidden   = true;
                    break;
                }
            };

            this.PersonDetailsSegment.Enabled = true;
        }