+ On <%# GetPageDetails(Eval("nodeid")) %> , <%# Eval("created") %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%# Container.DataItem %>
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI/usercontrols/MemberPicker.ascx b/src/Umbraco.Web.UI/usercontrols/MemberPicker.ascx
new file mode 100644
index 0000000000..c73e17174e
--- /dev/null
+++ b/src/Umbraco.Web.UI/usercontrols/MemberPicker.ascx
@@ -0,0 +1,14 @@
+<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MemberPicker.ascx.cs" Inherits="Training.Level2.usercontrols.MemberPicker" %>
+
+
+
+
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI/usercontrols/Parallel.ascx b/src/Umbraco.Web.UI/usercontrols/Parallel.ascx
new file mode 100644
index 0000000000..795df2c126
--- /dev/null
+++ b/src/Umbraco.Web.UI/usercontrols/Parallel.ascx
@@ -0,0 +1,2 @@
+<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Parallel.ascx.cs" Inherits="Umbraco.Web.UI.usercontrols.ParallelUserControl" %>
+
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI/usercontrols/Parallel.ascx.cs b/src/Umbraco.Web.UI/usercontrols/Parallel.ascx.cs
new file mode 100644
index 0000000000..ea3a38f605
--- /dev/null
+++ b/src/Umbraco.Web.UI/usercontrols/Parallel.ascx.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using umbraco.cms.businesslogic.web;
+using umbraco.BusinessLogic;
+
+namespace Umbraco.Web.UI.usercontrols
+{
+ public partial class ParallelUserControl : System.Web.UI.UserControl
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ protected void Button1_Click(object sender, EventArgs e)
+ {
+ ParallelDocumentUpdate test = new ParallelDocumentUpdate();
+ test.Execute();
+
+ }
+ }
+
+ public class ParallelDocumentUpdate
+ {
+ private List documents;
+ public ParallelDocumentUpdate()
+ {
+ documents = new List();
+
+ documents.Add(new myDocument(1079, "name1", "string1", 1, false, DateTime.Now.AddDays(1)));
+ documents.Add(new myDocument(1080, "name2", "string2", 2, true, DateTime.Now.AddDays(2)));
+ documents.Add(new myDocument(1082, "name3", "string3", 3, false, DateTime.Now.AddDays(3)));
+ documents.Add(new myDocument(1083, "name4", "string4", 4, true, DateTime.Now.AddDays(4)));
+ documents.Add(new myDocument(1084, "name5", "string5", 5, true, DateTime.Now.AddDays(4)));
+
+ }
+
+ public void Execute()
+ {
+
+ System.Threading.Tasks.Parallel.ForEach(documents, d =>
+ {
+ Document doc = new Document(d.Id);
+ doc.Text = d.Name + " " + d.Id.ToString();
+ doc.getProperty("string").Value = d.Prop1 + " " + d.Id.ToString();
+ doc.getProperty("int").Value = d.Prop2;
+ doc.getProperty("bool").Value = d.Prop3;
+ doc.getProperty("date").Value = d.Prop4;
+ doc.Publish(User.GetUser(0));
+ });
+
+ }
+ }
+
+ public class myDocument
+ {
+ public myDocument(int id, string name, string prop1, int prop2, bool prop3, DateTime prop4)
+ {
+ Id = id;
+ Name = name;
+ Prop1 = prop1;
+ Prop2 = prop2;
+ Prop3 = prop3;
+ Prop4 = prop4;
+ }
+
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public string Prop1 { get; set; }
+ public int Prop2 { get; set; }
+ public bool Prop3 { get; set; }
+ public DateTime Prop4 { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI/usercontrols/Parallel.ascx.designer.cs b/src/Umbraco.Web.UI/usercontrols/Parallel.ascx.designer.cs
new file mode 100644
index 0000000000..334046ec2c
--- /dev/null
+++ b/src/Umbraco.Web.UI/usercontrols/Parallel.ascx.designer.cs
@@ -0,0 +1,24 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Umbraco.Web.UI.usercontrols {
+
+
+ public partial class ParallelUserControl {
+
+ ///
+ /// Button1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Button Button1;
+ }
+}
diff --git a/src/Umbraco.Web.UI/usercontrols/RunwayContactForm/Contact.ascx b/src/Umbraco.Web.UI/usercontrols/RunwayContactForm/Contact.ascx
new file mode 100644
index 0000000000..3816d939d0
--- /dev/null
+++ b/src/Umbraco.Web.UI/usercontrols/RunwayContactForm/Contact.ascx
@@ -0,0 +1,21 @@
+<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Contact.ascx.cs" Inherits="UmbracoShop.Controls.Contact" %>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Umbraco.Web/Macros/PartialViewMacroController.cs b/src/Umbraco.Web/Macros/PartialViewMacroController.cs
index 913a79e61e..765846c5c5 100644
--- a/src/Umbraco.Web/Macros/PartialViewMacroController.cs
+++ b/src/Umbraco.Web/Macros/PartialViewMacroController.cs
@@ -7,37 +7,37 @@ using System.Linq;
namespace Umbraco.Web.Macros
{
- ///
- /// Controller to render macro content for Parital View Macros
- ///
- internal class PartialViewMacroController : Controller
- {
- private readonly UmbracoContext _umbracoContext;
- private readonly MacroModel _macro;
- private readonly INode _currentPage;
-
- public PartialViewMacroController(UmbracoContext umbracoContext, MacroModel macro, INode currentPage)
- {
- _umbracoContext = umbracoContext;
- _macro = macro;
- _currentPage = currentPage;
- }
+ ///
+ /// Controller to render macro content for Parital View Macros
+ ///
+ internal class PartialViewMacroController : Controller
+ {
+ private readonly UmbracoContext _umbracoContext;
+ private readonly MacroModel _macro;
+ private readonly INode _currentPage;
- ///
- /// Child action to render a macro
- ///
- ///
- [ChildActionOnly]
- public PartialViewResult Index()
- {
- var model = new PartialViewMacroModel(
- _currentPage.ConvertFromNode(),
+ public PartialViewMacroController(UmbracoContext umbracoContext, MacroModel macro, INode currentPage)
+ {
+ _umbracoContext = umbracoContext;
+ _macro = macro;
+ _currentPage = currentPage;
+ }
+
+ ///
+ /// Child action to render a macro
+ ///
+ ///
+ [ChildActionOnly]
+ public PartialViewResult Index()
+ {
+ var model = new PartialViewMacroModel(
+ _currentPage.ConvertFromNode(),
_macro.Id,
_macro.Alias,
_macro.Name,
- _macro.Properties.ToDictionary(x => x.Key, x => (object)x.Value));
- return PartialView(_macro.ScriptName, model);
- }
+ _macro.Properties.ToDictionary(x => x.Key, x => (object)x.Value));
+ return PartialView(_macro.ScriptName, model);
+ }
- }
+ }
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs
index 595c94bebb..be0d4dc332 100644
--- a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs
+++ b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs
@@ -17,48 +17,48 @@ using System.Web.Mvc.Html;
namespace Umbraco.Web.Macros
{
- ///
- /// A macro engine using MVC Partial Views to execute
- ///
- public class PartialViewMacroEngine : IMacroEngine
- {
- private readonly Func _getHttpContext;
- private readonly Func _getUmbracoContext;
+ ///
+ /// A macro engine using MVC Partial Views to execute
+ ///
+ public class PartialViewMacroEngine : IMacroEngine
+ {
+ private readonly Func _getHttpContext;
+ private readonly Func _getUmbracoContext;
- public const string EngineName = "Partial View Macro Engine";
+ public const string EngineName = "Partial View Macro Engine";
- public PartialViewMacroEngine()
- {
- _getHttpContext = () =>
- {
- if (HttpContext.Current == null)
- throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null HttpContext.Current reference");
- return new HttpContextWrapper(HttpContext.Current);
- };
+ public PartialViewMacroEngine()
+ {
+ _getHttpContext = () =>
+ {
+ if (HttpContext.Current == null)
+ throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null HttpContext.Current reference");
+ return new HttpContextWrapper(HttpContext.Current);
+ };
- _getUmbracoContext = () =>
- {
- if (UmbracoContext.Current == null)
- throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null UmbracoContext.Current reference");
- return UmbracoContext.Current;
- };
- }
+ _getUmbracoContext = () =>
+ {
+ if (UmbracoContext.Current == null)
+ throw new InvalidOperationException("The " + this.GetType() + " cannot execute with a null UmbracoContext.Current reference");
+ return UmbracoContext.Current;
+ };
+ }
- ///
- /// Constructor generally used for unit testing
- ///
- ///
- ///
- internal PartialViewMacroEngine(HttpContextBase httpContext, UmbracoContext umbracoContext)
- {
- _getHttpContext = () => httpContext;
- _getUmbracoContext = () => umbracoContext;
- }
+ ///
+ /// Constructor generally used for unit testing
+ ///
+ ///
+ ///
+ internal PartialViewMacroEngine(HttpContextBase httpContext, UmbracoContext umbracoContext)
+ {
+ _getHttpContext = () => httpContext;
+ _getUmbracoContext = () => umbracoContext;
+ }
- public string Name
- {
- get { return EngineName; }
- }
+ public string Name
+ {
+ get { return EngineName; }
+ }
//NOTE: We do not return any supported extensions because we don't want the MacroEngineFactory to return this
// macro engine when searching for engines via extension. Those types of engines are reserved for files that are
@@ -77,45 +77,45 @@ namespace Umbraco.Web.Macros
{
get { return Enumerable.Empty(); }
}
- public Dictionary SupportedProperties
- {
- get { throw new NotSupportedException(); }
- }
+ public Dictionary SupportedProperties
+ {
+ get { throw new NotSupportedException(); }
+ }
- public bool Validate(string code, string tempFileName, INode currentPage, out string errorMessage)
- {
- var temp = GetVirtualPathFromPhysicalPath(tempFileName);
- try
- {
- CompileAndInstantiate(temp);
- }
- catch (Exception exception)
- {
- errorMessage = exception.Message;
- return false;
- }
- errorMessage = string.Empty;
- return true;
- }
+ public bool Validate(string code, string tempFileName, INode currentPage, out string errorMessage)
+ {
+ var temp = GetVirtualPathFromPhysicalPath(tempFileName);
+ try
+ {
+ CompileAndInstantiate(temp);
+ }
+ catch (Exception exception)
+ {
+ errorMessage = exception.Message;
+ return false;
+ }
+ errorMessage = string.Empty;
+ return true;
+ }
- public string Execute(MacroModel macro, INode currentPage)
- {
- if (macro == null) throw new ArgumentNullException("macro");
- if (currentPage == null) throw new ArgumentNullException("currentPage");
+ public string Execute(MacroModel macro, INode currentPage)
+ {
+ if (macro == null) throw new ArgumentNullException("macro");
+ if (currentPage == null) throw new ArgumentNullException("currentPage");
if (macro.ScriptName.IsNullOrWhiteSpace()) throw new ArgumentException("The ScriptName property of the macro object cannot be null or empty");
- if (!macro.ScriptName.StartsWith(SystemDirectories.MvcViews + "/MacroPartials/")
- && (!Regex.IsMatch(macro.ScriptName, "~/App_Plugins/.+?/Views/MacroPartials", RegexOptions.Compiled)))
- {
- throw new InvalidOperationException("Cannot render the Partial View Macro with file: " + macro.ScriptName + ". All Partial View Macros must exist in the " + SystemDirectories.MvcViews + "/MacroPartials/ folder");
- }
+ if (!macro.ScriptName.StartsWith(SystemDirectories.MvcViews + "/MacroPartials/")
+ && (!Regex.IsMatch(macro.ScriptName, "~/App_Plugins/.+?/Views/MacroPartials", RegexOptions.Compiled)))
+ {
+ throw new InvalidOperationException("Cannot render the Partial View Macro with file: " + macro.ScriptName + ". All Partial View Macros must exist in the " + SystemDirectories.MvcViews + "/MacroPartials/ folder");
+ }
- var http = _getHttpContext();
- var umbCtx = _getUmbracoContext();
- var routeVals = new RouteData();
- routeVals.Values.Add("controller", "PartialViewMacro");
- routeVals.Values.Add("action", "Index");
- routeVals.DataTokens.Add("umbraco-context", umbCtx); //required for UmbracoViewPage
+ var http = _getHttpContext();
+ var umbCtx = _getUmbracoContext();
+ var routeVals = new RouteData();
+ routeVals.Values.Add("controller", "PartialViewMacro");
+ routeVals.Values.Add("action", "Index");
+ routeVals.DataTokens.Add("umbraco-context", umbCtx); //required for UmbracoViewPage
//lets render this controller as a child action if we are currently executing using MVC
//(otherwise don't do this since we're using webforms)
@@ -131,44 +131,44 @@ namespace Umbraco.Web.Macros
routeVals.DataTokens.Add("ParentActionViewContext", viewContext);
}
- var request = new RequestContext(http, routeVals);
- string output;
- using (var controller = new PartialViewMacroController(umbCtx, macro, currentPage))
- {
+ var request = new RequestContext(http, routeVals);
+ string output;
+ using (var controller = new PartialViewMacroController(umbCtx, macro, currentPage))
+ {
//bubble up the model state from the main view context to our custom controller.
//when merging we'll create a new dictionary, otherwise you might run into an enumeration error
// caused from ModelStateDictionary
controller.ModelState.Merge(new ModelStateDictionary(viewContext.ViewData.ModelState));
controller.ControllerContext = new ControllerContext(request, controller);
//call the action to render
- var result = controller.Index();
+ var result = controller.Index();
output = controller.RenderViewResultAsString(result);
- }
+ }
- return output;
- }
+ return output;
+ }
- private string GetVirtualPathFromPhysicalPath(string physicalPath)
- {
- string rootpath = _getHttpContext().Server.MapPath("~/");
- physicalPath = physicalPath.Replace(rootpath, "");
- physicalPath = physicalPath.Replace("\\", "/");
- return "~/" + physicalPath;
- }
+ private string GetVirtualPathFromPhysicalPath(string physicalPath)
+ {
+ string rootpath = _getHttpContext().Server.MapPath("~/");
+ physicalPath = physicalPath.Replace(rootpath, "");
+ physicalPath = physicalPath.Replace("\\", "/");
+ return "~/" + physicalPath;
+ }
- private static PartialViewMacroPage CompileAndInstantiate(string virtualPath)
- {
- //Compile Razor - We Will Leave This To ASP.NET Compilation Engine & ASP.NET WebPages
- //Security in medium trust is strict around here, so we can only pass a virtual file path
- //ASP.NET Compilation Engine caches returned types
- //Changed From BuildManager As Other Properties Are Attached Like Context Path/
- var webPageBase = WebPageBase.CreateInstanceFromVirtualPath(virtualPath);
- var webPage = webPageBase as PartialViewMacroPage;
- if (webPage == null)
- throw new InvalidCastException("All Partial View Macro views must inherit from " + typeof(PartialViewMacroPage).FullName);
- return webPage;
- }
+ private static PartialViewMacroPage CompileAndInstantiate(string virtualPath)
+ {
+ //Compile Razor - We Will Leave This To ASP.NET Compilation Engine & ASP.NET WebPages
+ //Security in medium trust is strict around here, so we can only pass a virtual file path
+ //ASP.NET Compilation Engine caches returned types
+ //Changed From BuildManager As Other Properties Are Attached Like Context Path/
+ var webPageBase = WebPageBase.CreateInstanceFromVirtualPath(virtualPath);
+ var webPage = webPageBase as PartialViewMacroPage;
+ if (webPage == null)
+ throw new InvalidCastException("All Partial View Macro views must inherit from " + typeof(PartialViewMacroPage).FullName);
+ return webPage;
+ }
- }
+ }
}
diff --git a/src/Umbraco.Web/Macros/PartialViewMacroPage.cs b/src/Umbraco.Web/Macros/PartialViewMacroPage.cs
index 2cf95cca95..8f5c11b044 100644
--- a/src/Umbraco.Web/Macros/PartialViewMacroPage.cs
+++ b/src/Umbraco.Web/Macros/PartialViewMacroPage.cs
@@ -5,11 +5,11 @@ using Umbraco.Web.Mvc;
namespace Umbraco.Web.Macros
{
- ///
- /// The base view class that PartialViewMacro views need to inherit from
- ///
- public abstract class PartialViewMacroPage : UmbracoViewPage
- {
+ ///
+ /// The base view class that PartialViewMacro views need to inherit from
+ ///
+ public abstract class PartialViewMacroPage : UmbracoViewPage
+ {
protected override void InitializePage()
{
base.InitializePage();
@@ -24,5 +24,5 @@ namespace Umbraco.Web.Macros
/// Returns the a DynamicPublishedContent object
///
public dynamic CurrentPage { get; private set; }
- }
+ }
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Models/PartialViewMacroModel.cs b/src/Umbraco.Web/Models/PartialViewMacroModel.cs
index b21b7cdb81..0a3129d876 100644
--- a/src/Umbraco.Web/Models/PartialViewMacroModel.cs
+++ b/src/Umbraco.Web/Models/PartialViewMacroModel.cs
@@ -5,16 +5,16 @@ using Umbraco.Core.Models;
namespace Umbraco.Web.Models
{
- ///
- /// The model used when rendering Partial View Macros
- ///
- public class PartialViewMacroModel
- {
+ ///
+ /// The model used when rendering Partial View Macros
+ ///
+ public class PartialViewMacroModel
+ {
- public PartialViewMacroModel(IPublishedContent page,
- int macroId,
- string macroAlias,
- string macroName,
+ public PartialViewMacroModel(IPublishedContent page,
+ int macroId,
+ string macroAlias,
+ string macroName,
IDictionary macroParams)
{
Content = page;
@@ -26,11 +26,11 @@ namespace Umbraco.Web.Models
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Use the constructor accepting the macro id instead")]
- public PartialViewMacroModel(IPublishedContent page, IDictionary macroParams)
- {
+ public PartialViewMacroModel(IPublishedContent page, IDictionary macroParams)
+ {
Content = page;
- MacroParameters = macroParams;
- }
+ MacroParameters = macroParams;
+ }
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Use the Content property instead")]
@@ -43,7 +43,7 @@ namespace Umbraco.Web.Models
public string MacroName { get; private set; }
public string MacroAlias { get; private set; }
public int MacroId { get; private set; }
- public IDictionary MacroParameters { get; private set; }
+ public IDictionary MacroParameters { get; private set; }
- }
+ }
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Mvc/Constants.cs b/src/Umbraco.Web/Mvc/Constants.cs
index 4151c412f4..e175ef2ea8 100644
--- a/src/Umbraco.Web/Mvc/Constants.cs
+++ b/src/Umbraco.Web/Mvc/Constants.cs
@@ -3,10 +3,10 @@ namespace Umbraco.Web.Mvc
///
/// constants
///
- internal static class Constants
- {
+ internal static class Constants
+ {
internal const string ViewLocation = "~/Views";
internal const string DataTokenCurrentViewContext = "umbraco-current-view-context";
- }
+ }
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Mvc/ControllerExtensions.cs b/src/Umbraco.Web/Mvc/ControllerExtensions.cs
index b26ed39b79..0e383add83 100644
--- a/src/Umbraco.Web/Mvc/ControllerExtensions.cs
+++ b/src/Umbraco.Web/Mvc/ControllerExtensions.cs
@@ -97,58 +97,58 @@ namespace Umbraco.Web.Mvc
}
}
- ///
- /// Normally in MVC the way that the View object gets assigned to the result is to Execute the ViewResult, this however
- /// will write to the Response output stream which isn't what we want. Instead, this method will use the same logic inside
- /// of MVC to assign the View object to the result but without executing it. This also ensures that the ViewData and the TempData
- /// is assigned from the controller.
- /// This is only relavent for view results of PartialViewResult or ViewResult.
- ///
- ///
- ///
- internal static void EnsureViewObjectDataOnResult(this ControllerBase controller, ViewResultBase result)
- {
+ ///
+ /// Normally in MVC the way that the View object gets assigned to the result is to Execute the ViewResult, this however
+ /// will write to the Response output stream which isn't what we want. Instead, this method will use the same logic inside
+ /// of MVC to assign the View object to the result but without executing it. This also ensures that the ViewData and the TempData
+ /// is assigned from the controller.
+ /// This is only relavent for view results of PartialViewResult or ViewResult.
+ ///
+ ///
+ ///
+ internal static void EnsureViewObjectDataOnResult(this ControllerBase controller, ViewResultBase result)
+ {
//when merging we'll create a new dictionary, otherwise you might run into an enumeration error
// caused from ModelStateDictionary
result.ViewData.ModelState.Merge(new ModelStateDictionary(controller.ViewData.ModelState));
- // Temporarily copy the dictionary to avoid enumerator-modification errors
- var newViewDataDict = new ViewDataDictionary(controller.ViewData);
- foreach (var d in newViewDataDict)
- result.ViewData[d.Key] = d.Value;
+ // Temporarily copy the dictionary to avoid enumerator-modification errors
+ var newViewDataDict = new ViewDataDictionary(controller.ViewData);
+ foreach (var d in newViewDataDict)
+ result.ViewData[d.Key] = d.Value;
- result.TempData = controller.TempData;
+ result.TempData = controller.TempData;
- if (result.View != null) return;
+ if (result.View != null) return;
- if (string.IsNullOrEmpty(result.ViewName))
- result.ViewName = controller.ControllerContext.RouteData.GetRequiredString("action");
+ if (string.IsNullOrEmpty(result.ViewName))
+ result.ViewName = controller.ControllerContext.RouteData.GetRequiredString("action");
- if (result.View != null) return;
+ if (result.View != null) return;
- if (result is PartialViewResult)
- {
- var viewEngineResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, result.ViewName);
+ if (result is PartialViewResult)
+ {
+ var viewEngineResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, result.ViewName);
- if (viewEngineResult.View == null)
- {
- throw new InvalidOperationException("Could not find the view " + result.ViewName + ", the following locations were searched: " + Environment.NewLine + string.Join(Environment.NewLine, viewEngineResult.SearchedLocations));
- }
+ if (viewEngineResult.View == null)
+ {
+ throw new InvalidOperationException("Could not find the view " + result.ViewName + ", the following locations were searched: " + Environment.NewLine + string.Join(Environment.NewLine, viewEngineResult.SearchedLocations));
+ }
- result.View = viewEngineResult.View;
- }
- else if (result is ViewResult)
- {
- var vr = (ViewResult)result;
- var viewEngineResult = ViewEngines.Engines.FindView(controller.ControllerContext, vr.ViewName, vr.MasterName);
+ result.View = viewEngineResult.View;
+ }
+ else if (result is ViewResult)
+ {
+ var vr = (ViewResult)result;
+ var viewEngineResult = ViewEngines.Engines.FindView(controller.ControllerContext, vr.ViewName, vr.MasterName);
- if (viewEngineResult.View == null)
- {
- throw new InvalidOperationException("Could not find the view " + vr.ViewName + ", the following locations were searched: " + Environment.NewLine + string.Join(Environment.NewLine, viewEngineResult.SearchedLocations));
- }
+ if (viewEngineResult.View == null)
+ {
+ throw new InvalidOperationException("Could not find the view " + vr.ViewName + ", the following locations were searched: " + Environment.NewLine + string.Join(Environment.NewLine, viewEngineResult.SearchedLocations));
+ }
- result.View = viewEngineResult.View;
- }
- }
+ result.View = viewEngineResult.View;
+ }
+ }
}
}
diff --git a/src/Umbraco.Web/Mvc/SurfaceController.cs b/src/Umbraco.Web/Mvc/SurfaceController.cs
index b222eb8a39..a4470e7fea 100644
--- a/src/Umbraco.Web/Mvc/SurfaceController.cs
+++ b/src/Umbraco.Web/Mvc/SurfaceController.cs
@@ -8,75 +8,75 @@ using Umbraco.Core;
namespace Umbraco.Web.Mvc
{
- ///
- /// The base controller that all Presentation Add-in controllers should inherit from
- ///
- [MergeModelStateToChildAction]
- public abstract class SurfaceController : PluginController
- {
+ ///
+ /// The base controller that all Presentation Add-in controllers should inherit from
+ ///
+ [MergeModelStateToChildAction]
+ public abstract class SurfaceController : PluginController
+ {
- ///
- /// Default constructor
- ///
- ///
- protected SurfaceController(UmbracoContext umbracoContext)
- : base(umbracoContext)
- {
- }
+ ///
+ /// Default constructor
+ ///
+ ///
+ protected SurfaceController(UmbracoContext umbracoContext)
+ : base(umbracoContext)
+ {
+ }
- ///
- /// Empty constructor, uses Singleton to resolve the UmbracoContext
- ///
- protected SurfaceController()
- : base(UmbracoContext.Current)
- {
- }
+ ///
+ /// Empty constructor, uses Singleton to resolve the UmbracoContext
+ ///
+ protected SurfaceController()
+ : base(UmbracoContext.Current)
+ {
+ }
- ///
- /// Redirects to the Umbraco page with the given id
- ///
- ///
- ///
- protected RedirectToUmbracoPageResult RedirectToUmbracoPage(int pageId)
- {
- return new RedirectToUmbracoPageResult(pageId, UmbracoContext);
- }
+ ///
+ /// Redirects to the Umbraco page with the given id
+ ///
+ ///
+ ///
+ protected RedirectToUmbracoPageResult RedirectToUmbracoPage(int pageId)
+ {
+ return new RedirectToUmbracoPageResult(pageId, UmbracoContext);
+ }
- ///
- /// Redirects to the Umbraco page with the given id
- ///
- ///
- ///
- protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IPublishedContent publishedContent)
- {
- return new RedirectToUmbracoPageResult(publishedContent, UmbracoContext);
- }
+ ///
+ /// Redirects to the Umbraco page with the given id
+ ///
+ ///
+ ///
+ protected RedirectToUmbracoPageResult RedirectToUmbracoPage(IPublishedContent publishedContent)
+ {
+ return new RedirectToUmbracoPageResult(publishedContent, UmbracoContext);
+ }
- ///
- /// Redirects to the currently rendered Umbraco page
- ///
- ///
- protected RedirectToUmbracoPageResult RedirectToCurrentUmbracoPage()
- {
- return new RedirectToUmbracoPageResult(CurrentPage, UmbracoContext);
- }
+ ///
+ /// Redirects to the currently rendered Umbraco page
+ ///
+ ///
+ protected RedirectToUmbracoPageResult RedirectToCurrentUmbracoPage()
+ {
+ return new RedirectToUmbracoPageResult(CurrentPage, UmbracoContext);
+ }
- ///
- /// Returns the currently rendered Umbraco page
- ///
- ///
- protected UmbracoPageResult CurrentUmbracoPage()
- {
- return new UmbracoPageResult();
- }
+ ///
+ /// Returns the currently rendered Umbraco page
+ ///
+ ///
+ protected UmbracoPageResult CurrentUmbracoPage()
+ {
+ return new UmbracoPageResult();
+ }
- ///
- /// Gets the current page.
- ///
- protected IPublishedContent CurrentPage
- {
- get
- {
+ ///
+ /// Gets the current page.
+ ///
+ protected IPublishedContent CurrentPage
+ {
+ get
+ {
var routeDefAttempt = TryGetRouteDefinitionFromAncestorViewContexts();
if (!routeDefAttempt.Success)
{
@@ -84,9 +84,9 @@ namespace Umbraco.Web.Mvc
}
var routeDef = routeDefAttempt.Result;
- return routeDef.PublishedContentRequest.PublishedContent;
- }
- }
+ return routeDef.PublishedContentRequest.PublishedContent;
+ }
+ }
///
/// we need to recursively find the route definition based on the parent view context
@@ -120,7 +120,7 @@ namespace Umbraco.Web.Mvc
return new Attempt(
new InvalidOperationException("Cannot find the Umbraco route definition in the route values, the request must be made in the context of an Umbraco request"));
}
+
-
- }
+ }
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Mvc/UmbracoViewPage.cs b/src/Umbraco.Web/Mvc/UmbracoViewPage.cs
index 92a46a9858..ba936ee9ee 100644
--- a/src/Umbraco.Web/Mvc/UmbracoViewPage.cs
+++ b/src/Umbraco.Web/Mvc/UmbracoViewPage.cs
@@ -4,94 +4,94 @@ using Umbraco.Web.Routing;
namespace Umbraco.Web.Mvc
{
- ///
- /// The View that umbraco front-end views inherit from
- ///
- public abstract class UmbracoViewPage : WebViewPage
- {
- protected UmbracoViewPage()
- {
+ ///
+ /// The View that umbraco front-end views inherit from
+ ///
+ public abstract class UmbracoViewPage : WebViewPage
+ {
+ protected UmbracoViewPage()
+ {
- }
-
- ///
- /// Returns the current UmbracoContext
- ///
- public UmbracoContext UmbracoContext
- {
- get
- {
- //we should always try to return the context from the data tokens just in case its a custom context and not
- //using the UmbracoContext.Current.
- //we will fallback to the singleton if necessary.
- if (ViewContext.RouteData.DataTokens.ContainsKey("umbraco-context"))
- {
- return (UmbracoContext)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-context");
- }
- //next check if it is a child action and see if the parent has it set in data tokens
- if (ViewContext.IsChildAction)
- {
- if (ViewContext.ParentActionViewContext.RouteData.DataTokens.ContainsKey("umbraco-context"))
- {
- return (UmbracoContext)ViewContext.ParentActionViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-context");
- }
- }
-
- //lastly, we will use the singleton, the only reason this should ever happen is is someone is rendering a page that inherits from this
- //class and are rendering it outside of the normal Umbraco routing process. Very unlikely.
- return UmbracoContext.Current;
- }
- }
+ }
- ///
- /// Returns the current ApplicationContext
- ///
- public ApplicationContext ApplicationContext
- {
- get { return UmbracoContext.Application; }
- }
+ ///
+ /// Returns the current UmbracoContext
+ ///
+ public UmbracoContext UmbracoContext
+ {
+ get
+ {
+ //we should always try to return the context from the data tokens just in case its a custom context and not
+ //using the UmbracoContext.Current.
+ //we will fallback to the singleton if necessary.
+ if (ViewContext.RouteData.DataTokens.ContainsKey("umbraco-context"))
+ {
+ return (UmbracoContext)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-context");
+ }
+ //next check if it is a child action and see if the parent has it set in data tokens
+ if (ViewContext.IsChildAction)
+ {
+ if (ViewContext.ParentActionViewContext.RouteData.DataTokens.ContainsKey("umbraco-context"))
+ {
+ return (UmbracoContext)ViewContext.ParentActionViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-context");
+ }
+ }
- ///
- /// Returns the current PublishedContentRequest
- ///
- internal PublishedContentRequest PublishedContentRequest
- {
- get
- {
- //we should always try to return the object from the data tokens just in case its a custom object and not
- //using the UmbracoContext.Current.
- //we will fallback to the singleton if necessary.
- if (ViewContext.RouteData.DataTokens.ContainsKey("umbraco-doc-request"))
- {
- return (PublishedContentRequest)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request");
- }
- //next check if it is a child action and see if the parent has it set in data tokens
- if (ViewContext.IsChildAction)
- {
- if (ViewContext.ParentActionViewContext.RouteData.DataTokens.ContainsKey("umbraco-doc-request"))
- {
- return (PublishedContentRequest)ViewContext.ParentActionViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request");
- }
- }
+ //lastly, we will use the singleton, the only reason this should ever happen is is someone is rendering a page that inherits from this
+ //class and are rendering it outside of the normal Umbraco routing process. Very unlikely.
+ return UmbracoContext.Current;
+ }
+ }
- //lastly, we will use the singleton, the only reason this should ever happen is is someone is rendering a page that inherits from this
- //class and are rendering it outside of the normal Umbraco routing process. Very unlikely.
- return UmbracoContext.Current.PublishedContentRequest;
- }
- }
+ ///
+ /// Returns the current ApplicationContext
+ ///
+ public ApplicationContext ApplicationContext
+ {
+ get { return UmbracoContext.Application; }
+ }
- private UmbracoHelper _helper;
+ ///
+ /// Returns the current PublishedContentRequest
+ ///
+ internal PublishedContentRequest PublishedContentRequest
+ {
+ get
+ {
+ //we should always try to return the object from the data tokens just in case its a custom object and not
+ //using the UmbracoContext.Current.
+ //we will fallback to the singleton if necessary.
+ if (ViewContext.RouteData.DataTokens.ContainsKey("umbraco-doc-request"))
+ {
+ return (PublishedContentRequest)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request");
+ }
+ //next check if it is a child action and see if the parent has it set in data tokens
+ if (ViewContext.IsChildAction)
+ {
+ if (ViewContext.ParentActionViewContext.RouteData.DataTokens.ContainsKey("umbraco-doc-request"))
+ {
+ return (PublishedContentRequest)ViewContext.ParentActionViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request");
+ }
+ }
- ///
- /// Gets an UmbracoHelper
- ///
- ///
- /// This constructs the UmbracoHelper with the content model of the page routed to
- ///
- public virtual UmbracoHelper Umbraco
- {
- get { return _helper ?? (_helper = new UmbracoHelper(UmbracoContext)); }
- }
+ //lastly, we will use the singleton, the only reason this should ever happen is is someone is rendering a page that inherits from this
+ //class and are rendering it outside of the normal Umbraco routing process. Very unlikely.
+ return UmbracoContext.Current.PublishedContentRequest;
+ }
+ }
+
+ private UmbracoHelper _helper;
+
+ ///
+ /// Gets an UmbracoHelper
+ ///
+ ///
+ /// This constructs the UmbracoHelper with the content model of the page routed to
+ ///
+ public virtual UmbracoHelper Umbraco
+ {
+ get { return _helper ?? (_helper = new UmbracoHelper(UmbracoContext)); }
+ }
///
/// Ensure that the current view context is added to the route data tokens so we can extract it if we like
@@ -112,5 +112,5 @@ namespace Umbraco.Web.Mvc
}
- }
+ }
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/content.cs b/src/Umbraco.Web/umbraco.presentation/content.cs
index 9ce77c173c..819b70725b 100644
--- a/src/Umbraco.Web/umbraco.presentation/content.cs
+++ b/src/Umbraco.Web/umbraco.presentation/content.cs
@@ -1099,8 +1099,7 @@ namespace umbraco
string sql =
@"select umbracoNode.id, umbracoNode.parentId, umbracoNode.sortOrder, cmsContentXml.xml from umbracoNode
inner join cmsContentXml on cmsContentXml.nodeId = umbracoNode.id and umbracoNode.nodeObjectType = @type
-inner join cmsDocument on cmsDocument.nodeId = umbracoNode.id
-where cmsDocument.published = 1
+where umbracoNode.id in (select cmsDocument.nodeId from cmsDocument where cmsDocument.published = 1)
order by umbracoNode.level, umbracoNode.sortOrder";
lock (DbReadSyncLock)
diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs
index 6d08688590..cb97423082 100644
--- a/src/Umbraco.Web/umbraco.presentation/macro.cs
+++ b/src/Umbraco.Web/umbraco.presentation/macro.cs
@@ -16,19 +16,19 @@ using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Xsl;
using Umbraco.Core;
+using Umbraco.Core.Events;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Web;
using Umbraco.Web.Macros;
using Umbraco.Web.Templates;
using umbraco.BusinessLogic;
-using umbraco.BusinessLogic.Utils;
+using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.macro;
using umbraco.cms.businesslogic.member;
using umbraco.DataLayer;
using umbraco.NodeFactory;
using umbraco.presentation.templateControls;
-using umbraco.presentation.xslt.Exslt;
using Content = umbraco.cms.businesslogic.Content;
using Macro = umbraco.cms.businesslogic.macro.Macro;
@@ -373,6 +373,18 @@ namespace umbraco
switch (macroType)
{
case (int)MacroTypes.PartialView:
+
+ //error handler for partial views, is an action because we need to re-use it twice below
+ Action handleError = e =>
+ {
+ LogHelper.WarnWithException("Error loading Partial View (file: " + ScriptFile + ")", true, e);
+
+ // Invoke any error handlers for this macro
+ var macroErrorEventArgs = new MacroErrorEventArgs { Name = Model.Name, Alias = Model.Alias, ItemKey = Model.ScriptName, Exception = e, Behaviour = UmbracoSettings.MacroErrorBehaviour };
+
+ macroControl = RaiseAndHandleErrorForBehavior("Error loading Partial View script (file: " + ScriptFile + ")", macroErrorEventArgs);
+ };
+
TraceInfo("umbracoMacro", "Partial View added (" + Model.TypeName + ")");
try
{
@@ -380,41 +392,16 @@ namespace umbraco
macroControl = new LiteralControl(result.Result);
if (result.ResultException != null)
{
- // we'll throw the error if we run in release mode, show details if we're in release mode!
renderFailed = true;
- if (HttpContext.Current != null && !HttpContext.Current.IsDebuggingEnabled)
- throw result.ResultException;
+ Exceptions.Add(result.ResultException);
+ handleError(result.ResultException);
}
- break;
}
catch (Exception e)
{
renderFailed = true;
Exceptions.Add(e);
-
- LogHelper.WarnWithException("Error loading MacroEngine script (file: " + ScriptFile + ", Type: '" + Model.TypeName + "'",
- true,
- e);
-
- var result =
- new LiteralControl("Error loading MacroEngine script (file: " + ScriptFile + ")");
-
- /*
- string args = "
";
- foreach(object key in attributes.Keys)
- args += "
");
}
- else
+
+ try
{
+ var xsltFile = getXslt(XsltFile);
+
try
{
- XslCompiledTransform xsltFile = getXslt(XsltFile);
+ Control result = CreateControlsFromText(GetXsltTransformResult(macroXML, xsltFile));
- try
- {
- Control result = CreateControlsFromText(GetXsltTransformResult(macroXML, xsltFile));
+ TraceInfo("umbracoMacro", "After performing transformation");
- TraceInfo("umbracoMacro", "After performing transformation");
-
- return result;
- }
- catch (Exception e)
- {
- Exceptions.Add(e);
- LogHelper.WarnWithException("Error parsing XSLT file", e);
- // inner exception code by Daniel Lindstr?m from SBBS.se
- Exception ie = e;
- while (ie != null)
- {
- TraceWarn("umbracoMacro InnerException", ie.Message, ie);
- ie = ie.InnerException;
- }
- return new LiteralControl("Error parsing XSLT file: \\xslt\\" + XsltFile);
- }
+ return result;
}
catch (Exception e)
{
Exceptions.Add(e);
- LogHelper.WarnWithException("Error loading XSLT " + Model.Xslt, true, e);
- return new LiteralControl("Error reading XSLT file: \\xslt\\" + XsltFile);
+ LogHelper.WarnWithException("Error parsing XSLT file", e);
+ // inner exception code by Daniel Lindstr?m from SBBS.se
+ Exception ie = e;
+ while (ie != null)
+ {
+ TraceWarn("umbracoMacro InnerException", ie.Message, ie);
+ ie = ie.InnerException;
+ }
+
+ var macroErrorEventArgs = new MacroErrorEventArgs {Name = Model.Name, Alias = Model.Alias, ItemKey = Model.Xslt, Exception = e, Behaviour = UmbracoSettings.MacroErrorBehaviour};
+ return RaiseAndHandleErrorForBehavior("Error parsing XSLT file: \\xslt\\" + XsltFile, macroErrorEventArgs);
}
}
+ catch (Exception e)
+ {
+ Exceptions.Add(e);
+ LogHelper.WarnWithException("Error loading XSLT " + Model.Xslt, true, e);
+
+ // Invoke any error handlers for this macro
+ var macroErrorEventArgs = new MacroErrorEventArgs {Name = Model.Name, Alias = Model.Alias, ItemKey = Model.Xslt, Exception = e, Behaviour = UmbracoSettings.MacroErrorBehaviour};
+ return RaiseAndHandleErrorForBehavior("Error reading XSLT file: \\xslt\\" + XsltFile, macroErrorEventArgs);
+ }
}
- else
- {
- TraceWarn("macro", "Xslt is empty");
- return new LiteralControl(string.Empty);
- }
+
+ TraceWarn("macro", "Xslt is empty");
+ return new LiteralControl(string.Empty);
}
///
@@ -1502,7 +1501,7 @@ namespace umbraco
string userControlPath = IOHelper.FindFile(fileName);
if (!File.Exists(IOHelper.MapPath(userControlPath)))
- return new LiteralControl(string.Format("UserControl {0} does not exist.", fileName));
+ throw new UmbracoException(string.Format("UserControl {0} does not exist.", fileName));
var oControl = (UserControl)new UserControl().LoadControl(userControlPath);
@@ -1528,11 +1527,7 @@ namespace umbraco
catch (Exception e)
{
LogHelper.WarnWithException(string.Format("Error creating usercontrol ({0})", fileName), true, e);
-
- return new LiteralControl(
- string.Format(
- "
Error creating control ({0}). Maybe file doesn't exists or the usercontrol has a cache directive, which is not allowed! See the tracestack for more information!
",
- fileName));
+ throw;
}
}
@@ -1799,5 +1794,26 @@ namespace umbraco
value = false;
return false;
}
+
+ #region Events
+
+ ///
+ /// Occurs when a macro error is raised.
+ ///
+ public static event EventHandler Error;
+
+ ///
+ /// Raises the event.
+ ///
+ /// The instance containing the event data.
+ protected void OnError(MacroErrorEventArgs e)
+ {
+ if (Error != null)
+ {
+ Error(this, e);
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs
index dc94b66cd8..db27764b80 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/Macro.cs
@@ -183,6 +183,7 @@ namespace umbraco.presentation.templateControls
System.Web.HttpContext.Current.Trace.Warn("Template", "Result of macro " + tempMacro.Name + " is null");
} catch (Exception ee) {
System.Web.HttpContext.Current.Trace.Warn("Template", "Error adding macro " + tempMacro.Name, ee);
+ throw;
}
}
}
diff --git a/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs b/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs
index e30d8c5dca..83304f7ab2 100644
--- a/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs
+++ b/src/umbraco.MacroEngines/RazorCore/RazorMacroEngine.cs
@@ -171,11 +171,7 @@ namespace umbraco.MacroEngines
Success = false;
ResultException = exception;
HttpContext.Current.Trace.Warn("umbracoMacro", string.Format("Error Loading Razor Script (file: {0}) {1} {2}", macro.Name, exception.Message, exception.StackTrace));
- var loading = string.Format("