Ejemplo n.º 1
0
        // import data from web api
        public async Task ImportDataFromWebApi()
        {
            Property PR = DB.GetPropertyAsync().Result;

            if (PR != null && PR.WebApiAddress != "" && PR.WebApiAddress != null)
            {
                try
                {
                    var MS = new WebApi(PR.WebApiAddress);
                    MoviesFound = await MS.GetDataMovieArchiveWS(PR.GetMovieLastUpdate);

                    if (MoviesFound.Count > 0)
                    {
                        DB.InsertMoviesAsync(MoviesFound).Wait();
                    }

                    //Update date
                    PR.GetMovieLastUpdate = PR.GetRatingLastUpdate = DateTime.Now;
                    int r = DB.UpdatePropertyAsync(PR).Result;
                }
                catch (Exception e)
                { throw e; }
            }
            else
            {
                throw new NotSupportedException("ERROR: WebApi address not valid");
            }
        }
Ejemplo n.º 2
0
        public TvShowCard(TvShow tvshow)
        {
            InitializeComponent();

            DB = new DataBase();
            PY = DB.GetPropertyAsync().Result;
            TC = new TvShowCardModel(tvshow);
            if (tvshow.ID == 0)
            {
                this.ToolbarItems.Add(new ToolbarItem("AddTvShow", "addmedia.png", async() =>
                {
                    TvShow mi = new TvShow((TvShow)TC.TvShowDet);

                    mi.ID      = await DB.GetNextTvShowIDAsync();
                    mi.DateIns = DateTime.Now;

                    if (await DB.InsertTvShowAsync(mi) > 0)
                    {
                        DependencyService.Get <IMessage>().ShortAlert(String.Format(AppResources.MessageTitleTvShowImported, mi.Title));
                        //disabled for multiple tap
                        ((ToolbarItem)this.ToolbarItems[0]).IsEnabled = false;
                    }
                }));
            }
        }
Ejemplo n.º 3
0
        public MovieCard(Movie movie)
        {
            InitializeComponent();

            DB = new DataBase();
            PY = DB.GetPropertyAsync().Result;
            MC = new MovieCardModel(movie);
            if (movie.ID == 0)
            {
                this.ToolbarItems.Add(new ToolbarItem("AddMovie", "addmovie.png", () =>
                {
                    Movie mi = new Movie((Movie)MC.MovieDet);

                    mi.ID      = DB.GetNextMovieID();
                    mi.DateIns = DateTime.Now;

                    if (DB.InsertMovieAsync(mi).Result > 0)
                    {
                        DependencyService.Get <IMessage>().ShortAlert(String.Format(AppResources.MessageTitleMovieImported, mi.Title));
                        //disabled for multiple tap
                        ((ToolbarItem)this.ToolbarItems[0]).IsEnabled = false;
                    }
                }));
            }
        }
Ejemplo n.º 4
0
        protected async override void OnSleep()
        {
            // Se c'è connessione e il backup automatico è attivo eseguo backup
            try
            {
                var DB = new DataBase();

                var PR = await DB.GetPropertyAsync();

                if (PR != null && PR.AutomaticBackup)
                {
                    var DBS = new DropBoxLib();
                    await DBS.Authorize();

                    if (DBS.IsAuthorized)
                    {
                        // Write the database to DropBox folder
                        //await DBS.WriteFile(File.ReadAllBytes(DB.dbPath), "/"+Path.GetFileName(DB.dbPath));
                        MemoryStream s = DependencyService.Get <IFile>().GetFileStream(DB.dbPath);
                        await DBS.WriteFile(s, "/" + Path.GetFileName(DB.dbPath));
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                throw ex;
            };
        }
Ejemplo n.º 5
0
        int TypeOfMedia = 1;           // 1 = Movie  2 = Tv Show

        public InsertMedia()
        {
            InitializeComponent();
            DB         = new DataBase();
            PY         = DB.GetPropertyAsync().Result;
            MediaToIns = new InsertMediaModel();
        }
Ejemplo n.º 6
0
        public PersonCard(Person person)
        {
            InitializeComponent();

            DB = new DataBase();
            PY = DB.GetPropertyAsync().Result;
            PC = new PersonCardModel(person);
        }
Ejemplo n.º 7
0
        public TvShowSeason(int tmdbid, Season season)
        {
            InitializeComponent();

            DB    = new DataBase();
            PY    = DB.GetPropertyAsync().Result;
            TS    = new TvShowSeasonModel(tmdbid, season);
            Title = AppResources.TitleSeasonDetails + season.N.ToString();
        }
Ejemplo n.º 8
0
        public Properties()
        {
            InitializeComponent();

            DB = new DataBase();

            PY = DB.GetPropertyAsync().Result ?? new Property();
            AutoBkp.BindingContext       = PY;
            WebApiAddress.BindingContext = PY;
        }
Ejemplo n.º 9
0
        public MovieCardV2(Movie movie)
        {
            InitializeComponent();

            DB = new DataBase();
            PY = DB.GetPropertyAsync().Result;
            MC = new MovieCardModel(movie);
            if (movie.ID == 0)
            {
                this.ToolbarItems.Add(new ToolbarItem("AddMovie", "addmedia.png", async() =>
                {
                    Movie mi = new Movie((Movie)MC.MovieDet);

                    mi.ID      = await DB.GetNextMovieIDAsync();
                    mi.DateIns = DateTime.Now;

                    if (await DB.InsertMovieAsync(mi) > 0)
                    {
                        DependencyService.Get <IMessage>().ShortAlert(String.Format(AppResources.MessageTitleMovieImported, mi.Title));
                        //disabled for multiple tap
                        ((ToolbarItem)this.ToolbarItems[0]).IsEnabled = false;

                        if (PY.WebApiAddress != "" && PY.WebApiAddress != null)
                        {
                            //insert movie on db web
                            var WS = new WebApi(PY.WebApiAddress);
                            await WS.InsertNewMovie(mi.TmdbID, mi.Title, mi.PosterW342, mi.PosterW780);
                            var genrelist = MC.MovieDet.Genres.Split('-');
                            foreach (var genre in genrelist)
                            {
                                await WS.InsertMovieGenre(mi.ID, genre);
                            }
                        }
                    }
                }));
            }
        }
Ejemplo n.º 10
0
        public InsertMovie()
        {
            InitializeComponent();
            DB          = new DataBase();
            PY          = DB.GetPropertyAsync().Result;
            MoviesToIns = new InsertMovieModel();

            Folder.OnClickCommand = new Command(async() =>
            {
                FileData fileData = await CrossFilePicker.Current.PickFile();

                if (fileData != null)
                {
                    MoviesToIns.SearchMovieFromFile(Path.GetDirectoryName(fileData.FilePath));

                    MovieList.ItemsSource = MoviesToIns.Movies;
                }
            });
            Csv.OnClickCommand = new Command(async() =>
            {
                FileData fileData = await CrossFilePicker.Current.PickFile();

                if (fileData != null)
                {
                    await MoviesToIns.ImportMovieFromFile(fileData.FilePath);
                }
            });
            WebApi.OnClickCommand = new Command(async() =>
            {
                try
                {
                    await MoviesToIns.ImportMovieFromWebService();
                    DependencyService.Get <IMessage>().ShortAlert(String.Format(AppResources.MessageNMovieImported, MoviesToIns.Movies.Count.ToString()));
                }
                catch (Exception ex) { Console.Write(ex); }
            });
        }