Exemple #1
0
        public virtual ActionResult UpdateHtml(string positionId, string pageName, string value, bool?_draft_)
        {
            var data = new JsonResultData(ModelState);

            data.RunWithTry((resultData) =>
            {
                Page page = (PageHelper.Parse(Site.Current, pageName)).AsActual();

                if (page != null)
                {
                    bool isDraft = _draft_.HasValue && _draft_.Value == true;
                    if (isDraft)
                    {
                        page = PageProvider.GetDraft(page);
                    }
                    var position = page.PagePositions.Where(it => it.PagePositionId.EqualsOrNullEmpty(positionId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if (position != null && position is HtmlPosition)
                    {
                        ((HtmlPosition)position).Html = value;
                    }
                    if (isDraft)
                    {
                        PageProvider.SaveAsDraft(page);
                    }
                    else
                    {
                        CMS.Sites.Services.ServiceFactory.PageManager.Update(Site.Current, page, page);
                    }
                }
            });
            return(Json(data));
        }
Exemple #2
0
        public bool TryGetPageContent(string tcmUri, out string pageContent)
        {
            pageContent = string.Empty;

            string cacheKey = String.Format("PageContentByUri_{0}", tcmUri);

            pageContent = (string)CacheAgent.Load(cacheKey);
            if (pageContent != null)
            {
                return(true);
            }
            else
            {
                string tempPageContent = PageProvider.GetContentByUri(tcmUri);
                if (tempPageContent != string.Empty)
                {
                    pageContent = tempPageContent;
                    CacheAgent.Store(cacheKey, CacheRegion, pageContent);
                    return(true);
                }
            }


            return(false);
        }
Exemple #3
0
        public async Task UGetRecursive(int siteId)
        {
            LogMaxLevel  = 1;
            onlyUtestLog = true;
            SiteAuthorizationHandler.LogDisabled = true;
            PageAuthorizationHandler.LogDisabled = true;
            PostAuthorizationHandler.LogDisabled = true;

            SiteData siteDt = await DbUtil.GetSiteData(siteId);

            foreach (SiteClaim region in siteDt.regions)
            {
                // Create and init the context...
                WcmsAppContext ctx = await CreateAndInitAppContext(null, siteDt.site.Domain, "/", region.StringValue, null, false);

                if (ctx != null)
                {
                    _Log(1, ctx, $">>Checking page recursive get for region={region.StringValue}...");

                    PageProvider       provider = new PageProvider(ctx);
                    IEnumerable <Page> pages    = await provider?.Get(false, null, true);

                    Assert.NotEqual(null, pages);
                    //TODO: Add a check to validate a get with recusion enabled.
                }
            }
        }
Exemple #4
0
        private const string StaticWebsiteUrl = "http://localhost:2335"; // Change this to your own URL

        public void Initialize(InitializationEngine context)
        {
            var contentProviderManager = ServiceLocator.Current.GetInstance <IContentProviderManager>();

            var contentRepository = ServiceLocator.Current.GetInstance <IContentRepository>();
            var startPage         = contentRepository.GetChildren <StaticStartPage>(ContentReference.RootPage).FirstOrDefault();

            if (startPage == null)
            {
                return;
            }

            StaticAssetsRootFolder assetsFolder = EnsureAssetsFolder(contentRepository);

            var contentTypeRepository = ServiceLocator.Current.GetInstance <IContentTypeRepository>();
            var objectInstanceCache   = ServiceLocator.Current.GetInstance <IObjectInstanceCache>();
            var blobFactory           = ServiceLocator.Current.GetInstance <IBlobFactory>();

            AssetProvider assetProvider = new AssetProvider(assetsFolder, contentTypeRepository, objectInstanceCache, blobFactory);

            SetupProvider(assetProvider, assetsFolder.ContentLink, contentProviderManager);

            var pageProvider = new PageProvider(startPage, assetProvider.Assets, contentTypeRepository, objectInstanceCache);

            SetupProvider(pageProvider, startPage.PageLink, contentProviderManager);

            var siteDefinitionRepository = ServiceLocator.Current.GetInstance <ISiteDefinitionRepository>();

            EnsureSiteDefinition(siteDefinitionRepository, startPage.ContentLink, assetsFolder.ContentLink);
        }
Exemple #5
0
        public void ConfigureServices(IServiceCollection services)
        {
            // Init low-level DB singleton
            InitDB(config, loggerFactory, true);
            // Application-specific singletons.
            services.AddSingleton(new CountryResolver(config["ipv4FileName"]));
            PageProvider pageProvider = new PageProvider(loggerFactory, config["privatePagesFolder"],
                                                         env.IsDevelopment(), mut, config["baseUrl"]);

            services.AddSingleton(pageProvider);
            services.AddSingleton(new LangRepo(config["uniHanziFileName"]));
            services.AddSingleton(new SqlDict(loggerFactory, mut));
            Emailer emailer = new Emailer(config);

            services.AddSingleton(emailer);
            if (mut == Mutation.CHD)
            {
                services.AddSingleton(new Sphinx(loggerFactory, config["perlBin"],
                                                 config["sphinxScript"], config["corpusBinFileName"]));
            }
            // These below have a shutdown action, so we store them in a member too.
            auth = new Auth(mut, loggerFactory, config, emailer, pageProvider);
            services.AddSingleton(auth);
            qlog = new QueryLogger(config["queryLogFileName"], config["hwriteLogFileName"]);
            services.AddSingleton(qlog);
            // MVC for serving pages and REST
            services.AddMvc();
            // Configuration singleton
            services.AddSingleton <IConfiguration>(sp => { return(config); });
        }
Exemple #6
0
        public virtual bool TryFindPageContent(string url, out string pageContent)
        {
            LoggerService.Debug(">>TryFindPageContent ({0}", LoggingCategory.Performance, url);

            pageContent = string.Empty;

            string cacheKey = String.Format("PageContent_{0}_{1}", PublicationId, url);

            LoggerService.Debug("about to load page content from cache with key {0}", LoggingCategory.Performance, cacheKey);
            pageContent = (string)CacheAgent.Load(cacheKey);
            LoggerService.Debug("finished loading page content from cache with key {0}, pageContent found {1}", LoggingCategory.Performance, cacheKey, Convert.ToString(!(string.IsNullOrEmpty(pageContent))));
            if (pageContent != null)
            {
                LoggerService.Debug("<<TryFindPageContent ({0}", LoggingCategory.Performance, url);
                return(true);
            }
            else
            {
                LoggerService.Debug("about to load page content from provider with url {0}", LoggingCategory.Performance, url);
                string tempPageContent = PageProvider.GetContentByUrl(url);
                LoggerService.Debug("finished loading page content from provider with url {0}, has value: {1}", LoggingCategory.Performance, url, Convert.ToString(!(string.IsNullOrEmpty(tempPageContent))));
                if (!string.IsNullOrEmpty(tempPageContent))
                {
                    pageContent = tempPageContent;
                    LoggerService.Debug("about to store page in cache with key {0}", LoggingCategory.Performance, cacheKey);
                    CacheAgent.Store(cacheKey, CacheRegion, pageContent);
                    LoggerService.Debug("finished storing page in cache with key {0}", LoggingCategory.Performance, cacheKey);
                    LoggerService.Debug("<<TryFindPageContent ({0}", LoggingCategory.Performance, url);
                    return(true);
                }
            }

            LoggerService.Debug("<<TryFindPageContent ({0}", LoggingCategory.Performance, url);
            return(false);
        }
Exemple #7
0
        public void TestInit()
        {
            IHtmlWebWrapper htmlWeb = Substitute.For <IHtmlWebWrapper>();

            htmlWeb.Load(Arg.Any <Uri>()).Returns(_expectedContent);
            _pageProvider = new PageProvider(htmlWeb);
        }
Exemple #8
0
        public virtual void Localize(string fullName, Site currentSite)
        {
            var targetPage = new Page(currentSite, fullName);
            var sourcePage = targetPage.LastVersion();

            PageProvider.Localize(sourcePage, currentSite);
        }
Exemple #9
0
        public bool TryGetPage(string tcmUri, out IPage page)
        {
            page = null;

            string cacheKey = String.Format("PageByUri_{0}", tcmUri);


            page = (IPage)CacheAgent.Load(cacheKey);
            if (page != null)
            {
                return(true);
            }
            string tempPageContent = PageProvider.GetContentByUri(tcmUri);

            if (tempPageContent != string.Empty)
            {
                page = GetIPageObject(tempPageContent);
                if (IncludeLastPublishedDate)
                {
                    ((Page)page).LastPublishedDate = PageProvider.GetLastPublishedDateByUri(tcmUri);
                }

                CacheAgent.Store(cacheKey, CacheRegion, page);

                return(true);
            }

            return(false);
        }
Exemple #10
0
 public MainPage()
 {
     InitializeComponent();
     PageProvider = new PageProvider();
     Detail       = PageProvider.Get(typeof(HomePage));
     Menu.ListView.ItemSelected += ListView_ItemSelected;
 }
Exemple #11
0
 public virtual void Publish(Page page, bool publishSchedule, bool publishDraft, bool period, DateTime publishDate, DateTime offlineDate, string userName)
 {
     if (!publishSchedule)
     {
         page = page.AsActual();
         if (publishDraft)
         {
             page = PageProvider.GetDraft(page);
             PageProvider.RemoveDraft(page);
         }
         page.Published = true;
         page.UserName  = userName;
         PageProvider.Update(page, page);
         VersionManager.LogVersion(page);
     }
     else
     {
         PagePublishingQueueItem publishingItem = new PagePublishingQueueItem()
         {
             Site             = page.Site,
             PageName         = page.FullName,
             PublishDraft     = publishDraft,
             CreationUtcDate  = DateTime.UtcNow,
             UtcDateToPublish = publishDate.ToUniversalTime(),
             Period           = period,
             UtcDateToOffline = offlineDate.ToUniversalTime(),
             UserName         = userName
         };
         PagePublishingProvider.Add(publishingItem);
     }
 }
Exemple #12
0
        public virtual ActionResult Draft(Page newModel, string old_key, bool?preview, bool?setPublished, string @return)
        {
            var data = new JsonResultData();

            data.RunWithTry((resultData) =>
            {
                newModel.Site = Site;

                var old = Manager.Get(Site, old_key);

                SavePosition(newModel);

                newModel.Published = false;
                newModel.UserName  = User.Identity.Name;
                PageProvider.SaveAsDraft(newModel);

                if (setPublished.HasValue && setPublished.Value == true)
                {
                    Manager.Publish(old, true, User.Identity.Name);

                    data.RedirectUrl = @return;
                }
                else
                {
                    resultData.AddMessage("The item has been saved.".Localize());
                }
            });
            return(Json(data));
        }
Exemple #13
0
 public MainPage()
 {
     InitializeComponent();
     PageProvider = new PageProvider();
     PageProvider.SetLifeTime(typeof(StatisticPage), PageLifeTime.OneTime);
     Detail = PageProvider.Get(typeof(HomePage));
     Menu.ListView.ItemSelected += ListView_ItemSelected;
 }
Exemple #14
0
        public DateTime GetLastPublishedDateByUrl(string url)
        {
            LoggerService.Debug("about to retrieve last published date from provider for url {0}", LoggingCategory.Performance, url);
            DateTime dt = PageProvider.GetLastPublishedDateByUrl(url);

            LoggerService.Debug("finished retrieving last published date from provider for url {0}", LoggingCategory.Performance, url);
            return(dt);
        }
Exemple #15
0
 public virtual void Unpublish(Page page, string userName)
 {
     page           = page.AsActual();
     page.Published = false;
     page.UserName  = userName;
     PageProvider.Update(page, page);
     VersionManager.LogVersion(page);
 }
        private void BeforeScenario()
        {
            string url = Settings.Default.Url;

            PageProvider = new PageProvider(Settings.Default.browserType);
            PageProvider.Browser.Navigate().GoToUrl(url);
            test = extentReport.CreateTest(context.ScenarioInfo.Title);
        }
 /// <summary>
 /// Ctor: infuse dependencies.
 /// </summary>
 public IndexController(PageProvider pageProvider, IConfiguration config,
                        ILoggerFactory loggerFactory, Auth auth, SqlDict dict)
 {
     mut            = config["MUTATION"] == "HDD" ? Mutation.HDD : Mutation.CHD;
     baseUrl        = config["baseUrl"];
     dpc            = new DynpageController(pageProvider, config, loggerFactory, auth, dict, null, null, null, null);
     gaCode         = config["gaCode"];
     captchaSiteKey = config["captchaSiteKey"];
 }
Exemple #18
0
        public void CanGetPageById()
        {
            // Act
            Page r = PageProvider.Get(MyPage.Id);

            // Assert
            Assert.IsNotNull(r);
            Assert.AreEqual(MyPage.Id, r.Id);
            Assert.AreEqual(MyPage.Title, r.Title);
        }
Exemple #19
0
        public virtual bool TryFindPage(string url, out IPage page)
        {
            LoggerService.Debug(">>TryFindPage ({0}", LoggingCategory.Performance, url);
            page = null;

            string cacheKey = CacheKeyFactory.GenerateKey(CacheRegion, url, Convert.ToString(PublicationId));

            LoggerService.Debug("about to load page from cache with key {0}", LoggingCategory.Performance, cacheKey);
            page = (IPage)CacheAgent.Load(cacheKey);
            LoggerService.Debug("finished loading page from cache with key {0}, page found = {1}", LoggingCategory.Performance, cacheKey, Convert.ToString(page != null));

            if (page != null)
            {
                if (page.Title == CacheValueNullTitle)
                {
                    page = null;
                    return(false);
                }

                LoggerService.Debug("<<TryFindPage ({0}", LoggingCategory.Performance, url);
                return(true);
            }
            else
            {
                LoggerService.Debug("about to load page content from provider with url {0}", LoggingCategory.Performance, url);
                string pageContentFromBroker = PageProvider.GetContentByUrl(url);
                LoggerService.Debug("finished loading page content from provider with url {0}, has value: {1}", LoggingCategory.Performance, url, Convert.ToString(!(string.IsNullOrEmpty(pageContentFromBroker))));

                if (string.IsNullOrEmpty(pageContentFromBroker))
                {
                    CacheAgent.Store(cacheKey, CacheRegion404, CacheValueNull);
                }
                else
                {
                    LoggerService.Debug("about to create IPage from content for url {0}", LoggingCategory.Performance, url);
                    page = GetIPageObject(pageContentFromBroker);
                    if (IncludeLastPublishedDate)
                    {
                        ((Page)page).LastPublishedDate = PageProvider.GetLastPublishedDateByUrl(url);
                    }
                    LoggerService.Debug("finished creating IPage from content for url {0}", LoggingCategory.Performance, url);
                    LoggerService.Debug("about to store page in cache with key {0}", LoggingCategory.Performance, cacheKey);
                    CacheAgent.Store(cacheKey, CacheRegion, page, new List <string> {
                        page.Id
                    });
                    LoggerService.Debug("finished storing page in cache with key {0}", LoggingCategory.Performance, cacheKey);
                    LoggerService.Debug("<<TryFindPage ({0}", LoggingCategory.Performance, url);
                    return(true);
                }
            }

            LoggerService.Debug("<<TryFindPage ({0}", LoggingCategory.Performance, url);
            return(false);
        }
        public FragmentComposer(FragmentProvider fragmentProvider, PageProvider pageProvider)
        {
            Guard.VerifyArgumentNotNull(fragmentProvider, nameof(fragmentProvider));
            Guard.VerifyArgumentNotNull(pageProvider, nameof(pageProvider));

            _fragmentProvider           = fragmentProvider;
            _pageProvider               = pageProvider;
            _fragmentComposingFunctions = new Dictionary <string, Func <LayoutType, HtmlDocument> >();

            compose();
        }
        public void Test_Construct_WithNoBindingListRequest_ShouldCreateRequest()
        {
            //---------------Set up test pack-------------------
            
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            PageProvider<FakeBO> pageProvider = new PageProvider<FakeBO>();
            //---------------Test Result -----------------------
            Assert.IsNotNull(pageProvider.Filter);
        }
Exemple #22
0
        public Form1()
        {
            InitializeComponent();

            //We use raw input for CTRL so that Win10 users can zoom with CTRL + scroll wheel without the window being in focus.
            RawInput.RegisterDevice(HIDUsagePage.Generic, HIDUsage.Keyboard, RawInputDeviceFlags.InputSink, this.Handle);
            provider = new PageProvider(source);
            infiniteReader.SetPageProvider(provider);
            ShowBrowserScreen();
            CheckForUpdates();
        }
Exemple #23
0
 public virtual Page GetPageByUrlIdentifier(Site site, string identifier)
 {
     foreach (var page in PageProvider.All(site))
     {
         var found = GetPageByUrlIdentifier(site, page, identifier);
         if (found != null)
         {
             return(found);
         }
     }
     return(null);
 }
Exemple #24
0
        public void Test_Construct_WithNoBindingListRequest_ShouldCreateRequest()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            PageProvider <FakeBO> pageProvider = new PageProvider <FakeBO>();

            //---------------Test Result -----------------------
            Assert.IsNotNull(pageProvider.Filter);
        }
Exemple #25
0
 /// <summary>
 /// Ctor: Infuse app services.
 /// </summary>
 /// <remarks>
 /// Default null values make controller accessible to <see cref="IndexController"/>.
 /// That way, functionality is limited to serving static pages.
 /// </remarks>
 public DynpageController(PageProvider pageProvider, IConfiguration config, ILoggerFactory loggerFactory,
                          Auth auth, SqlDict dict, CountryResolver cres, QueryLogger qlog, Sphinx sphinx, LangRepo langRepo)
 {
     this.cres         = cres;
     this.pageProvider = pageProvider;
     this.dict         = dict;
     this.sphinx       = sphinx;
     this.qlog         = qlog;
     this.config       = config;
     this.logger       = loggerFactory.CreateLogger("DynpageController");
     this.auth         = auth;
     this.langRepo     = langRepo;
 }
 public void Test_Construct_PageProvider_ShouldSetupFilterString()
 {
     //---------------Set up test pack-------------------
     BindingListRequest<FakeBO> request = new BindingListRequest<FakeBO>();
     const string expectedFilterString = "FakeBOName Like 'w%'";
     request.Filter = expectedFilterString;
     //---------------Assert Precondition----------------
     Assert.AreEqual(expectedFilterString, request.Filter);
     //---------------Execute Test ----------------------
     PageProvider<FakeBO> pageProvider = new PageProvider<FakeBO>(request);
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedFilterString, pageProvider.Filter);
 }
Exemple #27
0
        public ActionResult show(string key)
        {
            Book b = BookProvider.GetByKey(key);
            IEnumerable <Page> pages = PageProvider.GetPages(b.PageIds);

            BookViewModel result = new BookViewModel
            {
                Book  = b,
                Pages = pages.ToList()
            };

            return(View(result));
        }
Exemple #28
0
        public void Test_SetFilter_ShouldSetFilterString()
        {
            //---------------Set up test pack-------------------
            BindingListRequest <FakeBO> request      = new BindingListRequest <FakeBO>();
            PageProvider <FakeBO>       pageProvider = new PageProvider <FakeBO>(request);
            const string expectedFilterString        = "FakeBOName Like 'w%'";

            //---------------Assert Precondition----------------
            Assert.IsNullOrEmpty(pageProvider.Filter);
            //---------------Execute Test ----------------------
            pageProvider.Filter = expectedFilterString;
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedFilterString, pageProvider.Filter);
        }
Exemple #29
0
        protected virtual void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
        {
            if (_disposed)
            {
                return;
            }

            if (itIsSafeToAlsoFreeManagedObjects)
            {
                tally.Dispose();
                PageProvider.Dispose();
            }

            _disposed = true;
        }
Exemple #30
0
        public void Test_Construct_PageProvider_ShouldSetupSortString()
        {
            //---------------Set up test pack-------------------
            BindingListRequest <FakeBO> request = new BindingListRequest <FakeBO>();
            const string expectedSortString     = "FakeBOName";

            request.Sort = expectedSortString;
            //---------------Assert Precondition----------------
            Assert.AreEqual(expectedSortString, request.Sort);
            //---------------Execute Test ----------------------
            PageProvider <FakeBO> pageProvider = new PageProvider <FakeBO>(request);

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedSortString, pageProvider.Sort);
        }
Exemple #31
0
        public void GetPage_ShouldResolveAndReturnPageSpecifiedPageType(string name)
        {
            // Arrange
            var container    = Substitute.For <IObjectContainer>();
            var expectedPage = new DummyPage();

            container.Resolve <DummyPage>(name).Returns(expectedPage);
            PageProvider.SetContainer(container);

            // Act
            var result = PageProvider.GetPage <DummyPage>(name);

            // Assert
            result.Should().BeSameAs(expectedPage);
        }
Exemple #32
0
        public void Test_Construct_PageProvider_ShouldSetupRowsPerPage()
        {
            //---------------Set up test pack-------------------
            BindingListRequest <FakeBO> request = new BindingListRequest <FakeBO>();
            const int expectedRowsPerPage       = 99;

            request.RowsPerPage = expectedRowsPerPage;
            //---------------Assert Precondition----------------
            Assert.AreEqual(expectedRowsPerPage, request.RowsPerPage);
            //---------------Execute Test ----------------------
            PageProvider <FakeBO> pageProvider = new PageProvider <FakeBO>(request);

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedRowsPerPage, pageProvider.RowsPerPage);
        }
        public void Register(IContainerManager containerManager, ITypeFinder typeFinder)
        {
            var htmlBlockProvider = new HtmlBlockProvider(containerManager.Resolve<IHtmlBlockProvider>());
            containerManager.AddComponentInstance(typeof(IHtmlBlockProvider), htmlBlockProvider);
            containerManager.AddComponentInstance(typeof(IProvider<HtmlBlock>), htmlBlockProvider);

            var layoutProvider = new LayoutProvider(containerManager.Resolve<ILayoutProvider>());
            containerManager.AddComponentInstance(typeof(ILayoutProvider), layoutProvider);
            containerManager.AddComponentInstance(typeof(IProvider<Layout>), layoutProvider);

            var pageProvider = new PageProvider(containerManager.Resolve<IPageProvider>());
            containerManager.AddComponentInstance(typeof(IPageProvider), pageProvider);
            containerManager.AddComponentInstance(typeof(IProvider<Page>), pageProvider);

            var siteProvider = new SiteProvider(containerManager.Resolve<ISiteProvider>());
            containerManager.AddComponentInstance(typeof(ISiteProvider), siteProvider);
            containerManager.AddComponentInstance(typeof(IProvider<Site>), siteProvider);

            var urlKeyMapProvider = new UrlKeyMapProvider(containerManager.Resolve<IUrlKeyMapProvider>());
            containerManager.AddComponentInstance(typeof(IUrlKeyMapProvider), urlKeyMapProvider);
            containerManager.AddComponentInstance(typeof(IProvider<UrlKeyMap>), urlKeyMapProvider);

            var viewProvider = new ViewProvider(containerManager.Resolve<IViewProvider>());
            containerManager.AddComponentInstance(typeof(IViewProvider), viewProvider);
            containerManager.AddComponentInstance(typeof(IProvider<Kooboo.CMS.Sites.Models.View>), viewProvider);

            var visitRuleSettingProvider = new ABRuleSettingProvider(containerManager.Resolve<IABRuleSettingProvider>());
            containerManager.AddComponentInstance(typeof(IABRuleSettingProvider), visitRuleSettingProvider);
            containerManager.AddComponentInstance(typeof(IProvider<Kooboo.CMS.Sites.ABTest.ABRuleSetting>), visitRuleSettingProvider);

            var siteVisitRuleProvider = new ABSiteSettingProvider(containerManager.Resolve<IABSiteSettingProvider>());
            containerManager.AddComponentInstance(typeof(IABSiteSettingProvider), siteVisitRuleProvider);
            containerManager.AddComponentInstance(typeof(IProvider<Kooboo.CMS.Sites.ABTest.ABSiteSetting>), siteVisitRuleProvider);

            var pageVisitRuleProvider = new ABPageSettingProvider(containerManager.Resolve<IABPageSettingProvider>());
            containerManager.AddComponentInstance(typeof(IABPageSettingProvider), pageVisitRuleProvider);
            containerManager.AddComponentInstance(typeof(IProvider<Kooboo.CMS.Sites.ABTest.ABPageSetting>), pageVisitRuleProvider);
        }
 public void Test_GetdataPage_WhenRecordsInDataSource_ShouldReturnRecords()
 {
     //---------------Set up test pack-------------------         
     BindingListRequest<FakeBO> request = new BindingListRequest<FakeBO>();
     PageProvider<FakeBO> pageProvider = new PageProvider<FakeBO>(request);
     BOTestFactory<FakeBO> assetFactory = BOTestFactoryRegistry.Instance.Resolve<FakeBO>();
     assetFactory.CreateManySavedBusinessObject(40);
     //---------------Assert Precondition----------------
     Assert.IsNullOrEmpty(pageProvider.Filter);
     Assert.AreEqual(0, request.PageNumber);
     Assert.AreEqual(20, request.RowsPerPage);
     //---------------Execute Test ----------------------
     IList<FakeBO> dataPage = pageProvider.GetDataPage(0);
     //---------------Test Result -----------------------
     Assert.AreEqual(request.RowsPerPage, dataPage.Count);
     //dataPage.
     
 }
 public void Test_SetSort_ShouldSetSortString()
 {
     //---------------Set up test pack-------------------
     BindingListRequest<FakeBO> request = new BindingListRequest<FakeBO>();
     PageProvider<FakeBO> pageProvider = new PageProvider<FakeBO>(request);
     const string expectedSortString = "FakeBOName";
     //---------------Assert Precondition----------------
     Assert.IsNullOrEmpty(pageProvider.Sort);
     //---------------Execute Test ----------------------
     pageProvider.Sort = expectedSortString;
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedSortString, pageProvider.Sort);
 }
Exemple #36
0
        protected override void Init()
        {
            base.Init();

            if (_pageProvider == null)
                _pageProvider = new PageProvider();
            if (_layoutProvider == null)
                _layoutProvider = new LayoutProvider();
            if (_siteProvider == null)
                _siteProvider = new SiteProvider();

            if (IsEdit)
            {
                Title = "Edit Page | Frebo Cms";
                ltlTitle.Text = "Edit";
            }
            else
            {
                Title = "New Page | Frebo Cms";
                ltlTitle.Text = "New";
            }
            FillPages();
        }
Exemple #37
0
        private void GetWebpartZoneByPageId(HttpRequest request, HttpResponse response)
        {
            int pageId = ValidationHelper.GetInteger(request.QueryString["id"], 0);
            using (PageProvider pageProvider = new PageProvider())
            {
                using (LayoutWebPartZoneProvider layoutWebPartZoneProvider = new LayoutWebPartZoneProvider())
                {
                    PageInfo pageInfo = pageProvider.Select(pageId, new ErrorInfoList());
                    if (pageInfo != null)
                    {
                        List<LayoutWebPartZoneInfo> webPartZones =
                            layoutWebPartZoneProvider.SelectAllByLayoutId(pageInfo.PageLayoutId, new ErrorInfoList());
                        DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<LayoutWebPartZoneInfo>));

                        serializer.WriteObject(response.OutputStream, webPartZones);
                        response.OutputStream.Close();
                    }
                }
            }
        }
Exemple #38
0
        protected override void Init()
        {
            base.Init();

            if (_articleProvider == null)
                _articleProvider = new ArticleProvider();
            if (_localizationProvider == null)
                _localizationProvider = new LocalizationProvider();
            if (_layoutProvider == null)
                _layoutProvider = new LayoutProvider();
            if (_pageProvider == null)
                _pageProvider = new PageProvider();
            if (_blockProvider == null)
                _blockProvider = new BlockProvider();

            if (IsEdit)
            {
                Title = "Edit Article | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "Edit Article";
            }
            else
            {
                Title = "New Article | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "New Article";
            }
            FillLanguages();
            FillPages();
            FillLayouts();
        }
 public void Test_Construct_PageProvider_ShouldSetupRowsPerPage()
 {
     //---------------Set up test pack-------------------
     BindingListRequest<FakeBO> request = new BindingListRequest<FakeBO>();
     const int expectedRowsPerPage = 99;
     request.RowsPerPage = expectedRowsPerPage;
     //---------------Assert Precondition----------------
     Assert.AreEqual(expectedRowsPerPage, request.RowsPerPage);
     //---------------Execute Test ----------------------
     PageProvider<FakeBO> pageProvider = new PageProvider<FakeBO>(request);
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedRowsPerPage, pageProvider.RowsPerPage);
 }
        protected override void Init()
        {
            base.Init();

            if (_layoutProvider == null)
                _layoutProvider = new LayoutProvider();
            if (_layoutWebPartZoneProvider == null)
                _layoutWebPartZoneProvider = new LayoutWebPartZoneProvider();
            if (_webPartProvider == null)
                _webPartProvider = new WebPartProvider();
            if (_blockProvider == null)
                _blockProvider = new BlockProvider();
            if (_pageNBlockProvider == null)
                _pageNBlockProvider = new PageNBlockProvider();
            if (_pageProvider == null)
                _pageProvider = new PageProvider();
            if (_localizationProvider == null)
                _localizationProvider = new LocalizationProvider();

            if (IsEdit)
            {
                Title = "Edit Block | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "Edit Block";
            }
            else
            {
                Title = "New Block | " + CoreSettings.CurrentSite.Name;
                ltlTitle.Text = "New Block";
            }
            FillLanguages();
        }
Exemple #41
0
 protected override void Init()
 {
     base.Init();
     if (_blockProvider == null)
         _blockProvider = new BlockProvider();
     if (_pageProvider == null)
         _pageProvider = new PageProvider();
     if (_pageNBlockProvider == null)
         _pageNBlockProvider = new PageNBlockProvider();
 }