本文整理汇总了C#中Cuyahoga.Core.Domain.Site类的典型用法代码示例。如果您正苦于以下问题:C# Site类的具体用法?C# Site怎么用?C# Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Site类属于Cuyahoga.Core.Domain命名空间,在下文中一共展示了Site类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetNodesBySite
// added for 1.6.0
public IList GetNodesBySite( Site site )
{
ISession session = this._sessionManager.OpenSession();
string hql = "from Node n where n.Site.Id = :siteId ";
IQuery q = session.CreateQuery( hql );
q.SetInt32( "siteId", site.Id );
return q.List();
}
开发者ID:martijnboland,项目名称:cuyahoga-1,代码行数:10,代码来源:SiteStructureDao.cs
示例17: GetRootNodeByCultureAndSite
public Node GetRootNodeByCultureAndSite(string culture, Site site)
{
ISession session = this._sessionManager.OpenSession();
string hql = "from Node n where n.ParentNode is null and n.Culture = :culture and n.Site.Id = :siteId";
IQuery q = session.CreateQuery(hql);
q.SetString("culture", culture);
q.SetInt32("siteId", site.Id);
q.SetCacheable(true);
q.SetCacheRegion("Nodes");
IList results = q.List();
if (results.Count == 1)
{
return results[0] as Node;
}
else if (results.Count == 0)
{
throw new NodeNullException(String.Format("No root node found for culture {0} and site {1}.", culture, site.Id));
}
else
{
throw new Exception(String.Format("Multiple root nodes found for culture {0} and site {1}.", culture, site.Id));
}
}
开发者ID:martijnboland,项目名称:cuyahoga-1,代码行数:24,代码来源:SiteStructureDao.cs
示例18: CreateNewNodeControl
private Control CreateNewNodeControl(Site site, HtmlGenericControl container)
{
string imgFolder = UrlHelper.GetSiteUrl() + "/Admin/Images/";
Image img = new Image();
img.ImageUrl = imgFolder + "sitepage-new-home.png";
img.ImageAlign = ImageAlign.Left;
img.AlternateText = "New Node";
container.Controls.Add(img);
HyperLink hpl = new HyperLink();
hpl.Text = "Add new root node";
hpl.NavigateUrl = String.Format("NodeEdit.aspx?SiteId={0}&NodeId=-1", site.Id.ToString());
hpl.CssClass = "navLink";
container.Controls.Add(hpl);
return container;
}
开发者ID:constructor,项目名称:Cuyahoga,代码行数:16,代码来源:AdminService.asmx.cs
示例19: CreateDisplaySite
private HtmlGenericControl CreateDisplaySite(Site site)
{
string imgFolder = UrlHelper.GetSiteUrl() + "/Admin/Images/";
string adminUrl = UrlHelper.GetSiteUrl() + "/Admin/";
HtmlGenericControl container = new HtmlGenericControl("div");
container.Attributes.Add("class", "sitepanel");
container.Attributes.Add("id", "site" + site.Id.ToString());
HtmlGenericControl siteul = new HtmlGenericControl("ul");
container.Controls.Add(siteul);
HtmlGenericControl siteli = new HtmlGenericControl("li");
siteli.Attributes.Add("class", "site");
siteli.Attributes.Add("site", site.Id.ToString());
siteul.Controls.Add(siteli);
Image img = new Image();
img.ImageUrl = imgFolder + "site.png";
img.ImageAlign = ImageAlign.Left;
img.AlternateText = "Site";
siteli.Controls.Add(img);
HyperLink hpl = new HyperLink();
hpl.Text = String.Format("{0}", site.SiteUrl);
hpl.NavigateUrl = String.Format("{0}SiteEdit.aspx?SiteId={1}", adminUrl, site.Id.ToString());
hpl.CssClass = "nodeLink";
siteli.Controls.Add(hpl);
DisplayNodes(site.RootNodes, siteli);
return container;
}
开发者ID:constructor,项目名称:Cuyahoga,代码行数:32,代码来源:AdminService.asmx.cs
示例20: ConnectRoleToSites
private void ConnectRoleToSites(Role role, Site currentSite)
{
role.Sites.Clear();
// If role is global, it has to be connected to all sites
if (role.IsGlobal)
{
// First check if the user is allowed to connect to all sites.
CheckGlobalRole(role);
IList<Site> allSites = this._commonDao.GetAll<Site>();
foreach (Site site in allSites)
{
role.Sites.Add(site);
}
}
else
{
role.Sites.Add(currentSite);
}
}
开发者ID:martijnboland,项目名称:Cuyahoga-Constructor,代码行数:20,代码来源:DefaultUserService.cs
注:本文中的Cuyahoga.Core.Domain.Site类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论