コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MediaService_Deleted(IMediaService sender, DeleteEventArgs<IMedia> e)
        {
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }

            foreach (var item in e.DeletedEntities)
            {
                string Resource = item.Name;

                SqlTransaction tran = connection.BeginTransaction();
                var command = new SqlCommand("dbo.[RequestCdnResourceInvalidation]", connection, tran);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.Add("@resource", SqlDbType.NVarChar, 256);
                command.Parameters["@resource"].Value = Resource;

                command.Parameters.Add("@ConversationHandle", SqlDbType.UniqueIdentifier);
                command.Parameters["@ConversationHandle"].Direction = ParameterDirection.Output;

                command.ExecuteNonQuery();
                tran.Commit();
            }
        }
コード例 #2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public UploadController(ILogger logger, IConfigService configService, IMediaService mediaService)
 {
     _logger = logger;
     _configService = configService;
     _mediaService = mediaService;
     saveRootPath = _configService.GetByKey<string>("UploadRootDir", "UploadFiles");
 }
コード例 #3
0
ファイル: RootPage.xaml.cs プロジェクト: kusl/vlcwinrt
 public RootPage(VlcService vlcService, IMediaService mediaService)
 {
     InitializeComponent();
     _vlcService = vlcService;
     (mediaService as MediaService).SetMediaElement(FoudationMediaElement);
     Loaded += SwapPanelLoaded;
 }
コード例 #4
0
 public MediaPostValidateAttribute(IMediaService mediaService, WebSecurity security)
 {
     if (mediaService == null) throw new ArgumentNullException("mediaService");
     if (security == null) throw new ArgumentNullException("security");
     _mediaService = mediaService;
     _security = security;
 }
コード例 #5
0
ファイル: WikiPageController.cs プロジェクト: kevinthant/wiki
 public WikiPageController(IOrchardServices orchardServices, 
     IRepository<WikiPageAttachmentRecord> repoWikiAttachment,
     ITagService tagService,
     IAuthorizationService authorizationService,
     INotifier notifier,
     ISiteService siteService,
     ISearchService searchService,
     IShapeFactory shapeFactory,
     IWikiPageService wikiPageService,
     IMediaService mediaService
    ){
     _orchardServices = orchardServices;
     _repoWikiAttachment = repoWikiAttachment;
     _tagService = tagService;
     _authorizationService = authorizationService;
     _notifier = notifier;
     _searchService = searchService;
     _siteService = siteService;
     _wikiPageService = wikiPageService;
     _mediaService = mediaService;
     Logger = NullLogger.Instance;
     Shape = shapeFactory;
    
     
 }
コード例 #6
0
 /// <summary>
 /// public ctor - will generally just be used for unit testing
 /// </summary>
 /// <param name="contentService"></param>
 /// <param name="mediaService"></param>
 /// <param name="contentTypeService"></param>
 /// <param name="dataTypeService"></param>
 /// <param name="fileService"></param>
 /// <param name="localizationService"></param>
 /// <param name="packagingService"></param>
 /// <param name="entityService"></param>
 /// <param name="relationService"></param>
 /// <param name="sectionService"></param>
 /// <param name="treeService"></param>
 /// <param name="tagService"></param>
 public ServiceContext(
     IContentService contentService, 
     IMediaService mediaService, 
     IContentTypeService contentTypeService, 
     IDataTypeService dataTypeService, 
     IFileService fileService, 
     ILocalizationService localizationService, 
     PackagingService packagingService, 
     IEntityService entityService,
     IRelationService relationService,
     ISectionService sectionService,
     IApplicationTreeService treeService,
     ITagService tagService)
 {
     _tagService = new Lazy<ITagService>(() => tagService);     
     _contentService = new Lazy<IContentService>(() => contentService);        
     _mediaService = new Lazy<IMediaService>(() => mediaService);
     _contentTypeService = new Lazy<IContentTypeService>(() => contentTypeService);
     _dataTypeService = new Lazy<IDataTypeService>(() => dataTypeService);
     _fileService = new Lazy<IFileService>(() => fileService);
     _localizationService = new Lazy<ILocalizationService>(() => localizationService);
     _packagingService = new Lazy<PackagingService>(() => packagingService);
     _entityService = new Lazy<IEntityService>(() => entityService);
     _relationService = new Lazy<IRelationService>(() => relationService);
     _sectionService = new Lazy<ISectionService>(() => sectionService);
     _treeService = new Lazy<IApplicationTreeService>(() => treeService);
 }
コード例 #7
0
        public static UserResponseModel ToModel(this User user, IMediaService mediaService, MediaSettings mediaSettings)
        {
            var model = new UserResponseModel()
            {
                Id = user.Id,
                FirstName = user.FirstName,
                LastName = user.LastName,
                Name = user.Name,
                DateCreatedUtc = user.DateCreated,
                DateCreatedLocal = DateTimeHelper.GetDateInUserTimeZone(user.DateCreated, DateTimeKind.Utc, user),
                UserName = user.UserName,
                CoverImageUrl = mediaService.GetPictureUrl(user.GetPropertyValueAs<int>(PropertyNames.DefaultCoverId), PictureSizeNames.MediumCover),
                ProfileImageUrl = mediaService.GetPictureUrl(user.GetPropertyValueAs<int>(PropertyNames.DefaultPictureId), PictureSizeNames.MediumProfileImage),
                Active = user.Active
            };

            if (!string.IsNullOrEmpty(model.CoverImageUrl) && !string.IsNullOrEmpty(model.ProfileImageUrl))
                return model;

            if (string.IsNullOrEmpty(model.CoverImageUrl))
                model.CoverImageUrl = mediaSettings.DefaultUserProfileCoverUrl;
            if (string.IsNullOrEmpty(model.ProfileImageUrl))
                model.ProfileImageUrl = mediaSettings.DefaultUserProfileImageUrl;

            return model;
        }
コード例 #8
0
        public PackageIconUploader(IMediaService mediaService, IPackageIconValidator packageIconValidator, IPackageMediaDirectoryHelper packageMediaDirectoryHelper) {
            _mediaService = mediaService;
            _packageMediaDirectoryHelper = packageMediaDirectoryHelper;
            _packageIconValidator = packageIconValidator;

            T = NullLocalizer.Instance;
        }
コード例 #9
0
 static void MediaServiceSaving(IMediaService sender, Core.Events.SaveEventArgs<IMedia> e)
 {
     foreach (var m in e.SavedEntities)
     {
         AutoFillProperties(m);
     }
 }
コード例 #10
0
        /// <summary>
        /// Get or Create a media folder
        /// </summary>
        /// <param name="mediaName"></param>
        /// <param name="mediaService"></param>
        /// <param name="documentType"> </param>
        /// <param name="parentNodeId"></param>
        /// <returns></returns>
        public static IMedia GetOrCreateMediaItem(IMediaService mediaService, string documentType, int parentNodeId, string mediaName, byte[] file = null)
        {
            var childItems = mediaService.GetChildren(parentNodeId);

            IMedia childItem = null;

            var enumerable = childItems as IMedia[] ?? childItems.ToArray();

            if (enumerable.Any())
            {
                childItem = enumerable.FirstOrDefault(i => i.Name.ToLower().Equals(mediaName.ToLower()));
            }

            if (childItem == null)
            {
                childItem = mediaService.CreateMedia(mediaName, parentNodeId, documentType);

                if (file != null)
                {
                    childItem.SetValue("umbracoFile", mediaName, new MemoryStream(file));
                }

                mediaService.Save(childItem);
            }

            return childItem;
        }
コード例 #11
0
 static void MediaServiceDeleting(IMediaService sender, DeleteEventArgs<IMedia> e)
 {
     foreach (var item in e.DeletedEntities)
     {
         library.ClearLibraryCacheForMedia(item.Id);
     }
 }
コード例 #12
0
        public static SponsorPublicModel ToPublicModel(this Sponsor sponsor, IUserService userService, IMediaService pictureService, ISponsorService sponsorService, IFormatterService formatterService, MediaSettings mediaSettings)
        {
            var user = userService.Get(sponsor.UserId);
            if (user == null)
                return null;

            //get sponsor data
            var sponsorData = sponsorService.GetSponsorData(sponsor.BattleId, sponsor.BattleType, sponsor.UserId);

            var model = new SponsorPublicModel
            {
                SponsorshipStatus = sponsor.SponsorshipStatus,
                SponsorshipStatusName = sponsor.SponsorshipStatus.ToString(),
                CustomerId = sponsor.UserId,
                SeName = user.GetPermalink().ToString(),
                SponsorName = user.GetPropertyValueAs<string>(PropertyNames.DisplayName),
                SponsorProfileImageUrl =
                    pictureService.GetPictureUrl(user.GetPropertyValueAs<int>(PropertyNames.DefaultPictureId)),
                SponsorshipAmount = sponsor.SponsorshipAmount,
                SponsorshipAmountFormatted = formatterService.FormatCurrency(sponsor.SponsorshipAmount, ApplicationContext.Current.ActiveCurrency),
                SponsorData = sponsorData.ToModel(pictureService),
                SponsorshipType = sponsor.SponsorshipType
            };

            return model;
        }
コード例 #13
0
 static void MediaServiceSaved(IMediaService sender, SaveEventArgs<IMedia> e)
 {
     foreach (var item in e.SavedEntities)
     {
         library.ClearLibraryCacheForMedia(item.Id);
     }
 }
コード例 #14
0
 public EventsController(IUserProfileService profileService, IEventService eventService, IFacebookService facebookService, IMediaService mediaService)
 {
     _profileService = profileService;
     _eventService = eventService;
     _facebookService = facebookService;
     _mediaService = mediaService;
 }
コード例 #15
0
ファイル: AdminController.cs プロジェクト: anycall/Orchard
        public AdminController(IOrchardServices services, IMediaService mediaService) {
            Services = services;
            _mediaService = mediaService;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
コード例 #16
0
ファイル: SermonEvents.cs プロジェクト: shferguson/ppc2010
 void MediaService_Deleted(IMediaService sender, DeleteEventArgs<IMedia> e)
 {
     foreach (IMedia entity in e.DeletedEntities.Where(entity => entity.ContentType.Alias == PPC_2010.Data.Constants.SermonAlias))
     {
         ServiceLocator.Instance.Locate<ISermonRepository>().RefreshSermon(entity.Id, true);
     }
 }
コード例 #17
0
        public ThumbnailsService(ShellSettings settings, IWorkContextAccessor wca, ICacheManager cacheManager, IMediaService mediaService, ISignals signals, IStorageProvider storageProvider)
        {
            _wca = wca;
            _cacheManager = cacheManager;
            _mediaService = mediaService;
            _signals = signals;
            _storageProvider = storageProvider;
            var appPath = "";
            if (HostingEnvironment.IsHosted)
            {
                appPath = HostingEnvironment.ApplicationVirtualPath;
            }
            if (!appPath.EndsWith("/"))
                appPath = appPath + '/';
            if (!appPath.StartsWith("/"))
                appPath = '/' + appPath;

            _publicPath = appPath + "Media/" + settings.Name + "/";

            var physPath = ThumbnailsCacheMediaPath.Replace('/', Path.DirectorySeparatorChar);
            var parent = Path.GetDirectoryName(physPath);
            var folder = Path.GetFileName(physPath);
            if (_mediaService.GetMediaFolders(parent).All(f => f.Name != folder))
            {
                _mediaService.CreateFolder(parent, folder);
            }
        }
コード例 #18
0
 public DirectoryCleanupTask(IContentManager contentManager,
     IMediaService mediaService)
 {
     _contentManager = contentManager;
     _mediaService = mediaService;
     Logger = NullLogger.Instance;
 }
コード例 #19
0
        public ContentTypeService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IContentService contentService, IMediaService mediaService)
        {
            _uowProvider = provider;
	        _repositoryFactory = repositoryFactory;
	        _contentService = contentService;
            _mediaService = mediaService;
        }
コード例 #20
0
ファイル: MusicPlayerViewModel.cs プロジェクト: kusl/vlcwinrt
 public MusicPlayerViewModel(HistoryService historyService, IMediaService mediaService, VlcService mediaPlayerService)
     : base(historyService, mediaService, mediaPlayerService)
 {
     _trackCollection = new TrackCollectionViewModel();
     _mediaService.MediaEnded += MediaService_MediaEnded;
     _historyService = historyService;
 }
コード例 #21
0
ファイル: ImageService.cs プロジェクト: k4gdw/BetterCMS
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageService" /> class.
 /// </summary>
 /// <param name="repository">The repository.</param>
 /// <param name="unitOfWork">The unit of work.</param>
 /// <param name="fileUrlResolver">The file URL resolver.</param>
 /// <param name="tagService">The tag service.</param>
 /// <param name="mediaService">The media service.</param>
 public ImageService(IRepository repository, IUnitOfWork unitOfWork, IMediaFileUrlResolver fileUrlResolver, ITagService tagService, IMediaService mediaService)
 {
     this.repository = repository;
     this.unitOfWork = unitOfWork;
     this.fileUrlResolver = fileUrlResolver;
     this.tagService = tagService;
     this.mediaService = mediaService;
 }
コード例 #22
0
        public PrettyGalleryService(IMediaService mediaService, IStorageProvider storageProvider, IOrchardServices orchardServices)
        {
            _mediaService = mediaService;
            _storageProvider = storageProvider;
            _orchardServices = orchardServices;

            T = NullLocalizer.Instance;
        }
コード例 #23
0
 public FriendsController(IFriendService friendService, IMediaService pictureService, IUserService customerService, IFollowService customerFollowService, IUserService userService)
 {
     _friendService = friendService;
     _pictureService = pictureService;
     _customerService = customerService;
     _customerFollowService = customerFollowService;
     _userService = userService;
 }
コード例 #24
0
ファイル: HomeController.cs プロジェクト: ciker/SimplCommerce
 public HomeController(UserManager<User> userManager, IRepository<Product> productRepository, IMediaService mediaService, IRepository<WidgetInstance> widgetInstanceRepository, IStringLocalizer<HomeController> localizer)
 {
     _userManager = userManager;
     _productRepository = productRepository;
     _mediaService = mediaService;
     _widgetInstanceRepository = widgetInstanceRepository;
     _localizer = localizer;
 }
コード例 #25
0
 public RelationsController()
 {
     relationService = ApplicationContext.Services.RelationService;
     contentService = ApplicationContext.Services.ContentService;
     mediaService = ApplicationContext.Services.MediaService;
     contentTypeService = ApplicationContext.Services.ContentTypeService;
     entityService = ApplicationContext.Services.EntityService;
 }
コード例 #26
0
 public ViewModelFactory(IApplicationConfig config, IPluginManager pluginManager, IApplicationState state, IPresetsManager presetsManager, IMediaService mediaService)
 {
     _config = config;
     _pluginManager = pluginManager;
     _state = state;
     _presetsManager = presetsManager;
     _mediaService = mediaService;
 }
コード例 #27
0
ファイル: ContentImporter.cs プロジェクト: pbevis/jumoo.usync
        int importCount = 0; // used just to say how many things we imported

        public ContentImporter()
        {
            _contentService = ApplicationContext.Current.Services.ContentService;
            _mediaService = ApplicationContext.Current.Services.MediaService    ; 

            // load the import table (from disk)
            ImportPairs.LoadFromDisk(); 
        }
コード例 #28
0
 public AuthenticationController(IUserService userService,
     ICryptographyService cryptographyService, IMediaService mediaService, MediaSettings mediaSettings)
 {
     _userService = userService;
     _cryptographyService = cryptographyService;
     _mediaService = mediaService;
     _mediaSettings = mediaSettings;
 }
コード例 #29
0
ファイル: MediaEvents.cs プロジェクト: pbevis/jumoo.usync
 void MediaService_Trashing(IMediaService sender, Umbraco.Core.Events.MoveEventArgs<IMedia> e)
 {
     SourceInfo.Load();
     LogHelper.Info<MediaEvents>("Archiving {0}", () => e.Entity.Name); 
     MediaExporter me = new MediaExporter();
     me.Archive(e.Entity);
     SourceInfo.Save(); 
 }
コード例 #30
0
 public PageController(CoreSettings coreSettings, IPermissionService permissionService, IPageService pageService, IWorkContext workContext, IMediaService mediaService, IWebHelper webHelper)
 {
     _coreSettings = coreSettings;
     _mediaService = mediaService;
     _pageService = pageService;
     _permissionService = permissionService;
     _webHelper = webHelper;
     _workContext = workContext;
 }
コード例 #31
0
 public SampleDataService(ISqlRepository sqlRepository, IMediaService mediaService)
 {
     _sqlRepository = sqlRepository;
     _mediaService  = mediaService;
 }
コード例 #32
0
 public MediaTypeService(IScopeProvider provider, ILogger logger, IEventMessagesFactory eventMessagesFactory, IMediaService mediaService,
                         IMediaTypeRepository mediaTypeRepository, IAuditRepository auditRepository, IMediaTypeContainerRepository entityContainerRepository,
                         IEntityRepository entityRepository)
     : base(provider, logger, eventMessagesFactory, mediaTypeRepository, auditRepository, entityContainerRepository, entityRepository)
 {
     MediaService = mediaService;
 }
コード例 #33
0
ファイル: MediaPruneHandler.cs プロジェクト: aurlaw/VueCore
 public MediaPruneHandler(ILogger <MediaPruneHandler> logger, IMediaService mediaService)
 {
     _logger       = logger;
     _mediaService = mediaService;
 }
コード例 #34
0
 public CategoryWidgetViewComponent(IRepository <Category> categoriesRepository, IMediaService mediaService)
 {
     _categoriesRepository = categoriesRepository;
     _mediaService         = mediaService;
 }
コード例 #35
0
 private void MediaService_Saved(IMediaService sender, SaveEventArgs <IMedia> e)
 {
     this.Update(e.SavedEntities.Select(x => this._umbracoHelper.TypedMedia(x.Id)).ToArray());
 }
コード例 #36
0
ファイル: LocatorService.cs プロジェクト: katyaap/WaMediaWeb
 public LocatorService(IMediaService mediaService)
 {
     this._mediaService = mediaService;
 }
コード例 #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiNodeTreePicker2MediaParser"/> class.
 /// </summary>
 public MultiNodeTreePicker2MediaParser()
 {
     this.dataTypeService = ApplicationContext.Current.Services.DataTypeService;
     this.mediaService    = ApplicationContext.Current.Services.MediaService;
     this.cache           = ApplicationContext.Current.ApplicationCache.StaticCache;
 }
コード例 #38
0
 /// <summary>
 /// After a media has been created, auto-fill the properties.
 /// </summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="args">The event arguments.</param>
 public void MediaServiceCreated(IMediaService sender, Core.Events.NewEventArgs <IMedia> args)
 {
     AutoFillProperties(args.Entity);
 }
コード例 #39
0
 public MediaController(IMediaService service)
 {
     _service = service;
 }
コード例 #40
0
 /// <summary>
 /// Returns true if there is any media in the recycle bin
 /// </summary>
 /// <param name="mediaService"></param>
 /// <returns></returns>
 public static bool RecycleBinSmells(this IMediaService mediaService)
 {
     return(mediaService.CountChildren(Constants.System.RecycleBinMedia) > 0);
 }
コード例 #41
0
        public BlogServiceIntegrationTestBase()
        {
            // ---------------------------------------------------------------- repos

            var catRepo  = new SqlCategoryRepository(_db);
            var tagRepo  = new SqlTagRepository(_db);
            var postRepo = new SqlPostRepository(_db);

            // ---------------------------------------------------------------- mock SettingService

            _settingSvcMock = new Mock <ISettingService>();
            _settingSvcMock.Setup(svc => svc.GetSettingsAsync <CoreSettings>()).Returns(Task.FromResult(new CoreSettings()));
            _settingSvcMock.Setup(svc => svc.GetSettingsAsync <BlogSettings>()).Returns(Task.FromResult(new BlogSettings()));

            // ---------------------------------------------------------------- mock AppSettings

            var appSettingsMock = new Mock <IOptionsSnapshot <AppSettings> >();

            appSettingsMock.Setup(o => o.Value).Returns(new AppSettings());

            // ---------------------------------------------------------------- mock IStorageProvider

            _storageProviderMock = new Mock <IStorageProvider>();
            _storageProviderMock.Setup(pro => pro.StorageEndpoint).Returns(STORAGE_ENDPOINT);

            // ---------------------------------------------------------------- MediaService

            var mediaRepo = new SqlMediaRepository(_db);

            _mediaSvc = new MediaService(_storageProviderMock.Object, appSettingsMock.Object, mediaRepo);

            // ---------------------------------------------------------------- Cache

            var serviceProvider = new ServiceCollection().AddMemoryCache().AddLogging().BuildServiceProvider();
            var memCacheOptions = serviceProvider.GetService <IOptions <MemoryDistributedCacheOptions> >();
            var cache           = new MemoryDistributedCache(memCacheOptions);

            // ---------------------------------------------------------------- LoggerFactory

            var loggerFactory     = serviceProvider.GetService <ILoggerFactory>();
            var loggerBlogPostSvc = loggerFactory.CreateLogger <BlogPostService>();
            var loggerPageSvc     = loggerFactory.CreateLogger <PageService>();
            var loggerCatSvc      = loggerFactory.CreateLogger <CategoryService>();
            var loggerTagSvc      = loggerFactory.CreateLogger <TagService>();

            // ---------------------------------------------------------------- Mapper, Shortcode

            var mapper = BlogUtil.Mapper;

            // ---------------------------------------------------------------- MediatR and Services

            var services = new ServiceCollection();

            services.AddScoped <ServiceFactory>(p => p.GetService);  // MediatR.ServiceFactory
            services.AddSingleton <IDistributedCache>(cache);        // cache
            services.AddSingleton <FanDbContext>(_db);               // DbContext for repos
            services.Scan(scan => scan
                          .FromAssembliesOf(typeof(IMediator), typeof(ILogger), typeof(IBlogPostService), typeof(ISettingService))
                          .AddClasses()
                          .AsImplementedInterfaces());

            var provider     = services.BuildServiceProvider();
            var mediator     = provider.GetRequiredService <IMediator>();
            var mediatorMock = new Mock <IMediator>();

            _catSvc      = new CategoryService(catRepo, _settingSvcMock.Object, mediatorMock.Object, cache, loggerCatSvc);
            _tagSvc      = new TagService(tagRepo, cache, loggerTagSvc);
            _imgSvc      = new ImageService(_mediaSvc, _storageProviderMock.Object, appSettingsMock.Object);
            _blogPostSvc = new BlogPostService(_settingSvcMock.Object, _imgSvc, postRepo, cache, loggerBlogPostSvc, mapper, mediator);
            _pageService = new PageService(_settingSvcMock.Object, postRepo, cache, loggerPageSvc, mapper, mediatorMock.Object);
        }
コード例 #42
0
 public CategoryApiController(IRepository <Category> categoryRepository, IRepository <ProductCategory> productCategoryRepository, ICategoryService categoryService, IMediaService mediaService)
 {
     _categoryRepository        = categoryRepository;
     _productCategoryRepository = productCategoryRepository;
     _categoryService           = categoryService;
     _mediaService = mediaService;
 }
コード例 #43
0
 public ViewModelFactory(IApplicationConfig config, IPluginManager pluginManager, IApplicationState state, IPresetsManager presetsManager, IMediaService mediaService)
 {
     _config         = config;
     _pluginManager  = pluginManager;
     _state          = state;
     _presetsManager = presetsManager;
     _mediaService   = mediaService;
 }
コード例 #44
0
 public CarouselWidgetApiController(IRepository <WidgetInstance> widgetInstanceRepository, IMediaService mediaService)
 {
     _widgetInstanceRepository = widgetInstanceRepository;
     _mediaService             = mediaService;
 }
コード例 #45
0
ファイル: uFPCComponent.cs プロジェクト: TomSchimmel/uFPC
 private void MediaService_Published(IMediaService sender, SaveEventArgs <IMedia> e)
 {
     throw new NotImplementedException();
 }
コード例 #46
0
        /// <summary>
        /// Performs a permissions check for the user to check if it has access to the node based on
        /// start node and/or permissions for the node
        /// </summary>
        /// <param name="storage">The storage to add the content item to so it can be reused</param>
        /// <param name="user"></param>
        /// <param name="mediaService"></param>
        /// <param name="entityService"></param>
        /// <param name="nodeId">The content to lookup, if the contentItem is not specified</param>
        /// <param name="media">Specifies the already resolved content item to check against, setting this ignores the nodeId</param>
        /// <returns></returns>
        internal static bool CheckPermissions(IDictionary <string, object> storage, IUser user, IMediaService mediaService, IEntityService entityService, int nodeId, IMedia media = null)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (mediaService == null)
            {
                throw new ArgumentNullException("mediaService");
            }
            if (entityService == null)
            {
                throw new ArgumentNullException("entityService");
            }

            if (media == null && nodeId != Constants.System.Root && nodeId != Constants.System.RecycleBinMedia)
            {
                media = mediaService.GetById(nodeId);
                //put the content item into storage so it can be retrieved
                // in the controller (saves a lookup)
                storage[typeof(IMedia).ToString()] = media;
            }

            if (media == null && nodeId != Constants.System.Root && nodeId != Constants.System.RecycleBinMedia)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var hasPathAccess = (nodeId == Constants.System.Root)
                ? user.HasMediaRootAccess(entityService)
                : (nodeId == Constants.System.RecycleBinMedia)
                    ? user.HasMediaBinAccess(entityService)
                    : user.HasPathAccess(media, entityService);

            return(hasPathAccess);
        }
コード例 #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiNodeTreePicker2MediaParser"/> class.
 /// </summary>
 /// <param name="mediaService">
 /// The content service.
 /// </param>
 /// <param name="cacheProvider">
 /// The cache provider.
 /// </param>
 public MultiNodeTreePicker2MediaParser(IMediaService mediaService, ICacheProvider cacheProvider)
 {
     this.mediaService = mediaService;
     this.cache        = cacheProvider;
 }
コード例 #48
0
 public ProductController(
     SmartDbContext db,
     IProductService productService,
     ICategoryService categoryService,
     IManufacturerService manufacturerService,
     ICustomerService customerService,
     IUrlService urlService,
     IWorkContext workContext,
     ILanguageService languageService,
     ILocalizationService localizationService,
     ILocalizedEntityService localizedEntityService,
     IMediaService mediaService,
     IProductTagService productTagService,
     IProductCloner productCloner,
     IActivityLogger activityLogger,
     IAclService aclService,
     IStoreContext storeContext,
     IStoreMappingService storeMappingService,
     AdminAreaSettings adminAreaSettings,
     IDateTimeHelper dateTimeHelper,
     IDiscountService discountService,
     IProductAttributeService productAttributeService,
     //IBackInStockSubscriptionService backInStockSubscriptionService,
     IShoppingCartService shoppingCartService,
     IProductAttributeFormatter productAttributeFormatter,
     //IProductAttributeParser productAttributeParser,
     CatalogSettings catalogSettings,
     IDownloadService downloadService,
     IDeliveryTimeService deliveryTimesService,
     IMeasureService measureService,
     MeasureSettings measureSettings,
     IEventPublisher eventPublisher,
     IGenericAttributeService genericAttributeService,
     ICommonServices services,
     ICatalogSearchService catalogSearchService,
     ProductUrlHelper productUrlHelper,
     SeoSettings seoSettings,
     MediaSettings mediaSettings,
     SearchSettings searchSettings)
 {
     _db                      = db;
     _productService          = productService;
     _categoryService         = categoryService;
     _manufacturerService     = manufacturerService;
     _customerService         = customerService;
     _urlService              = urlService;
     _workContext             = workContext;
     _languageService         = languageService;
     _localizationService     = localizationService;
     _localizedEntityService  = localizedEntityService;
     _mediaService            = mediaService;
     _productTagService       = productTagService;
     _productCloner           = productCloner;
     _activityLogger          = activityLogger;
     _aclService              = aclService;
     _storeContext            = storeContext;
     _storeMappingService     = storeMappingService;
     _adminAreaSettings       = adminAreaSettings;
     _dateTimeHelper          = dateTimeHelper;
     _discountService         = discountService;
     _productAttributeService = productAttributeService;
     //_backInStockSubscriptionService = backInStockSubscriptionService;
     _shoppingCartService       = shoppingCartService;
     _productAttributeFormatter = productAttributeFormatter;
     //_productAttributeParser = productAttributeParser;
     _catalogSettings         = catalogSettings;
     _downloadService         = downloadService;
     _deliveryTimesService    = deliveryTimesService;
     _measureService          = measureService;
     _measureSettings         = measureSettings;
     _eventPublisher          = eventPublisher;
     _genericAttributeService = genericAttributeService;
     _services             = services;
     _catalogSearchService = catalogSearchService;
     _productUrlHelper     = productUrlHelper;
     _seoSettings          = seoSettings;
     _mediaSettings        = mediaSettings;
     _searchSettings       = searchSettings;
 }
コード例 #49
0
 public SimpleProductWidgetViewComponent(IRepository <Product> productRepository, IMediaService mediaService, IProductPricingService productPricingService)
 {
     _productRepository     = productRepository;
     _mediaService          = mediaService;
     _productPricingService = productPricingService;
 }
コード例 #50
0
 public ContactApiController(IRepository <Contact> contactRepository, IMediaService mediaService, IWorkContext workContext)
 {
     _contactRepository = contactRepository;
     _mediaService      = mediaService;
     _workContext       = workContext;
 }
コード例 #51
0
 public MediaApiController(IMediaService mediaService, IUserService userService)
 {
     this._mediaService = mediaService;
     _userService       = userService;
     userId             = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(RequestContext.Principal.Identity);
 }
コード例 #52
0
 public NewsItemApiController(IRepository <NewsItem> newsItemRepository, INewsItemService newsItemService, IMediaService mediaService, IWorkContext workContext)
 {
     _newsItemRepository = newsItemRepository;
     _newsItemService    = newsItemService;
     _mediaService       = mediaService;
     _workContext        = workContext;
 }
コード例 #53
0
 private void MediaService_Deleted(IMediaService sender, DeleteEventArgs <IMedia> e)
 {
     this.Remove(e.DeletedEntities.Select(x => x.Id).ToArray());
 }
コード例 #54
0
 public BasicsUploadController(IBaseApiManager BaseApiManager, IHttpContextAccessor Accessor, IHostingEnvironment HostingEnvironment, IConfigService ConfigService, IAccountService AccountService, IMediaService MediaService) : base(BaseApiManager)
 {
     this.BaseApiManager     = BaseApiManager;
     this.Accessor           = Accessor;
     this.HostingEnvironment = HostingEnvironment;
     this.ConfigService      = ConfigService;
     this.AccountService     = AccountService;
     this.MediaService       = MediaService;
 }
コード例 #55
0
 public CartService(IRepository <Cart> cartRepository, IRepository <CartItem> cartItemRepository, ICouponService couponService, IMediaService mediaService, IConfiguration config)
 {
     _cartRepository           = cartRepository;
     _cartItemRepository       = cartItemRepository;
     _couponService            = couponService;
     _mediaService             = mediaService;
     _isProductPriceIncludeTax = config.GetValue <bool>("Tax.IsProductPriceIncludeTax");
 }
コード例 #56
0
        public static MediaReponseModel ToModel<T>(this Media media, int entityId,
            IMediaService mediaService,
            MediaSettings mediaSettings = null,
            GeneralSettings generalSettings = null,
            IUserService userService = null,
            IFollowService followService = null,
            IFriendService friendService = null,
            ICommentService commentService = null,
            ILikeService likeService = null,
            bool withUserInfo = true,
            bool withSocialInfo = false,
            bool withNextAndPreviousMedia = false,
            bool avoidMediaTypeForNextAndPreviousMedia = false) where T: BaseEntity
        {
            var model = new MediaReponseModel() {
                Id = media.Id,
                MediaType = media.MediaType,
                Url = media.MediaType == MediaType.Image ? mediaService.GetPictureUrl(media) : mediaService.GetVideoUrl(media),
                MimeType = media.MimeType,
                DateCreatedUtc = media.DateCreated,
                ThumbnailUrl = media.MediaType == MediaType.Image ? mediaService.GetPictureUrl(media, PictureSizeNames.ThumbnailImage) : WebHelper.GetUrlFromPath(media.ThumbnailPath, generalSettings?.ImageServerDomain)
            };
            if (withUserInfo && userService != null)
            {
                var user = userService.Get(media.UserId);
                if (user != null)
                {
                    model.CreatedBy = user.ToModel(mediaService, mediaSettings, followService, friendService);
                    model.DateCreatedLocal = DateTimeHelper.GetDateInUserTimeZone(media.DateCreated, DateTimeKind.Utc, user);
                }
            }
            if (withSocialInfo)
            {
                if (likeService != null)
                {
                    model.TotalLikes = likeService.GetLikeCount<Media>(media.Id);
                    model.LikeStatus =
                        likeService.GetCustomerLike<Media>(ApplicationContext.Current.CurrentUser.Id, media.Id) != null
                            ? 1
                            : 0;
                }

                if (commentService != null)
                {
                    model.TotalComments = commentService.GetCommentsCount(media.Id, typeof(Media).Name);
                    model.CanComment = true; //todo: perform check if comments are enabled or user has permission to comment
                }
            }

            if (withNextAndPreviousMedia)
            {
                MediaType? mediaType = null;
                if (!avoidMediaTypeForNextAndPreviousMedia)
                    mediaType = media.MediaType;
                var allMedia = mediaService.GetEntityMedia<T>(entityId, mediaType, 1, int.MaxValue).ToList();
                var mediaIndex = allMedia.FindIndex(x => x.Id == media.Id);

                model.PreviousMediaId = mediaIndex <= 0 ? 0 : allMedia[mediaIndex - 1].Id;
                model.NextMediaId = mediaIndex < 0 || mediaIndex == allMedia.Count - 1 ? 0 : allMedia[mediaIndex + 1].Id;
            }

            model.FullyLoaded = withSocialInfo && withNextAndPreviousMedia;
            return model;
            ;
        }
コード例 #57
0
        public ThumbnailsService(ShellSettings settings, IWorkContextAccessor wca, ICacheManager cacheManager, IMediaService mediaService, ISignals signals, IStorageProvider storageProvider)
        {
            _wca             = wca;
            _cacheManager    = cacheManager;
            _mediaService    = mediaService;
            _signals         = signals;
            _storageProvider = storageProvider;
            var appPath = "";

            if (HostingEnvironment.IsHosted)
            {
                appPath = HostingEnvironment.ApplicationVirtualPath;
            }
            if (!appPath.EndsWith("/"))
            {
                appPath = appPath + '/';
            }
            if (!appPath.StartsWith("/"))
            {
                appPath = '/' + appPath;
            }

            _publicPath = appPath + "Media/" + settings.Name + "/";

            var physPath = ThumbnailsCacheMediaPath.Replace('/', Path.DirectorySeparatorChar);
            var parent   = Path.GetDirectoryName(physPath);
            var folder   = Path.GetFileName(physPath);

            if (_mediaService.GetMediaFolders(parent).All(f => f.Name != folder))
            {
                _mediaService.CreateFolder(parent, folder);
            }
        }
コード例 #58
0
 public OrderController(IRepository <Order> orderRepository, IWorkContext workContext, IMediaService mediaService)
 {
     _orderRepository = orderRepository;
     _workContext     = workContext;
     _mediaService    = mediaService;
 }
コード例 #59
0
 public MediaAPIController(IMediaService mediaService)
 {
     this.mediaService = mediaService;
 }
コード例 #60
0
 static UProductService()
 {
     _cs = UmbracoContext.Current.Application.Services.ContentService;
     _ms = UmbracoContext.Current.Application.Services.MediaService;
 }