Ejemplo n.º 1
0
        public void InsertUser(string user)
        {
            SongDA songDA            = new SongDA();
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@UserID", user));
            songDA.UpdateData("INSERT_USER", list);
        }
Ejemplo n.º 2
0
        public bool InsertSong(IEnumerable <HttpPostedFileBase> files)
        {
            SongDA songDA = new SongDA();

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("SONG_NAME", typeof(string));
            dataTable.Columns.Add("ARTIST", typeof(string));
            dataTable.Columns.Add("ALBUM", typeof(string));
            dataTable.Columns.Add("DURATION", typeof(Int16));
            dataTable.Columns.Add("UPLOAD_USER", typeof(string));
            dataTable.Columns.Add("DIRECTORY_PATH", typeof(string));

            foreach (var file in files)
            {
                if (file.ContentLength > 0)
                {
                    // Get file name
                    string fileName = Path.GetFileName(file.FileName);

                    // Get file name with path
                    string path = Resource1.UploadPath + fileName;

                    // Save file to server
                    file.SaveAs(path);

                    // Load info from .mp3 file
                    TagLib.File tagFile = TagLib.File.Create(path);

                    // Create data for datatable
                    dataTable.Rows.Add(
                        tagFile.Tag.Title,
                        tagFile.Tag.Performers[0],
                        tagFile.Tag.Album,
                        tagFile.Properties.Duration.TotalSeconds,
                        this.GetUserAccount(HttpContext.Current.Request.LogonUserIdentity.Name),
                        path);
                }
            }

            // Insert info to database
            List <SqlParameter> listParam = new List <SqlParameter>();

            listParam.Add(new SqlParameter("@SongDataTable", dataTable));

            bool result = songDA.UpdateData("INSERT_SONG", listParam);


            return(result);
        }
Ejemplo n.º 3
0
        public void AddToDefaultList(string songID)
        {
            SongDA songDA = new SongDA();

            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("@UserID", GetUserAccount(HttpContext.Current.Request.LogonUserIdentity.Name)));
            list.Add(new SqlParameter("@SongID", songID));

            System.Diagnostics.Debug.WriteLine(GetUserAccount(HttpContext.Current.Request.LogonUserIdentity.Name));
            System.Diagnostics.Debug.WriteLine(songID);

            songDA.UpdateData("INSERT_SONG_TO_DEFAULT_LIST", list);
        }