using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZSMusic.BLL;
using ZSMusic.Model;

namespace WEB.musicspy
{
    public partial class search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<Music> list = new List<Music>();
            try
            {
                string word = Request["word"];
                int page = Convert.ToInt32(Request["page"]);
                int num = Convert.ToInt32(Request["num"]);
                list.AddRange(MusicHelper.Search(Request["source"],word, page, num));
            }
            catch (Exception ex)
            {
                Music m = new Music();
                m.Name = ex.Message;
                m.Artist = ex.GetType().ToString();
                m.Album = ex.TargetSite.ToString();
                list.Add(m);
            }
            List<SongResult> result = SongResult.Convert(list);
            Response.Write(JsonConvert.SerializeObject(result));
        }
    }
}