public void StartSync(FileHandler.platformType platform = FileHandler.platformType.Windows)
        {
            FileHandler          handler = new FileHandler();
            List <Movie>         movies  = handler.allMoviesInXml();
            List <List <Movie> > toSend  = DivideByAmt(this.groupSize, movies);

            CreateLink(toSend);
        }
Esempio n. 2
0
        /// <summary>
        /// Use to make sure the user files are in line.
        /// </summary>
        /// <param name="UID"></param>
        public async static Task SyncUserFiles(string UID, Client socket, FileHandler.platformType platform = FileHandler.platformType.Windows)
        {
            List <Movie> listOfMoviesDB = await MongoInteraction.AllMoviesByUser(UID, socket);

            FileHandler  tmpFileHandler  = new FileHandler(platform);
            List <Movie> listOfMoviesXML = tmpFileHandler.allMoviesInXml();

            //The user has no entries on the DB
            if (listOfMoviesDB.Count == 0)
            {
                if (listOfMoviesXML.Count == 0)
                {
                    //The user doesn't have any movies in their XML either.
                    return;
                }

                else
                {
                    await AddMoviesDB(listOfMoviesXML, UID, socket);
                }
            }

            //The user has no entries in their XML
            else if (listOfMoviesXML.Count == 0)
            {
                if (listOfMoviesDB.Count == 0)
                {
                    //The user doesn't have any movies in their DB.
                    return;
                }

                else
                {
                    TMDBHelper   helper  = new TMDBHelper();
                    FileHandler  handler = new FileHandler(platform);
                    List <Movie> toAdd   = new List <Movie>();

                    handler.addMovies(listOfMoviesDB);
                }
            }

            else
            {
                List <Movie> dbBalance = FindDifferences(listOfMoviesDB, listOfMoviesXML);
                if (dbBalance.Count != 0)
                {
                    await AddMoviesDB(dbBalance, UID, socket);
                }

                List <Movie> xmlBalance = FindDifferences(listOfMoviesXML, listOfMoviesDB);
                if (xmlBalance.Count != 0)
                {
                    AddMoviesXML(xmlBalance, platform);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Full version of the add movies function.
        /// </summary>
        /// <param name="listOfMovies"></param>
        private static void AddMoviesXMLFull(List <Movie> listOfMovies, FileHandler.platformType platform)
        {
            FileHandler handler = new FileHandler();

            handler.addMovies(listOfMovies);
        }
Esempio n. 4
0
        public async static Task AddMovies(List <Movie> toAdd, string UID, Client socket, FileHandler.platformType platform = FileHandler.platformType.Windows)
        {
            toAdd.ForEach(x => x.genresCSV = x.getGenreCommaSeperated());
            await AddMoviesDB(toAdd, UID, socket);

            AddMoviesXMLFull(toAdd, platform);
        }