public ActionResult UpdateSection(int id) { Section section = this._sectionService.GetSectionById(id); UpdateSectionSettingsFromForm(section, SettingsFormElementPrefix); try { if (TryUpdateModel(section, "section", new[] { "Title", "ShowTitle", "CacheDuration" }) && ValidateModel(section, new[] { "Title", "Settings" }, "section")) { this._sectionService.UpdateSection(section); Messages.AddMessage("SectionPropertiesUpdatedMessage"); } } catch (Exception ex) { Logger.Error("Unexpected error while updating section.", ex); Messages.AddException(ex); } var sectionViewData = BuildSectionViewData(section); if (Request.IsAjaxRequest()) { return(PartialView("SelectedSection", sectionViewData)); } else { return(View("SectionProperties", sectionViewData)); } }
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)); }
public override IMessages Run() { Messages messages = new Messages(); try { dynamic parser = new XmlParser(this.FileName); var environments = parser.Environments.Environment as IEnumerable <XmlParser>; dynamic environment = parser.Environments.Environment; while (environment.HasNext()) { if (environment["id"] != this.EnvironmentId) { environment.MoveNext(); } else { break; } } environment.IafDesktop.Create("Rendering", false).Create("UseGridsByDefault", this.UseGridsByDefault, false); parser.Save(); } catch (Exception e) { messages.AddException(e); } return(messages); }
public ActionResult Create([Bind(Exclude = "Id")] FileResource fileResource, HttpPostedFileBase fileData, int[] roleIds, string categoryids) { BindCategoriesAndRoles(fileResource, categoryids, roleIds); if (fileData != null && fileData.ContentLength > 0) { fileResource.Section = CurrentSection; fileResource.FileName = fileData.FileName; fileResource.PhysicalFilePath = Path.Combine(this._module.FileDir, fileResource.FileName); fileResource.Length = fileData.ContentLength; fileResource.MimeType = fileData.ContentType; if (ValidateModel(fileResource, new[] { "Title", "Summary", "FileName", "PublishedAt", "PublishedUntil" })) { try { this._fileResourceService.SaveFileResource(fileResource, fileData.InputStream); Messages.AddFlashMessage("FileSavedMessage"); return(RedirectToAction("Index", "ManageFiles", GetNodeAndSectionParams())); } catch (Exception ex) { Messages.AddException(ex); } } } else { Messages.AddErrorMessage("NoFileUploadedMessage"); } ViewData["Roles"] = this._userService.GetAllRolesBySite(CuyahogaContext.CurrentSite); return(View("New", GetModuleAdminViewModel(fileResource))); }
public ActionResult Update(long id, string categoryids) { Article article = this._contentItemService.GetById(id); // TODO: handle Categories etc. more generic. // Categories article.Categories.Clear(); if (!String.IsNullOrEmpty(categoryids)) { foreach (string categoryIdString in categoryids.Split(',')) { article.Categories.Add(this._categoryService.GetCategoryById(Convert.ToInt32(categoryIdString))); } } if (TryUpdateModel(article, new[] { "Title", "Summary", "Content", "Syndicate", "PublishedAt", "PublishedUntil" }) && ValidateModel(article, new[] { "Title", "Summary", "Content", "PublishedAt", "PublishedUntil" })) { try { this._contentItemService.Save(article); Messages.AddFlashMessageWithParams("ArticleUpdatedMessage", article.Title); return(RedirectToAction("Index", GetNodeAndSectionParams())); } catch (Exception ex) { Messages.AddException(ex); } return(RedirectToAction("Index", GetNodeAndSectionParams())); } return(View("Edit", GetModuleAdminViewModel(article))); }
public ActionResult UpdateRole(int id, int[] rightIds) { Role role = this._userService.GetRoleById(id); role.Rights.Clear(); try { UpdateModel(role, "role"); if (rightIds != null && rightIds.Length > 0) { IList <Right> rights = this._userService.GetRightsByIds(rightIds); foreach (Right right in rights) { role.Rights.Add(right); } } if (ValidateModel(role, this._roleModelValidator, new[] { "Name" })) { this._userService.UpdateRole(role, CuyahogaContext.CurrentSite); Messages.AddFlashMessageWithParams("RoleUpdatedMessage", role.Name); return(RedirectToAction("Roles")); } } catch (Exception ex) { Messages.AddException(ex); } ViewData["Title"] = GetText("EditRolePageTitle"); ViewData["Rights"] = this._userService.GetAllRights(); return(View("EditRole", role)); }
public ActionResult DeleteConnection(int sectionId, string actionName) { Section section = this._sectionService.GetSectionById(sectionId); try { section.Connections.Remove(actionName); this._sectionService.UpdateSection(section); Messages.AddMessageWithParams("ConnectionDeletedMessage", actionName); } catch (Exception ex) { Messages.AddException(ex); } if (Request.IsAjaxRequest()) { var sectionViewData = BuildSectionViewData(section); sectionViewData.ExpandConnections = true; return(PartialView("SelectedSection", sectionViewData)); } else { throw new NotImplementedException("DeleteConnection not yet implemented for non-AJAX scenario's"); } }
private Messages ReadMessages(string messagesFile) { Messages messages = new Messages(); if (!File.Exists(messagesFile)) { messages.AddWarning(string.Format("The report file {0} doesn't exist", messagesFile)); return(messages); } var parser = XElement.Load(messagesFile); foreach (var message in parser.Descendants("anyType")) { var resultState = message.Attribute("Type").Value; if (resultState != "error") { continue; } var description = message.Attribute("Description").Value; messages.AddException(new Exception(description)); } return(messages); }
public ActionResult UpdateAlias(int id, int?entryNodeId) { Site currentSite = CuyahogaContext.CurrentSite; SiteAlias siteAlias = this._siteService.GetSiteAliasById(id); try { if (entryNodeId.HasValue) { siteAlias.EntryNode = this._nodeService.GetNodeById(entryNodeId.Value); } else { siteAlias.EntryNode = null; } if (TryUpdateModel(siteAlias, new [] { "Url" }) && ValidateModel(siteAlias, this._siteAliasValidator, new[] { "Site", "Url" })) { this._siteService.SaveSiteAlias(siteAlias); Messages.AddFlashMessageWithParams("SiteAliasUpdatedMessage", siteAlias.Url); return(RedirectToAction("Aliases")); } } catch (Exception ex) { Messages.AddException(ex); } ViewData["Site"] = currentSite; ViewData["EntryNodes"] = new SelectList(GetDisplayRootNodes(currentSite), "Key", "Value", siteAlias.EntryNode != null ? siteAlias.EntryNode.Id : -1); return(View("NewAlias", currentSite)); }
public ActionResult Create(int[] roleIds) { User newUser = new User(); try { UpdateModel(newUser, new [] { "UserName", "FirstName", "LastName", "Email", "Website", "IsActive", "TimeZone" }); newUser.Password = CuyahogaUser.HashPassword(Request.Form["Password"]); newUser.PasswordConfirmation = CuyahogaUser.HashPassword(Request.Form["PasswordConfirmation"]); if (roleIds != null && roleIds.Length > 0) { IList <Role> roles = this._userService.GetRolesByIds(roleIds); foreach (Role role in roles) { newUser.Roles.Add(role); } } if (ValidateModel(newUser)) { this._userService.CreateUser(newUser); Messages.AddFlashMessageWithParams("UserCreatedMessage", newUser.UserName); return(RedirectToAction("Index")); } } catch (Exception ex) { Messages.AddException(ex); } ViewData["Roles"] = this._userService.GetAllRolesBySite(CuyahogaContext.CurrentSite); ViewData["TimeZones"] = new SelectList(TimeZoneUtil.GetTimeZones(), "Key", "Value", newUser.TimeZone); return(View("NewUser", newUser)); }
public ActionResult Update(int id, int defaultRoleId, int defaultTemplateId) { Site site = this._siteService.GetSiteById(id); try { UpdateModel(site, new [] { "Name", "SiteUrl", "WebmasterEmail", "UserFriendlyUrls", "DefaultCulture", "DefaultPlaceholder", "MetaDescription", "MetaKeywords" }); site.DefaultRole = this._userService.GetRoleById(defaultRoleId); site.DefaultTemplate = this._templateService.GetTemplateById(defaultTemplateId); if (ValidateModel(site)) { this._siteService.SaveSite(site); Messages.AddMessage("SiteUpdatedMessage"); RedirectToAction("Index"); } } 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"] = new SelectList(site.Templates, "Id", "Name", site.DefaultTemplate != null ? site.DefaultTemplate.Id : 0); if (site.DefaultTemplate != null) { string virtualTemplatePath = VirtualPathUtility.Combine(site.SiteDataDirectory, site.DefaultTemplate.Path); ViewData["PlaceHolders"] = new SelectList(ViewUtil.GetPlaceholdersFromVirtualPath(virtualTemplatePath).Keys, site.DefaultPlaceholder); } return(View("EditSite", site)); }
public ActionResult CreateAlias([Bind(Exclude = "Id")] SiteAlias siteAlias, int?entryNodeId) { Site currentSite = CuyahogaContext.CurrentSite; try { siteAlias.Site = currentSite; if (entryNodeId.HasValue) { siteAlias.EntryNode = this._nodeService.GetNodeById(entryNodeId.Value); } if (ValidateModel(siteAlias, this._siteAliasValidator, new[] { "Site", "Url" })) { this._siteService.SaveSiteAlias(siteAlias); Messages.AddFlashMessageWithParams("SiteAliasCreatedMessage", siteAlias.Url); return(RedirectToAction("Aliases")); } } catch (Exception ex) { Messages.AddException(ex); } ViewData["Site"] = currentSite; ViewData["EntryNodes"] = new SelectList(GetDisplayRootNodes(currentSite), "Key", "Value", entryNodeId.HasValue ? entryNodeId.Value : -1); return(View("NewAlias", siteAlias)); }
public ActionResult Login(string returnUrl) { var loginUser = new LoginViewData(); try { if (TryUpdateModel(loginUser) && ValidateModel(loginUser)) { User user = this._authenticationService.AuthenticateUser(loginUser.Username, loginUser.Password, Request.UserHostAddress); FormsAuthentication.SetAuthCookie(user.Id.ToString(), false); if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Dashboard")); } } catch (AuthenticationException ex) { Logger.WarnFormat("User {0} unsuccesfully logged in with password {1}.", loginUser.Username, loginUser.Password); Messages.AddException(ex); } catch (Exception ex) { Logger.Error("Unexpected error while logging in", ex); Messages.AddException(ex); } return(View("Index", loginUser)); }
public ActionResult Update(int id, int?parentCategoryId) { Category category = this._categoryService.GetCategoryById(id); if (parentCategoryId.HasValue) { category.SetParentCategory(this._categoryService.GetCategoryById(parentCategoryId.Value)); } else { category.SetParentCategory(null); } if (TryUpdateModel(category) && ValidateModel(category)) { try { this._categoryService.UpdateCategory(category); Messages.AddFlashMessageWithParams("CategoryUpdatedMessage", category.Name); return(RedirectToAction("Index")); } catch (Exception ex) { Messages.AddException(ex); } } SetupParentCategoriesViewData(category); return(View("Edit", category)); }
public ActionResult Create([Bind(Exclude = "Id")] Category category, int?parentCategoryId) { category.Site = CuyahogaContext.CurrentSite; if (parentCategoryId.HasValue) { category.SetParentCategory(this._categoryService.GetCategoryById(parentCategoryId.Value)); } else { category.SetParentCategory(null); } if (ValidateModel(category)) { try { this._categoryService.CreateCategory(category); Messages.AddFlashMessageWithParams("CategoryCreatedMessage", category.Name); return(RedirectToAction("Index")); } catch (Exception ex) { Messages.AddException(ex); } } SetupParentCategoriesViewData(category); return(View("New", category)); }
public override IMessages Run() { Messages messages = new Messages(); string fileName = Path.Combine(Directory.GetCurrentDirectory(), this.AssemblyPath); if (!File.Exists(fileName)) { messages.AddWarning(string.Format("The tester assembly {0} doesn't exist.", fileName)); return(messages); } try { var nunitConsolePath = Path.Combine(RegistryUtilities.ReadDefaultValue(@"HKEY_CURRENT_USER\SOFTWARE\nunit.org\NUnit\2.5.7", "InstallDir"), @"bin\net-2.0\nunit-console.exe"); if (!File.Exists(nunitConsolePath)) { messages.AddWarning(string.Format("The nunit console path {0} doesn't exist.", nunitConsolePath)); return(messages); } SystemUtilities.StartProcess(nunitConsolePath, string.Format("{0} /xml:{1}", fileName, this.OutputPath, this.HideWindow), 1000); messages = this.ReadMessages(this.OutputPath); } catch (Exception e) { messages.AddException(e); } return(messages); }
public ActionResult Update(int id, int[] roleIds) { User user = this._userService.GetUserById(id); user.Roles.Clear(); try { UpdateModel(user, new[] { "UserName", "FirstName", "LastName", "Email", "Website", "IsActive", "TimeZone" }); if (roleIds != null && roleIds.Length > 0) { IList <Role> roles = this._userService.GetRolesByIds(roleIds); foreach (Role role in roles) { user.Roles.Add(role); } } if (ValidateModel(user, new[] { "FirstName", "LastName", "Email", "Website", "Roles" })) { this._userService.UpdateUser(user); Messages.AddFlashMessageWithParams("UserUpdatedMessage", user.UserName); return(RedirectToAction("Index")); } } catch (Exception ex) { Messages.AddException(ex); } ViewData["Roles"] = this._userService.GetAllRolesBySite(CuyahogaContext.CurrentSite); ViewData["TimeZones"] = new SelectList(TimeZoneUtil.GetTimeZones(), "Key", "Value", user.TimeZone); return(View("EditUser", user)); }
public ActionResult Update(int id, HttpPostedFileBase fileData, int[] roleIds, string categoryids) { FileResource fileResource = this._contentItemService.GetById(id); BindCategoriesAndRoles(fileResource, categoryids, roleIds); if (TryUpdateModel(fileResource, new[] { "Title", "Summary", "PublishedAt", "PublishedUntil" }) && ValidateModel(fileResource, new[] { "Title", "Summary", "PublishedAt", "PublishedUntil" })) { try { if (fileData != null && fileData.ContentLength > 0) { fileResource.FileName = fileData.FileName; fileResource.PhysicalFilePath = Path.Combine(this._module.FileDir, fileResource.FileName); fileResource.Length = fileData.ContentLength; fileResource.MimeType = fileData.ContentType; this._fileResourceService.SaveFileResource(fileResource, fileData.InputStream); } else { this._fileResourceService.UpdateFileResource(fileResource); } Messages.AddFlashMessage("FileSavedMessage"); return(RedirectToAction("Index", "ManageFiles", GetNodeAndSectionParams())); } catch (Exception ex) { Messages.AddException(ex); } } ViewData["Roles"] = this._userService.GetAllRolesBySite(CuyahogaContext.CurrentSite); return(View("Edit", GetModuleAdminViewModel(fileResource))); }
public ActionResult Index() { SearchIndexProperties indexProperties = new SearchIndexProperties { IndexDirectory = "Unknown" }; try { indexProperties = this._searchService.GetIndexProperties(); } catch (Exception ex) { Messages.AddException(ex); } return(View(indexProperties)); }
public override IMessages Run() { Messages messages = new Messages(); try { if (!File.Exists(this.FileName)) { messages.AddWarning(string.Format("The file {0} doesn't exist.", this.FileName)); return(messages); } XDocument doc = XDocument.Load(this.FileName); var parentElement = doc.XPathSelectElement(XPath); if (parentElement == null) { messages.AddWarning(string.Format("The path '{0}' doesn't exist into the file.", this.XPath)); return(messages); } var values = parentElement.Descendants().Select(x => x.Attribute(this.AttrName1).Value); if (values == null) { messages.AddWarning(string.Format("The attribute '{0}' doesn't exist into the file.", this.AttrName1)); return(messages); } foreach (var value in values) { if (value == this.AttrValue1) { return(messages); } } messages.AddWarning(string.Format("The attribute {0} doesn't exist.", this.AttrValue1)); } catch (Exception e) { messages.AddException(e); } return(messages); }
public ActionResult CreateRootPage([Bind(Include = "Title, Culture")] Node newRootPage) { if (ValidateModel(newRootPage, new[] { "Title", "Culture" }, "NewRootPage")) { try { newRootPage = this._nodeService.CreateRootNode(CuyahogaContext.CurrentSite, newRootPage); Messages.AddFlashMessageWithParams("PageCreatedMessage", newRootPage.Title); return(RedirectToAction("Design", new { id = newRootPage.Id, expandaddnew = true })); } catch (Exception ex) { Messages.AddException(ex); } } ViewData["CurrentTask"] = "CreateRootPage"; return(Index(null)); }
public ActionResult CreateLink(int parentNodeId, [Bind(Include = "Title, LinkUrl, LinkTarget")] Node newLink) { if (ValidateModel(newLink, new[] { "Title", "LinkUrl" }, "NewLink")) { try { Node parentNode = this._nodeService.GetNodeById(parentNodeId); newLink = this._nodeService.CreateNode(parentNode, newLink); Messages.AddFlashMessageWithParams("LinkCreatedMessage", newLink.Title); return(RedirectToAction("Index", new { id = newLink.Id })); } catch (Exception ex) { Messages.AddException(ex); } } ViewData["CurrentTask"] = "CreateLink"; return(Index(parentNodeId)); }
public ActionResult CreatePage(int parentNodeId, [Bind(Include = "Title")] Node newPage) { if (ValidateModel(newPage, new[] { "Title" }, "NewPage")) { try { Node parentNode = this._nodeService.GetNodeById(parentNodeId); newPage = this._nodeService.CreateNode(parentNode, newPage); Messages.AddFlashMessageWithParams("PageCreatedMessage", newPage.Title); return(RedirectToAction("Design", new { id = newPage.Id, expandaddnew = true })); } catch (Exception ex) { Messages.AddException(ex); } } ViewData["CurrentTask"] = "CreatePage"; return(Index(parentNodeId)); }
public ActionResult Update(int id) { Template template = this._templateService.GetTemplateById(id); try { if (TryUpdateModel(template, new[] { "Name", "TemplateControl", "Css" }) && ValidateModel(template)) { this._templateService.SaveTemplate(template); Messages.AddFlashMessageWithParams("TemplateUpdatedMessage", template.Name); return(RedirectToAction("Index")); } } catch (Exception ex) { Messages.AddException(ex); } SetupTemplateControlAndCssLists(template, template.BasePath); return(View("EditTemplate", template)); }
public ActionResult Create() { Template template = new Template(); try { template.Site = CuyahogaContext.CurrentSite; if (TryUpdateModel(template, new[] { "Name", "BasePath", "TemplateControl", "Css" }) && ValidateModel(template)) { this._templateService.SaveTemplate(template); Messages.AddMessageWithParams("TemplateCreatedMessage", template.Name); return(RedirectToAction("Index")); } } catch (Exception ex) { Messages.AddException(ex); } return(RenderNewTemplateView(template)); }
public ActionResult SavePageProperties(int id) { Node node = this._nodeService.GetNodeById(id); var includeProperties = new[] { "Title", "ShortDescription", "Culture", "ShowInNavigation" }; try { if (TryUpdateModel(node, includeProperties) && ValidateModel(node, includeProperties)) { this._nodeService.SaveNode(node); Messages.AddFlashMessage("PagePropertiesUpdatedMessage"); return(RedirectToAction("Index", new { id = node.Id })); } } catch (Exception ex) { Messages.AddException(ex); } return(Index(node.Id)); }
public override IMessages Run() { Messages messages = new Messages(); try { if (!string.IsNullOrEmpty(this.Script)) { return(AutomationUtilities.OpenUrl(this.Url, this.Script)); } else { Process.Start(this.Url); } } catch (Exception e) { messages.AddException(e); } return(messages); }
public ActionResult SetSectionPermissions(int id, int[] viewRoleIds, int[] editRoleIds) { Section section = this._sectionService.GetSectionById(id); try { this._sectionService.SetSectionPermissions(section, viewRoleIds, editRoleIds); Messages.AddMessageWithParams("PermissionsUpdatedMessage", section.Title); } catch (Exception ex) { Messages.AddException(ex); } if (Request.IsAjaxRequest()) { var sectionViewData = BuildSectionViewData(section); return(PartialView("SelectedSection", sectionViewData)); } else { throw new NotImplementedException("SetSectionPermissions not yet implemented for non-AJAX scenario's"); } }
public ActionResult AddSectionToPage([Bind(Include = "PlaceHolderId, Title, ShowTitle, CacheDuration")] Section section, int moduleTypeId, int nodeId) { section.ModuleType = this._sectionService.GetModuleTypeById(moduleTypeId); section.Site = CuyahogaContext.CurrentSite; section.Node = this._nodeService.GetNodeById(nodeId); section.Node.AddSection(section); UpdateSectionSettingsFromForm(section, SettingsFormElementPrefix); try { if (ModelState.IsValid && ValidateModel(section, new [] { "Title", "ModuleType", "Settings" }, "section")) { this._sectionService.SaveSection(section); Messages.AddMessageWithParams("SectionCreatedMessage", section.Title); } } catch (Exception ex) { Logger.Error("Unexpected error while adding section to page.", ex); Messages.AddException(ex); } ViewData["NodeId"] = nodeId; return(View("NewSectionDialog", section)); }
public ActionResult ChangePassword(int id, string password, string passwordConfirmation) { User user = this._userService.GetUserById(id); try { user.Password = CuyahogaUser.HashPassword(password); user.PasswordConfirmation = CuyahogaUser.HashPassword(passwordConfirmation); if (ValidateModel(user, new[] { "Password", "PasswordConfirmation" })) { this._userService.UpdateUser(user); Messages.AddMessage("PasswordChangedMessage"); } } catch (Exception ex) { Messages.AddException(ex); } ViewData["Roles"] = this._userService.GetAllRolesBySite(CuyahogaContext.CurrentSite); ViewData["TimeZones"] = new SelectList(TimeZoneUtil.GetTimeZones(), "Key", "Value", user.TimeZone); return(View("EditUser", user)); }