Exemplo n.º 1
0
 public void GetCurrFiles()
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         curr_files = db.AllFiles.Where(x => x.FileIsOnDrive == true).ToList();
     }
 }
Exemplo n.º 2
0
 void GetVideoExtensions()
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         video_extensions = db.FileExtensions.Where(x => x.FileTypeID == 3).Select(x => x.FileExtensionID).ToArray <int>();
     }
 }
 void GetSoundExtensions()
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         sound_extensions = db.FileExtensions.Where(x => x.FileTypeID == 2).Select(x => x.FileExtensionID).ToArray <int>();
     }
 }
Exemplo n.º 4
0
 void GetImageExtensions()
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         image_extensions = db.FileExtensions.Where(x => x.FileTypeID == 1).Select(x => x.FileExtensionID).ToArray <int>();
     }
 }
Exemplo n.º 5
0
 public void SavePrevFiles()
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         //prev_files = db.AllFiles.Where(x => x.FileIsOnDrive == true).ToList<AllFile>();
     }
 }
Exemplo n.º 6
0
        public int GetVideosDBTotalCount()
        {
            int count;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                count = db.Videos.Count();
            }
            return(count);
        }
Exemplo n.º 7
0
        //*************************************UsageReport

        public int GetFilesDBTotalCount()
        {
            int count;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                count = db.AllFiles.Count();
            }
            return(count);
        }
Exemplo n.º 8
0
 public void AddView(int image_id)
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         Models.Image f_image = db.Images.Where(x => x.FileID == image_id).First();
         f_image.ImageViews++;
         db.Entry(f_image).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 9
0
        public List <AllFile> GetTopSizedFiles()
        {
            List <AllFile> top_size = new List <AllFile>(10);

            using (MultimediaEntities db = new MultimediaEntities())
            {
                top_size = db.AllFiles.OrderByDescending(x => x.FileSize).Take(10).ToList();
            }
            return(top_size);
        }
Exemplo n.º 10
0
 public void AddView(int sound_id)
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         Sound f_sound = db.Sounds.Where(x => x.FileID == sound_id).First();
         f_sound.SoundViews++;
         db.Entry(f_sound).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 11
0
        //Getting extension element from database due to string extension
        FileExtension GetExtention(string extension)
        {
            FileExtension fe;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                fe = db.FileExtensions.Where(x => x.FileExtensionName.ToUpper() == extension.ToUpper()).First();
            }
            return(fe);
        }
Exemplo n.º 12
0
        //Getting extensions from database
        void GetExtentions()
        {
            MultimediaEntities db = new MultimediaEntities();

            extensions = db.FileExtensions.Select(x => x.FileExtensionName).ToArray <string>();
            for (int i = 0; i < extensions.Count(); i++)
            {
                extensions[i] = extensions[i].ToUpper();
            }
        }
Exemplo n.º 13
0
 public void AddView(int video_id)
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         Video f_video = db.Videos.Where(x => x.FileID == video_id).First();
         f_video.VideoViews++;
         db.Entry(f_video).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 14
0
 public void AddFinding(int sound_id, int finding_type)
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         Finding finding = new Finding {
             FileID = sound_id, FindingTypeID = finding_type
         };
         db.Findings.Add(finding);
         db.SaveChanges();
     }
 }
Exemplo n.º 15
0
        public int GetVideoInProcessCount()
        {
            int count = 0;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                TimeSpan ts = new TimeSpan(0, 0, 0);
                count = db.Videos.Where(x => x.VideoCurrentPosition > ts).Count();
            }
            return(count);
        }
Exemplo n.º 16
0
 //Reseting file existion in database
 public void ResetFilesDB()
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         foreach (AllFile file in db.AllFiles)
         {
             file.FileIsOnDrive   = false;
             db.Entry(file).State = EntityState.Modified;
         }
         db.SaveChanges();
     }
 }
Exemplo n.º 17
0
 //Adding new image from file
 void AddToImages(FileTreeNode file, AllFile db_file)
 {
     Models.Image         image_db   = new Models.Image();
     System.Drawing.Image image_info = System.Drawing.Image.FromFile(file.href);
     image_db.FileID     = db_file.FileID;
     image_db.ImageSize  = image_info.Size.Width.ToString() + "x" + image_info.Size.Height.ToString();
     image_db.ImageViews = 0;
     using (MultimediaEntities db = new MultimediaEntities())
     {
         db.Images.Add(image_db);
         db.SaveChanges();
     }
 }
Exemplo n.º 18
0
        public int GetTotalImagesViews()
        {
            int views = 0;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                foreach (Image file in db.Images.ToList())
                {
                    views += file.ImageViews;
                }
            }
            return(views);
        }
Exemplo n.º 19
0
        public int GetTotalSoundsViews()
        {
            int views = 0;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                foreach (Sound file in db.Sounds.ToList())
                {
                    views += file.SoundViews;
                }
            }
            return(views);
        }
Exemplo n.º 20
0
        public int GetTotalVideosViews()
        {
            int views = 0;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                foreach (Video file in db.Videos.ToList())
                {
                    views += file.VideoViews;
                }
            }
            return(views);
        }
Exemplo n.º 21
0
        public List <AllFile> GetTopViewedImages()
        {
            List <AllFile> top_images = new List <AllFile>(10);

            using (MultimediaEntities db = new MultimediaEntities())
            {
                List <Image> topimages = db.Images.OrderBy(x => x.ImageViews).Take(10).ToList();
                foreach (Image image in topimages)
                {
                    top_images.Add(db.AllFiles.Find(image.FileID));
                }
            }
            return(top_images);
        }
Exemplo n.º 22
0
        public List <AllFile> GetTopViewedVideos()
        {
            List <AllFile> top_videos = new List <AllFile>(10);

            using (MultimediaEntities db = new MultimediaEntities())
            {
                List <Video> topvideos = db.Videos.OrderBy(x => x.VideoViews).Take(10).ToList();
                foreach (Video image in topvideos)
                {
                    top_videos.Add(db.AllFiles.Find(image.FileID));
                }
            }
            return(top_videos);
        }
Exemplo n.º 23
0
        public List <AllFile> GetTopViewedSounds()
        {
            List <AllFile> top_sounds = new List <AllFile>(10);

            using (MultimediaEntities db = new MultimediaEntities())
            {
                List <Sound> topsounds = db.Sounds.OrderBy(x => x.SoundViews).Take(10).ToList();
                foreach (Sound sound in topsounds)
                {
                    top_sounds.Add(db.AllFiles.Find(sound.FileID));
                }
            }
            return(top_sounds);
        }
Exemplo n.º 24
0
 public List <AllFile> GetDeletedFiles()
 {
     int[] all_deleted_files;
     using (MultimediaEntities db = new MultimediaEntities())
     {
         all_deleted_files = db.AllFiles.Where(x => x.FileIsOnDrive == false).Select(x => x.FileID).ToArray <int>();
     }
     foreach (AllFile file in prev_files)
     {
         if (all_deleted_files.Contains(file.FileID))
         {
             deleted_files.Add(file);
         }
     }
     return(deleted_files);
 }
Exemplo n.º 25
0
        //Adding new sound from file
        void AddToSounds(FileTreeNode file, AllFile db_file)
        {
            Sound sound_db = new Sound();

            sound_db.FileID = db_file.FileID;
            TagLib.File sound_tags = TagLib.File.Create(file.href);
            try
            {
                sound_db.SoundAlbum = sound_tags.Tag.Album;
            }
            catch
            {
                sound_db.SoundAlbum = "Unknown";
            }
            try
            {
                sound_db.SoundArtist = sound_tags.Tag.AlbumArtists[0];
            }
            catch
            {
                sound_db.SoundArtist = "Unknown";
            }
            try
            {
                sound_db.SoundDuration = sound_tags.Properties.Duration.Duration();
            }
            catch
            {
                sound_db.SoundDuration = new TimeSpan(0, 3, 0);
            }
            try
            {
                sound_db.SoundName = sound_tags.Tag.Title;
            }
            catch
            {
                sound_db.SoundName = "Unknown";
            }
            sound_db.SoundCurrentPosition = new TimeSpan(0, 0, 0);
            sound_db.SoundViews           = 0;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                db.Sounds.Add(sound_db);
                db.SaveChanges();
            }
        }
Exemplo n.º 26
0
        public string GetTotalVideoProcessed()
        {
            TimeSpan ts = new TimeSpan(0, 0, 0);

            using (MultimediaEntities db = new MultimediaEntities())
            {
                foreach (Video video in db.Videos.ToList())
                {
                    for (int i = 0; i < video.VideoViews; i++)
                    {
                        ts.Add(video.VideoDuration);
                    }
                    ts.Add(video.VideoCurrentPosition);
                }
            }
            return(ts.ToString());
        }
Exemplo n.º 27
0
        public string GetTotalSoundProcessed()
        {
            TimeSpan ts = new TimeSpan(0, 0, 0);

            using (MultimediaEntities db = new MultimediaEntities())
            {
                foreach (Sound sound in db.Sounds.ToList())
                {
                    for (int i = 0; i < sound.SoundViews; i++)
                    {
                        ts.Add(sound.SoundDuration);
                    }
                    ts.Add(sound.SoundCurrentPosition);
                }
            }
            return(ts.ToString());
        }
Exemplo n.º 28
0
 public void UpdateSoundCurrentPosition(int sound_id, string curr_pos)
 {
     using (MultimediaEntities db = new MultimediaEntities())
     {
         Sound    f_sound = db.Sounds.Where(x => x.FileID == sound_id).First();
         TimeSpan t_s;
         if (!TimeSpan.TryParse(curr_pos, out t_s))
         {
             f_sound.SoundCurrentPosition = new TimeSpan(0, 0, 0);
         }
         else
         {
             f_sound.SoundCurrentPosition = t_s;
         }
         db.Entry(f_sound).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 29
0
        public List <string> GetImageInfo(int image_id)
        {
            List <string> image_info = new List <string>();

            Models.Image f_image;
            AllFile      f_file;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                f_image = db.Images.Where(x => x.FileID == image_id).First();
                f_file  = db.AllFiles.Where(x => x.FileID == image_id).First();
            }
            image_info.Add(f_file.FileName);
            image_info.Add(f_file.FilePath);
            image_info.Add(f_file.FileSize.ToString());
            image_info.Add(f_image.ImageSize);
            return(image_info);
        }
Exemplo n.º 30
0
        public int GetTotalVideosCount()
        {
            int[] video_extensions;
            int   count = 0;

            using (MultimediaEntities db = new MultimediaEntities())
            {
                video_extensions = db.FileExtensions.Where(x => x.FileTypeID == 3).Select(x => x.FileExtensionID).ToArray <int>();
            }
            foreach (AllFile file in curr_files)
            {
                if (video_extensions.Contains(file.FileExtensionID))
                {
                    count++;
                }
            }
            return(count);
        }