Esempio n. 1
0
        private async Task SoftUpdateSiteFields(ModelDbContext dbContext, Site existing, SiteDto updatedDto)
        {
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.Name, updatedDto.Name);
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.Contact, updatedDto.Contact);
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.Address1, updatedDto.Address1);
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.Address2, updatedDto.Address2);
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.Town, updatedDto.Town);
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.CoT, updatedDto.CoT);
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.BillingAddress, updatedDto.BillingAddress);
            SetStringPropertyIfNotNullOrEmpty(existing, e => e.Postcode, updatedDto.Postcode);

            await dbContext.Update(existing);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新资料
        /// </summary>
        /// <param name="prefix"></param>
        public static void Update(string prefix)
        {
            SettingFile sf = new SettingFile(cmsConfigFile);

            switch (prefix)
            {
            case "sys":
                sf["license_name"]          = Settings.License_NAME;
                sf["license_key"]           = Settings.License_KEY;
                sf["server_static_enabled"] = Settings.SERVER_STATIC_ENABLED?"true":"false";
                sf["server_static"]         = Settings.SERVER_STATIC;
                sf["sys_admin_tag"]         = Settings.SYS_ADMIN_TAG;

                //301跳转
                if (!sf.Contains("sys_autowww"))
                {
                    sf.Add("sys_autowww", Settings.SYS_AUTOWWW ? "true" : "false");
                }
                else
                {
                    sf["sys_autowww"] = Settings.SYS_AUTOWWW ? "true" : "false";
                }

                //虚拟路径
                //if (!sf.Contains("sys_virthpath"))
                //{
                //    sf.Add("sys_virthpath", Settings.SYS_VIRTHPATH);
                //}
                //else
                //{
                //    sf["sys_virthpath"] = Settings.SYS_VIRTHPATH;
                //}
                break;

            case "db":
                sf["db_prefix"] = Settings.DB_PREFIX;
                break;

            case "tpl":

                //压缩代码
                if (!sf.Contains("tpl_usecompress"))
                {
                    sf.Add("tpl_usecompress", Settings.TPL_UseCompress ? "true" : "false");
                }
                else
                {
                    sf["tpl_usecompress"] = Settings.TPL_UseCompress ? "true" : "false";
                }

                //使用完整路径
                if (!sf.Contains("tpl_usefullpath"))
                {
                    sf.Add("tpl_usefullpath", Settings.TPL_UseFullPath ? "true" : "false");
                }
                else
                {
                    sf["tpl_usefullpath"] = Settings.TPL_UseFullPath ? "true" : "false";
                }


                Cms.Template.Register();

                break;

            //优化
            case "opti":

                WebConfig.SetDebug(Settings.Opti_Debug);

                //缓存项
                if (!sf.Contains("opti_IndexCacheSeconds"))
                {
                    sf.Add("opti_IndexCacheSeconds", Settings.Opti_IndexCacheSeconds.ToString());
                }
                else
                {
                    sf["opti_IndexCacheSeconds"] = Settings.Opti_IndexCacheSeconds.ToString();
                }

                if (!sf.Contains("Opti_GC_Collect_Interval"))
                {
                    sf.Add("Opti_GC_Collect_Interval", Settings.Opti_GC_Collect_Interval.ToString());
                }
                else
                {
                    sf["Opti_GC_Collect_Interval"] = Settings.Opti_GC_Collect_Interval.ToString();
                }

                if (!sf.Contains("opti_ClientCacheSeconds"))
                {
                    sf.Add("opti_ClientCacheSeconds", Settings.Opti_ClientCacheSeconds.ToString());
                }
                else
                {
                    sf["opti_ClientCacheSeconds"] = Settings.Opti_ClientCacheSeconds.ToString();
                }


                break;
            }

            //
            //Version:兼容更新站点
            //
            SiteDto site = Cms.Context.CurrentSite;

            if (site.SiteId > 0)
            {
                if (sf.Contains("idx_title"))
                {
                    site.SeoTitle = sf["idx_title"];
                    sf.Remove("idx_title");
                }
                if (sf.Contains("idx_keywords"))
                {
                    site.SeoKeywords = sf["idx_keywords"];
                    sf.Remove("idx_keywords");
                }
                if (sf.Contains("idx_description"))
                {
                    site.SeoDescription = sf["idx_description"];
                    sf.Remove("idx_description");
                }
                if (sf.Contains("sys_alias"))
                {
                    sf.Remove("sys_alias");
                }
            }

            if (sf.Contains("sys_name"))
            {
                if (sf.Contains("license_name"))
                {
                    sf["license_name"] = sf["sys_name"];
                    sf["license_key"]  = sf["sys_key"];
                }
                else
                {
                    sf.Add("license_name", sf["sys_name"]);
                    sf.Add("license_key", sf["sys_key"]);
                }
                sf.Remove("sys_name");
                sf.Remove("sys_key");
            }

            sf.Flush();
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SiteAdmin"/> class.
 /// </summary>
 /// <param name="dto">The dto.</param>
 internal SiteAdmin(SiteDto dto)
 {
     _DataSet = dto;
 }
Esempio n. 4
0
 private static void SetCurrentSiteToSession(ICompatibleHttpContext context, SiteDto site)
 {
     context.Session.SetObjectAsJson(CurrentSiteSessionStr, site);
 }
Esempio n. 5
0
 /// <summary>
 /// Loads the context.
 /// </summary>
 /// <param name="context">The context.</param>
 public void LoadContext(IDictionary context)
 {
     _SiteDtoSrc  = (SiteDto)context[_SiteDtoSourceString];
     _SiteDtoDest = (SiteDto)context[_SiteDtoDestinationString];
 }
Esempio n. 6
0
 public bool Update(SiteDto site)
 {
     site.ModifiedDate = DateTimeOffset.UtcNow;
     return(Update(_mapper.toEntity <Site>(site), true) > 0);
 }
Esempio n. 7
0
 public bool Delete(SiteDto site)
 => Delete(_mapper.toEntity <Site>(site), true) > 0;
Esempio n. 8
0
        public async Task <SiteDto> AddOrUpdateSiteAsync(SiteDto siteDto, string userEmail)
        {
            var user = await _userDao.GetUserAsync(userEmail);

            return(await _siteDao.AddOrUpdateSiteAsync(siteDto, user.Id));
        }
Esempio n. 9
0
        /// <summary>
        /// 搜索文档
        /// </summary>
        public void GetSearchArchivesJsonResult_POST()
        {
            string key = base.Request["key"].Trim();
            string size = base.Request["size"] ?? "20";
            bool   onlyTitle = Request["only_title"] == "true";
            string categoryTag = Request["category"];
            int    count, pages;
            int    intSiteId = 0;

            int.TryParse(Request["site_id"], out intSiteId);

            StringBuilder strBuilder = new StringBuilder(500);

            int lft = 0;
            int rgt = 0;

            if (!String.IsNullOrEmpty(categoryTag))
            {
                CategoryDto c = ServiceCall.Instance.SiteService.GetCategory(intSiteId, categoryTag);
                if (c.ID > 0)
                {
                    lft = c.Lft;
                    rgt = c.Rgt;
                }
            }

            IEnumerable <ArchiveDto> list = ServiceCall.Instance.ArchiveService
                                            .SearchArchives(intSiteId, lft, rgt, onlyTitle, key,
                                                            int.Parse(size),
                                                            1,
                                                            out count,
                                                            out pages,
                                                            null
                                                            );

            int i = 0;

            strBuilder.Append("[");
            SiteDto site = default(SiteDto);

            foreach (ArchiveDto a in list)
            {
                if (++i != 1)
                {
                    strBuilder.Append(",");
                }
                if (site.SiteId == 0 || site.SiteId != a.Category.SiteId)
                {
                    site = ServiceCall.Instance.SiteService.GetSiteById(a.Category.SiteId);
                }

                strBuilder.Append("{'id':'").Append(a.Id)
                .Append("','alias':'").Append(String.IsNullOrEmpty(a.Alias) ? a.StrId : a.Alias)
                .Append("',title:'").Append(a.Title)
                .Append("',siteId:").Append(site.SiteId)
                .Append(",siteName:'").Append(site.Name)
                .Append("',category:'").Append(a.Category.Name).Append("(").Append(a.Category.Tag).Append(")")
                .Append("'}");
            }
            strBuilder.Append("]");

            base.Response.Write(strBuilder.ToString());
        }
Esempio n. 10
0
 public bool UpdateSite(SiteDto site)
 {
     return(_siteRepository.Update(site));
 }
Esempio n. 11
0
        /// <summary>
        /// 获取博客列表
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public CookComputing.Blogger.BlogInfo[] getUsersBlogs(string appKey, string username, string password)
        {
            User user;

            if ((user = ValidUser(username, password)) != null)
            {
                //获得当前域名
                string       domain;
                const string portDomainStr = "http://{0}:{1}";
                const string domainStr     = "http://{0}";

                HttpRequest request = HttpContext.Current.Request;
                domain = String.Format(request.Url.IsDefaultPort ? domainStr : portDomainStr, request.Url.Host, request.Url.Port);



                SiteDto site2 = SiteCacheManager.GetSite(user.SiteId > 0 ? user.SiteId : this.siteId);

                //返回博客列表
                return(new CookComputing.Blogger.BlogInfo[]
                {
                    new CookComputing.Blogger.BlogInfo {
                        blogid = site2.SiteId.ToString(), blogName = site2.Name, url = domain
                    }
                });

                //========================================================//

                //返回单个站点
                if (user.SiteId > 0)
                {
                    SiteDto site = SiteCacheManager.GetSite(user.SiteId);
                    //返回博客列表
                    return(new CookComputing.Blogger.BlogInfo[]
                    {
                        new CookComputing.Blogger.BlogInfo {
                            blogid = site.SiteId.ToString(), blogName = site.Name, url = domain
                        }
                    });
                }
                else
                {
                    IList <SiteDto> sites = SiteCacheManager.GetAllSites();
                    CookComputing.Blogger.BlogInfo[] blogs = new CookComputing.Blogger.BlogInfo[sites.Count];
                    for (int i = 0; i < sites.Count; i++)
                    {
                        blogs[i] = new CookComputing.Blogger.BlogInfo
                        {
                            blogid   = sites[i].SiteId.ToString(),
                            blogName = sites[i].Name,
                            url      = !String.IsNullOrEmpty(sites[i].Domain) ?
                                       "http://" + sites[i].Domain + "/" :
                                       (!String.IsNullOrEmpty(sites[i].DirName) ?
                                        domain + "/" + sites[i].DirName + "/" : domain
                                       )
                        };
                    }
                    return(blogs);
                }
            }
            return(null);
        }
Esempio n. 12
0
 public bool CreateSite(SiteDto site)
 {
     return(_siteRepository.Add(site));
 }
Esempio n. 13
0
 public PageGeneratorObject(CmsContext context)
 {
     //this.context=context;
     this.site = context.CurrentSite;
 }
Esempio n. 14
0
 public async Task <ActionResult <SiteDto> > EditSite(SiteDto pSiteDto)
 {
     _sitesService.EditSite(pSiteDto);
     return(Ok());
 }
Esempio n. 15
0
 public bool Add(SiteDto site)
 {
     site.Id          = site.Id != default ? site.Id : Guid.NewGuid();
     site.CreatedDate = DateTimeOffset.UtcNow;
     return(Add(_mapper.toEntity <Site>(site), true) > 0);
 }
Esempio n. 16
0
        public SiteDto Convert(Site site, SecureSiteData secureSiteData)
        {
            SiteDto siteData = Convert(site);

            return(ExtendFromSecureData(siteData, secureSiteData));
        }
Esempio n. 17
0
 public async Task <bool> AddAsync(SiteDto site)
 {
     site.Id          = site.Id != default ? site.Id : Guid.NewGuid();
     site.CreatedDate = DateTimeOffset.UtcNow;
     return(await Task.Run(() => Add(_mapper.toEntity <Site>(site), true) > 0));
 }
Esempio n. 18
0
 private SiteDto ExtendFromSecureData(SiteDto site, SecureSiteData secureSiteData)
 {
     site.Address = secureSiteData?.Url;
     site.Port    = secureSiteData?.Port ?? 0;
     return(site);
 }
Esempio n. 19
0
 public async Task <bool> UpdateAsync(SiteDto site)
 {
     site.ModifiedDate = DateTimeOffset.UtcNow;
     return(await Task.Run(() => Update(_mapper.toEntity <Site>(site), true) > 0));
 }
Esempio n. 20
0
        /// <summary>
        /// 呈现首页
        /// </summary>
        /// <param name="context"></param>
        public static void RenderIndex(CmsContext context)
        {
            //检测网站状态
            if (!context.CheckSiteState())
            {
                return;
            }

            //检查缓存
            if (!context.CheckAndSetClientCache())
            {
                return;
            }

            SiteDto site = context.CurrentSite;

            //跳转
            if (!String.IsNullOrEmpty(site.Location))
            {
                //string url;
                //if (Regex.IsMatch(archive.Location, "^http://", RegexOptions.IgnoreCase))
                //{
                //    url = archive.Location;
                //}
                //else
                //{
                //    if (archive.Location.StartsWith("/")) throw new Exception("URL不能以\"/\"开头!");
                //    url = String.Concat(context.SiteDomain, site.Location);
                //}

                context.Response.Redirect(site.Location, true);  //302

                return;
            }


            int    siteID  = site.SiteId;
            string cacheID = String.Concat("cms_s", siteID.ToString(), "_index_page");

            ICmsPageGenerator cmsPage = new PageGeneratorObject(context);

            if (context.Request["cache"] == "0")
            {
                Cms.Cache.Rebuilt();
            }


            string html = String.Empty;

            if (Settings.Opti_IndexCacheSeconds > 0)
            {
                ICmsCache cache = Cms.Cache;
                object    obj   = cache.Get(cacheID);
                if (obj == null)
                {
                    html = cmsPage.GetIndex(null);
                    cache.Insert(cacheID, html, DateTime.Now.AddSeconds(Settings.Opti_IndexCacheSeconds));
                }
                else
                {
                    html = obj as string;
                }
            }
            else
            {
                //DateTime dt = DateTime.Now;
                html = cmsPage.GetIndex(null);
                //context.Render("<br />"+(DateTime.Now - dt).TotalMilliseconds.ToString() + "<br />");
            }

            //response.AddHeader("Cache-Control", "max-age=" + maxAge.ToString());
            context.Render(html);
        }
Esempio n. 21
0
 public async Task <bool> DeleteAsync(SiteDto site)
 => await Task.Run(() => Delete(_mapper.toEntity <Site>(site), true) > 0);
Esempio n. 22
0
        /// <summary>
        /// Gets the content management alerts.
        /// </summary>
        /// <returns></returns>
        private IEnumerable <Alert> GetContentManagementAlerts()
        {
            bool isAdmin = false;

            if (ProfileConfiguration.Instance.EnablePermissions)
            {
                isAdmin = ProfileContext.Current.CheckPermission("content:site:mng:edit");
            }
            else
            {
                isAdmin = SecurityManager.CheckPermission(new string[] { CmsRoles.AdminRole });
            }

            // Check if there are any sites
            SiteDto sitedto = CMSContext.Current.GetSitesDto(AppContext.Current.ApplicationId);

            if (sitedto.Site.Count == 0)
            {
                if (isAdmin)
                {
                    yield return(new Alert(String.Format("No sites found, please create a new <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-List\")'>here</a>  or import a sample site <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-Import\")'>here</a>."), AlertLevel.Error));
                }
                else
                {
                    yield return(new Alert(String.Format("No sites configured, please contact site admin."), AlertLevel.Error));
                }
            }
            else // check if there active sites
            {
                bool foundActive  = false;
                bool foundDefault = false;
                foreach (SiteDto.SiteRow site in sitedto.Site)
                {
                    if (site.IsActive)
                    {
                        foundActive = true;
                    }
                    if (site.IsDefault)
                    {
                        foundDefault = true;
                    }

                    // Check if urls are configured correctly, since that will cause some functions not to work correctly
                    bool?urlConfigured          = null;
                    bool urlLocalhostConfigured = false;
                    bool?foundAnalytics         = null;
                    SiteDto.main_GlobalVariablesRow[] varRows = site.Getmain_GlobalVariablesRows();

                    if (varRows.Length > 0)
                    {
                        foreach (SiteDto.main_GlobalVariablesRow varRow in varRows)
                        {
                            if (varRow.KEY.Equals("url", StringComparison.OrdinalIgnoreCase))
                            {
                                if (String.IsNullOrEmpty(varRow.VALUE))
                                {
                                    urlConfigured = false;
                                    continue;
                                }
                                else
                                {
                                    urlConfigured = true;

                                    if (varRow.VALUE.Contains("localhost"))
                                    {
                                        urlLocalhostConfigured = true;
                                    }

                                    continue;
                                }
                            }

                            if (varRow.KEY.Equals("cm_url", StringComparison.OrdinalIgnoreCase))
                            {
                                if (String.IsNullOrEmpty(varRow.VALUE))
                                {
                                    urlConfigured = false;
                                    continue;
                                }
                                else
                                {
                                    urlConfigured = true;
                                    continue;
                                }
                            }

                            if (varRow.KEY.Equals("page_include", StringComparison.OrdinalIgnoreCase))
                            {
                                if (String.IsNullOrEmpty(varRow.VALUE))
                                {
                                    foundAnalytics = false;
                                    continue;
                                }
                                else
                                {
                                    foundAnalytics = true;
                                    continue;
                                }
                            }
                        }
                    }
                    else
                    {
                        foundAnalytics = false;
                        urlConfigured  = false;
                    }

                    /*
                     * if (urlConfigured == null || !(bool)urlConfigured)
                     * {
                     *  if (isAdmin)
                     *      yield return new Alert(String.Format("The \"{0}\" site does not have Public or Admin URLs configured correctly. This will cause certain features to not work correctly. Please correct it by going <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-Edit\", \"siteid={1}\")'>here</a>.", site.Name, site.SiteId), AlertLevel.Error);
                     *  else
                     *      yield return new Alert(String.Format("The \"{0}\" site does not have Public or Admin URLs configured correctly. Please contact site admin.", site.Name), AlertLevel.Error);
                     * }
                     * */

                    if (foundAnalytics == null || !(bool)foundAnalytics)
                    {
                        if (isAdmin)
                        {
                            yield return(new Alert(String.Format("The <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-Edit\", \"siteid={1}\")'>\"{0}\"</a> site does not have Analytics configured, it is very important for a site to track visitors and such statistic as conversion rate. Please correct it by going <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-Edit\", \"siteid={1}\")'>here</a> or you can read more about this topic <a target=\"_blank\" href=\"http://docs.mediachase.com/doku.php?id=ecf:50:operations:analytics\">here</a>.", site.Name, site.SiteId), AlertLevel.Warning));
                        }
                        else
                        {
                            yield return(new Alert(String.Format("The \"{0}\" site does not have Analytics configured, it is very important for a site to track visitors and such statistic as conversion rate. Please contact site admin or read more about this topic <a target=\"_blank\" href=\"http://docs.mediachase.com/doku.php?id=ecf:50:operations:analytics\">here</a>.", site.Name, site.SiteId), AlertLevel.Warning));
                        }
                    }

                    if (urlLocalhostConfigured)
                    {
                        if (isAdmin)
                        {
                            yield return(new Alert(String.Format("The <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-Edit\", \"siteid={1}\")'>\"{0}\"</a> site has a public URL configured as localhost which will not work correctly for external users. Please correct it by going <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-Edit\", \"siteid={1}\")'>here</a>.", site.Name, site.SiteId), AlertLevel.Warning));
                        }
                        else
                        {
                            yield return(new Alert(String.Format("The \"{0}\" site has a public URL configured as localhost which will not work correctly for external users. Please contact site admin or read more about this topic <a target=\"_blank\" href=\"http://docs.mediachase.com/doku.php?id=ecf:50:operations:analytics\">here</a>.", site.Name, site.SiteId), AlertLevel.Warning));
                        }
                    }
                }

                if (!foundActive)
                {
                    if (isAdmin)
                    {
                        yield return(new Alert(String.Format("No active sites found, please make atleast one site active <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-List\")'>here</a>."), AlertLevel.Warning));
                    }
                    else
                    {
                        yield return(new Alert(String.Format("No active sites configured, please contact site admin."), AlertLevel.Warning));
                    }
                }

                if (!foundDefault)
                {
                    if (isAdmin)
                    {
                        yield return(new Alert(String.Format("No default site found, please make one site default <a href='javascript:CSManagementClient.ChangeView(\"Content\", \"Site-List\")'>here</a>."), AlertLevel.Warning));
                    }
                    else
                    {
                        yield return(new Alert(String.Format("No default sites configured, please contact site admin."), AlertLevel.Warning));
                    }
                }
            }
            yield return(null);
        }
Esempio n. 23
0
        /// <summary>
        /// Finds the site row from URL.
        /// </summary>
        /// <param name="ctx">The CTX.</param>
        /// <returns></returns>
        SiteDto.SiteRow FindSiteFromUrl(CMSContext ctx)
        {
            SiteDto.SiteRow siteRow = null;

            SiteDto sites = CMSContext.Current.GetSitesDto(CmsConfiguration.Instance.ApplicationId);

            string url           = ctx.SitePath;
            string defaultDomain = ctx.Context.Request.Url.Host.Replace("www.", string.Empty);
            string appPath       = ctx.Context.Request.ApplicationPath;
            Guid   siteId        = Guid.Empty;

            // Check if we have siteid reference
            if (!String.IsNullOrEmpty(ctx.Context.Request["siteid"]))
            {
                siteId = new Guid(ctx.Context.Request["siteid"]);
            }

            // Match score is used to score the URL matching site definitions, the higher the score, the better the match,
            // it is used to prevent lower matches overwriting higher matched
            int matchScore = 0;

            if (appPath == "/")
            {
                appPath = String.Empty;
            }

            foreach (SiteDto.SiteRow row in sites.Site.Rows)
            {
                // Check if site is active
                if (!row.IsActive)
                {
                    continue;
                }

                // Check if we reference specific site id
                if (siteId != Guid.Empty && row.SiteId == siteId)
                {
                    ctx.AppPath = row.Folder;

                    if (String.IsNullOrEmpty(ctx.AppPath))
                    {
                        ctx.AppPath = "/";
                    }

                    siteRow = row;
                    return(siteRow);
                }

                // Check if site is default
                if (row.IsDefault && siteRow == null)
                {
                    siteRow = row;
                }

                // Split domains
                string   rowDomain = row.Domain.Replace("\r\n", "\n");
                string[] domains   = rowDomain.Split(new char[] { '\n' });

                // Cycle through domains
                foreach (string domain in domains)
                {
                    int    domainScoreModifier = 0;
                    string d = domain;
                    if (String.IsNullOrEmpty(domain))
                    {
                        d = defaultDomain;
                    }
                    else
                    {
                        domainScoreModifier = 100;
                    }

                    if (url.Equals(d + row.Folder, StringComparison.OrdinalIgnoreCase))
                    {
                        // Check matching score
                        int newMatchScore = (row.Folder).Length + domainScoreModifier;
                        if (newMatchScore <= matchScore)
                        {
                            continue;
                        }
                        matchScore  = newMatchScore;
                        ctx.AppPath = row.Folder;

                        if (String.IsNullOrEmpty(ctx.AppPath))
                        {
                            ctx.AppPath = "/";
                        }

                        siteRow = row;
                    }
                    else if (url.Equals(d + appPath + row.Folder, StringComparison.OrdinalIgnoreCase))
                    {
                        // Check matching score
                        int newMatchScore = (appPath + row.Folder).Length + domainScoreModifier;
                        if (newMatchScore <= matchScore)
                        {
                            continue;
                        }
                        matchScore  = newMatchScore;
                        ctx.AppPath = appPath + row.Folder;

                        if (String.IsNullOrEmpty(ctx.AppPath))
                        {
                            ctx.AppPath = "/";
                        }

                        siteRow = row;
                    }
                    else if (url.StartsWith(d + appPath + row.Folder, StringComparison.OrdinalIgnoreCase))
                    {
                        // Check matching score
                        int newMatchScore = (appPath + row.Folder).Length + domainScoreModifier;
                        if (newMatchScore <= matchScore)
                        {
                            continue;
                        }

                        matchScore  = newMatchScore;
                        ctx.AppPath = appPath + row.Folder;

                        if (String.IsNullOrEmpty(ctx.AppPath))
                        {
                            ctx.AppPath = "/";
                        }

                        siteRow = row;
                    }
                    else if (url.StartsWith(d + row.Folder, StringComparison.OrdinalIgnoreCase))
                    {
                        // Check matching score
                        int newMatchScore = (row.Folder).Length + domainScoreModifier;
                        if (newMatchScore <= matchScore)
                        {
                            continue;
                        }

                        matchScore  = newMatchScore;
                        ctx.AppPath = row.Folder;

                        if (String.IsNullOrEmpty(ctx.AppPath))
                        {
                            ctx.AppPath = "/";
                        }

                        siteRow = row;
                    }
                }
            }

            return(siteRow);
        }
Esempio n. 24
0
 private string GetTitleField(SiteDto siteDto) =>
 (!string.IsNullOrWhiteSpace(siteDto.Title))
     ? siteDto.Title
     : (!string.IsNullOrWhiteSpace(siteDto.Name)) ? siteDto.Name : Constants.NO_DATA;
Esempio n. 25
0
        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <param name="context">The context.</param>
        public void SaveChanges(IDictionary context)
        {
            SiteDto dto = (SiteDto)context[_SiteDtoDestinationString];

            SiteDto.SiteRow row = null;

            if (dto.Site != null && dto.Site.Count > 0)
            {
                row = dto.Site[0];
            }
            else
            {
                if (!String.IsNullOrEmpty(SiteTemplatesList.SelectedValue))
                {
                    // create site from template
                    FileStream         fs     = new FileStream(SiteTemplatesList.SelectedValue, FileMode.Open, FileAccess.Read);
                    ImportExportHelper helper = new ImportExportHelper();
                    Guid[]             ids    = helper.ImportSite(fs, mc.CmsConfiguration.Instance.ApplicationId, Guid.Empty, true);
                    if (ids.Length > 0)
                    {
                        context[_SiteDtoDestinationString] = mc.CMSContext.Current.GetSiteDto(ids[0], true);
                        dto = (SiteDto)context[_SiteDtoDestinationString];
                        if (dto.Site.Count > 0)
                        {
                            row = dto.Site[0];
                        }
                        else
                        {
                            throw new Exception(String.Format("Could not load the site after importing. id={0}", ids[0]));
                        }
                    }
                    else
                    {
                        throw new Exception("Import function did not return siteId.");
                    }
                }
                else
                {
                    row               = dto.Site.NewSiteRow();
                    row.SiteId        = Guid.NewGuid();
                    row.ApplicationId = mc.CmsConfiguration.Instance.ApplicationId;
                }
            }

            row.Name        = SiteName.Text;
            row.Description = SiteDescription.Text;
            row.IsActive    = IsSiteActive.IsSelected;
            row.IsDefault   = IsSiteDefault.IsSelected;
            row.Folder      = SiteFolder.Text;
            row.Domain      = SiteDomains.Text;

            if (row.RowState == DataRowState.Detached)
            {
                dto.Site.Rows.Add(row);

                /*
                 *
                 * SiteDto.ApplicationSiteRow appRow = dto.ApplicationSite.NewApplicationSiteRow();
                 * appRow.SiteId = row.SiteId;
                 * appRow.ApplicationId = CatalogConfiguration.ApplicationId;
                 * dto.ApplicationSite.Rows.Add(appRow);
                 * */
            }

            // Populate languages
            // Remove existing languages
            foreach (SiteDto.SiteLanguageRow langRow in dto.SiteLanguage.Rows)
            {
                if (langRow.RowState == DataRowState.Deleted)
                {
                    continue;
                }

                bool found = false;
                foreach (ListItem item in LanguageList.RightItems)
                {
                    if (item.Value.Equals(langRow.LanguageCode))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    langRow.Delete();
                }
            }

            foreach (ListItem item in LanguageList.RightItems)
            {
                bool exists = false;
                foreach (SiteDto.SiteLanguageRow langRow in dto.SiteLanguage.Rows)
                {
                    if (langRow.RowState != DataRowState.Deleted)
                    {
                        if (langRow.LanguageCode.Equals(item.Value))
                        {
                            exists = true;
                        }
                    }
                }

                if (!exists)
                {
                    SiteDto.SiteLanguageRow langRow = dto.SiteLanguage.NewSiteLanguageRow();
                    langRow.SiteId       = row.SiteId;
                    langRow.LanguageCode = item.Value;
                    dto.SiteLanguage.Rows.Add(langRow);
                }
            }
        }
Esempio n. 26
0
 private static void SetCurrentSiteToSession(HttpContext context, SiteDto site)
 {
     context.Session[CurrentSiteSessionStr] = site;
 }
Esempio n. 27
0
 public Site(SiteDto dto)
 {
     _dto = dto;
     teamColl = new List<Team>();
 }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SiteAdmin"/> class.
 /// </summary>
 internal SiteAdmin()
 {
     _DataSet = new SiteDto();
 }