public MovieOldV2 LoadMovieBase(XmlNode xmlNode, bool isFake) { var result = new MovieOldV2(); result.id = TempIdCounter++; result.useFakeNames = isFake; foreach (XmlLinkedNode movieChild in xmlNode.ChildNodes) { switch (movieChild.Name) { case "title": if (isFake) { result.titleFake = movieChild.GetElementValue(); } else { result.title = movieChild.GetElementValue(); } break; case "description": result.description = movieChild.GetElementValue(); break; case "data": result.actors = movieChild.GetAttribute("actors"); result.director = movieChild.GetAttribute("director"); result.country = movieChild.GetAttribute("country"); result.year = movieChild.GetAttributeInteger("year"); result.genre = movieChild.GetAttributeInteger("genre"); result.blocks = movieChild.GetAttributeInteger("blocks"); result.time = movieChild.GetAttributeInteger("time"); result.price = movieChild.GetAttributeInteger("price"); result.critics = movieChild.GetAttributeInteger("critics"); result.speed = movieChild.GetAttributeInteger("speed"); result.outcome = movieChild.GetAttributeInteger("outcome"); result.xrated = movieChild.GetAttributeInteger("xrated") == 1; result.deleted = false; result.custom = false; break; } } return(result); }
public List <MovieOldV2> LoadMovie(XmlNode xmlNode, bool isFake) { var result = new List <MovieOldV2>(); MovieOldV2 currentMovie = LoadMovieBase(xmlNode, isFake); result.Add(currentMovie); foreach (XmlLinkedNode movieChild in xmlNode.ChildNodes) { switch (movieChild.Name) { case "episode": var episode = LoadMovieBase(movieChild, isFake); episode.episode = movieChild.GetAttributeInteger("number"); episode.parentID = currentMovie.id; result.Add(episode); break; } } return(result); }
public static List <MovieOldV2> LoadMoviesOldV2(MySqlConnection connection) { var result = new List <MovieOldV2>(); var command = connection.CreateCommand(); command.CommandText = "SELECT * FROM tvt_filme"; var Reader = command.ExecuteReader(); try { while (Reader.Read()) { var reader = new SQLReaderOldV2(Reader); var movie = new MovieOldV2(); movie.id = reader.GetInt("id"); movie.title = reader.GetString("title"); movie.titleEnglish = reader.GetString("titleEnglish"); movie.description = reader.GetString("description"); movie.descriptionEnglish = reader.GetString("descriptionEnglish"); movie.actors = reader.GetString("actors"); movie.director = reader.GetString("director"); movie.price = reader.GetInt("price"); movie.year = reader.GetInt("year"); movie.country = reader.GetString("country"); movie.genre = reader.GetInt("genre"); movie.blocks = reader.GetInt("blocks"); movie.critics = reader.GetInt("critics"); movie.outcome = reader.GetInt("outcome"); movie.speed = reader.GetInt("speed"); movie.xrated = reader.GetBool("xrated"); movie.parentID = reader.GetInt("parentID"); movie.episode = reader.GetInt("episode"); movie.approved = reader.GetBool("approved"); movie.time = reader.GetInt("time"); movie.creatorID = reader.GetString("creatorID"); movie.editorID = reader.GetString("editorID"); movie.deleted = reader.GetBool("deleted"); movie.custom = reader.GetBool("custom"); result.Add(movie); } } finally { if (Reader != null && !Reader.IsClosed) { Reader.Close(); } } //var fakes = new Dictionary<string, string>(); //Fakes command = connection.CreateCommand(); command.CommandText = "SELECT * FROM tvt_convert WHERE type = 'title'"; Reader = command.ExecuteReader(); try { while (Reader.Read()) { var oldValue = Reader.GetString("old").Trim(); var newValue = Reader.GetString("new").Trim(); var foundMovies = result.Where(x => x.title == oldValue); foreach (var movie in foundMovies) { movie.titleFake = newValue; } foundMovies = result.Where(x => x.titleEnglish == oldValue); foreach (var movie in foundMovies) { movie.titleEnglishFake = newValue; } foundMovies = result.Where(x => string.IsNullOrEmpty(x.titleFake) && x.title.Contains(oldValue)); foreach (var movie in foundMovies) { movie.titleFake = movie.title.Replace(oldValue, newValue); } foundMovies = result.Where(x => string.IsNullOrEmpty(x.titleEnglishFake) && x.titleEnglish.Contains(oldValue)); foreach (var movie in foundMovies) { movie.titleEnglishFake = movie.titleEnglish.Replace(oldValue, newValue); } } } finally { if (Reader != null && !Reader.IsClosed) { Reader.Close(); } } return(result); }