private void ScanForSongsRecursively(object folder)
    {
        List <SongInfo> list = new List <SongInfo>();

        string[] chartFiles    = Directory.GetFiles(dir, "*.chart", SearchOption.AllDirectories);
        string[] midFiles      = Directory.GetFiles(dir, "*.mid", SearchOption.AllDirectories);
        string[] combinedFiles = chartFiles.Concat(midFiles).ToArray();

        foreach (string s in combinedFiles)
        {
            switch (s.Substring(s.Length - 1, 1))
            {
            case "t":
                try
                {
                    ChartReader testReader        = new ChartReader();
                    Song        _testCurrentChart = new Song();
                    _testCurrentChart = testReader.ReadChartFile(s);
                    list.Add(CreateSongInfo(s, Song.ChartType.chart));
                }
                catch (Exception e)
                {
                }
                break;

            case "d":
                try
                {
                    SongMID midFile = MidReader.ReadMidi(s, false);
                    ChartWriter.WriteChart(midFile, dir + "/notes.chart", false);
                    ChartReader testReader        = new ChartReader();
                    Song        _testCurrentChart = new Song();
                    _testCurrentChart = testReader.ReadChartFile(@dir + "/notes.chart");
                    File.Delete(@dir + "/notes.chart");
                    list.Add(CreateSongInfo(s, Song.ChartType.mid));
                }
                catch (Exception e)
                {
                }
                break;
            }
        }

        lock (lockObject)
        {
            songs = list;
        }
    }
Exemple #2
0
        public static QBCParser LoadMidiSong(string fileName, bool forceRB3)
        {
            QBCParser qbc  = null;
            Song      song = null;

            try {
                song = MidReader.ReadMidi(fileName);
                String      chartFile   = ChartWriter.writeChart(song, "", false, forceRB3).ToString();
                ChartParser chartParser = new ChartParser(chartFile, false);
                qbc = chartParser.ConvertToQBC();
            }
            catch (Exception e)
            {
                MessageBox.Show("Error using the new MIDI importer.\nReverting to original GHTCP method. \n\n" + e.ToString(), "MIDI Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                qbc = new MIDIParser(fileName).LoadMidi().ConvertToQBC();
            }
            return(qbc);
        }
        public void TestPaging()
        {
            var data = new[]
            {
                Point(now), Point(now.PlusDays(5)), Point(now.PlusDays(20)),
                Point(now.PlusDays(21)), Point(now.PlusDays(25)),
                Point(now.PlusDays(50))
            };

            var expected = new[]
            {
                new[] { Point(now), Point(now.PlusDays(5)), Point(now.PlusDays(20)) },
                new[] { Point(now.PlusDays(21)), Point(now.PlusDays(25)) },
                new[] { Point(now.PlusDays(50)) }
            };

            var actual = ChartWriter.Group(data).Select(list => list.ToArray()).ToArray();

            AssertArraysEqual(expected, actual);
        }
        public IHttpActionResult GenerateChart([FromBody] List <SerializedDataPoint> data, string format = "", string timezone = "Z")
        {
            try
            {
                if (data == null || data.Count == 0)
                {
                    throw new ArgumentException("Missing PEF body");
                }
                var parsedFormat = ChartWriter.ParseFormat(format);

                var dateTimeZone = DataParser.ParseTimeZone(timezone);
                var deserialized = DataParser.Parse(data, dateTimeZone);

                var stream = writer.Stream(deserialized, parsedFormat);
                return(WrapStream(stream, parsedFormat));
            }
            catch (ArgumentException e)
            {
                return(new BadRequestErrorMessageResult(e.Message, this));
            }
        }