示例#1
0
        public static void FinishUpload(string temporaryFileName, Music music)
        {
            if (music.Id == 0 || string.IsNullOrEmpty(music.Name) || music.ChannelId == 0)
            {
                throw new ApplicationException("Uploaded data is invalid { Id:" + music.Id + ", Name:" + music.Name + ", Channel:" + music.ChannelId + " }.");
            }

            // Creates channel's directory, if it doesn't exist already.
            var path = TryToCreateDirectory(music.ChannelId.ToString());

            // Finally, move file to correct destination.
            var fileRealName = Path.ChangeExtension(music.Id.ToString(), Path.GetExtension(music.Name));
            path = Path.Combine(path, fileRealName);
            
            try
            {
                File.Copy(temporaryFileName, path);
                File.Delete(temporaryFileName);
            }
            catch (IOException) { }
        }
示例#2
0
 public static FileInfo GetFileInfo(Music music)
 {
     return GetFileInfo(TranslateLocalFileName(music));
 }
示例#3
0
 public static string TranslateLocalFileName(Music music)
 {
     return ContextualizedPath(
             DEFAULT_DIRECTORY,
             music.ChannelId.ToString(),
             Path.ChangeExtension(
                 music.Id.ToString(),
                 Path.GetExtension(music.Name))
         );
 }
示例#4
0
 public static void TryToRemoveMusic(Music music)
 {
     TryToRemove(ContextualizedPath(DEFAULT_DIRECTORY, music.ChannelId.ToString(), music.Id.ToString()));
 }
示例#5
0
        public void Update(Music c)
        {
            if (c.Id != Id)
            {
                throw new ApplicationException("Cannot update a music with Id that does not match the view-model Id.");
            }

            c.Name = Name;
        }
示例#6
0
 public MusicStreamProvider(Music music, int bufferSize = DEFAULT_BUFFER_SIZE)
     : this(music.Id, music.Name, music.ChannelId, bufferSize)
 {
 }
示例#7
0
 public MusicStreamProvider(Music music)
     : this(music, DEFAULT_BUFFER_SIZE)
 {
 }