Beispiel #1
0
        private void CheckExist(out List <ModifiedPPDScoreInfo> deletedScoreInfo)
        {
            var deleteIds = new List <object[]>();

            deletedScoreInfo = new List <ModifiedPPDScoreInfo>();
            using (var reader = ExecuteReader("select * from ScoreTable;", new SQLiteParameter[0]))
            {
                while (reader.Reader.Read())
                {
                    var  directorypath = (string)reader.Reader["directorypath"];
                    var  parentpath    = (string)reader.Reader["parentpath"];
                    var  scoreid       = DatabaseUtility.GetInt32(reader.Reader, 0);
                    bool isppd         = DatabaseUtility.GetInt32(reader.Reader, 26) == 1;
                    if (!Directory.Exists(directorypath))
                    {
                        deleteIds.Add(new object[] { scoreid, Directory.Exists(parentpath), parentpath });
                        if (isppd)
                        {
                            var guid  = (string)reader.Reader["guid"];
                            var bests = new int[] {
                                DatabaseUtility.GetInt32(reader.Reader, 15),
                                DatabaseUtility.GetInt32(reader.Reader, 16),
                                DatabaseUtility.GetInt32(reader.Reader, 17),
                                DatabaseUtility.GetInt32(reader.Reader, 18)
                            };
                            var deleted = new ModifiedPPDScoreInfo(scoreid, guid)
                            {
                                BestEasyID    = bests[0],
                                BestNormalID  = bests[1],
                                BestHardID    = bests[2],
                                BestExtremeID = bests[3],
                                Latency       = DatabaseUtility.GetFloat(reader.Reader, 31),
                                EasyHash      = GetHash(reader.Reader, 32),
                                NormalHash    = GetHash(reader.Reader, 33),
                                HardHash      = GetHash(reader.Reader, 34),
                                ExtremeHash   = GetHash(reader.Reader, 35),
                                UserVolume    = DatabaseUtility.GetInt32(reader.Reader, 41)
                            };
                            deletedScoreInfo.Add(deleted);
                        }
                    }
                }
            }
            foreach (object[] data in deleteIds)
            {
                var id          = (int)data[0];
                var parentexist = (bool)data[1];
                var parentpath  = (string)data[2];
                ExecuteDataTable(@"delete from ScoreTable where scoreid == @scoreid;", new SQLiteParameter[] {
                    new SQLiteParameter("@scoreid", id)
                });
            }
        }
Beispiel #2
0
 private static bool ComapreHashes(ModifiedPPDScoreInfo mppdsi1, ModifiedPPDScoreInfo mppdsi2)
 {
     if (mppdsi1.EasyHash.Length > 0 && mppdsi2.EasyHash.Length > 0 && SameHash(mppdsi1.EasyHash, mppdsi2.EasyHash))
     {
         return(true);
     }
     if (mppdsi1.NormalHash.Length > 0 && mppdsi2.NormalHash.Length > 0 && SameHash(mppdsi1.NormalHash, mppdsi2.NormalHash))
     {
         return(true);
     }
     if (mppdsi1.HardHash.Length > 0 && mppdsi2.HardHash.Length > 0 && SameHash(mppdsi1.HardHash, mppdsi2.HardHash))
     {
         return(true);
     }
     if (mppdsi1.ExtremeHash.Length > 0 && mppdsi2.ExtremeHash.Length > 0 && SameHash(mppdsi1.ExtremeHash, mppdsi2.ExtremeHash))
     {
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        private void UpdatePPDSongInformation(string dir, string parentdir, bool forceUpdate, out bool hasppd, List <ModifiedPPDScoreInfo> addedScoreInfo, SongInformation[] songInfos)
        {
            hasppd = false;
            var time = Directory.GetLastWriteTime(dir);

            // check files
            if (!CheckPPDDirectory(dir))
            {
                foreach (string childdir in Directory.GetDirectories(dir))
                {
                    UpdatePPDSongInformation(childdir, dir, forceUpdate, out bool temp, addedScoreInfo, songInfos);
                    hasppd |= temp;
                }
                if (hasppd)
                {
                    IsUpdatedDirectory(dir, time.ToString(CultureInfo.InvariantCulture), out bool IsExistDir);
                    if (!IsExistDir)
                    {
                        ExecuteDataTable("insert into ScoreTable(directorypath,isppd,parentpath,updatedate) values(@dir,@isppd,@parentdir,@updatedate);", new SQLiteParameter[] {
                            new SQLiteParameter("@dir", dir),
                            new SQLiteParameter("@isppd", "0"),
                            new SQLiteParameter("@parentdir", parentdir),
                            new SQLiteParameter("@updatedate", time.ToString(CultureInfo.InvariantCulture))
                        });
                    }
                }
                else
                {
                    // PPDの譜面がないフォルダ
                    // DBにフォルダがある場合はそのデータを削除
                    ExecuteDataTable("delete from ScoreTable where directorypath == @dir", new SQLiteParameter[] {
                        new SQLiteParameter("@dir", dir)
                    });
                }
            }
            else
            {
                hasppd = true;
                if (File.Exists(Path.Combine(dir, "data.ini")))
                {
                    time = GetLastFileTime(Path.Combine(dir, "data.ini"));
                }
                bool shouldUpdate = (IsUpdatedDirectory(dir, time.ToString(CultureInfo.InvariantCulture), out bool IsExistDir) || forceUpdate) || (songInfos != null && songInfos.FirstOrDefault(s => s.DirectoryPath.ToLower() == dir.ToLower()) != null);
                if (!shouldUpdate)
                {
                    return;
                }
                var info = SongInformation.ReadData(dir);
                if (!IsExistDir)
                {
                    ExecuteDataTable(@"insert into ScoreTable(
                                directorypath,
                                thumbtimestart,
                                thumbtimeend,
                                start,
                                end,
                                bpm,
                                difficultyeasy,
                                difficultynormal,
                                difficultyhard,
                                difficultyextreme,
                                availableeasy,
                                availablenormal,
                                availablehard,
                                availableextreme,
                                moviecutleft,
                                moviecutright,
                                moviecuttop,
                                moviecutbottom,
                                guid,
                                authorname,
                                updatedate,
                                isppd,
                                movievolume,
                                moviepath,
                                parentpath,
                                isold,
                                latency,
                                easyhash,
                                normalhash,
                                hardhash,
                                extremehash,
                                isaceasy,
                                isacnormal,
                                isachard,
                                isacextreme,
                                bpmstring
                        ) values(
                                @directorypath,
                                @thumbtimestart,
                                @thumbtimeend,
                                @start,
                                @end,
                                @bpm,
                                @difficultyeasy,
                                @difficultynormal,
                                @difficultyhard,
                                @difficultyextreme,
                                @availableeasy,
                                @availablenormal,
                                @availablehard,
                                @availableextreme,
                                @moviecutleft,
                                @moviecutright,
                                @moviecuttop,
                                @moviecutbottom,
                                @guid,
                                @authorname,
                                @updatedate,
                                @isppd,
                                @movievolume,
                                @moviepath,
                                @parentpath,
                                @isold,
                                @latency,
                                @easyhash,
                                @normalhash,
                                @hardhash,
                                @extremehash,
                                @isaceasy,
                                @isacnormal,
                                @isachard,
                                @isacextreme,
                                @bpmstring
                            );", new SQLiteParameter[] {
                        new SQLiteParameter("@directorypath", dir),
                        new SQLiteParameter("@thumbtimestart", info.ThumbStartTime),
                        new SQLiteParameter("@thumbtimeend", info.ThumbEndTime),
                        new SQLiteParameter("@start", info.StartTime),
                        new SQLiteParameter("@end", info.EndTime),
                        new SQLiteParameter("@bpm", info.BPM),
                        new SQLiteParameter("@difficultyeasy", info.GetDifficultyString(Difficulty.Easy)),
                        new SQLiteParameter("@difficultynormal", info.GetDifficultyString(Difficulty.Normal)),
                        new SQLiteParameter("@difficultyhard", info.GetDifficultyString(Difficulty.Hard)),
                        new SQLiteParameter("@difficultyextreme", info.GetDifficultyString(Difficulty.Extreme)),
                        new SQLiteParameter("@availableeasy", (info.Difficulty & SongInformation.AvailableDifficulty.Easy) == SongInformation.AvailableDifficulty.Easy?1:0),
                        new SQLiteParameter("@availablenormal", (info.Difficulty & SongInformation.AvailableDifficulty.Normal) == SongInformation.AvailableDifficulty.Normal?1:0),
                        new SQLiteParameter("@availablehard", (info.Difficulty & SongInformation.AvailableDifficulty.Hard) == SongInformation.AvailableDifficulty.Hard?1:0),
                        new SQLiteParameter("@availableextreme", (info.Difficulty & SongInformation.AvailableDifficulty.Extreme) == SongInformation.AvailableDifficulty.Extreme?1:0),
                        new SQLiteParameter("@moviecutleft", info.TrimmingData.Left),
                        new SQLiteParameter("@moviecutright", info.TrimmingData.Right),
                        new SQLiteParameter("@moviecuttop", info.TrimmingData.Top),
                        new SQLiteParameter("@moviecutbottom", info.TrimmingData.Bottom),
                        new SQLiteParameter("@guid", info.GUID),
                        new SQLiteParameter("@authorname", info.AuthorName),
                        new SQLiteParameter("@updatedate", time.ToString(CultureInfo.InvariantCulture)),
                        new SQLiteParameter("@isppd", 1),
                        new SQLiteParameter("@movievolume", info.MovieVolume),
                        new SQLiteParameter("@moviepath", info.MoviePath),
                        new SQLiteParameter("@parentpath", parentdir),
                        new SQLiteParameter("@isold", info.IsOld?1:0),
                        new SQLiteParameter("@latency", info.Latency),
                        new SQLiteParameter("@easyhash", info.EasyHash),
                        new SQLiteParameter("@normalhash", info.NormalHash),
                        new SQLiteParameter("@hardhash", info.HardHash),
                        new SQLiteParameter("@extremehash", info.ExtremeHash),
                        new SQLiteParameter("@isaceasy", (int)info.EasyNoteType),
                        new SQLiteParameter("@isacnormal", (int)info.NormalNoteType),
                        new SQLiteParameter("@isachard", (int)info.HardNoteType),
                        new SQLiteParameter("@isacextreme", (int)info.ExtremeNoteType),
                        new SQLiteParameter("@bpmstring", info.BPMString)
                    });
                }
                else
                {
                    ExecuteDataTable(@"update ScoreTable set
                                thumbtimestart     =@thumbtimestart,
                                thumbtimeend       =@thumbtimeend,
                                start              =@start,
                                end                =@end,
                                bpm                =@bpm,
                                difficultyeasy     =@difficultyeasy,
                                difficultynormal   =@difficultynormal,
                                difficultyhard     =@difficultyhard,
                                difficultyextreme  =@difficultyextreme,
                                availableeasy      =@availableeasy,
                                availablenormal    =@availablenormal,
                                availablehard      =@availablehard,
                                availableextreme   =@availableextreme,
                                moviecutleft       =@moviecutleft,
                                moviecutright      =@moviecutright,
                                moviecuttop        =@moviecuttop ,
                                moviecutbottom     =@moviecutbottom,
                                guid               =@guid,
                                authorname         =@authorname,
                                updatedate         =@updatedate,
                                isppd              =@isppd,
                                movievolume        =@movievolume,
                                moviepath          =@moviepath,
                                parentpath         =@parentpath,
                                isold              =@isold,
                                easyhash           =@easyhash,
                                normalhash         =@normalhash,
                                hardhash           =@hardhash,
                                extremehash        =@extremehash,
                                isaceasy           =@isaceasy,
                                isacnormal         =@isacnormal,
                                isachard           =@isachard,
                                isacextreme        =@isacextreme,
                                bpmstring          =@bpmstring
                        where directorypath = @directorypath;", new SQLiteParameter[] {
                        new SQLiteParameter("@directorypath", dir),
                        new SQLiteParameter("@thumbtimestart", info.ThumbStartTime),
                        new SQLiteParameter("@thumbtimeend", info.ThumbEndTime),
                        new SQLiteParameter("@start", info.StartTime),
                        new SQLiteParameter("@end", info.EndTime),
                        new SQLiteParameter("@bpm", info.BPM),
                        new SQLiteParameter("@difficultyeasy", info.GetDifficultyString(Difficulty.Easy)),
                        new SQLiteParameter("@difficultynormal", info.GetDifficultyString(Difficulty.Normal)),
                        new SQLiteParameter("@difficultyhard", info.GetDifficultyString(Difficulty.Hard)),
                        new SQLiteParameter("@difficultyextreme", info.GetDifficultyString(Difficulty.Extreme)),
                        new SQLiteParameter("@availableeasy", (info.Difficulty & SongInformation.AvailableDifficulty.Easy) == SongInformation.AvailableDifficulty.Easy?1:0),
                        new SQLiteParameter("@availablenormal", (info.Difficulty & SongInformation.AvailableDifficulty.Normal) == SongInformation.AvailableDifficulty.Normal?1:0),
                        new SQLiteParameter("@availablehard", (info.Difficulty & SongInformation.AvailableDifficulty.Hard) == SongInformation.AvailableDifficulty.Hard?1:0),
                        new SQLiteParameter("@availableextreme", (info.Difficulty & SongInformation.AvailableDifficulty.Extreme) == SongInformation.AvailableDifficulty.Extreme?1:0),
                        new SQLiteParameter("@moviecutleft", info.TrimmingData.Left),
                        new SQLiteParameter("@moviecutright", info.TrimmingData.Right),
                        new SQLiteParameter("@moviecuttop", info.TrimmingData.Top),
                        new SQLiteParameter("@moviecutbottom", info.TrimmingData.Bottom),
                        new SQLiteParameter("@guid", info.GUID),
                        new SQLiteParameter("@authorname", info.AuthorName),
                        new SQLiteParameter("@updatedate", time.ToString(CultureInfo.InvariantCulture)),
                        new SQLiteParameter("@isppd", 1),
                        new SQLiteParameter("@movievolume", info.MovieVolume),
                        new SQLiteParameter("@moviepath", info.MoviePath),
                        new SQLiteParameter("@parentpath", parentdir),
                        new SQLiteParameter("@isold", info.IsOld?1:0),
                        new SQLiteParameter("@easyhash", info.EasyHash),
                        new SQLiteParameter("@normalhash", info.NormalHash),
                        new SQLiteParameter("@hardhash", info.HardHash),
                        new SQLiteParameter("@extremehash", info.ExtremeHash),
                        new SQLiteParameter("@isaceasy", (int)info.EasyNoteType),
                        new SQLiteParameter("@isacnormal", (int)info.NormalNoteType),
                        new SQLiteParameter("@isachard", (int)info.HardNoteType),
                        new SQLiteParameter("@isacextreme", (int)info.ExtremeNoteType),
                        new SQLiteParameter("@bpmstring", info.BPMString)
                    });
                }
                using (var reader = ExecuteReader("select * from ScoreTable where directorypath = @directorypath;",
                                                  new SQLiteParameter[] { new SQLiteParameter("@directorypath", dir) }))
                {
                    while (reader.Reader.Read())
                    {
                        var index = reader.Reader.GetInt32(0);
                        var guid  = reader.Reader.GetString(23);
                        if (!IsExistDir)
                        {
                            var mppdsi = new ModifiedPPDScoreInfo(index, guid)
                            {
                                EasyHash    = info.EasyHash,
                                NormalHash  = info.NormalHash,
                                HardHash    = info.HardHash,
                                ExtremeHash = info.ExtremeHash
                            };
                            addedScoreInfo.Add(mppdsi);
                        }
                        break;
                    }
                }
            }
        }