Did some preliminary streaming tests from an mobile app and the functionality works. it is a little rough but it can be smoothed out. Created manager classes to abstract functionality from the SongManager class. #7
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Configuration;
|
||||||
|
|
||||||
|
using Icarus.Controllers.Utilities;
|
||||||
|
using Icarus.Models;
|
||||||
|
using Icarus.Models.Context;
|
||||||
|
|
||||||
|
namespace Icarus.Controllers.Managers
|
||||||
|
{
|
||||||
|
public class AlbumManager : BaseManager
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Configuration;
|
||||||
|
|
||||||
|
using Icarus.Controllers.Utilities;
|
||||||
|
using Icarus.Models;
|
||||||
|
using Icarus.Models.Context;
|
||||||
|
|
||||||
|
namespace Icarus.Controllers.Managers
|
||||||
|
{
|
||||||
|
public class ArtistManager : BaseManager
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Configuration;
|
||||||
|
|
||||||
|
using Icarus.Controllers.Utilities;
|
||||||
|
using Icarus.Models;
|
||||||
|
using Icarus.Models.Context;
|
||||||
|
|
||||||
|
namespace Icarus.Controllers.Managers
|
||||||
|
{
|
||||||
|
public class GenreManager : BaseManager
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1131,7 +1131,7 @@ namespace Icarus.Controllers.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var album = albumStore.GetAlbum(song);
|
var album = albumStore.GetAlbum(song, true);
|
||||||
|
|
||||||
if (album.SongCount <= 1)
|
if (album.SongCount <= 1)
|
||||||
{
|
{
|
||||||
@@ -1146,7 +1146,7 @@ namespace Icarus.Controllers.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var artist = artistStore.GetArtist(song);
|
var artist = artistStore.GetArtist(song, true);
|
||||||
|
|
||||||
if (artist.SongCount <= 1)
|
if (artist.SongCount <= 1)
|
||||||
{
|
{
|
||||||
@@ -1161,7 +1161,7 @@ namespace Icarus.Controllers.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var genre = genreStore.GetGenre(song);
|
var genre = genreStore.GetGenre(song, true);
|
||||||
|
|
||||||
if (genre.SongCount <= 1)
|
if (genre.SongCount <= 1)
|
||||||
{
|
{
|
||||||
@@ -1176,7 +1176,7 @@ namespace Icarus.Controllers.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var year = yearStore.GetSongYear(song);
|
var year = yearStore.GetSongYear(song, true);
|
||||||
|
|
||||||
if (year.SongCount <= 1)
|
if (year.SongCount <= 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Configuration;
|
||||||
|
|
||||||
|
using Icarus.Controllers.Utilities;
|
||||||
|
using Icarus.Models;
|
||||||
|
using Icarus.Models.Context;
|
||||||
|
|
||||||
|
namespace Icarus.Controllers.Managers
|
||||||
|
{
|
||||||
|
public class YearManager : BaseManager
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Web;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
@@ -37,23 +39,19 @@ namespace Icarus.Controllers
|
|||||||
|
|
||||||
#region HTTP endpoints
|
#region HTTP endpoints
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public IActionResult Get(int id)
|
public async Task<IActionResult> Get(int id)
|
||||||
{
|
{
|
||||||
var songStore= HttpContext
|
var songStore= HttpContext
|
||||||
.RequestServices
|
.RequestServices
|
||||||
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
|
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
|
||||||
|
|
||||||
var song = songStore.GetSong(new Song
|
var song = songStore.GetSong(new Song { Id = id });
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var mem = new MemoryStream();
|
var mem = new MemoryStream();
|
||||||
|
|
||||||
using (var stream = new FileStream(song.SongPath, FileMode.Open, FileAccess.Read))
|
using (var stream = new FileStream(song.SongPath, FileMode.Open, FileAccess.Read))
|
||||||
{
|
{
|
||||||
stream.CopyToAsync(mem);
|
await stream.CopyToAsync(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
mem.Position = 0;
|
mem.Position = 0;
|
||||||
|
|||||||
@@ -193,21 +193,17 @@ namespace Icarus.Models.Context
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("dddd");
|
|
||||||
_logger.Info("Retrieving song from database");
|
_logger.Info("Retrieving song from database");
|
||||||
|
|
||||||
using (var conn = GetConnection())
|
using (var conn = GetConnection())
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
var query = "SELECT * FROM Song WHERE Id=@Id";
|
var query = "SELECT * FROM Song WHERE Id=@Id";
|
||||||
Console.WriteLine("Transfer");
|
|
||||||
|
|
||||||
using (var cmd = new MySqlCommand(query, conn))
|
using (var cmd = new MySqlCommand(query, conn))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Temperment");
|
|
||||||
cmd.Parameters.AddWithValue("@Id", song.Id);
|
cmd.Parameters.AddWithValue("@Id", song.Id);
|
||||||
|
|
||||||
Console.WriteLine("Lost");
|
|
||||||
using (var reader = cmd.ExecuteReader())
|
using (var reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
song = ParseSingleData(reader);
|
song = ParseSingleData(reader);
|
||||||
@@ -303,7 +299,6 @@ namespace Icarus.Models.Context
|
|||||||
{
|
{
|
||||||
Song song = new Song();
|
Song song = new Song();
|
||||||
|
|
||||||
Console.WriteLine("ddddddddddddd");
|
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
song.Id = Convert.ToInt32(reader["Id"]);
|
song.Id = Convert.ToInt32(reader["Id"]);
|
||||||
@@ -321,8 +316,6 @@ namespace Icarus.Models.Context
|
|||||||
song.YearId = Convert.ToInt32(reader["YearId"].ToString());
|
song.YearId = Convert.ToInt32(reader["YearId"].ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Panic");
|
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user