Esempio n. 1
0
        public async Task OnGetAsync()
        {
            var galleries = await _galleryService.GetAllGalleries();

            foreach (var gallery in galleries)
            {
                gallery.Comics = await _comicService.GetComics(gallery, 0, 6);
            }
            Galleries = galleries;
        }
Esempio n. 2
0
        public ActionResult LeftSideMenu(int?id)
        {
            var model = new GalleryNavModel();

            var galleries = _galleryService.GetAllGalleries();

            foreach (var gallery in galleries)
            {
                if (id != null && gallery.Id == id)
                {
                    model.CurrentID = gallery.Id;
                }
                model.MenuItems.Add(gallery.Id, gallery.Name);
                model.IDs.Add(gallery.Id);
                model.Names.Add(gallery.Name);
            }

            return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/LeftSideMenu.cshtml", model));
        }
Esempio n. 3
0
        public async Task Scan()
        {
            Scanning = true;
            await SendScanStatus();

            DirectoryInfo  rootDir   = new DirectoryInfo(_options.Value.RootDir);
            List <Gallery> galleries = await _galleryService.GetAllGalleries();

            int maxIndex = 0;

            if (galleries.Count() != 0)
            {
                maxIndex = galleries.Select(g => g.Index).OrderByDescending(i => i).FirstOrDefault() + 1;
            }
            List <Gallery> newGalleries = new List <Gallery>();

            await SendMessage("开始扫描");

            foreach (var galleryDir in rootDir.GetDirectories())
            {
                if (galleryDir.Name.StartsWith(".") || galleryDir.Name.StartsWith("@"))
                {
                    continue;
                }
                if (await _galleryService.GetGallery(galleryDir.FullName) == null)
                {
                    Gallery newGallery = new Gallery
                    {
                        Name       = galleryDir.Name,
                        Index      = maxIndex,
                        DefaultDir = galleryDir.FullName
                    };
                    maxIndex++;
                    await SendMessage($"新增分类:{newGallery.Name}");

                    await _galleryService.AddGallery(newGallery);

                    newGalleries.Add(newGallery);
                }
            }
            galleries.AddRange(newGalleries);
            int newComicCount = 0;

            foreach (var gallery in galleries)
            {
                DirectoryInfo dir = new DirectoryInfo(gallery.DefaultDir);
                newComicCount += await scanComic(dir, gallery.Id);
            }
            await SendMessage($"扫描完毕,共增加{newGalleries.Count}个分类,{newComicCount}个漫画");

            Scanning = false;
            await SendScanStatus();
        }
Esempio n. 4
0
        protected override void Then(GalleryCategory model, GalleryCategoryViewModel viewModel)
        {
            base.Then(model, viewModel);
            var galleris = _galleryService.GetAllGalleries().ToList();

            galleris.ForEach(x =>
            {
                var gallery = _mapperProvieder.GetViewModelMapper <Gallery, GalleryViewModel>()
                              .Map(_contentMapper.Map(x));
                gallery.ImageUrl = x.GetPropertyValue <string>("image");
                viewModel.Galleries.Add(gallery);
            });
        }
        public ActionResult Configure()
        {
            var galleries = _galleryService.GetAllGalleries();
            var model     = new ConfigurationModel
            {
                WidgetZones             = _gallerySettings.WidgetZones,
                GalleryWidgetZones      = _gallerySettings.GalleryWidgetZones,
                ShowGallery             = _gallerySettings.ShowGalleries,
                ShowImageAfterGalleries = _gallerySettings.ShowImageAfterGalleries,
                ProductPerPage          = _gallerySettings.ItemPerPage,
                ProductPerWidgetPage    = _gallerySettings.ItemPerWidgetPage,
                SortByCreatedDate       = _gallerySettings.SortByCreatedDate ? "true" : "false",
                SliderGallery           = _gallerySettings.SliderGallery ? "true" : "false",
                GalleryWidgetName       = _gallerySettings.GalleryWidgetName,
                ShareImage = _gallerySettings.ShareImage
            };

            model.GalleryNames.Add(new SelectListItem {
                Text = "*", Value = "-1"
            });
            if (galleries.Count > 0)
            {
                foreach (var gallery in galleries)
                {
                    model.GalleryNames.Add(new SelectListItem {
                        Text = gallery.Name, Value = gallery.Id.ToString()
                    });
                }
            }
            else
            {
                model.GalleryNames.Add(new SelectListItem {
                    Text = "", Value = ""
                });
            }
            model.GalleryTypes.Add(new SelectListItem {
                Text = _localizationService.GetResource("Plugin.Widgets.Gallery.Slider"), Value = "true"
            });
            model.GalleryTypes.Add(new SelectListItem {
                Text = _localizationService.GetResource("Plugin.Widgets.Gallery.ImagesList"), Value = "false"
            });
            model.SortedFilters.Add(new SelectListItem {
                Text = _localizationService.GetResource("Plugin.Widgets.Gallery.SortByDate"), Value = "true"
            });
            model.SortedFilters.Add(new SelectListItem {
                Text = _localizationService.GetResource("Plugin.Widgets.Gallery.SortByDisplayOrder"), Value = "false"
            });

            return(View("~/Plugins/Widgets.Gallery/Views/GalleryConfigure/Configure.cshtml", model));
        }