当前位置: 首页>>代码示例>>C#>>正文


C# Domain.Site类代码示例

本文整理汇总了C#中Cuyahoga.Core.Domain.Site的典型用法代码示例。如果您正苦于以下问题:C# Site类的具体用法?C# Site怎么用?C# Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Site类属于Cuyahoga.Core.Domain命名空间,在下文中一共展示了Site类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteSite

        public void DeleteSite(Site site)
        {
            if (site.RootNodes.Count > 0)
            {
                throw new Exception("Can't delete a site when there are still related nodes. Please delete all nodes before deleting an entire site.");
            }
            else
            {
                IList aliases = this._siteStructureDao.GetSiteAliasesBySite(site);
                if (aliases.Count > 0)
                {
                    throw new Exception("Unable to delete a site when a site has related aliases.");
                }
                else
                {
                    try
                    {
                        // We need to use a specific DAO to also enable clearing the query cache.
                        this._siteStructureDao.DeleteSite(site);
                    }
                    catch (Exception ex)
                    {
                        log.Error("Error deleting site", ex);
                        throw;
                    }

                }
            }
        }
开发者ID:martijnboland,项目名称:cuyahoga-1,代码行数:29,代码来源:SiteService.cs

示例2: Create

        public ActionResult Create(int defaultRoleId, int[] templateIds)
        {
            Site site = new Site();
            try
            {
                UpdateModel(site, new [] { "Name", "SiteUrl", "WebmasterEmail", "UserFriendlyUrls", "DefaultCulture"});
                site.DefaultRole = this._userService.GetRoleById(defaultRoleId);
                if (ValidateModel(site))
                {
                    IList<Template> templates = new List<Template>();
                    if (templateIds.Length > 0)
                    {
                        templates = this._templateService.GetAllSystemTemplates().Where(t => templateIds.Contains(t.Id)).ToList();
                    }
                    string systemTemplateDir = Server.MapPath(Config.GetConfiguration()["TemplateDir"]);
                    this._siteService.CreateSite(site, Server.MapPath("~/SiteData"), templates, systemTemplateDir);

                    return RedirectToAction("CreateSuccess", new { siteId = site.Id });
                }
            }
            catch (Exception ex)
            {
                Messages.AddException(ex);
            }
            ViewData["Roles"] = new SelectList(this._userService.GetAllGlobalRoles(), "Id", "Name", site.DefaultRole.Id);
            ViewData["Cultures"] = new SelectList(Globalization.GetOrderedCultures(), "Key", "Value", site.DefaultCulture);
            ViewData["Templates"] = this._templateService.GetAllSystemTemplates();
            return View("NewSite", site);
        }
开发者ID:xwyangjshb,项目名称:cuyahoga,代码行数:29,代码来源:SiteController.cs

示例3: DeleteSiteUsers

        public void DeleteSiteUsers(Site site)
        {
            ISession session = this._sessionManager.OpenSession();
            //IList<User> siteUsers = GetUsersBySiteID(site.Id);
            foreach (User u in site.Users)
            {
                if (u.Sites != null && u.Sites.Count > 1)
                {
                    u.Sites.Remove(site);
                }
                else
                {
                    session.Delete(u);
                }
            }

            //Need to find a better way to handle large numbers of users?
            //
            //ISession session = this._sessionManager.OpenSession();

            //string deletesql = " DELETE FROM cuyahoga_user " +
            //                   " FROM cuyahoga_user INNER JOIN " +
            //                   " cuyahoga_userrole ON cuyahoga_user.userid = cuyahoga_userrole.userid " +
            //                   " WHERE cuyahoga_user.siteid = " + site.Id.ToString(); //add [; select @@ROWCOUNT count;] after delete query to get number of deleted users

            //Object result = session.CreateSQLQuery(deletesql)
            //    .AddScalar("count", NHibernateUtil.Int32)
            //    .UniqueResult();
        }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:29,代码来源:UserDao.cs

示例4: GetAllRootCategories

 /// <summary>
 /// Gets all root categories, ordered by path for a given site
 /// </summary>
 /// <returns></returns>
 public IList<Category> GetAllRootCategories(Site site)
 {
     ISession session = this.sessionManager.OpenSession();
     string hql = "from Cuyahoga.Core.Domain.Category c where c.Site = :site and c.ParentCategory is null order by c.Path asc";
     IQuery query = session.CreateQuery(hql);
     query.SetParameter("site", site);
     return query.List<Category>();
 }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:12,代码来源:CategoryDao.cs

示例5: DeleteSiteUsers

 public void DeleteSiteUsers(Site site)
 {
     User currentUser = Thread.CurrentPrincipal as User;
     if (currentUser.Sites.Contains(site))
     {
         throw new DeleteForbiddenException("DeleteYourselfNotAllowedException");
     }
     this._userDao.DeleteSiteUsers(site);
 }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:9,代码来源:DefaultUserService.cs

示例6: ApplyTemplateAllNodesInSite

 public void ApplyTemplateAllNodesInSite(Template template, Site site)
 {
     ISession session = this._sessionManager.OpenSession();
     string sql = "UPDATE cuyahoga_node  SET templateid = :Template  WHERE (siteid = :Site)";
     ISQLQuery SQLQuery = session.CreateSQLQuery(sql);
     SQLQuery.SetInt32("Template", template.Id);
     SQLQuery.SetInt32("Site", site.Id);
     SQLQuery.ExecuteUpdate();
 }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:9,代码来源:SiteStructureDao.cs

示例7: GetByPathByParent

 /// <summary>
 /// Gets categories by the specified partial category path, ordered by path
 /// </summary>
 /// <param name="path"></param>
 public IList<Category> GetByPathByParent(Site site, string path)
 {
     ISession session = this.sessionManager.OpenSession();
         string hql = "from Cuyahoga.Core.Domain.Category c where c.Site = :site and c.Path like :path order by c.Path asc";
         IQuery query = session.CreateQuery(hql);
         query.SetEntity("site", site);
         query.SetString("path", string.Concat(path, "%"));
         return query.List<Category>();
 }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:13,代码来源:CategoryDao.cs

示例8: CreateSite

        public virtual void CreateSite(Site site, string siteDataRoot, IList<Template> templatesToCopy, string systemTemplatesDirectory)
        {
            try
            {
                // 1. Add global roles to site
                IList<Role> roles = this._commonDao.GetAll<Role>();
                foreach (Role role in roles)
                {
                    if (role.IsGlobal)
                    {
                        site.Roles.Add(role);
                    }
                }

                // 2. Save site in database
                this._commonDao.SaveObject(site);

                // 3. Create SiteData folder structure
                if (! this._fileService.CheckIfDirectoryIsWritable(siteDataRoot))
                {
                    throw new IOException(string.Format("Unable to create the site because the directory {0} is not writable.", siteDataRoot));
                }
                string siteDataPhysicalDirectory = Path.Combine(siteDataRoot, site.Id.ToString());
                this._fileService.CreateDirectory(siteDataPhysicalDirectory);
                this._fileService.CreateDirectory(Path.Combine(siteDataPhysicalDirectory, "UserFiles"));
                this._fileService.CreateDirectory(Path.Combine(siteDataPhysicalDirectory, "index"));
                string siteTemplatesDirectory = Path.Combine(siteDataPhysicalDirectory, "Templates");
                this._fileService.CreateDirectory(siteTemplatesDirectory);

                // 4. Copy templates
                IList<string> templateDirectoriesToCopy = new List<string>();
                foreach (Template template in templatesToCopy)
                {
                    string templateDirectoryName = template.BasePath.Substring(template.BasePath.IndexOf("/") + 1);
                    if (! templateDirectoriesToCopy.Contains(templateDirectoryName))
                    {
                        templateDirectoriesToCopy.Add(templateDirectoryName);
                    }
                    Template newTemplate = template.GetCopy();
                    newTemplate.Site = site;
                    site.Templates.Add(newTemplate);
                    this._commonDao.SaveOrUpdateObject(newTemplate);
                    this._commonDao.SaveOrUpdateObject(site);
                }
                foreach (string templateDirectory in templateDirectoriesToCopy)
                {
                    string sourceDir = Path.Combine(systemTemplatesDirectory, templateDirectory);
                    string targetDir = Path.Combine(siteTemplatesDirectory, templateDirectory);
                    this._fileService.CopyDirectoryContents(sourceDir, targetDir);
                }
            }
            catch (Exception ex)
            {
                log.Error("An unexpected error occured while creating a new site.", ex);
                throw;
            }
        }
开发者ID:xwyangjshb,项目名称:cuyahoga,代码行数:57,代码来源:SiteService.cs

示例9: GetByExactPathAndSite

 /// <summary>
 /// Gets a category by the specified category path
 /// </summary>
 /// <param name="path"></param>
 public Category GetByExactPathAndSite(Site site, string path)
 {
     ISession session = this.sessionManager.OpenSession();
         string hql = "from Cuyahoga.Core.Domain.Category c where c.Site = :site and c.Path = :path";
         IQuery query = session.CreateQuery(hql);
         query.SetEntity("site", site);
         query.SetString("path", path);
         return query.UniqueResult<Category>();
 }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:13,代码来源:CategoryDao.cs

示例10: GetCultureRootNodesBySite

 /// <summary>
 /// Get a dictionary of rootnodes for the current site with the culture as the key.
 /// </summary>
 /// <param name="site"></param>
 /// <returns></returns>
 public Dictionary<string, Node> GetCultureRootNodesBySite(Site site)
 {
     IList<Node> rootNodes = this._nodeService.GetRootNodes(site);
     Dictionary<string, Node> cultureNodes = new Dictionary<string, Node>(rootNodes.Count);
     foreach (Node node in rootNodes)
     {
         cultureNodes.Add(node.Culture, node);
     }
     return cultureNodes;
 }
开发者ID:xwyangjshb,项目名称:cuyahoga,代码行数:15,代码来源:LanguageSwitcherModule.cs

示例11: DeleteSite

        public void DeleteSite(Site site)
        {
            ISession session = this._sessionManager.OpenSession();

            // Clear query cache first
            session.SessionFactory.EvictQueries("Sites");

            // Delete site
            session.Delete(site);
        }
开发者ID:martijnboland,项目名称:cuyahoga-1,代码行数:10,代码来源:SiteStructureDao.cs

示例12: CreateRootNode

 public Node CreateRootNode(Site site, Node newNode)
 {
     // ShortDescription is equal to language part of culture by default.
         CultureInfo ci = new CultureInfo(newNode.Culture);
         newNode.ShortDescription = ci.TwoLetterISOLanguageName;
         newNode.Site = site;
         newNode.Position = site.RootNodes.Count;
         site.RootNodes.Add(newNode);
         this._commonDao.SaveObject(newNode);
         return newNode;
 }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:11,代码来源:NodeService.cs

示例13: CreateUser

        public string CreateUser(string username, string email, Site currentSite)
        {
            User user = new User();
            user.UserName = username;
            user.Email = email;
            user.IsActive = true;
            string newPassword = user.GeneratePassword();
            // Add the default role from the current site.
            user.Roles.Add(currentSite.DefaultRole);
            this._commonDao.SaveOrUpdateObject(user);

            return newPassword;
        }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:13,代码来源:DefaultUserService.cs

示例14: DeleteSiteTemplates

        public void DeleteSiteTemplates(Site site)
        {
            ISession session = this._sessionManager.OpenSession();

            //Count before
            int templatecount = site.Templates.Count - 1;

            for (int i = 0; i <= templatecount; i++)
            {
                Template t = site.Templates[0];
                site.Templates.Remove(t);
                session.Delete(t);
            }
            site.DefaultTemplate = null;
            session.Save(site);
            session.Flush();
        }
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:17,代码来源:SiteStructureDao.cs

示例15: FindCategoryByTitleAndSite

        public virtual ArticleCategory FindCategoryByTitleAndSite(string title, Site site)
        {
            string hql = "from Cuyahoga.Modules.Articles.Domain.Category c where lower(c.Title) = :title and c.Site.Id = :siteId";
            ISession session = this._sessionManager.OpenSession();

            // HACK: set the FlushMode of the session to temporarily to Commit because this method is being called in a transaction
            // (in ArticleModule.cs) and we have to prevent Flushing until the transaction is comitted.
            FlushMode originalFlushMode = session.FlushMode;
            session.FlushMode = FlushMode.Commit;

            IQuery q = this._sessionManager.OpenSession().CreateQuery(hql);
            q.SetString("title", title.ToLower(CultureInfo.InvariantCulture));
            q.SetInt32("siteId", site.Id);
            ArticleCategory category = q.UniqueResult() as ArticleCategory;
            session.FlushMode = originalFlushMode;
            return category;
        }
开发者ID:martijnboland,项目名称:cuyahoga-1,代码行数:17,代码来源:ArticleDao.cs


注:本文中的Cuyahoga.Core.Domain.Site类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。