Exemplo n.º 1
0
        private Image CreateExampleImage(int accountid, string imagename, string originalfilename, string storedfilename, string tags)
        {
            try
            {
                string sourceimage = HttpContext.Current.Server.MapPath(@"~/ExampleImages/" + storedfilename);
                string newimage    = HttpContext.Current.Server.MapPath(@"~/Media");
                if (!newimage.EndsWith(@"\"))
                {
                    newimage += @"\";
                }
                System.IO.Directory.CreateDirectory(newimage + Convert.ToString(accountid) + @"\Images\");
                newimage += Convert.ToString(accountid) + @"\Images\" + storedfilename;

                if (!System.IO.File.Exists(newimage))
                {
                    System.IO.File.Copy(sourceimage, newimage);
                }

                IImageRepository imagerep = new EntityImageRepository();

                Image image = imagerep.GetImageByGuid(accountid, storedfilename);

                if (image == null || image.ImageID == 0)
                {
                    image                  = new Image();
                    image.AccountID        = accountid;
                    image.ImageName        = imagename;
                    image.OriginalFilename = originalfilename;
                    image.StoredFilename   = storedfilename;
                    image.Tags             = tags;
                    image.IsActive         = true;
                    imagerep.CreateImage(image);
                }

                return(image);
            }
            catch { return(null); }
        }
Exemplo n.º 2
0
        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 { }
        }