Esempio n. 1
0
        public static string GetArchivePath(ISiteContext context, string segment, string name, bool uri, string page = null)
        {
            name = EncodePathSegment(name, uri)
                .ToLower();         // TODO: Make this conditional

            string dest = Path.Combine(context.DestinationDir, segment);

            string file;
            if (context.Config.Rebase)
            {
                file = Path.Combine(dest, name);
                if (!String.IsNullOrWhiteSpace(page))
                    file = Path.Combine(file, page);
                if (!uri || context.Config.Local)
                    file = Path.Combine(file, context.Config.IndexName);
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(page))
                    name = name + "-" + page;
                file = Path.Combine(dest, name + context.Config.Extension);
            }

            return file;
        }
Esempio n. 2
0
        public override string GetDestinationPath(ISiteContext context, string src, string dst, string file)
        {
            if (String.IsNullOrWhiteSpace(this.Permalink) &&
                String.IsNullOrWhiteSpace(context.Config.Permalink))
            {
                return base.GetDestinationPath(context, src, dst, file);
            }

            string pattern = String.IsNullOrWhiteSpace(this.Permalink)
                ? context.Config.Permalink
                : this.Permalink;

            var permalink = RewritePermalink(pattern, src, dst, this.Year, this.Month, this.Day);

            // If the rewrite isn't terminated by a path separator,
            // we must truncate the path to its directory component
            // and build a new filename from the last segment.
            if (permalink.Last() != Path.DirectorySeparatorChar)
            {
                int index = permalink.LastIndexOf(Path.DirectorySeparatorChar);
                file = permalink.Substring(index + 1) + context.Config.Extension;
                permalink = permalink.Substring(0, index);
            }
            else
            {
                // Remove final separator, just for uniformity.
                permalink = permalink.Substring(0, permalink.Length - 1);
                file = context.Config.IndexName;
            }

            // Apply the rewrite.
            dst = context.DestinationDir + permalink;

            return Path.Combine(dst, file);
        }
        public MarkpadDocumentBaseTests()
        {
            fileSystem = Substitute.For<IFileSystem>();
            siteContext = Substitute.For<ISiteContext>();
            documentFactory = Substitute.For<IDocumentFactory>();

            markpadDocumentBase = new TestMarkpadDocumentBase("Title", "Content", null, new FileReference[0], documentFactory, siteContext, fileSystem);
        }
 public Task SendAccountConfirmationEmailAsync(
     ISiteContext siteSettings,
     string toAddress,
     string subject,
     string confirmationUrl)
 {
     return Task.FromResult(0);
 }
Esempio n. 5
0
 void GenerateContent(ISiteContext context, PageModel model, string path, string segment, string name, List<PageInfo> list, int itemsPerPage)
 {
     int pages = PaginatorInfo.PageCount(itemsPerPage, list.Count);
     for (int page = 0; page < pages; page++)
     {
         GeneratePage(context, model, path, segment, name, list, page, page * itemsPerPage, itemsPerPage);
     }
 }
 public Task SendSecurityCodeEmailAsync(
     ISiteContext siteSettings,
     string toAddress,
     string subject,
     string securityCode)
 {
     return Task.FromResult(0);
 }
 public Task SendPasswordResetEmailAsync(
     ISiteContext siteSettings,
     string toAddress,
     string subject,
     string resetUrl)
 {
     return Task.FromResult(0);
 }
 public Task SendAccountApprovalNotificationAsync(
     ISiteContext siteSettings,
     string toAddress,
     string subject,
     string loginUrl)
 {
     return Task.FromResult(0);
 }
Esempio n. 9
0
        public PageModel(ISiteContext context)
        {
            var map = new Dictionary<string, PageInfo>();
            var pages = new List<PageInfo>();
            var posts = new List<PostInfo>();

            // Transform the page map keys to relative paths and build out
            // separate page and post lists.
            foreach (var item in context.PageMap)
            {
                var path = item.Key;
                var page = item.Value;

                var file = FileUtility.GetRelativePath(context.SourceDir, path);

                map.Add(file, page);
                if (page is PostInfo)
                {
                    posts.Add(page as PostInfo);
                }
                else
                {
                    pages.Add(page);
                }
            }

            var categoryList = new List<string>();
            var categoryPaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            foreach (var item in context.Categories)
            {
                categoryList.Add(item.Key);

                string path = FileUtility.GetArchiveUrl(context, context.Config.CategoryDir, item.Key);

                categoryPaths.Add(item.Key, path);
            }

            var tagList = new List<string>();
            var tagPaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            foreach (var item in context.Tags)
            {
                tagList.Add(item.Key);

                string path = FileUtility.GetArchiveUrl(context, context.Config.TagDir, item.Key);

                tagPaths.Add(item.Key, path);
            }

            Categories = categoryList.ToArray();
            Tags = tagList.ToArray();
            CategoryPaths = categoryPaths;
            TagPaths = tagPaths;
            CategoryPages = context.Categories;
            TagPages = context.Tags;
            PageMap = map;
            Pages = pages.OrderByDescending(p => p.Date).ToArray();
            Posts = posts.OrderByDescending(p => p.Date).ToArray();
        }
Esempio n. 10
0
        public static RedirectResult RedirectToSiteRoot(this Controller controller, ISiteContext site)
        {
            if(site.SiteFolderName.Length > 0)
            {
                return controller.Redirect("/" + site.SiteFolderName);
            }

            return controller.Redirect("/");
        }
        public StyleGuidelineController(ITenant tenant,
                                        ISiteContext siteContext,
                                        IBenefitsModelFactory benefitsModelFactory)
        {
            _tenant                                 = tenant;
            _siteContext                            = siteContext;
            _benefitsModelFactory                   = benefitsModelFactory;

        }
        public FileMarkdownDocumentTests()
        {
            siteContext = Substitute.For<ISiteContext>();
            documentFactory = Substitute.For<IDocumentFactory>();
            eventAggregator = Substitute.For<IEventAggregator>();
            dialogService = Substitute.For<IDialogService>();
            fileSystem = TestObjectMother.GetFileSystem();

            documentUnderTest = CreateFileMarkdownDocument(DocumentFilename, "Content");
        }
        public string EnsureFolderSegmentIfNeeded(ISiteContext site, string returnUrl)
        {
            // only adjust if the return url is an endpoint url
            if (!IsEndpointReturnUrl(returnUrl)) return returnUrl;
            if (site == null) return returnUrl;
            if (string.IsNullOrEmpty(site.SiteFolderName)) return returnUrl;
            var folderSegment = "/" + site.SiteFolderName;
            if (returnUrl.StartsWith(folderSegment)) return returnUrl;

            return folderSegment + returnUrl;
        }
Esempio n. 14
0
        public void Generate(ISiteContext context, PageModel model)
        {
            int itemsPerPage = context.Config.ItemsPerPage;
            if (itemsPerPage <= 0)
            {
                throw new Exception("ItemsPerPage must be a positive number.");
            }

            if (!Directory.Exists(context.TemplatesDir))
            {
                Console.WriteLine("Templates directory not found.");
                return;
            }

            string template;
            string segment;
            Dictionary<string, List<PageInfo>> list;
            if (_type == ArchiveType.Category)
            {
                list = context.Categories;
                template = context.Config.CategoryTemplate;
                segment = context.Config.CategoryDir;
            }
            else // if (_type == ArchiveType.Tag)
            {
                list = context.Tags;
                template = context.Config.TagTemplate;
                segment = context.Config.TagDir;
            }

            string templatePath = Path.Combine(context.TemplatesDir, template);
            if (!File.Exists(templatePath))
            {
                Console.WriteLine("Warning: Template '{0}' not found.", template);
                return;
            }

            _template = new TemplateProcessor<PageModel>(context, templatePath);
            _template.Load();

            string dir = Path.Combine(context.DestinationDir, segment);

            Directory.CreateDirectory(dir);

            foreach (var item in list)
            {
                GenerateContent(context, model, templatePath, segment, item.Key, item.Value, itemsPerPage);
            }
        }
Esempio n. 15
0
        private TwilioSmsCredentials GetCredentials(ISiteContext site)
        {
            if(site == null) { return null; }
            if(string.IsNullOrWhiteSpace(site.SmsClientId)) { return null; }
            if (string.IsNullOrWhiteSpace(site.SmsSecureToken)) { return null; }
            if (string.IsNullOrWhiteSpace(site.SmsFrom)) { return null; }

            TwilioSmsCredentials creds = new TwilioSmsCredentials();
            creds.AccountSid = site.SmsClientId;
            creds.AuthToken = site.SmsSecureToken;
            creds.FromNumber = site.SmsFrom;

            return creds;

        }
Esempio n. 16
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="httpContextAccessor">HTTP context accessor</param>
 /// <param name="currencySettings">Currency settings</param>
 /// <param name="authenticationService">Authentication service</param>
 /// <param name="currencyService">Currency service</param>
 /// <param name="userService">User service</param>
 /// <param name="genericAttributeService">Generic attribute service</param>
 /// <param name="languageService">Language service</param>
 /// <param name="siteContext">Site context</param>
 /// <param name="siteMappingService">Site mapping service</param>
 /// <param name="userAgentHelper">User gent helper</param>
 /// <param name="vendorService">Vendor service</param>
 /// <param name="localizationSettings">Localization settings</param>
 /// <param name="taxSettings">Tax settings</param>
 public WebWorkContext(IHttpContextAccessor httpContextAccessor,
                       IAuthenticationService authenticationService,
                       IUserService userService,
                       IGenericAttributeService genericAttributeService,
                       ISiteContext siteContext,
                       ISiteMappingService siteMappingService,
                       IUserAgentHelper userAgentHelper)
 {
     this._httpContextAccessor     = httpContextAccessor;
     this._authenticationService   = authenticationService;
     this._userService             = userService;
     this._genericAttributeService = genericAttributeService;
     this._siteContext             = siteContext;
     this._siteMappingService      = siteMappingService;
     this._userAgentHelper         = userAgentHelper;
 }
Esempio n. 17
0
 public virtual string GetDestinationPath(ISiteContext context, string src, string dst, string file)
 {
     string name = Path.GetFileNameWithoutExtension(file);
     string index = Path.GetFileNameWithoutExtension(context.Config.IndexName);
     if (name == index || !this.Rebase)
     {
         file = name + context.Config.Extension;
     }
     else
     {
         // Create a new directory: dst/page[/index.html]
         dst = Path.Combine(dst, name);
         file = context.Config.IndexName;
     }
     return Path.Combine(dst, file);
 }
        public CatalogService(
            ISiteContext siteContext,
            ICatalogMapper catalogMapper,
            ISearchService searchService,
            IProductBuilder <Item> productBuilder)
        {
            Assert.ArgumentNotNull(siteContext, nameof(siteContext));
            Assert.ArgumentNotNull(catalogMapper, nameof(catalogMapper));
            Assert.ArgumentNotNull(searchService, nameof(searchService));
            Assert.ArgumentNotNull(productBuilder, nameof(productBuilder));

            this.siteContext    = siteContext;
            this.catalogMapper  = catalogMapper;
            this.searchService  = searchService;
            this.productBuilder = productBuilder;
        }
 GetNodeIdByType(
     IUnitOfWork unitOfWork,
     ISiteContext siteContext,
     string pageType
     )
 {
     return(unitOfWork
            .GetRepository <Node>()
            .GetTableAsNoTracking()
            .Where(
                o =>
                o.WebsiteId == siteContext.WebsiteDto.Id &&
                o.Type == pageType)
            .Select(o => o.Id)
            .FirstOrDefault());
 }
Esempio n. 20
0
 public MesajServisi(ISiteContext siteContext,
                     IMesajTemasıServisi mesajTemasıServisi,
                     IEmailHesapServisi emailHesapServisi,
                     EmailHesapAyarları emailHesapAyarları,
                     ISiteServisi siteServisi,
                     GenelAyarlar genelAyarlar,
                     IBekleyenMailServisi bekleyeneMailServisi)
 {
     this._siteContext         = siteContext;
     this._mesajTemasıServisi  = mesajTemasıServisi;
     this._emailHesapServisi   = emailHesapServisi;
     this._emailHesapAyarları  = emailHesapAyarları;
     this._siteServisi         = siteServisi;
     this._genelAyarlar        = genelAyarlar;
     this._bekleyenMailServisi = bekleyeneMailServisi;
 }
Esempio n. 21
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="cacheManager">Cache manager</param>
        /// <param name="clientRepository">Category repository</param>
        /// <param name="productClientRepository">ProductCategory repository</param>
        /// <param name="productRepository">Product repository</param>
        /// <param name="siteMappingRepository">Site mapping repository</param>
        /// <param name="workContext">Work context</param>
        /// <param name="siteContext">Site context</param>
        /// <param name="eventPublisher">Event published</param>
        public ClientService(ICacheManager cacheManager,
                             IRepository <Client> clientRepository,
                             IRepository <SiteMapping> siteMappingRepository,
                             IWorkContext workContext,
                             ISiteContext siteContext,
                             IEventPublisher eventPublisher)
        {
            _cacheManager          = cacheManager;
            _clientRepository      = clientRepository;
            _siteMappingRepository = siteMappingRepository;
            _workContext           = workContext;
            _siteContext           = siteContext;
            _eventPublisher        = eventPublisher;

            this.QuerySettings = DbQuerySettings.Default;
        }
        public async Task SendAccountConfirmationEmailAsync(
            ISiteContext siteSettings,
            string toAddress,
            string subject,
            string confirmationUrl,
            string confirmCode)
        {
            var sender = await _emailSenderResolver.GetEmailSender(siteSettings.Id.ToString());

            if (sender == null)
            {
                var logMessage = $"failed to send account confirmation email because email settings are not populated for site {siteSettings.SiteName}";
                _log.LogError(logMessage);
                return;
            }

            var model = new ConfirmEmailAddessViewModel
            {
                ConfirmationUrl  = confirmationUrl,
                ConfirmationCode = confirmCode,
                Tenant           = siteSettings
            };


            try
            {
                var plainTextMessage
                    = await _viewRenderer.RenderViewAsString <ConfirmEmailAddessViewModel>("EmailTemplates/ConfirmAccountTextEmail", model).ConfigureAwait(false);

                var htmlMessage
                    = await _viewRenderer.RenderViewAsString <ConfirmEmailAddessViewModel>("EmailTemplates/ConfirmAccountHtmlEmail", model).ConfigureAwait(false);

                await sender.SendEmailAsync(
                    toAddress,
                    siteSettings.DefaultEmailFromAddress,
                    subject,
                    plainTextMessage,
                    htmlMessage,
                    configLookupKey : siteSettings.Id.ToString()

                    ).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _log.LogError($"error sending account confirmation email: {ex.Message} stacktrace: {ex.StackTrace}");
            }
        }
Esempio n. 23
0
        private static bool TryEnsureTenantWwwRoot(ISiteContext tenant, MultiTenantOptions options)
        {
            var siteFilesPath = Path.Combine(Directory.GetCurrentDirectory(), options.SiteFilesFolderName);

            if (!Directory.Exists(siteFilesPath))
            {
                try
                {
                    Directory.CreateDirectory(siteFilesPath);
                }
                catch
                {
                    return(false);
                }
            }

            var tenantFolder = Path.Combine(siteFilesPath, tenant.AliasId);

            if (!Directory.Exists(tenantFolder))
            {
                try
                {
                    Directory.CreateDirectory(tenantFolder);
                }
                catch
                {
                    return(false);
                }
            }

            var tenantWwwRoot = Path.Combine(tenantFolder, options.SiteContentFolderName);

            if (!Directory.Exists(tenantWwwRoot))
            {
                try
                {
                    Directory.CreateDirectory(tenantWwwRoot);
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }
        private SmtpOptions GetSmptOptions(ISiteContext siteSettings)
        {
            if(!siteSettings.SmtpIsConfigured()) { return globalSmtpSettings; }
            
            SmtpOptions smtpOptions = new SmtpOptions();
            smtpOptions.Password = siteSettings.SmtpPassword;
            smtpOptions.Port = siteSettings.SmtpPort;
            smtpOptions.PreferredEncoding = siteSettings.SmtpPreferredEncoding;
            smtpOptions.RequiresAuthentication = siteSettings.SmtpRequiresAuth;
            smtpOptions.Server = siteSettings.SmtpServer;
            smtpOptions.User = siteSettings.SmtpUser;
            smtpOptions.UseSsl = siteSettings.SmtpUseSsl;
            smtpOptions.DefaultEmailFromAddress = siteSettings.DefaultEmailFromAddress;
            smtpOptions.DefaultEmailFromAlias = siteSettings.DefaultEmailFromAlias;

            return smtpOptions;
        }
Esempio n. 25
0
        public GenelModelFactory(IKategoriServisi categoryService,
                                 ISayfalarServisi topicService,
                                 ILanguageService languageService,
                                 ILocalizationService localizationService,
                                 IWorkContext workContext,
                                 ISiteContext storeContext,
                                 ITemaContext themeContext,
                                 ITemaSağlayıcı themeProvider,
                                 IForumServisi forumservice,
                                 IGenelÖznitelikServisi genericAttributeService,
                                 IWebYardımcısı webHelper,
                                 IİzinServisi permissionService,
                                 IStatikÖnbellekYönetici cacheManager,
                                 ISayfaHeadOluşturucu pageHeadBuilder,
                                 IResimServisi pictureService,
                                 IHostingEnvironment hostingEnvironment,

                                 KatalogAyarları catalogSettings,
                                 SiteBilgiAyarları storeInformationSettings,
                                 GenelAyarlar commonSettings,
                                 BlogAyarları blogSettings,
                                 ForumAyarları forumSettings,
                                 LocalizationSettings localizationSettings)
        {
            this._categoryService         = categoryService;
            this._topicService            = topicService;
            this._languageService         = languageService;
            this._localizationService     = localizationService;
            this._workContext             = workContext;
            this._storeContext            = storeContext;
            this._themeContext            = themeContext;
            this._themeProvider           = themeProvider;
            this._genericAttributeService = genericAttributeService;
            this._webHelper                = webHelper;
            this._permissionService        = permissionService;
            this._cacheManager             = cacheManager;
            this._pageHeadBuilder          = pageHeadBuilder;
            this._pictureService           = pictureService;
            this._hostingEnvironment       = hostingEnvironment;
            this._catalogSettings          = catalogSettings;
            this._storeInformationSettings = storeInformationSettings;
            this._commonSettings           = commonSettings;
            this._blogSettings             = blogSettings;
            this._forumSettings            = forumSettings;
            this._localizationSettings     = localizationSettings;
        }
Esempio n. 26
0
        public virtual string GetDestinationPath(ISiteContext context, string src, string dst, string file)
        {
            string name  = Path.GetFileNameWithoutExtension(file);
            string index = Path.GetFileNameWithoutExtension(context.Config.IndexName);

            if (name == index || !this.Rebase)
            {
                file = name + context.Config.Extension;
            }
            else
            {
                // Create a new directory: dst/page[/index.html]
                dst  = Path.Combine(dst, name);
                file = context.Config.IndexName;
            }
            return(Path.Combine(dst, file));
        }
Esempio n. 27
0
 public ThemeContext(
     IWorkContext workContext,
     ISiteContext siteContext,
     IGenericAttributeService genericAttributeService,
     ThemeSettings themeSettings,
     IThemeRegistry themeRegistry,
     IMobileDeviceHelper mobileDeviceHelper,
     HttpContextBase httpContext)
 {
     this._workContext             = workContext;
     this._siteContext             = siteContext;
     this._genericAttributeService = genericAttributeService;
     this._themeSettings           = themeSettings;
     this._themeRegistry           = themeRegistry;
     this._mobileDeviceHelper      = mobileDeviceHelper;
     this._httpContext             = httpContext;
 }
Esempio n. 28
0
        public PollService(IRepository <Poll> pollRepository,
                           IRepository <PollAnswer> pollAnswerRepository,
                           IRepository <PollVotingRecord> pollVotingRecords,
                           IRepository <SiteMapping> SiteMappingRepository,
                           ICacheManager cacheManager, IEventPublisher eventPublisher,
                           ISiteContext SiteContext)
        {
            this._pollRepository        = pollRepository;
            this._pollAnswerRepository  = pollAnswerRepository;
            this._pollVotingRecords     = pollVotingRecords;
            this._SiteMappingRepository = SiteMappingRepository;
            this._cacheManager          = cacheManager;
            this._eventPublisher        = eventPublisher;
            this._SiteContext           = SiteContext;

            this.QuerySettings = DbQuerySettings.Default;
        }
Esempio n. 29
0
        public override async Task <SmtpOptions> GetSmtpOptions(string lookupKey = null)
        {
            ISiteContext currentSite = null;

            if (!string.IsNullOrWhiteSpace(lookupKey) && lookupKey.Length == 36)
            {
                try
                {
                    currentSite = await _siteResolver.GetById(new Guid(lookupKey));

                    if (currentSite != null)
                    {
                        if (string.IsNullOrEmpty(currentSite.SmtpServer))
                        {
                            return(await base.GetSmtpOptions(lookupKey));
                        }

                        SmtpOptions smtpOptions = new SmtpOptions
                        {
                            Password = currentSite.SmtpPassword,
                            Port     = currentSite.SmtpPort,
                            PlainTextBodyDefaultEncoding = currentSite.SmtpPreferredEncoding,
                            RequiresAuthentication       = currentSite.SmtpRequiresAuth,
                            Server = currentSite.SmtpServer,
                            User   = currentSite.SmtpUser,
                            UseSsl = currentSite.SmtpUseSsl,
                            DefaultEmailFromAddress = currentSite.DefaultEmailFromAddress,
                            DefaultEmailFromAlias   = currentSite.DefaultEmailFromAlias
                        };

                        return(smtpOptions);
                    }
                    else
                    {
                        _log.LogError($"failed to lookup site to get email settings, no site found using lookupKey {lookupKey}");
                    }
                }
                catch (Exception ex)
                {
                    _log.LogError($"failed to lookup site to get email settings, lookupKey was not a valid guid string for siteid. {ex.Message} - {ex.StackTrace}");
                }
            }

            return(await base.GetSmtpOptions(lookupKey));
        }
Esempio n. 30
0
 public CommonController(
     IWebHelper webHelper,
     ILanguageService languageService,
     IWorkContext workContext,
     ISiteContext siteContext,
     IUserService userService,
     ILocalizationService localizationService,
     Lazy <SecuritySettings> securitySettings,
     Lazy <IMenuPublisher> menuPublisher,
     Lazy <CurrencySettings> currencySettings,
     Lazy <MeasureSettings> measureSettings,
     Lazy <IMeasureService> measureService,
     Lazy <IDateTimeHelper> dateTimeHelper,
     Lazy <IPluginFinder> pluginFinder,
     Lazy <IImageCache> imageCache,
     IPermissionService permissionService,
     IGenericAttributeService genericAttributeService,
     IArticleService articleService,
     ICommonServices services,
     IDbContext dbContext,
     SiteInformationSettings siteSettings,
     Func <string, ICacheManager> cache)
 {
     this._webHelper               = webHelper;
     this._currencySettings        = currencySettings;
     this._measureSettings         = measureSettings;
     this._measureService          = measureService;
     this._languageService         = languageService;
     this._workContext             = workContext;
     this._siteContext             = siteContext;
     this._userService             = userService;
     this._localizationService     = localizationService;
     this._securitySettings        = securitySettings;
     this._menuPublisher           = menuPublisher;
     this._pluginFinder            = pluginFinder;
     this._genericAttributeService = genericAttributeService;
     this._permissionService       = permissionService;
     this._dateTimeHelper          = dateTimeHelper;
     this._imageCache              = imageCache;
     this._dbContext               = dbContext;
     this._cache          = cache;
     this._services       = services;
     this._articleService = articleService;
     this._siteSettings   = siteSettings;
 }
Esempio n. 31
0
        private RetrievePageResult NotFoundPage(IUnitOfWork unitOfWork, ISiteContext siteContext)
        {
            var notFoundPage = this.PageVersionQuery(unitOfWork, siteContext).Where(o => o.Page.Node.Type == "NotFoundErrorPage")
                               .Select(o => o.Value).FirstOrDefault();

            if (notFoundPage == null)
            {
                LogHelper.For(this).Warn("NotFoundErrorPage is not found");
            }

            var errorResult = new RetrievePageResult
            {
                StatusCode = HttpStatusCode.NotFound,
                Page       = notFoundPage != null?JsonConvert.DeserializeObject <PageModel>(notFoundPage) : null
            };

            return(errorResult);
        }
 public ProductListRepository(
     ISiteContext siteContext,
     IStorefrontContext storefrontContext,
     IVisitorContext visitorContext,
     ICatalogManager catalogManager,
     ISitecoreService sitecoreService,
     ISearchInformationProvider searchInformationProvider,
     ISettingsProvider settingsProvider,
     ISearchManager searchManager,
     ICurrencyProvider currencyProvider)
     : base(currencyProvider, siteContext, storefrontContext, visitorContext, catalogManager, sitecoreService)
 {
     this.storefrontContext         = storefrontContext;
     this.searchInformationProvider = searchInformationProvider;
     this.settingsProvider          = settingsProvider;
     this.searchManager             = searchManager;
     this.siteContext = siteContext;
 }
Esempio n. 33
0
 public KategoriServisi(IOlayYayınlayıcı olayYayınlayıcı,
                        GenelAyarlar genelAyarlar,
                        IDataSağlayıcı dataSağlayıcı,
                        IWorkContext workContext,
                        IDbContext dbContext,
                        IDepo <Kategori> kategoriDepo,
                        ISiteContext siteContext,
                        IÖnbellekYönetici önbellekYönetici)
 {
     this._olayYayınlayıcı  = olayYayınlayıcı;
     this._genelAyarlar     = genelAyarlar;
     this._dataSağlayıcı    = dataSağlayıcı;
     this._workContext      = workContext;
     this._dbContext        = dbContext;
     this._kategoriDepo     = kategoriDepo;
     this._siteContext      = siteContext;
     this._önbellekYönetici = önbellekYönetici;
 }
Esempio n. 34
0
 public ArticleCategoryController(
     IModelTemplateService modelTemplateService,
     ILocalizationService localizationService,
     ILocalizedEntityService localizedEntityService,
     IUserService userService,
     UserSettings userSettings,
     IArticleCategoryService categoryService,
     IUrlRecordService urlRecordService,
     ILanguageService languageService,
     IPictureService pictureService,
     IAclService aclService,
     IUserActivityService userActivityService,
     ISiteService siteService, ISiteMappingService siteMappingService,
     IDateTimeHelper dateTimeHelper,
     IEventPublisher eventPublisher,
     ArticleCatalogSettings catalogSettings,
     IPermissionService permissionService,
     IChannelService channelService,
     IWorkContext workContext,
     ISiteContext siteContext,
     SiteInformationSettings siteSettings)
 {
     this._modelTemplateService   = modelTemplateService;
     this._categoryService        = categoryService;
     this._localizedEntityService = localizedEntityService;
     this._urlRecordService       = urlRecordService;
     this._localizationService    = localizationService;
     this._userService            = userService;
     this._userSettings           = userSettings;
     this._userActivityService    = userActivityService;
     this._aclService             = aclService;
     this._languageService        = languageService;
     this._pictureService         = pictureService;
     this._siteService            = siteService;
     this._siteMappingService     = siteMappingService;
     this._dateTimeHelper         = dateTimeHelper;
     this._eventPublisher         = eventPublisher;
     this._workContext            = workContext;
     this._catalogSettings        = catalogSettings;
     this._permissionService      = permissionService;
     this._channelService         = channelService;
     this._siteContext            = siteContext;
     this._siteSettings           = siteSettings;
 }
        public async Task SendSecurityCodeEmailAsync(
            ISiteContext siteSettings,
            string toAddress,
            string subject,
            string securityCode)
        {
            var sender = await _emailSenderResolver.GetEmailSender(siteSettings.Id.ToString());

            if (sender == null)
            {
                var logMessage = $"failed to send security code email because email settings are not populated for site {siteSettings.SiteName}";
                _log.LogError(logMessage);
                return;
            }

            var model = new SecurityCodeEmailViewModel
            {
                Tenant       = siteSettings,
                SecurityCode = securityCode
            };

            try
            {
                var plainTextMessage
                    = await _viewRenderer.RenderViewAsString <SecurityCodeEmailViewModel>("EmailTemplates/SendSecurityCodeTextEmail", model);

                var htmlMessage
                    = await _viewRenderer.RenderViewAsString <SecurityCodeEmailViewModel>("EmailTemplates/SendSecurityCodeHtmlEmail", model);

                await sender.SendEmailAsync(
                    toAddress,
                    siteSettings.DefaultEmailFromAddress,
                    subject,
                    plainTextMessage,
                    htmlMessage,
                    configLookupKey : siteSettings.Id.ToString()
                    ).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _log.LogError("error sending security code email: " + ex.Message + " stacktrace: " + ex.StackTrace);
            }
        }
Esempio n. 36
0
 public SitemapGenerator(
     ISiteContext siteContext,
     //ICategoryService categoryService,
     //  IProductService productService,
     //IManufacturerService manufacturerService,
     ITopicService topicService,
     CommonSettings commonSettings,
     IWebHelper webHelper,
     SecuritySettings securitySettings)
 {
     this._siteContext = siteContext;
     //  this._categoryService = categoryService;
     //  this._productService = productService;
     // this._manufacturerService = manufacturerService;
     this._topicService     = topicService;
     this._commonSettings   = commonSettings;
     this._webHelper        = webHelper;
     this._securitySettings = securitySettings;
 }
        public async Task AccountPendingApprovalAdminNotification(
            ISiteContext siteSettings,
            ISiteUser user)
        {
            if (siteSettings.AccountApprovalEmailCsv.Length == 0)
            {
                return;
            }

            SmtpOptions smtpOptions = GetSmptOptions(siteSettings);

            if (smtpOptions == null)
            {
                var logMessage = $"failed to send new account notifications to admins because smtp settings are not populated for site {siteSettings.SiteName}";
                log.LogError(logMessage);
                return;
            }

            string subject = "新用户审批";

            EmailSender sender = new EmailSender();

            try
            {
                var plainTextMessage
                    = await viewRenderer.RenderViewAsString <ISiteUser>("EmailTemplates/AccountPendingApprovalAdminNotificationTextEmail", user).ConfigureAwait(false);

                var htmlMessage
                    = await viewRenderer.RenderViewAsString <ISiteUser>("EmailTemplates/AccountPendingApprovalAdminNotificationHtmlEmail", user).ConfigureAwait(false);

                await sender.SendMultipleEmailAsync(
                    smtpOptions,
                    siteSettings.AccountApprovalEmailCsv,
                    siteSettings.DefaultEmailFromAddress,
                    subject,
                    plainTextMessage,
                    htmlMessage).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                log.LogError("error sending email verification email", ex);
            }
        }
        private SmtpOptions GetSmptOptions(ISiteContext siteSettings)
        {
            if (string.IsNullOrWhiteSpace(siteSettings.SmtpServer))
            {
                return(globalSmtpSettings);
            }

            SmtpOptions smtpOptions = new SmtpOptions();

            smtpOptions.Password               = siteSettings.SmtpPassword;
            smtpOptions.Port                   = siteSettings.SmtpPort;
            smtpOptions.PreferredEncoding      = siteSettings.SmtpPreferredEncoding;
            smtpOptions.RequiresAuthentication = siteSettings.SmtpRequiresAuth;
            smtpOptions.Server                 = siteSettings.SmtpServer;
            smtpOptions.User                   = siteSettings.SmtpUser;
            smtpOptions.UseSsl                 = siteSettings.SmtpUseSsl;

            return(smtpOptions);
        }
        public async Task SendPasswordResetEmailAsync(
            ISiteContext siteSettings,
            string toAddress,
            string subject,
            string resetUrl)
        {
            SmtpOptions smtpOptions = GetSmptOptions(siteSettings);

            if (smtpOptions == null)
            {
                var logMessage = $"failed to send password reset email because smtp settings are not populated for site {siteSettings.SiteName}";
                log.LogError(logMessage);
                return;
            }

            EmailSender sender = new EmailSender();

            // in account controller we are calling this method without await
            // so it doesn't block the UI. Which means it is running on a background thread
            // similar as the old ThreadPool.QueueWorkItem
            // as such we need to handle any error that may happen so it doesn't
            // brind down the thread or the process
            try
            {
                var plainTextMessage
                    = await viewRenderer.RenderViewAsString <string>("EmailTemplates/PasswordResetTextEmail", resetUrl);

                var htmlMessage
                    = await viewRenderer.RenderViewAsString <string>("EmailTemplates/PasswordResetHtmlEmail", resetUrl);

                await sender.SendEmailAsync(
                    smtpOptions,
                    toAddress,
                    siteSettings.DefaultEmailFromAddress,
                    subject,
                    plainTextMessage,
                    htmlMessage).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                log.LogError("error sending password reset email", ex);
            }
        }
Esempio n. 40
0
 public DefaultWidgetSelector(
     IWidgetService widgetService,
     ITopicService topicService,
     ISiteContext siteContext,
     ICacheManager cacheManager,
     IWorkContext workContext,
     IDbContext dbContext,
     IWidgetProvider widgetProvider,
     ICommonServices services)
 {
     this._widgetService  = widgetService;
     this._topicService   = topicService;
     this._siteContext    = siteContext;
     this._cacheManager   = cacheManager;
     this._workContext    = workContext;
     this._dbContext      = dbContext;
     this._widgetProvider = widgetProvider;
     this._services       = services;
 }
        GetPagesByParent(
            IUnitOfWork unitOfWork,
            ISiteContext siteContext,
            Guid parentNodeId
            )
        {
            var pageVersionQuery =
                this.PageVersionQuery(unitOfWork, siteContext);
            var pageVersions =
                pageVersionQuery
                .Where(o => o.Page.Node.ParentId == parentNodeId)
                .GroupBy(o => o.PageId)
                .Select(o => o.FirstOrDefault())
                .ToList();

            return(pageVersions
                   .Select(o => JsonConvert.DeserializeObject <PageModel>(o.Value))
                   .ToList());
        }
Esempio n. 42
0
        public virtual async Task HandleRegisterPostSuccess(
            ISiteContext site,
            RegisterViewModel viewModel,
            HttpContext httpContext,
            UserLoginResult loginResult,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            await EnsureProps();

            // we "could" re-validate here but
            // the method above gets called just before this in the same postback
            // so we know there were no validation errors or this method would not be invoked
            SiteUser siteUser = null;

            if (_userPropertyService.HasAnyNativeProps(_props.Properties))
            {
                siteUser = await _userPropertyService.GetUser(loginResult.User.Id.ToString());
            }
            if (loginResult.User != null)
            {
                foreach (var p in _props.Properties)
                {
                    if (p.VisibleOnRegistration)
                    {
                        if (!_userPropertyService.IsNativeUserProperty(p.Key))
                        {
                            var postedValue = httpContext.Request.Form[p.Key];
                            // persist to kvp storage
                            await _userPropertyService.CreateOrUpdate(
                                site.Id.ToString(),
                                loginResult.User.Id.ToString(),
                                p.Key,
                                postedValue);
                        }
                    }
                }
            }
            else
            {
                _log.LogError("user was null in HandleRegisterPostSuccess, unable to update user with custom data");
            }
        }
Esempio n. 43
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="cacheManager">Cache manager</param>
        /// <param name="manufacturerRepository">Category repository</param>
        /// <param name="productManufacturerRepository">ProductCategory repository</param>
        /// <param name="productRepository">Product repository</param>
        /// <param name="siteMappingRepository">Site mapping repository</param>
        /// <param name="workContext">Work context</param>
        /// <param name="siteContext">Site context</param>
        /// <param name="eventPublisher">Event published</param>
        public ManufacturerService(ICacheManager cacheManager,
                                   IRepository <Manufacturer> manufacturerRepository,
                                   IRepository <ProductManufacturer> productManufacturerRepository,
                                   IRepository <Product> productRepository,
                                   IRepository <SiteMapping> siteMappingRepository,
                                   IWorkContext workContext,
                                   ISiteContext siteContext,
                                   IEventPublisher eventPublisher)
        {
            _cacheManager                  = cacheManager;
            _manufacturerRepository        = manufacturerRepository;
            _productManufacturerRepository = productManufacturerRepository;
            _productRepository             = productRepository;
            _siteMappingRepository         = siteMappingRepository;
            _workContext    = workContext;
            _siteContext    = siteContext;
            _eventPublisher = eventPublisher;

            this.QuerySettings = DbQuerySettings.Default;
        }
Esempio n. 44
0
        IEnumerable<FileReference> GetAssociatedImages(string markdownFileContents, ISiteContext siteContext)
        {
            const string imageRegex = @"!\[(?<AltText>.*?)\]\((?<Link>\S+?)\s*(?<OptionalTitle>("".*""){0,1}?)\)";
            var images = Regex.Matches(markdownFileContents, imageRegex);
            var associatedImages = new List<FileReference>();

            foreach (Match image in images)
            {
                var imageLink = image.Groups["Link"].Value;
                if (Path.IsPathRooted(imageLink) && fileSystem.File.Exists(imageLink))
                    associatedImages.Add(new FileReference(image.Value, image.Value, true));
                else
                {
                    var fullPath = Path.Combine(siteContext.WorkingDirectory, imageLink);
                    if (fileSystem.File.Exists(fullPath))
                        associatedImages.Add(new FileReference(fullPath, imageLink, true));
                }
            }
            return associatedImages;
        }
Esempio n. 45
0
 public WebWorkContext(IHttpContextAccessor httpContextAccessor,
                       IKullanıcıServisi KullanıcıService,
                       ISiteContext storeContext,
                       IGenelÖznitelikServisi genericAttributeService,
                       IKullanıcıAracıYardımcısı userAgentHelper,
                       IKimlikDoğrulamaServisi kimlikDoğrulamaServisi,
                       LocalizationSettings localizationSettings,
                       ILanguageService languageService,
                       ISiteMappingServisi siteMappingService)
 {
     this._httpContextAccessor     = httpContextAccessor;
     this._KullanıcıService        = KullanıcıService;
     this._storeContext            = storeContext;
     this._genericAttributeService = genericAttributeService;
     this._userAgentHelper         = userAgentHelper;
     this._kimlikDoğrulamaServisi  = kimlikDoğrulamaServisi;
     this._localizationSettings    = localizationSettings;
     this._languageService         = languageService;
     this._siteMappingService      = siteMappingService;
 }
        public Task HandleRegisterPostSuccess(
            ISiteContext site,
            RegisterViewModel viewModel,
            HttpContext httpContext,
            UserLoginResult loginResult,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            if (loginResult.User != null)
            {
                // here is where you could process additional custom fields into your own custom data storage
                // if only updating native properties of siteuser use the method above
            }
            else
            {
                log.LogError("user was null in HandleRegisterPostSuccess, unable to update user with custom data");
            }

            return(Task.FromResult(0));
        }
        protected MarkpadDocumentBase(
            string title, string content, 
            string saveLocation,
            IEnumerable<FileReference> associatedFiles,
            IDocumentFactory documentFactory,
            ISiteContext siteContext, 
            IFileSystem fileSystem)
        {
            if (title == null) throw new ArgumentNullException("title");
            if (documentFactory == null) throw new ArgumentNullException("documentFactory");
            if (siteContext == null) throw new ArgumentNullException("siteContext");

            Title = title;
            MarkdownContent = content;
            SaveLocation = saveLocation;
            SiteContext = siteContext;
            FileSystem = fileSystem;
            this.documentFactory = documentFactory;
            this.associatedFiles.AddRange(associatedFiles);
        }
Esempio n. 48
0
        public WorkflowMessageService(IMessageTemplateService messageTemplateService,
                                      IQueuedEmailService queuedEmailService, ILanguageService languageService,
                                      ITokenizer tokenizer, IEmailAccountService emailAccountService,
                                      IMessageTokenProvider messageTokenProvider,
                                      EmailAccountSettings emailAccountSettings,
                                      IEventPublisher eventPublisher, ISiteContext siteContext,
                                      IWorkContext workContext)
        {
            this._messageTemplateService = messageTemplateService;
            this._queuedEmailService     = queuedEmailService;
            this._languageService        = languageService;
            this._tokenizer            = tokenizer;
            this._emailAccountService  = emailAccountService;
            this._messageTokenProvider = messageTokenProvider;

            this._emailAccountSettings = emailAccountSettings;
            this._eventPublisher       = eventPublisher;
            this._workContext          = workContext;
            this._siteContext          = siteContext;
        }
        public virtual async Task HandleUserEditPostSuccess(
            ISiteContext site,
            ISiteUser siteUser,
            EditUserViewModel viewModel,
            HttpContext httpContext,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            await EnsureProps();

            // we "could" re-validate here but
            // the method above gets called just before this in the same postback
            // so we know there were no validation errors or this method would not be invoked
            if (siteUser != null)
            {
                foreach (var p in _props.Properties)
                {
                    if (p.EditableOnAdminUserEdit)
                    {
                        var postedValue = httpContext.Request.Form[p.Key];
                        if (_userPropertyService.IsNativeUserProperty(p.Key))
                        {
                            _userPropertyService.UpdateNativeUserProperty(siteUser, p.Key, postedValue);
                        }
                        else
                        {
                            // persist to kvp storage
                            await _userPropertyService.CreateOrUpdate(
                                site.Id.ToString(),
                                siteUser.Id.ToString(),
                                p.Key,
                                postedValue);
                        }
                    }
                }
            }
            else
            {
                _log.LogError("user was null in HandleUserInfoPostSuccess, unable to update user with custom data");
            }
        }
Esempio n. 50
0
        void GeneratePage(ISiteContext context, PageModel model, string path, string segment, string name, List<PageInfo> list, int page, int skip, int take)
        {
            string format = FileUtility.GetArchiveUrl(context, segment, name, "{0}");
            string first = FileUtility.GetArchiveUrl(context, segment, name);
            string file = FileUtility.GetArchivePath(context, segment, name, false, page);

            // Provide a default list to the template. The template 
            // may present their own ordering using skip/take.
            PageInfo[] pages = list
                .OrderByDescending(p => p.Date)
                .Skip(skip)
                .Take(take)
                .ToArray();

            model.Paginator = new PaginatorInfo(pages, page, list.Count, skip, take, first, format);

            string result = _template.Build(model, file, true, (ctx) =>
                {
                    ctx.ViewBag.ArchiveName = name;
                    ctx.ViewBag.ArchiveType = _type.ToString();
                });
        }
        public async Task SendAccountConfirmationEmailAsync(
            ISiteContext siteSettings,
            string toAddress,
            string subject,
            string confirmationUrl)
        {
            SmtpOptions smtpOptions = GetSmptOptions(siteSettings);
            if (smtpOptions == null)
            {
                var logMessage = $"failed to send account confirmation email because smtp settings are not populated for site {siteSettings.SiteName}";
                log.LogError(logMessage);
                return;
            }
            
            EmailSender sender = new EmailSender();
            try
            {
                var plainTextMessage
                = await viewRenderer.RenderViewAsString<string>("EmailTemplates/ConfirmAccountTextEmail", confirmationUrl).ConfigureAwait(false);

                var htmlMessage
                    = await viewRenderer.RenderViewAsString<string>("EmailTemplates/ConfirmAccountHtmlEmail", confirmationUrl).ConfigureAwait(false);

                await sender.SendEmailAsync(
                    smtpOptions,
                    toAddress,
                    smtpOptions.DefaultEmailFromAddress,
                    subject,
                    plainTextMessage,
                    htmlMessage).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                log.LogError("error sending account confirmation email", ex);
            }

        }
Esempio n. 52
0
        public async Task SendSmsAsync(
            ISiteContext site,
            string phoneNumber, 
            string message)
        {
            if (string.IsNullOrWhiteSpace(phoneNumber))
            {
                throw new ArgumentException("toPhoneNumber was not provided");
            }

            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentException("message was not provided");
            }

            var credentials = GetCredentials(site);
            if(credentials == null)
            {
                log.LogError("tried to send sms message with no credentials");
                return;
            }

            TwilioSmsSender sender = new TwilioSmsSender(log);
            try
            {
                await sender.SendMessage(
                    credentials, 
                    phoneNumber, 
                    message).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                log.LogError("error sending twilio message", ex);
            }
                
        }
Esempio n. 53
0
 public TemplateResolver(ISiteContext context)
 {
     _context = context;
 }
 public string EnsureFolderSegmentIfNeeded(ISiteContext site, string returnUrl)
 {
     return returnUrl;
 }
 public Task AccountPendingApprovalAdminNotification(
     ISiteContext siteSettings,
     ISiteUser user)
 {
     return Task.FromResult(0);
 }
Esempio n. 56
0
 public TemplateActivator(ISiteContext context)
 {
     _context = context;
 }
Esempio n. 57
0
 public MarkdownProcessor(ISiteContext context)
     : base(context)
 {
 }
 public TestMarkpadDocumentBase(string title, string content, string saveLocation, IEnumerable<FileReference> associatedFiles,
     IDocumentFactory documentFactory, ISiteContext siteContext, IFileSystem fileSystem) :
     base(title, content, saveLocation, associatedFiles, documentFactory, siteContext, fileSystem)
 {
 }
Esempio n. 59
0
 public StartProcessor(ISiteContext context, RazorEngine.Configuration.TemplateServiceConfiguration config)
 {
     _context = context;
     _startTemplateService = new RazorEngine.Templating.TemplateService(config);
 }
Esempio n. 60
0
 public RazorProcessor(ISiteContext context)
 {
     _context = context;
 }