private async Task PerformExportDescriptionToFileAsync(Guid idSiteMap, Func <Task <IOrganizationServiceExtented> > getService)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.WindowStatusStrings.CreatingEntityDescription);

            var service = await getService();

            if (service != null)
            {
                var repository = new SitemapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, new ColumnSet(true));

                var description = await EntityDescriptionHandler.GetEntityDescriptionAsync(sitemap, EntityFileNameFormatter.SiteMapIgnoreFields, service.ConnectionData);

                string filePath = await CreateDescriptionFileAsync(service.ConnectionData, sitemap.SiteMapName, sitemap.Id, EntityFileNameFormatter.Headers.EntityDescription, description);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);
            }

            ToggleControls(true, Properties.WindowStatusStrings.CreatingEntityDescriptionCompleted);
        }
예제 #2
0
        public tbl_Content GetContentBySitemapID(int sectionID, int contentID = 0)
        {
            tbl_Content content;
            var         siteMap = SitemapRepository.GetByID(sectionID);

            if (siteMap == null)
            {
                return(null);
            }

            if (contentID == 0)
            {
                content = siteMap.tbl_Content.FirstOrDefault(c => !c.C_Deleted && c.C_Approved);
                if (content == null)
                {
                    content = siteMap.tbl_Content.OrderByDescending(c => c.C_ModificationDate).FirstOrDefault(c => !c.C_Deleted);
                }
            }
            else
            {
                content = siteMap.tbl_Content.FirstOrDefault(c => c.ContentID == contentID);
            }

            return(content);
        }
        private async Task PerformExportXmlToFileAsync(Guid idSiteMap, Func <Task <IOrganizationServiceExtented> > getService, string fieldName, string fieldTitle)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.WindowStatusStrings.ExportingXmlFieldToFileFormat1, fieldTitle);

            var service = await getService();

            if (service != null)
            {
                var repository = new SitemapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, new ColumnSet(true));

                string xmlContent = sitemap.GetAttributeValue <string>(fieldName);

                string filePath = await CreateFileAsync(service.ConnectionData, sitemap.SiteMapName, sitemap.SiteMapNameUnique, sitemap.Id, fieldTitle, xmlContent);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);
            }

            ToggleControls(true, Properties.WindowStatusStrings.ExportingXmlFieldToFileCompletedFormat1, fieldName);
        }
예제 #4
0
        private async Task PerformExportXmlToFile(string folder, Guid idSiteMap, string name, string nameUnique, string fieldName, string fieldTitle)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            var service = await GetService();

            ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.ExportingXmlFieldToFileFormat1, fieldTitle);

            try
            {
                var repository = new SitemapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, new ColumnSet(fieldName));

                string xmlContent = sitemap.GetAttributeValue <string>(fieldName);

                string filePath = await CreateFileAsync(folder, name, nameUnique, idSiteMap, fieldTitle, xmlContent);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);

                ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.ExportingXmlFieldToFileCompletedFormat1, fieldName);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);

                ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.ExportingXmlFieldToFileFailedFormat1, fieldName);
            }
        }
예제 #5
0
        private async Task PerformExportEntityDescription(string folder, Guid idSiteMap, string name, string nameUnique)
        {
            var service = await GetService();

            ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.CreatingEntityDescription);

            try
            {
                string fileName = EntityFileNameFormatter.GetSiteMapFileName(service.ConnectionData.Name, name, idSiteMap, EntityFileNameFormatter.Headers.EntityDescription, "txt");
                string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName));

                var repository = new SitemapRepository(service);

                var sitemap = await repository.GetByIdAsync(idSiteMap, new ColumnSet(true));

                await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, sitemap, EntityFileNameFormatter.SiteMapIgnoreFields, service.ConnectionData);

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.ExportedEntityDescriptionForConnectionFormat3
                                                   , service.ConnectionData.Name
                                                   , sitemap.LogicalName
                                                   , filePath);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);

                ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.CreatingEntityDescriptionCompleted);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);

                ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.CreatingEntityDescriptionFailed);
            }
        }
예제 #6
0
        public tbl_Content GetContentBySitemapUrl(string url, int domainID)
        {
            var siteMap = SitemapRepository.GetByUrl(url, domainID).Where(b => b.SM_PublishDate == null || b.SM_PublishDate <= DateTime.Now).FirstOrDefault();

            return((siteMap == null || (siteMap.IsType(ContentType.Blog) && !siteMap.SM_Live)) ?
                   null:
                   siteMap.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault());
        }
예제 #7
0
        public tbl_Content GetContentBySitemapUrl(string url, ContentType type, int domainID)
        {
            var         sType   = type.ToString();
            tbl_SiteMap siteMap = SitemapRepository.GetByUrl(url, domainID).Where(sm => sm.tbl_ContentType.CTP_Value.Equals(sType)).FirstOrDefault();

            return((siteMap == null || (siteMap.IsType(ContentType.Blog) && !siteMap.SM_Live)) ?
                   null :
                   siteMap.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault());
        }
예제 #8
0
        public bool AddCategoryToSitemap(int sitemapID, int categoryID)
        {
            if (sitemapID == 0 || categoryID == 0)
            {
                return(false);
            }

            return(SitemapRepository.AddCategory(sitemapID, categoryID));
        }
        private async Task PerformShowingDifferenceDescriptionAsync(LinkedEntities <SiteMap> linked, bool showAllways)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.WindowStatusStrings.ShowingDifferenceEntityDescription);

            try
            {
                var service1 = await GetService1();

                var service2 = await GetService2();

                if (service1 != null && service2 != null)
                {
                    var repository1 = new SitemapRepository(service1);
                    var repository2 = new SitemapRepository(service2);

                    var sitemap1 = await repository1.GetByIdAsync(linked.Entity1.Id, new ColumnSet(true));

                    var sitemap2 = await repository2.GetByIdAsync(linked.Entity2.Id, new ColumnSet(true));

                    var desc1 = await EntityDescriptionHandler.GetEntityDescriptionAsync(sitemap1, EntityFileNameFormatter.SiteMapIgnoreFields);

                    var desc2 = await EntityDescriptionHandler.GetEntityDescriptionAsync(sitemap2, EntityFileNameFormatter.SiteMapIgnoreFields);

                    if (showAllways || desc1 != desc2)
                    {
                        string filePath1 = await CreateDescriptionFileAsync(service1.ConnectionData, sitemap1.SiteMapName, sitemap1.Id, EntityFileNameFormatter.Headers.EntityDescription, desc1);

                        string filePath2 = await CreateDescriptionFileAsync(service2.ConnectionData, sitemap2.SiteMapName, sitemap2.Id, EntityFileNameFormatter.Headers.EntityDescription, desc2);

                        if (File.Exists(filePath1) && File.Exists(filePath2))
                        {
                            this._iWriteToOutput.ProcessStartProgramComparer(filePath1, filePath2, Path.GetFileName(filePath1), Path.GetFileName(filePath2));
                        }
                        else
                        {
                            this._iWriteToOutput.PerformAction(service1.ConnectionData, filePath1);

                            this._iWriteToOutput.PerformAction(service2.ConnectionData, filePath2);
                        }
                    }
                }

                ToggleControls(true, Properties.WindowStatusStrings.ShowingDifferenceEntityDescriptionCompleted);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(null, ex);

                ToggleControls(true, Properties.WindowStatusStrings.ShowingDifferenceEntityDescriptionFailed);
            }
        }
        private async Task PerformShowingDifferenceSingleXmlAsync(LinkedEntities <SiteMap> linked, bool showAllways, string fieldName, string fieldTitle)
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            ToggleControls(false, Properties.WindowStatusStrings.ShowingDifferenceXmlForFieldFormat1, fieldName);

            try
            {
                var service1 = await GetService1();

                var service2 = await GetService2();

                if (service1 != null && service2 != null)
                {
                    var repository1 = new SitemapRepository(service1);
                    var repository2 = new SitemapRepository(service2);

                    var sitemap1 = await repository1.GetByIdAsync(linked.Entity1.Id, new ColumnSet(true));

                    var sitemap2 = await repository2.GetByIdAsync(linked.Entity2.Id, new ColumnSet(true));

                    string xml1 = sitemap1.GetAttributeValue <string>(fieldName);
                    string xml2 = sitemap2.GetAttributeValue <string>(fieldName);

                    if (showAllways || !ContentCoparerHelper.CompareXML(xml1, xml2).IsEqual)
                    {
                        string filePath1 = await CreateFileAsync(service1.ConnectionData, sitemap1.SiteMapName, sitemap1.SiteMapNameUnique, sitemap1.Id, fieldTitle, xml1);

                        string filePath2 = await CreateFileAsync(service2.ConnectionData, sitemap2.SiteMapName, sitemap2.SiteMapNameUnique, sitemap2.Id, fieldTitle, xml2);

                        if (File.Exists(filePath1) && File.Exists(filePath2))
                        {
                            this._iWriteToOutput.ProcessStartProgramComparer(filePath1, filePath2, Path.GetFileName(filePath1), Path.GetFileName(filePath2));
                        }
                        else
                        {
                            this._iWriteToOutput.PerformAction(service1.ConnectionData, filePath1);

                            this._iWriteToOutput.PerformAction(service2.ConnectionData, filePath2);
                        }
                    }
                }

                ToggleControls(true, Properties.WindowStatusStrings.ShowingDifferenceXmlForFieldCompletedFormat1, fieldName);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(null, ex);

                ToggleControls(true, Properties.WindowStatusStrings.ShowingDifferenceXmlForFieldFailedFormat1, fieldName);
            }
        }
예제 #11
0
        public List <tbl_Content> GetContentByTagUrl(string url, int domainID)
        {
            var sitemaps = SitemapRepository.GetByTag(url, domainID).Where(c => c.SM_Live).OrderByDescending(b => b.SM_Date);

            if (sitemaps == null || sitemaps.Count() == 0)
            {
                return(null);
            }

            return(sitemaps.Select(s => s.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault()).Where(b => b != null).ToList());
        }
        private void FillSolutionComponentFromSchemaName(ICollection <SolutionComponent> result, string sitemapName, int?behavior)
        {
            var repository = new SitemapRepository(_service);

            var entity = repository.FindByExactName(sitemapName, new ColumnSet(false));

            if (entity != null)
            {
                FillSolutionComponentInternal(result, entity.Id, behavior);
            }
        }
예제 #13
0
 public tbl_Content ApproveContent(int sectionID, int contentID = 0)
 {
     if (contentID == 0)
     {
         tbl_SiteMap section = SitemapRepository.GetByID(sectionID);
         if (section != null)
         {
             contentID = section.tbl_Content.Where(c => !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).Select(c => c.ContentID).FirstOrDefault();
         }
     }
     return(ContentRepository.ApproveContent(contentID));
 }
예제 #14
0
        public tbl_Content GetContentByRedirectUrl(string url, int domainID, int contentID = 0)
        {
            tbl_SiteMap section = SitemapRepository.GetByRedirectUrl(url, domainID);

            if (section == null || (section.IsType(ContentType.Blog) && !section.SM_Live))
            {
                return(null);
            }

            return((contentID == 0) ?
                   section.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault():
                   section.tbl_Content.FirstOrDefault(c => c.ContentID == contentID));
        }
예제 #15
0
        public tbl_Domains SaveDomain(string address, string name, string phone, string consumerKey, string consumerSecret, string css, string defaultDesc, string keywords,
                                      int langID, string title, string desc, string domainName, string email, string googleAnalytics, string googleAnalyticsCode, bool googleAnalyticsVisible,
                                      string robots, string headline, int homePageID, int?launchYear, bool primaryDomain, string share, string twitterSecret, string twitterToken, string twitterUser, bool updateTwitter,
                                      bool isMailChimpEnabled, string mailChimpAPIKey, string mailChimpListID, bool isCommuniGatorEnabled, string communiGatorUser, string communiGatorPassword,
                                      List <tbl_SettingsValue> settingsValues, bool IsPaypalPayment, bool IsSagePayPayment, bool IsSecureTradingPayment, EventViewType eventView, bool enableEventSale,
                                      bool enableProductSale, string theme, bool devMode, int domainID, bool isCoockieConsentEnabled, bool isStripePayment, List <tbl_Social> socialValues, bool customRouteHandler)
        {
            if (String.IsNullOrEmpty(domainName))
            {
                return(null);
            }

            var domain = DomainsRepository.SaveDomain(address, name, phone, consumerKey, consumerSecret,
                                                      css, defaultDesc, keywords, langID, title, desc, domainName, email, googleAnalytics, googleAnalyticsCode,
                                                      googleAnalyticsVisible, robots, headline, homePageID, launchYear, primaryDomain, share, twitterSecret,
                                                      twitterToken, twitterUser, updateTwitter, isMailChimpEnabled, mailChimpAPIKey, mailChimpListID,
                                                      isCommuniGatorEnabled, communiGatorUser, communiGatorPassword, eventView, enableEventSale,
                                                      enableProductSale, theme, devMode, isCoockieConsentEnabled, customRouteHandler, domainID);

            if (domain != null)
            {
                if (domainID == 0)
                {
                    foreach (var value in Enum.GetValues(typeof(SiteMapType)))
                    {
                        SiteMapType type = (SiteMapType)Enum.Parse(typeof(SiteMapType), value.ToString());

                        var sitemap = SitemapRepository.SaveSiteMap(string.Empty, 1, 0, domain.DomainID, String.Empty, false, false, type.ToString(), null,
                                                                    (decimal)0.5, String.Empty, FriendlyUrl.CreateFriendlyUrl(type.ToString()), true, false, ContentType.Content, type.ToString(), 0, 0, (int)type, true);

                        if (sitemap != null)
                        {
                            ContentRepository.SaveContent(String.Empty, String.Empty, type.ToString(), 0, string.Empty, type.ToString(), type.ToString(),
                                                          string.Empty, 0, string.Empty, string.Empty, string.Empty, type.ToString(), string.Empty, false, sitemap.SiteMapID, 0);
                        }
                    }

                    socialValues = this.GetDefaultSocialValues(domain.DomainID);
                }

                PaymentDomainRepository.UpdateStatus(IsPaypalPayment, PaymentType.PayPal, domain.DomainID);
                PaymentDomainRepository.UpdateStatus(IsSagePayPayment, PaymentType.SagePay, domain.DomainID);
                PaymentDomainRepository.UpdateStatus(IsSecureTradingPayment, PaymentType.SecureTrading, domain.DomainID);
                PaymentDomainRepository.UpdateStatus(isStripePayment, PaymentType.Stripe, domain.DomainID);
                SettingsValuesRepository.Save(settingsValues, domain.DomainID);
                SocialRepository.SaveMultipleSocial(socialValues);
                return(domain);
            }

            return(null);
        }
예제 #16
0
        public List <ExtendedSelectListItem> GetSitemapListURLByContent(int domainID, string selectedUrl)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(ContentType.Content);

            if (type == null)
            {
                return(null);
            }

            List <ExtendedSelectListItem> sections = new List <ExtendedSelectListItem>();

            foreach (var section in SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID).OrderBy(c => c.SM_OrderBy))
            {
                var parent = sections.FirstOrDefault(s => s.ID == section.SM_ParentID);
                if (sections.Contains(parent))
                {
                    string appendix = String.Empty;
                    int    level    = parent.Level;
                    while (level > 0)
                    {
                        appendix += "&nbsp;&nbsp;"; level--;
                    }

                    sections.Insert(sections.IndexOf(parent) + 1, new ExtendedSelectListItem
                    {
                        Text     = appendix + section.SM_Name,
                        Value    = section.SM_URL,
                        Selected = section.SM_URL == selectedUrl,
                        Level    = parent.Level + 1,
                        ID       = section.SiteMapID
                    });
                }
                else
                {
                    sections.Add(new ExtendedSelectListItem
                    {
                        Text     = section.SM_Name,
                        Value    = section.SM_URL,
                        Selected = section.SM_URL == selectedUrl,
                        Level    = 1,
                        ID       = section.SiteMapID
                    });
                }
            }
            return(sections);
        }
예제 #17
0
        public List <tbl_Content> GetContentBySitemapDate(string year, string month, int domainID)
        {
            int y = 0, m = 0;

            int.TryParse(year, out y);
            int.TryParse(month, out m);
            var date = new DateTime(y, m, 1);

            var siteMaps = SitemapRepository.GetByDate(date, domainID).Where(b => b.SM_Live && (b.SM_PublishDate == null || b.SM_PublishDate <= DateTime.Now)).OrderByDescending(b => b.SM_Date);

            if (siteMaps == null || siteMaps.Count() == 0)
            {
                return(null);
            }

            return(siteMaps.Select(s => s.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault()).Where(b => b != null).ToList());
        }
예제 #18
0
        public int GetSitemapRootID(int domainID, int sitemapID)
        {
            tbl_SiteMap sitemap = SitemapRepository.GetByID(sitemapID);

            if (sitemap == null)
            {
                return(0);
            }

            if (sitemap.SM_ParentID == 0)
            {
                return(sitemap.SiteMapID);
            }
            else
            {
                return(this.GetSitemapRootID(domainID, sitemap.SM_ParentID));
            }
        }
        /// <inheritdoc />
        /// <summary>
        /// Required by IHttpHandler, this is called by ASP.NET when an appropriate URL match is found.
        /// </summary>
        /// <param name="context">The current request context.</param>
        public void ProcessRequest(HttpContext context)
        {
            var site = SiteContextFactory.GetSiteContext(context.Request.Url.Host, context.Request.Url.LocalPath, context.Request.Url.Port);

            if (SitemapRepository.IsOnIgnoreList(site))
            {
                context.Response.Clear();
                context.Response.StatusCode = 404;
                context.Response.Status     = "Not Found";
                context.Response.End();
            }

            var document = SitemapRepository.GetSitemap(site);

            context.Response.Clear();
            context.Response.ContentType = "text/xml";
            document.Save(context.Response.OutputStream);
            context.Response.End();
        }
예제 #20
0
        public void Expect_Sitemap_Without_Language_In_URL()
        {
            var sitemapData = new SitemapData
            {
                Host = "Sitemap.xml", SiteUrl = "https://xyz.com/"
            };

            var expectedSiteMapUrl = "sitemap.xml";

            var siteDefinitionResolver = new Mock <ISiteDefinitionResolver>();
            var sitemapLoader          = new Mock <ISitemapLoader>();

            var siteMapService = new SitemapRepository(_languageBranchRepository.Object, siteDefinitionResolver.Object, sitemapLoader.Object);

            var sitemapUrl = siteMapService.GetHostWithLanguage(sitemapData);

            Assert.True(sitemapUrl != null);
            Assert.Equal(sitemapUrl, expectedSiteMapUrl);
        }
예제 #21
0
        /// <summary>
        /// The method called by the Event pipeline in Sitecore.
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="args">The event args</param>
        public void OnPublishEnd(object sender, EventArgs args)
        {
            // Get all the sites in the system
            var sites = Sitecore.Configuration.Factory.GetSiteInfoList();

            Log.Info($"Constellation.Foundation.SitemapXml OnPublishEnd regenerating {sites.Count} sitemap.xml documents", this);

            foreach (var site in sites)
            {
                if (SitemapXmlConfiguration.Current.SitesToIgnore.Contains(site.Name))
                {
                    Log.Debug($"Constellation.Foundation.SitemapXml OnPublishEnd ignoring {site.Name} site.", this);
                    continue;
                }

                Log.Info($"Constellation.Foundation.SitemapXml generating {site.Name} sitemap.xml", this);
                SitemapRepository.GetSitemap(new SiteContext(site), true);
                Log.Info($"Constellation.Foundation.SitemapXml {site.Name} sitemap.xml generated.", this);
            }
        }
        /// <summary>
        /// This is the method the Scheduler should call when executing this agent.
        /// </summary>
        public void Refresh()
        {
            // Get all the sites in the system
            var sites = Sitecore.Configuration.Factory.GetSiteInfoList();

            Log.Info($"Constellation.Foundation.SitemapXml OnPublishEnd regenerating {sites.Count} sitemap.xml documents", this);

            foreach (var site in sites)
            {
                if (SitemapXmlConfiguration.Current.SitesToIgnore.Contains(site.Name))
                {
                    Log.Debug($"Constellation.Foundation.SitemapXml OnPublishEnd ignoring {site.Name} site.", this);
                    continue;
                }

                Log.Info($"Constellation.Foundation.SitemapXml generating {site.Name} sitemap.xml", this);
                SitemapRepository.GetSitemap(new SiteContext(site), false);                 // we want to catch when the cache is expired, no need to do work that's not needed.
                Log.Info($"Constellation.Foundation.SitemapXml {site.Name} sitemap.xml generated.", this);
            }
        }
예제 #23
0
        public List <tbl_Content> GetContentByContentType(ContentType contentType, int domainID, int top)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(contentType);

            if (type == null)
            {
                return(null);
            }

            var sitemaps = SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID)
                           .Where(c => (contentType != ContentType.Blog || (c.SM_Live && (c.SM_PublishDate == null || c.SM_PublishDate <= DateTime.Now))))
                           .OrderByDescending(b => b.SM_Date).Take(top);

            if (sitemaps == null || sitemaps.Count() == 0)
            {
                return(null);
            }

            return(sitemaps.Select(s => s.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault()).Where(b => b != null).ToList());
        }
예제 #24
0
        public void Can_Retrieve_SiteMapData_By_URL_When_SiteMapData_SiteUrl_Is_Null()
        {
            var requestUrl          = "https://www.domain.com/en/sitemap.xml";
            var expectedSitemapData = new SitemapData
            {
                Language = "en", Host = "Sitemap.xml", SiteUrl = null
            };

            var hostDefinition = new HostDefinition();
            var siteDefinition = new SiteDefinition();

            siteDefinition.Hosts = new List <HostDefinition>
            {
                new HostDefinition {
                    Name = "www.domain.com"
                }
            };

            var siteDefinitionResolver = new Mock <ISiteDefinitionResolver>();

            siteDefinitionResolver
            .Setup(x => x.GetByHostname(It.IsAny <string>(), It.IsAny <bool>(), out hostDefinition))
            .Returns(siteDefinition);

            var sitemapDataList = new List <SitemapData>
            {
                expectedSitemapData
            };

            var sitemapLoader = new Mock <ISitemapLoader>();

            sitemapLoader
            .Setup(x => x.GetAllSitemapData())
            .Returns(sitemapDataList);

            var siteMapService = new SitemapRepository(_languageBranchRepository.Object, siteDefinitionResolver.Object, sitemapLoader.Object);

            var siteMapData = siteMapService.GetSitemapData(requestUrl);

            Assert.Equal(siteMapData, expectedSitemapData);
        }
예제 #25
0
        private async Task ShowExistingSiteMaps()
        {
            if (!this.IsControlsEnabled)
            {
                return;
            }

            var service = await GetService();

            ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.LoadingSiteMaps);

            this._itemsSource.Clear();

            IEnumerable <SiteMap> list = Enumerable.Empty <SiteMap>();

            try
            {
                if (service != null)
                {
                    var repository = new SitemapRepository(service);
                    list = await repository.GetListAsync(new ColumnSet(SiteMap.EntityPrimaryIdAttribute, SiteMap.Schema.Attributes.sitemapname, SiteMap.Schema.Attributes.sitemapnameunique));
                }
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);
            }

            string textName = string.Empty;

            txtBFilter.Dispatcher.Invoke(() =>
            {
                textName = txtBFilter.Text.Trim().ToLower();
            });

            list = FilterList(list, textName);

            LoadSiteMaps(list);

            ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.LoadingSiteMapsCompletedFormat1, list.Count());
        }
예제 #26
0
        public List <tbl_Content> SearchContent(string keyword, int domainID)
        {
            tbl_ContentType textType = ContentTypeRepository.GetByType(ContentType.Content);
            tbl_ContentType blogType = ContentTypeRepository.GetByType(ContentType.Blog);

            if (textType == null || blogType == null)
            {
                return(null);
            }

            IQueryable <tbl_SiteMap> texts = SitemapRepository.GetByDomainID(domainID)
                                             .Where(c => (c.SM_ContentTypeID == blogType.ContentTypeID && c.SM_Live) ||
                                                    c.SM_ContentTypeID == textType.ContentTypeID).OrderByDescending(b => b.SM_Date);

            return(texts.Select(b => b.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault())
                   .Where(c => c != null && (c.C_Title.Contains(keyword) ||
                                             c.C_Content.Contains(keyword) ||
                                             c.C_Description.Contains(keyword) ||
                                             c.C_Keywords.Contains(keyword) ||
                                             c.C_SearchKeywords.Contains(keyword))).ToList());
        }
예제 #27
0
        public void One_Host_And_Multiple_Sitemaps_Can_Retrieve_Correct_SiteMap(string[] siteMapUrls, string requestedHostURL)
        {
            var requestUrl = $"{requestedHostURL}/en/sitemap.xml";

            var sitemapDataList = siteMapUrls.Select(x => new SitemapData
            {
                Language = "en", Host = "Sitemap.xml", SiteUrl = x
            }).ToList();

            var expectedSitemapData = sitemapDataList.FirstOrDefault(x => x.SiteUrl.Equals(requestedHostURL));

            var hostDefinition = new HostDefinition();
            var siteDefinition = new SiteDefinition();

            siteDefinition.Hosts = new List <HostDefinition>
            {
                new HostDefinition {
                    Name = new Uri(requestedHostURL, UriKind.Absolute).Authority
                }
            };

            var siteDefinitionResolver = new Mock <ISiteDefinitionResolver>();

            siteDefinitionResolver
            .Setup(x => x.GetByHostname(It.IsAny <string>(), It.IsAny <bool>(), out hostDefinition))
            .Returns(siteDefinition);

            var sitemapLoader = new Mock <ISitemapLoader>();

            sitemapLoader
            .Setup(x => x.GetAllSitemapData())
            .Returns(sitemapDataList);

            var siteMapService = new SitemapRepository(_languageBranchRepository.Object, siteDefinitionResolver.Object, sitemapLoader.Object);

            var siteMapData = siteMapService.GetSitemapData(requestUrl);

            Assert.True(siteMapData != null);
            Assert.Equal(siteMapData, expectedSitemapData);
        }
예제 #28
0
        public tbl_SiteMap SaveSiteMap(string R301, int languageID, int menuID, int domainID, string css, bool isMenu, bool isFooter, string menuText, DateTime?date,
                                       string spriority, string notifyEmail, string path, bool requiresApproval, bool isSiteMap, ContentType type, string siteMapName, int parentID, int siteMapID,
                                       int?typeID = null, bool isPredefined = false, MenuDisplayType menuDisplayType = MenuDisplayType.UnderParent, DateTime?publishDate = null)
        {
            decimal priority = 0;

            Decimal.TryParse(spriority, out priority);

            if (siteMapID > 0)
            {
                var sitemap = SitemapRepository.GetByID(siteMapID);
                if (sitemap != null && sitemap.SM_IsPredefined)
                {
                    isPredefined = true;
                    typeID       = sitemap.SM_TypeID;
                }
            }

            return(SitemapRepository.SaveSiteMap(R301, languageID, menuID, domainID, Sanitizer.GetSafeHtmlFragment(css), isMenu, isFooter,
                                                 Sanitizer.GetSafeHtmlFragment(menuText), date, priority, Sanitizer.GetSafeHtmlFragment(notifyEmail), FriendlyUrl.CreateFriendlyUrl(path),
                                                 requiresApproval, isSiteMap, type, Sanitizer.GetSafeHtmlFragment(siteMapName), parentID, siteMapID, typeID, isPredefined, (int)menuDisplayType, publishDate));
        }
예제 #29
0
        public List <ExtendedSelectListItem> GetSitemapListByContent(int domainID, int selectedSitemapID)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(ContentType.Content);

            if (type == null)
            {
                return(null);
            }

            List <ExtendedSelectListItem> sections = new List <ExtendedSelectListItem>();

            foreach (var section in SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID).OrderBy(c => c.SM_OrderBy))
            {
                var parent = sections.FirstOrDefault(s => s.Value == section.SM_ParentID.ToString());
                if (sections.Contains(parent))
                {
                    sections.Insert(sections.IndexOf(parent) + 1, new ExtendedSelectListItem
                    {
                        Text     = section.SM_Name,
                        Value    = section.SiteMapID.ToString(),
                        Selected = section.SiteMapID == selectedSitemapID,
                        Level    = parent != null ? parent.Level + 1 : 1
                    });
                }
                else
                {
                    sections.Add(new ExtendedSelectListItem
                    {
                        Text     = section.SM_Name,
                        Value    = section.SiteMapID.ToString(),
                        Selected = section.SiteMapID == selectedSitemapID,
                        Level    = parent != null ? parent.Level + 1 : 1
                    });
                }
            }
            return(sections);
        }
예제 #30
0
        public List <tbl_SiteMap> GetSitemapByContentType(ContentType contentType, int domainID)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(contentType);

            if (type == null)
            {
                return(new List <tbl_SiteMap>());
            }

            var sitemaps = SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID).ToList();

            switch (contentType)
            {
            case ContentType.Product:
                sitemaps = sitemaps.Where(s => s.tbl_Products != null).ToList();
                break;

            case ContentType.Category:
                sitemaps = sitemaps.Where(s => s.tbl_ProdCategories != null).ToList();
                break;
            }

            return(sitemaps);
        }