public bool SaveModel(string ID = "") { string table = ((Main)GetWindowByName("Main")).GetCurrentList(); if (ID == "" && DetailMovie != null && DetailMovie.id.ToUpper() == id.ToUpper()) { InsertMovie(table); return(true); } id = ID; if (DetailMovie != null) { if (DetailMovie.id.ToUpper() != id.ToUpper()) { //修改了原来的识别码 if (string.IsNullOrEmpty(table)) { if (DataBase.SelectMovieByID(ID) != null) { return(false); } DataBase.DeleteByField("movie", "id", DetailMovie.id); DetailMovie.id = id; DataBase.InsertFullMovie(DetailMovie); } else { //修改了清单中的识别码 using (MySqlite mySqlite = new MySqlite("mylist")) { if (mySqlite.SelectMovieBySql($"select * from {table} where id='{ID}'") != null) { return(false); } mySqlite.DeleteByField(table, "id", DetailMovie.id); DetailMovie.id = id; mySqlite.InsertFullMovie(DetailMovie, table); } } } else { InsertMovie(table); } return(true); } return(false); }
private void InsertMovie(string table) { if (string.IsNullOrEmpty(table)) { DataBase.InsertFullMovie(DetailMovie); } else { using (MySqlite mySqlite = new MySqlite("mylist")) { mySqlite.InsertFullMovie(DetailMovie, table); } } }
public void Create() { int max = number; string savepath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "database", $"sample_{max}.sqlite"); MySqlite db = new MySqlite(savepath, true); db.CreateTable(DataBase.SQLITETABLE_MOVIE); db.CreateTable(DataBase.SQLITETABLE_ACTRESS); db.CreateTable(DataBase.SQLITETABLE_LIBRARY); db.CreateTable(DataBase.SQLITETABLE_JAVDB); db.CloseDB(); List <string> ID = GetID(max); using (MySqlite mySqlite = new MySqlite(savepath, true)) { for (int i = 0; i < max; i++) { Movie movie = new Movie() { id = ID[i], favorites = new Random(Guid.NewGuid().GetHashCode()).Next(0, 6), visits = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100), title = GetSomeText(30, i), runtime = new Random(Guid.NewGuid().GetHashCode()).Next(0, 300), rating = (float)(new Random(Guid.NewGuid().GetHashCode()).Next(0, 100)) / 10, filesize = Math.Abs(5 * 1024 * new Random(Guid.NewGuid().GetHashCode()).Next(0, 1024 * 1024)), subsection = i % 100 == 0 ? "path1;path2" : "", scandate = DateTime.Now.AddDays(-new Random(Guid.NewGuid().GetHashCode()).Next(-500, 500)).ToString("yyyy-MM-dd HH:mm:ss"), otherinfo = DateTime.Now.AddDays(-new Random(Guid.NewGuid().GetHashCode()).Next(-500, 500)).ToString("yyyy-MM-dd HH:mm:ss"), releasedate = DateTime.Now.AddDays(-new Random(Guid.NewGuid().GetHashCode()).Next(-500, 500)).ToString("yyyy-MM-dd"), vediotype = new Random(Guid.NewGuid().GetHashCode()).Next(1, 4), tag = "系列" + new Random(Guid.NewGuid().GetHashCode()).Next(defaultmax), director = "导演" + new Random(Guid.NewGuid().GetHashCode()).Next(defaultmax), studio = "发行商" + new Random(Guid.NewGuid().GetHashCode()).Next(defaultmax) }; movie.genre = GetGenre(movie); movie.actor = GetActor(max); movie.label = GetLabel(max); mySqlite.InsertFullMovie(movie, "movie"); Console.WriteLine(i); } } }