public Beatmap GetBeatmapByIdentifiable(IMapIdentifiable id) { return(ThreadedProvider.Query <Beatmap>(TABLE_BEATMAP, new Where[] { ("version", id.Version), ("folderName", id.FolderName) },
public Beatmap GetBeatmapByIdentifiable(IMapIdentifiable map) { var entity = Ctx.Beatmaps.FirstOrDefault(full => map.FolderName == full.FolderName && map.Version == full.Version); return(entity); }
public static Beatmap GetBeatmapByIdentifiable(this AppDbOperator op, IMapIdentifiable id) { try { return(op.ThreadedProvider.Query <Beatmap>(TABLE_BEATMAP, new Where[] { ("version", id.Version), ("folderName", id.FolderName) }, count: 1).FirstOrDefault()); }
public bool TryRemoveMapFromCollection(IMapIdentifiable identity, Collection collection) { try { _dbOperator.RemoveMapFromCollection(identity, collection); return(true); } catch (Exception ex) { Notification.Push($"Error while removing beatmap from recent: {ex.Message}"); return(false); } }
public static string GetFolder(this IMapIdentifiable map, out bool isFromDb, out string freePath) { if (map.IsMapTemporary()) { var folder = Path.GetDirectoryName(map.FolderName); isFromDb = false; freePath = map.FolderName; return(folder); } isFromDb = true; freePath = null; return(map.InOwnDb ? Path.Combine(Domain.CustomSongPath, map.FolderName) : Path.Combine(Domain.OsuSongPath, map.FolderName)); }
public BeatmapSettings GetMapFromDb(IMapIdentifiable id) { try { if (id.IsMapTemporary()) { Logger.Debug("需确认加入自定义目录后才可继续"); } var map = ThreadedProvider.Query <BeatmapSettings>(TABLE_MAP, new Where[] { ("version", id.Version), ("folder", id.FolderName), ("ownDb", id.InOwnDb) }, count: 1) .FirstOrDefault(); if (map == null) { var guid = Guid.NewGuid().ToString(); ThreadedProvider.Insert(TABLE_MAP, new Dictionary <string, object>() { ["id"] = guid, ["version"] = id.Version, ["folder"] = id.FolderName, ["ownDb"] = id.InOwnDb, ["offset"] = 0 }); return(new BeatmapSettings { Id = guid, Version = id.Version, FolderName = id.FolderName, InOwnDb = id.InOwnDb, Offset = 0 }); } return(map); }
public Beatmap GetBeatmapByIdentifiable(IMapIdentifiable beatmap) { Beatmap map; try { map = _dbOperator.GetBeatmapByIdentifiable(beatmap); if (map is null) { Notification.Push(I18NUtil.GetString("err-mapNotInDb"), I18NUtil.GetString("text-error")); } } catch (Exception ex) { Notification.Push($"Error while getting beatmap by IMapIdentifiable from database: {ex.Message}"); map = null; } return(map); }
public static MapIdentity GetIdentity(this IMapIdentifiable entry) => entry != null ? new MapIdentity(entry.FolderName, entry.Version) : default;
public static MapIdentity GetIdentity(this IMapIdentifiable identifiable) => identifiable != null ? new MapIdentity(identifiable.FolderName, identifiable.Version) : default;
public static bool EqualsTo(this IMapIdentifiable id1, IMapIdentifiable id2) => id1.FolderName == id2.FolderName && id1.Version == id2.Version;
public static Beatmap GetBeatmapsByIdentifiable(IMapIdentifiable map) { return(GetBeatmapsByIdentifiable(new[] { map }).FirstOrDefault()); }
public static bool IsMapTemporary(this IMapIdentifiable map) { return(Path.IsPathRooted(map.FolderName)); }