Ejemplo n.º 1
0
        public void ReadFromStream(MStreamReader sr)
        {
            Extra = sr.ReadInt32();

            int count = sr.ReadInt16();

            ReplayFrames = new List <ReplayFrame>(count);
            for (var i = 0; i < count; i++)
            {
                var rframes = sr.ReadData <ReplayFrame>();
                ReplayFrames.Add(rframes);
            }

            Action = sr.ReadByte();

            var sframe = new ScoreFrame();

            sframe.ReadFromStream(sr);
            ScoreFrame = sframe;
        }
Ejemplo n.º 2
0
        public void ReadFromStream(MStreamReader sr)
        {
            SetId = sr.ReadInt32();

            var count = sr.ReadInt32();

            ChildrenBeatmaps = new List <ChildrenBeatmap>();
            for (var i = 0; i < count; i++)
            {
                ChildrenBeatmaps.Add(sr.ReadData <ChildrenBeatmap>());
            }

            RankedStatus = (BeatmapSetOnlineStatus)sr.ReadSByte();

            if (DateTime.TryParse(sr.ReadString(), out var res))
            {
                ApprovedDate = res;
            }

            if (DateTime.TryParse(sr.ReadString(), out res))
            {
                LastUpdate = res;
            }

            if (DateTime.TryParse(sr.ReadString(), out res))
            {
                LastChecked = res;
            }

            Artist     = sr.ReadString();
            Title      = sr.ReadString();
            Creator    = sr.ReadString();
            Source     = sr.ReadString();
            Tags       = sr.ReadString();
            HasVideo   = sr.ReadBoolean();
            Genre      = (Genre)sr.ReadSByte();
            Language   = (Language)sr.ReadSByte();
            Favourites = sr.ReadInt64();
            Disabled   = sr.ReadBoolean();
        }
Ejemplo n.º 3
0
 public void ReadFromStream(MStreamReader sr)
 {
     Frame = sr.ReadData <ScoreFrame>();
 }
Ejemplo n.º 4
0
 public void ReadFromStream(MStreamReader sr)
 {
     Frames = sr.ReadData <SpectatorFrame>();
 }
Ejemplo n.º 5
0
        public ActionResult PutDatabase(
            [FromQuery] string key,
            [FromQuery] bool drop
            )
        {
            if (key != Environment.GetEnvironmentVariable("PRIVATE_API_KEY"))
            {
                return(Unauthorized("Key is wrong!"));
            }

            if (drop)
            {
                _searchEngine.DeleteAllBeatmaps();
                using (var db = _contextFactory.GetForWrite()) {
                    db.Context.Database.ExecuteSqlCommand
                        ("SET FOREIGN_KEY_CHECKS = 0;" +
                        "TRUNCATE TABLE `Beatmaps`;" +
                        "ALTER TABLE `Beatmaps` AUTO_INCREMENT = 1;" +
                        "TRUNCATE TABLE `BeatmapSet`;" +
                        "ALTER TABLE `BeatmapSet` AUTO_INCREMENT = 1;" +
                        "SET FOREIGN_KEY_CHECKS = 1;");
                }
            }

            lock (_lock) {
                var f = Request.Form.Files["dump.piss"];

                using (var stream = f.OpenReadStream())
                    using (var sr = new MStreamReader(stream))
                        using (var db = _contextFactory.GetForWrite())
                        {
                            var count = sr.ReadInt32();
                            Logger.LogPrint($"Count: {count}");

                            for (var i = 0; i < count; i++)
                            {
                                var set = sr.ReadData <BeatmapSet>();

                                Logger.LogPrint($"Importing BeatmapSet {set.SetId} {set.Artist} - {set.Title} ({set.Creator}) of Index {i}", LoggingTarget.Database, LogLevel.Important);

                                if (!drop)
                                {
                                    if (db.Context.BeatmapSet.Any(s => s.SetId == set.SetId))
                                    {
                                        db.Context.BeatmapSet.Update(set);
                                    }
                                    else
                                    {
                                        db.Context.BeatmapSet.Add(set);
                                    }
                                }
                                else
                                {
                                    db.Context.BeatmapSet.Add(set);
                                }
                            }
                            Logger.LogPrint("Finish importing maps!");
                        }

                return(Ok("Success!"));
            }
        }