private Music CreateExampleMusic(int accountid, string musicname, string originalfilename, string storedfilename, string tags) { try { string sourcemusic = HttpContext.Current.Server.MapPath(@"~/ExampleMusic/" + storedfilename); string newmusic = HttpContext.Current.Server.MapPath(@"~/Media"); if (!newmusic.EndsWith(@"\")) { newmusic += @"\"; } System.IO.Directory.CreateDirectory(newmusic + Convert.ToString(accountid) + @"\Music\"); newmusic += Convert.ToString(accountid) + @"\Music\" + storedfilename; if (!System.IO.File.Exists(newmusic)) { System.IO.File.Copy(sourcemusic, newmusic); } IMusicRepository musicrep = new EntityMusicRepository(); Music music = musicrep.GetMusicByGuid(accountid, storedfilename); if (music == null || music.MusicID == 0) { music = new Music(); music.AccountID = accountid; music.MusicName = musicname; music.OriginalFilename = originalfilename; music.StoredFilename = storedfilename; music.Tags = tags; music.IsActive = true; musicrep.CreateMusic(music); } return(music); } catch { return(null); } }
public void CreateExampleData(int accountid) { try { List <Image> newimages = new List <Image>(); bool createimages = true; bool createvideos = true; bool createmusics = true; IImageRepository imagerep = new EntityImageRepository(); IEnumerable <Image> images = imagerep.GetAllImages(accountid); foreach (Image image in images) { if ( image.StoredFilename.ToLower() == "60255096-6a72-409e-b905-4d98ee717bb0.jpg".ToLower() || image.StoredFilename.ToLower() == "612bb76c-e16e-4fe8-87f2-bddc7eb59300.jpg".ToLower() || image.StoredFilename.ToLower() == "626c6a35-4523-46aa-9d0a-c2687b581e27.jpg".ToLower() || image.StoredFilename.ToLower() == "69f99c47-d1b0-4123-b62b-8f18bdc5702f.jpg".ToLower() ) { newimages.Add(image); createimages = false; } } IVideoRepository videorep = new EntityVideoRepository(); IEnumerable <Video> videos = videorep.GetAllVideos(accountid); foreach (Video video in videos) { if (video.StoredFilename.ToLower() == "0EBC6160-CA2C-4497-960C-0A2C2DE7B380.mp4".ToLower()) { createvideos = false; } } IMusicRepository musicrep = new EntityMusicRepository(); IEnumerable <Music> musics = musicrep.GetAllMusics(accountid); foreach (Music music in musics) { if (music.StoredFilename.ToLower() == "1B36982F-4101-4D38-AF20-FAD88A0FA9B5.mp3".ToLower()) { createmusics = false; } } // Initialize the example data for a new account so there is data available if (createimages) { newimages = CreateExampleImageAndSlideShowData(accountid); // Also creates screen, default playergroup, and schedule } if (createvideos) { CreateExampleVideoAndPlayListData(accountid); } if (createmusics) { CreateExampleMusicAndTimelineData(accountid, newimages); } } catch { } }