コード例 #1
0
        protected override async void Loaded(string args)
        {
            base.Loaded(args);

            var cases = await this.Service1.GetListAsync();

            this.SelectCase = cases?.FirstOrDefault();
        }
コード例 #2
0
        public async Task <IActionResult> Create(mbc_dc_case mbc_dv_movie)
        {
            if (ModelState.IsValid)
            {
                await _respository.InsertAsync(mbc_dv_movie);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mbc_dv_movie));
        }
コード例 #3
0
        public async Task RefreshMovie(mbc_dc_case item)
        {
            var extends = await this.GetExtends();

            List <string> allextends = new List <string>();

            if (extends != null)
            {
                foreach (var item1 in extends)
                {
                    allextends.AddRange(item1.Value.Trim().ToLower().Split('/'));
                }
            }

            Predicate <FileInfo> match = l =>
            {
                if (allextends.Count == 0)
                {
                    return(false);
                }

                return(allextends.Exists(k => k == l.Extension));
            };

            if (!Directory.Exists(item.BaseUrl))
            {
                Directory.CreateDirectory(item.BaseUrl);
            }

            var movies = await this.GetListAsync(l => l.CaseType == item.ID);

            List <FileInfo> files = null;

            await MessageService.ShowWaittingMessge(() =>
            {
                files = this.GetAllFiles(item.BaseUrl, match);
            });


            Action <FileInfo> action = l =>
            {
                if (movies != null)
                {
                    if (movies.Exists(k => k.Url == l.FullName))
                    {
                        return;
                    }
                }

                if (!match(l))
                {
                    return;
                }

                mbc_dv_movie movie = new mbc_dv_movie();
                //  Message:基础数据
                movie.Name       = l.Name;
                movie.Url        = l.FullName;
                movie.ExtendType = l.Extension;
                movie.CaseType   = item.ID;
                movie.Size       = l.Length;
                movie.FromType   = "local";

                var tags = _dataContext.mbc_db_tagtypes.Where(k =>
                                                              l.Name.Contains(k.Value));

                List <string> list = new List <string>();

                foreach (var ss in _dataContext.mbc_db_tagtypes)
                {
                    if (l.Name.Contains(ss.Value))
                    {
                        list.Add(ss.Value);
                    }
                }

                if (list != null && list.Count > 0)
                {
                    movie.TagTypes = list.Aggregate((m, k) => m + "," + k);
                }

                System.Console.WriteLine("加载文件详情:" + l.FullName);
                //try
                //{
                //    //  Message:ffmpeg数据
                //    var detial = FFmpegService.Instance.GetMediaEntity(l.FullName);

                //    if (detial != null)
                //    {
                //        movie.Duration = detial.Duration;
                //        movie.Bitrate = detial.Bitrate;
                //        movie.MediaCode = detial.MediaCode;
                //        movie.VedioType = detial.MediaType;
                //        movie.Resoluction = detial.Resoluction;
                //        movie.Aspect = detial.Aspect;
                //        movie.Rate = detial.Rate;
                //    }
                //}
                //catch (Exception ex)
                //{
                //    System.Console.WriteLine("获取ffmpeg详情信息错误:" + ex);
                //}

                System.Console.WriteLine("加载缩略图:" + l.FullName);
                //  Message:缩略图和预览图
                string shootcutpath = Path.Combine(Path.GetDirectoryName(movie.Url), Path.GetFileNameWithoutExtension(movie.Url) + "_shootcut.png");


                ////  Message:默认一分钟图片作为缩略图
                //FFmpegService.Instance.ShootCut(movie.Url, shootcutpath, "00:01:00");


                //if (File.Exists(shootcutpath))
                //{
                //    movie.Image = "data:image/jpeg;base64," + EncodeImageToString(shootcutpath);

                //    File.Delete(shootcutpath);
                //}

                _dataContext.mbc_dv_movies.Add(movie);

                System.Console.WriteLine("加载预览图:" + l.FullName);

                string shootcutbatpath = Path.Combine(Path.GetDirectoryName(movie.Url), Path.GetFileNameWithoutExtension(movie.Url) + "_shootcut");

                ////  Message:默认一分钟图片作为缩略图
                //var images = FFmpegService.Instance.ShootCutBat(movie.Url, shootcutbatpath);

                //foreach (var m in images)
                //{
                //    if (!File.Exists(m)) continue;

                //    mbc_dv_movieimage image = new mbc_dv_movieimage();

                //    image.MovieID = movie.ID;
                //    image.Image = "data:image/jpeg;base64," + EncodeImageToString(m);
                //    image.Text = Path.GetFileName(m);

                //    _dbContext.mbc_dv_movieimages.Add(image);

                //    //  Message:保存完删除图片
                //    File.Delete(m);
                //}

                //  Message:一个文件一保存
                _dbContext.SaveChanges();
            };


            //this.DoAllFiles(item.BaseUrl, action);

            Action <IStringProgress> actionProgress = l =>
            {
                for (int i = 0; i < files.Count; i++)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        l.MessageStr = $"正在处理第{i + 1}条视频,共计{files.Count}条视频";
                    });

                    action(files[i]);
                }
            };


            await MessageService.ShowStringProgress(actionProgress);


            item.State = 1;
        }
コード例 #4
0
        public async Task RefreshImage(mbc_dc_case item)
        {
            if (item.State == 1)
            {
                var result = await MessageService.ShowResultMessge("当前案例已经加载过,是否重新扫描!");

                if (!result)
                {
                    return;
                }
            }

            var extends = await this.GetExtends();

            List <string> allextends = new List <string>();

            if (extends != null)
            {
                foreach (var item1 in extends)
                {
                    allextends.AddRange(item1.Value.Trim().ToLower().Split('/'));
                }
            }

            Predicate <FileInfo> match = l =>
            {
                if (allextends.Count == 0)
                {
                    return(true);
                }

                return(allextends.Exists(k => k == l.Extension));
            };

            if (!Directory.Exists(item.BaseUrl))
            {
                Directory.CreateDirectory(item.BaseUrl);
            }

            var movies = await this.GetListAsync(l => l.CaseType == item.ID);

            List <FileInfo> files = null;

            await MessageService.ShowWaittingMessge(() =>
            {
                files = this.GetAllFiles(item.BaseUrl, match);
            });


            Action <FileInfo> action = l =>
            {
                if (movies != null)
                {
                    if (movies.Exists(k => k.Url == l.FullName))
                    {
                        return;
                    }
                }

                if (!match(l))
                {
                    return;
                }

                mbc_dv_image movie = new mbc_dv_image();
                //  Message:基础数据
                movie.Name       = l.Name;
                movie.Url        = l.FullName;
                movie.ExtendType = l.Extension;
                movie.CaseType   = item.ID;
                movie.Size       = l.Length;
                movie.FromType   = "local";

                var tags = _dataContext.mbc_db_tagtypes.Where(k =>
                                                              l.Name.Contains(k.Value));

                List <string> list = new List <string>();

                foreach (var ss in _dataContext.mbc_db_tagtypes)
                {
                    if (l.Name.Contains(ss.Value))
                    {
                        list.Add(ss.Value);
                    }
                }

                if (list != null && list.Count > 0)
                {
                    movie.TagTypes = list.Aggregate((m, k) => m + "," + k);
                }

                this.Insert(movie);
            };


            //this.DoAllFiles(item.BaseUrl, action);

            Action <IStringProgress> actionProgress = l =>
            {
                for (int i = 0; i < files.Count; i++)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        l.MessageStr = $"正在处理第{i + 1}条图片,共计{files.Count}条图片";
                    });

                    action(files[i]);
                }
            };


            await MessageService.ShowStringProgress(actionProgress);


            item.State = 1;
        }