private Video CreateExampleVideo(int accountid, string videoname, string originalfilename, string storedfilename, string tags) { try { string sourcevideo = HttpContext.Current.Server.MapPath(@"~/ExampleVideos/" + storedfilename); string newvideo = HttpContext.Current.Server.MapPath(@"~/Media"); if (!newvideo.EndsWith(@"\")) { newvideo += @"\"; } System.IO.Directory.CreateDirectory(newvideo + Convert.ToString(accountid) + @"\Videos\"); newvideo += Convert.ToString(accountid) + @"\Videos\" + storedfilename; if (!System.IO.File.Exists(newvideo)) { System.IO.File.Copy(sourcevideo, newvideo); } IVideoRepository videorep = new EntityVideoRepository(); Video video = videorep.GetVideoByGuid(accountid, storedfilename); if (video == null || video.VideoID == 0) { video = new Video(); video.AccountID = accountid; video.VideoName = videoname; video.OriginalFilename = originalfilename; video.StoredFilename = storedfilename; video.Tags = tags; video.IsActive = true; videorep.CreateVideo(video); } return(video); } 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 { } }