public PropertiesEntry GetPropertiesEntry()
        {
            var key           = Key.Replace("-", ".");
            var propertiesSet = PropertiesProvider.GetInstance(key);

            var entry            = new PropertiesEntry(key);
            var propertiesValues = new List <PropertiesValue>();

            foreach (var propertiesElement in Properties)
            {
                var property = propertiesSet.GetType().GetProperty(propertiesElement.Key.Replace("-", "."));
                if (property != null)
                {
                    foreach (var propertyValue in propertiesElement.Values)
                    {
                        var value           = ParsePropertyValue(property.PropertyType, propertyValue.Value);
                        var propertiesValue = propertiesValues.FirstOrDefault(v => v.SiteId == propertyValue.SiteId);
                        if (propertiesValue == null)
                        {
                            propertiesValue = new PropertiesValue(propertyValue.SiteId, PropertiesProvider.GetInstance(key));
                            propertiesValues.Add(propertiesValue);
                        }

                        property.SetValue(propertiesValue.Value, value);
                    }
                }
            }

            entry.Properties.AddRange(propertiesValues);

            return(entry);
        }
Exemple #2
0
 protected PageViewModel(PageViewModelContext context)
 {
     Site               = context.Site;
     Section            = context.Section;
     PropertiesProvider = context.PropertiesProvider;
     LinkGenerator      = context.LinkGenerator;
 }
Exemple #3
0
 public PageViewModelContext(LinkGenerator linkGenerator, PropertiesProvider propertiesProvider,
                             Entities.Site site, Section section = null)
 {
     LinkGenerator      = linkGenerator;
     PropertiesProvider = propertiesProvider;
     Site    = site;
     Section = section;
 }
 protected BioRepository(BioRepositoryContext <TEntity> repositoryContext)
 {
     DbContext          = repositoryContext.DbContext;
     Validators         = repositoryContext.Validators ?? new List <IValidator <TEntity> >();
     PropertiesProvider = repositoryContext.PropertiesProvider;
     HooksManager       = repositoryContext.HooksManager;
     Init();
 }
Exemple #5
0
 protected virtual async Task ParseEntityAsync(TEntity entity)
 {
     Id               = entity.Id;
     DateAdded        = entity.DateAdded;
     DateUpdated      = entity.DateUpdated;
     PropertiesGroups = (await _propertiesProvider.GetAsync(entity))
                        .Select(p => PropertiesGroup.Create(p, PropertiesProvider.GetSchema(p.Key))).ToList();
 }
Exemple #6
0
 public override void ConfigureServices(IServiceCollection services, IConfiguration configuration,
                                        IHostEnvironment environment)
 {
     base.ConfigureServices(services, configuration, environment);
     PropertiesProvider.RegisterBioEngineSectionProperties <SeoContentPropertiesSet>("seo");
     PropertiesProvider.RegisterBioEngineContentProperties <SeoContentPropertiesSet>("seo");
     PropertiesProvider.RegisterBioEngineProperties <SeoSitePropertiesSet, Site>("seosite");
 }
Exemple #7
0
        public override async Task <PageMetaModel> GetMetaAsync()
        {
            var path = LinkGenerator.GeneratePublicUrl(Entity);
            var meta = new PageMetaModel
            {
                Title = $"{Entity.Title} / {Site.Title}", CurrentUrl = new Uri($"{Site.Url}{path}")
            };

            var seoPropertiesSet = await PropertiesProvider.GetAsync <SeoContentPropertiesSet>(Entity);

            if (seoPropertiesSet != null && !string.IsNullOrEmpty(seoPropertiesSet.Description))
            {
                meta.Description = seoPropertiesSet.Description;
            }
            else
            {
                if (Entity is IContentEntity contentEntity)
                {
                    if (contentEntity.Blocks.OrderBy(b => b.Position).FirstOrDefault(b => b is TextBlock) is TextBlock
                        textBlock)
                    {
                        meta.Description = HtmlHelper.GetDescriptionFromHtml(textBlock.Data.Text);
                    }
                }
            }

            if (seoPropertiesSet != null && !string.IsNullOrEmpty(seoPropertiesSet.Keywords))
            {
                meta.Keywords = seoPropertiesSet.Keywords;
            }
            else
            {
                if (Entity is ITaggedContentEntity taggedContentEntity)
                {
                    meta.Keywords = string.Join(", ", taggedContentEntity.Tags.Select(t => t.Title));
                }
            }

            if (Entity is IContentEntity contEntity)
            {
                foreach (var block in contEntity.Blocks.OrderBy(b => b.Position))
                {
                    if (block is PictureBlock pictureBlock)
                    {
                        meta.ImageUrl = pictureBlock.Data.Picture.PublicUri;
                        break;
                    }

                    if (block is GalleryBlock galleryBlock && galleryBlock.Data.Pictures.Length > 0)
                    {
                        meta.ImageUrl = galleryBlock.Data.Pictures[0].PublicUri;
                        break;
                    }
                }
            }

            return(meta);
        }
Exemple #8
0
        public override void ConfigureServices(IServiceCollection services, IConfiguration configuration,
                                               IHostEnvironment environment)
        {
            services.AddSingleton <FacebookService>();
            services.AddScoped <IContentPublisher <FacebookConfig>, FacebookContentPublisher>();
            services.AddScoped <FacebookContentPublisher>();

            PropertiesProvider.RegisterBioEngineProperties <FacebookSitePropertiesSet, Site>("facebooksite");
        }
Exemple #9
0
        public override void ConfigureServices(IServiceCollection services, IConfiguration configuration,
                                               IHostEnvironment environment)
        {
            services.AddSingleton <TwitterService>();
            services.AddScoped <IContentPublisher <TwitterPublishConfig>, TwitterContentPublisher>();
            services.AddScoped <TwitterContentPublisher>();

            PropertiesProvider.RegisterBioEngineProperties <TwitterSitePropertiesSet, Site>("twittersite");
        }
 public BaseControllerContext(ILoggerFactory loggerFactory, IStorage storage,
                              PropertiesProvider propertiesProvider, LinkGenerator linkGenerator,
                              BioEngineCoreModuleConfig coreModuleConfig)
 {
     LinkGenerator      = linkGenerator;
     Storage            = storage;
     PropertiesProvider = propertiesProvider;
     Logger             = loggerFactory.CreateLogger(GetType());
     Version            = coreModuleConfig.Version;
 }
Exemple #11
0
 public IPBCommentsSynchronizer(BioContext dbContext, SitesRepository sitesRepository,
                                PropertiesProvider propertiesProvider, IPBApiClientFactory ipbApiClientFactory,
                                ILogger <IPBCommentsSynchronizer> logger)
 {
     _dbContext           = dbContext;
     _sitesRepository     = sitesRepository;
     _propertiesProvider  = propertiesProvider;
     _ipbApiClientFactory = ipbApiClientFactory;
     _logger = logger;
 }
Exemple #12
0
        public override void ConfigureServices(IServiceCollection services, IConfiguration configuration,
                                               IHostEnvironment environment)
        {
            PropertiesProvider.RegisterBioEngineProperties <IPBSitePropertiesSet, Site>("ipbsite");

            services.AddSingleton(typeof(IPBModuleConfig), Config);
            services.AddSingleton(Config);
            services.AddSingleton <IPBApiClientFactory>();
            services.AddScoped <IPBCommentsSynchronizer>();
            services.AddHttpClient();
        }
        protected virtual Task ParseEntityAsync(TEntity entity)
        {
            Id          = entity.Id;
            DateAdded   = entity.DateAdded;
            DateUpdated = entity.DateUpdated;

            Title = entity.Title;

            PropertiesGroups =
                entity.Properties.Select(p => PropertiesGroup.Create(p, PropertiesProvider.GetSchema(p.Key))).ToList();
            return(Task.CompletedTask);
        }
 public Importer(BioContext dbContext, ILogger <Importer> logger, FilesUploader filesUploader,
                 PropertiesProvider propertiesProvider, HtmlParser htmlParser,
                 LinkGenerator linkGenerator, IOptions <ImporterOptions> options)
 {
     _dbContext          = dbContext;
     _logger             = logger;
     _filesUploader      = filesUploader;
     _propertiesProvider = propertiesProvider;
     _htmlParser         = htmlParser;
     _linkGenerator      = linkGenerator;
     _options            = options.Value;
 }
Exemple #15
0
 public BRCPostsPublisher(IPBContentPublisher ipbContentPublisher,
                          TwitterContentPublisher twitterContentPublisher,
                          FacebookContentPublisher facebookContentPublisher, SitesRepository sitesRepository,
                          SectionsRepository sectionsRepository,
                          PropertiesProvider propertiesProvider, IOptions <BrcApiOptions> options)
 {
     _ipbContentPublisher      = ipbContentPublisher;
     _twitterContentPublisher  = twitterContentPublisher;
     _facebookContentPublisher = facebookContentPublisher;
     _sitesRepository          = sitesRepository;
     _sectionsRepository       = sectionsRepository;
     _propertiesProvider       = propertiesProvider;
     _options = options.Value;
 }
        protected virtual async Task SavePropertiesAsync(RestModel <TEntity> restModel, TEntity entity)
        {
            var properties = restModel.PropertiesGroups?.Select(s => s.GetPropertiesEntry()).ToList();

            if (properties != null)
            {
                foreach (var propertiesEntry in properties)
                {
                    foreach (var val in propertiesEntry.Properties)
                    {
                        await PropertiesProvider.SetAsync(val.Value, entity, val.SiteId);
                    }
                }
            }
        }
        private IEnumerable <string> ReturnNamespaces(PropertiesProvider prov)
        {
            var attrs = prov.GetType()
                        .GetCustomAttributes(typeof(QueryNamespaceAttribute), false)
                        .OfType <QueryNamespaceAttribute>()
                        .Select(k => k.Namespace)
                        .ToArray();

            if (!attrs.Any())
            {
                throw new InvalidOperationException("Описатель ресурсов проекции должен иметь атрибут пространства имен проекции");
            }

            return(attrs);
        }
        public async Task <ActionResult <ListResponse <PropertiesOption> > > GetAsync(
            string setKey, string propertyKey)
        {
            var propertiesSet = PropertiesProvider.GetInstance(setKey.Replace("-", "."));

            if (propertiesSet == null)
            {
                return(NotFound());
            }

            var resolver = _resolvers.FirstOrDefault(r => r.CanResolve(propertiesSet));

            if (resolver == null)
            {
                return(NotFound());
            }

            var options = await resolver.ResolveAsync(propertiesSet, propertyKey.Replace("-", "."));

            return(new ListResponse <PropertiesOption>(options, options.Count));
        }
Exemple #19
0
 public Site(PropertiesProvider propertiesProvider) : base(propertiesProvider)
 {
 }
Exemple #20
0
 protected ContentEntityRestModel(LinkGenerator linkGenerator, SitesRepository sitesRepository, PropertiesProvider propertiesProvider) : base(propertiesProvider)
 {
     _linkGenerator   = linkGenerator;
     _sitesRepository = sitesRepository;
 }
Exemple #21
0
 public Section(LinkGenerator linkGenerator, SitesRepository sitesRepository,
                PropertiesProvider propertiesProvider) : base(linkGenerator,
                                                              sitesRepository, propertiesProvider)
 {
 }
Exemple #22
0
 public TopicRequestItem(LinkGenerator linkGenerator, SitesRepository sitesRepository,
                         PropertiesProvider propertiesProvider) : base(linkGenerator, sitesRepository, propertiesProvider)
 {
 }
Exemple #23
0
 public Menu(PropertiesProvider propertiesProvider) : base(propertiesProvider)
 {
 }
Exemple #24
0
 protected RestModel(PropertiesProvider propertiesProvider)
 {
     _propertiesProvider = propertiesProvider;
 }
Exemple #25
0
 public Tag(PropertiesProvider propertiesProvider) : base(propertiesProvider)
 {
 }
Exemple #26
0
 protected ResponseSectionRestModel(LinkGenerator linkGenerator, SitesRepository sitesRepository,
                                    PropertiesProvider propertiesProvider) : base(
         linkGenerator, sitesRepository, propertiesProvider)
 {
 }
Exemple #27
0
 protected SiteEntityRestModel(PropertiesProvider propertiesProvider) : base(propertiesProvider)
 {
 }