예제 #1
0
 private void CheckIsVideoExist()
 {
     while (IsVisibleProgressBar)
     {
         AzureHelper helper = new AzureHelper();
         if (context.Videos.IsExist(Video.IdVideo))
         {
             Thread.Sleep(1000);
         }
         else
         {
             downloadThread.Abort();
             IsVisibleProgressBar = false;
             SimpleIoc.Default.GetInstance <MainViewModel>().Message      = Properties.Resources.Video_was_deleted_from_server;
             SimpleIoc.Default.GetInstance <MainViewModel>().IsOpenDialog = true;
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Start download video from Azure with file name like in database,
        /// if this name is already taken , than add Guid.NewGuid().ToString("N")
        /// </summary>
        private void Download()
        {
            AzureHelper helper     = new AzureHelper();
            string      NameToSave = Video.Name;

            if (!string.IsNullOrWhiteSpace(PathFolder))
            {
                string[] files = Directory.GetFiles(PathFolder);
                foreach (var file in files)
                {
                    string filename = file.Substring(file.LastIndexOf('\\') + 1);
                    if (filename == (Video.Name + ".mp4"))
                    {
                        NameToSave += Guid.NewGuid().ToString("N");
                    }
                }
            }
            helper.download_FromBlob(Video.Path, NameToSave, PathFolder);
            IsVisibleProgressBar = false;

            SimpleIoc.Default.GetInstance <MainViewModel>().Message      = Properties.Resources.Your_video_downloaded;
            SimpleIoc.Default.GetInstance <MainViewModel>().IsOpenDialog = true;
        }
예제 #3
0
        private void Upload()
        {
            maxDuration = Video.GetMaxDuration(PathVideo);

            AzureHelper helper = new AzureHelper();

            serverfilepath = helper.upload_ToBlob(PathVideo, Name);

            user = SimpleIoc.Default.GetInstance <MainViewModel>().User;

            Video video = new Video(Name, Description, image, user.IdUser, serverfilepath, maxDuration);

            context.Videos.Create(video);

            context.Save();

            NotificationVideoName = Name;
            Notification(video);
            SimpleIoc.Default.GetInstance <MainViewModel>().Message      = Properties.Resources.Your_video_uploaded;
            SimpleIoc.Default.GetInstance <MainViewModel>().IsOpenDialog = true;
            IsVisibleProgressBar = false;

            Name = Description = PathVideo = string.Empty;
        }