public IActionResult FetchThumbnail(string thumbnailKey)
        {
            long       thumbnailId = 0L;
            IThumbnail thumbnail   = null;

            try {
                if (long.TryParse(thumbnailKey, out thumbnailId))
                {
                    thumbnail = thumbnailRepository.Load(thumbnailId);
                }
                else
                {
                    thumbnail = thumbnailRepository.FindByKey(thumbnailKey).FirstOrDefault();
                }
            } catch (Exception) {
                // サムネイルが正常に取得できない場合は、常にnullとする。
                thumbnail = null;
            }

            // リソースの有効期限等を決定する
            //DateTimeOffset now = DateTime.Now;
            //var etag = new EntityTagHeaderValue("\"" + Guid.NewGuid().ToString() + "\"");

            if (thumbnail == null)
            {
                System.Reflection.Assembly assm = System.Reflection.Assembly.GetExecutingAssembly();
                string filePath = string.Format("Foxpict.Service.Web.Assets.Icon.UI.Article3.png");
                return(new FileStreamResult(assm.GetManifestResourceStream(filePath), "image/png"));
            }

            return(new FileContentResult(thumbnail.BitmapBytes, thumbnail.MimeType));
        }
Beispiel #2
0
        public ShortUrlService(IUserRepository userRepository, IShortUrlRepository shortUrlRepository, IVisitRepository visitRepository, IBannedDomainRepository bannedDomainRepository, IReservedAliasRepository reservedAliasRepository, IUnitOfWork unitOfWork, IExternalContentService externalContentService, IThumbnail thumbnail, IBaseX baseX, IUrlResolver urlResolver, IEventAggregator eventAggregator, ISpamDetector[] spamDetectors)
        {
            Check.Argument.IsNotNull(userRepository, "userRepository");
            Check.Argument.IsNotNull(shortUrlRepository, "shortUrlRepository");
            Check.Argument.IsNotNull(visitRepository, "visitRepository");
            Check.Argument.IsNotNull(bannedDomainRepository, "bannedDomainRepository");
            Check.Argument.IsNotNull(reservedAliasRepository, "reservedAliasRepository");
            Check.Argument.IsNotNull(unitOfWork, "unitOfWork");
            Check.Argument.IsNotNull(externalContentService, "externalContentService");
            Check.Argument.IsNotNull(thumbnail, "thumbnail");
            Check.Argument.IsNotNull(baseX, "baseX");
            Check.Argument.IsNotNull(urlResolver, "urlResolver");
            Check.Argument.IsNotNull(eventAggregator, "eventAggregator");
            Check.Argument.IsNotNull(spamDetectors, "spamDetectors");

            this.userRepository          = userRepository;
            this.shortUrlRepository      = shortUrlRepository;
            this.visitRepository         = visitRepository;
            this.bannedDomainRepository  = bannedDomainRepository;
            this.reservedAliasRepository = reservedAliasRepository;
            this.unitOfWork             = unitOfWork;
            this.externalContentService = externalContentService;
            this.thumbnail       = thumbnail;
            this.baseX           = baseX;
            this.urlResolver     = urlResolver;
            this.eventAggregator = eventAggregator;
            this.spamDetectors   = spamDetectors;
        }
Beispiel #3
0
        public StoryService(IConfigurationSettings settings, IDomainObjectFactory factory, ICategoryRepository categoryRepository, ITagRepository tagRepository, IStoryRepository storyRepository, IMarkAsSpamRepository markAsSpamRepository, IEventAggregator eventAggregator, ISpamProtection spamProtection, ISpamPostprocessor spamPostprocessor, IContentService contentService, IHtmlSanitizer htmlSanitizer, IThumbnail thumbnail, IStoryWeightCalculator[] storyWeightCalculators, IVoteRepository voteRepository)
        {
            Check.Argument.IsNotNull(settings, "settings");
            Check.Argument.IsNotNull(factory, "factory");
            Check.Argument.IsNotNull(categoryRepository, "categoryRepository");
            Check.Argument.IsNotNull(tagRepository, "tagRepository");
            Check.Argument.IsNotNull(storyRepository, "storyRepository");
            Check.Argument.IsNotNull(markAsSpamRepository, "markAsSpamRepository");
            Check.Argument.IsNotNull(eventAggregator, "eventAggregator");
            Check.Argument.IsNotNull(spamProtection, "spamProtection");
            Check.Argument.IsNotNull(spamPostprocessor, "spamPostprocessor");
            Check.Argument.IsNotNull(contentService, "contentService");
            Check.Argument.IsNotNull(htmlSanitizer, "htmlSanitizer");
            Check.Argument.IsNotNull(thumbnail, "thumbnail");
            Check.Argument.IsNotEmpty(storyWeightCalculators, "storyWeightCalculators");
            Check.Argument.IsNotNull(voteRepository, "voteRepository");

            _settings               = settings;
            _factory                = factory;
            _categoryRepository     = categoryRepository;
            _tagRepository          = tagRepository;
            _storyRepository        = storyRepository;
            _markAsSpamRepository   = markAsSpamRepository;
            _eventAggregator        = eventAggregator;
            _spamProtection         = spamProtection;
            _spamPostprocessor      = spamPostprocessor;
            _contentService         = contentService;
            _htmlSanitizer          = htmlSanitizer;
            _thumbnail              = thumbnail;
            _storyWeightCalculators = storyWeightCalculators;
            _voteRepository         = voteRepository;
        }
        public MThumbnailDetails(ThumbnailDetails thumbnailDetails)
        {
            if (thumbnailDetails == null)
            {
                return;
            }

            _high     = new MThumbnail(thumbnailDetails.High);
            _maxres   = new MThumbnail(thumbnailDetails.Maxres);
            _medium   = new MThumbnail(thumbnailDetails.Medium);
            _standard = new MThumbnail(thumbnailDetails.Standard);
            _default  = new MThumbnail(thumbnailDetails.Default__);
        }
        public IActionResult FetchThumbnail(string thumbnailKey)
        {
            long       thumbnailId = 0L;
            IThumbnail thumbnail   = null;

            if (long.TryParse(thumbnailKey, out thumbnailId))
            {
                thumbnail = thumbnailRepository.Load(thumbnailId);
            }
            else
            {
                thumbnail = thumbnailRepository.FindByKey(thumbnailKey).FirstOrDefault();
            }
            if (thumbnail == null)
            {
                throw new ApplicationException(string.Format("サムネイル画像({0})が見つかりません", thumbnailKey));
            }

            // リソースの有効期限等を決定する
            //DateTimeOffset now = DateTime.Now;
            //var etag = new EntityTagHeaderValue("\"" + Guid.NewGuid().ToString() + "\"");

            return(new FileContentResult(thumbnail.BitmapBytes, thumbnail.MimeType));
        }
 public void Delete(IThumbnail entity)
 {
     this.Delete((Thumbnail)entity);
 }
Beispiel #7
0
 public void DisplayThumbnail(IThumbnail thumb)
 {
     //Do Stuff to things.
 }
Beispiel #8
0
        public async Task GetDayScheduleAsync(DateTime date, IProgress progress, IThumbnail thumbnail)
        {
            if (progress.IsCancelled)
            {
                return;
            }

            var      reduxItems = new ReduxEntities();
            Services services   = new Services();
            DateTime dayStart   = date.Date;
            DateTime dayEnd     = dayStart.AddDays(1);
            //if (reduxItems.Scanned.Any(p => p.DateScanned == dayStart) == false)
            //{
            List <XElement> programmeElements = new List <XElement>();
            //var dayItems = from item in reduxItems.Items
            //               where item.Aired >= dayStart && item.Aired < dayEnd
            //               select item;
            var sids = services.Select(s => s.Id).ToArray();

            var tasks = (from srv in sids
                         select LoadXmlAsync(services.ProgrammesUrl(srv, dayStart))).ToArray();

            var pages = await TaskEx.WhenAll(tasks);

            for (int i = 0; i < sids.Length; i++)
            {
                var      sid      = sids[i];
                string   url      = services.ProgrammesUrl(sid, dayStart);
                XElement schedule = pages[i];
                var      items    = from element in schedule.Element("day").Element("broadcasts").Elements("broadcast")
                                    select new XElement("programme", new XAttribute("serviceid", sid), element);
                XElement previous = null;
                //foreach (var item in items)
                //{
                //    if (previous != null)
                //    {
                //        var st = previous.Element("broadcast").GetElementDate("end");
                //        var en = item.Element("broadcast").GetElementDate("start");
                //        if (st < en)
                //        {
                //            if ((sid == 1 || sid == 6) && en.Hour == 19 && en.Minute == 0)
                //            {
                //            }
                //            else
                //            {

                //            }
                //        }
                //    }
                //    previous = item;
                //}
                programmeElements.AddRange(items);
            }

            var programmes = from element in programmeElements
                             let broadcast = element.Element("broadcast")
                                             let episode = broadcast.Elements("programme").First(e => e.Attribute("type").Value == "episode")
                                                           select new pips_programmes()
            {
                service_id       = element.GetAttributeInt("serviceid"),
                service_name     = services[element.GetAttributeInt("serviceid")].Name,
                start_time       = broadcast.GetElementDate("start").ToLocalTime(),
                end_time         = broadcast.GetElementDate("end").ToLocalTime(),
                start_gmt        = broadcast.GetElementDate("start"),
                end_gmt          = broadcast.GetElementDate("end"),
                duration         = broadcast.GetElementInt("duration"),
                programme_name   = episode.Element("title").Value,
                display_title    = episode.Element("display_titles").Element("title").Value,
                display_subtitle = episode.Element("display_titles").Element("subtitle").Value,
                pid         = episode.Element("pid").Value,
                description = episode.Element("short_synopsis").Value
            };

            DateTime timerstart = DateTime.Now;
            var      start_pad  = dayStart.AddDays(-1);
            var      end_pad    = dayEnd.AddDays(1);
            var      already    = (from p in reduxItems.pips_programmes
                                   where p.start_time >= start_pad && p.start_time < end_pad
                                   orderby p.start_gmt
                                   select p).ToList();

            List <pips_programmes> newProgrammes = new List <pips_programmes>();

            List <Task> pendingTasks = new List <Task>();

            foreach (var prog in programmes)
            {
                if (progress.IsCancelled)
                {
                    break;
                }
                if (already.Any(p => p.service_id == prog.service_id && p.start_gmt == prog.start_gmt) == false)
                {
                    reduxItems.pips_programmes.AddObject(prog);
                    reduxItems.SaveChanges();
                    newProgrammes.Add(prog);
                    progress.WriteLine("Updating {0} on {1}", prog.display_title, prog.start_gmt);
                    pendingTasks.Add(AddGenresAsync(prog.pid, prog.id, progress, thumbnail));
                    if (pendingTasks.Count >= 12)
                    {
                        await TaskEx.WhenAll(pendingTasks);

                        pendingTasks.Clear();
                    }
                }
            }
            if (pendingTasks.Count > 0)
            {
                await TaskEx.WhenAll(pendingTasks);
            }
            //reduxItems.Scanned.Add(new Scanned() { DateScanned = dayStart });

            //}
        }
Beispiel #9
0
        public async Task AddGenresAsync(string pid, int pips_id, IProgress progress, IThumbnail thumbnail)
        {
            //progress.WriteLine("Start Fetching for {0}", pid);
            if (progress.IsCancelled)
            {
                return;
            }
            try
            {
                thumbnail.ShowImage("http://node2.bbcimg.co.uk/iplayer/images/episode/" + pid + "_314_176.jpg");
                var waitIon  = LoadXmlAsync("http://www.bbc.co.uk/iplayer/ion/episodedetail/episode/" + pid + "/format/xml");
                var waitPips = LoadXmlAsync("http://www.bbc.co.uk/programmes/" + pid + ".xml");
                var pages    = await TaskEx.WhenAll(waitIon, waitPips);

                var progpage = pages[1];
                var ionPage  = pages[0];
                //var progpage = await LoadXmlAsync("http://www.bbc.co.uk/programmes/" + pid + ".xml");
                var genres = (from cat in progpage.XPathSelectElements("categories//category[ancestor-or-self::category[@type='genre']]")
                              let cats = from c in cat.XPathSelectElements("./descendant-or-self::category") select c.Attribute("key").Value
                                         select new
                {
                    pips_id = pips_id,
                    title = cat.Element("title").Value,
                    name = cat.Attribute("key").Value,
                    //Cats = cats,
                    path = string.Join("/", cats.Reverse().ToArray())
                }
                              ).Distinct();
                var data = new ReduxEntities();
                foreach (var g in genres)
                {
                    data.genres.AddObject(new genre
                    {
                        pips_id = g.pips_id,
                        name    = g.name,
                        title   = g.title,
                        path    = g.path
                    });
                }
                try
                {
                    data.SaveChanges();
                }
                catch (Exception exp)
                {
                    var msg4 = exp.Message;
                    throw;
                }
                FetchContributors(ionPage, data, pid);
                FetchTags(ionPage, data, pid);
                FetchCategories(ionPage, data, pid);
            }
            catch (WebException)
            {
            }
        }
 public void LoadRootFoder(IThumbnail collection)
 {
     breadcrumbs.Clear();
     LoadFolder(collection);
 }
        private void ShowCloudCommunitiesItemContextMenu(IThumbnail item)
        {
            contextMenu = new ContextMenuStrip();

            var showItem = new ToolStripMenuItem(Language.GetLocalizedText(995, "Show on Community Web Site"));
            var editItem = new ToolStripMenuItem(Language.GetLocalizedText(996, "Edit on Community Web Site"));
            var deleteItem = new ToolStripMenuItem(Language.GetLocalizedText(997, "Delete from Community Web Site"));

            showItem.Click += showItem_Click;
            editItem.Click += editItem_Click;
            deleteItem.Click += deleteItem_Click;
            showItem.Tag = item;
            editItem.Tag = item;
            deleteItem.Tag = item;

            var edit = false;

            if (item is Tour)
            {
                edit = ((((Tour)item).Permission & 8) == 8);
            }

            if (item is Place)
            {
                edit = ((((Place)item).Permission & 8) == 8);
            }

            if (item is ImageSet)
            {
                 edit = ((((ImageSet)item).Permission & 8) == 8);
            }

            contextMenu.Items.Add(showItem);

            if (edit)
            {
                contextMenu.Items.Add(editItem);
                contextMenu.Items.Add(deleteItem);
            }
            contextMenu.Show(Cursor.Position);
        }
        private void LoadFolder(IThumbnail parent)
        {
            Cursor.Current = Cursors.WaitCursor;
            var topLevel = breadcrumbs.Count == 0;

            var communityNode = false;
            var firstSearchable = true;
            if (breadcrumbs.Count == 1)
            {
                if (MyCommunities == breadcrumbs.Peek())
                {
                    communityNode = true;
                }
            }

            breadcrumbs.Push(parent);
            BrowseList.Clear();
            if (topLevel && showMyFolders)
            {
                AddCollectionFolders();
            }

            if (topLevel)
            {
                BrowseList.ThumbnailSize = rootSize;
            }
            else
            {
                BrowseList.ThumbnailSize = ThumbnailSize.Small;
                BrowseList.Add(new FolderUp());
            }

            //Folder temp = new Folder();
            //temp.Name = "Constellations";
            var children = parent.Children;

            if (children != null)
            {
                foreach (var child in children)
                {
                    if (child is Folder)
                    {
                        var folderItem = (Folder)child;
                        if (folderItem.Browseable == FolderBrowseable.True)
                        {
                            BrowseList.Add(child);
                        }
                        if (communityNode &&folderItem.Searchable == FolderSearchable.True)
                        {
                            ContextSearch.SetCommunitySearch(folderItem, firstSearchable);
                            firstSearchable = false;
                        }
                        if (!parent.ReadOnly)
                        {
                            folderItem.ReadOnly = false;
                        }
                    }
                    else
                    {
                        BrowseList.Add(child);
                        //IThumbnail c = (IThumbnail)child;

                        //if (!c.IsFolder)
                        //{
                        //    temp.AddChildPlace(Place.FromIPlace((IPlace)child));
                        //}
                    }
                }

            }

            //temp.SaveToFile("C:\\namedStars.wtml");

            var sb = new StringBuilder();

            var text = "";

            foreach (var item in breadcrumbs)
            {
                text = item.Name + "  > " + text;
            }

            if (Earth3d.IsLoggedIn)
            {
                exploreText.Text ="(" + Properties.Settings.Default.LiveIdUser + ") " + text;
            }
            else
            {
                exploreText.Text = text;
            }
            BrowseList.ShowAddButton = (!parent.ReadOnly) && !(hideAddButtonInLowerLevels && !topLevel);
            Refresh();
            Cursor.Current = Cursors.Default;
        }