/// <summary>
 /// Retrieves the all messages.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="username"> </param>
 /// <returns></returns>
 public Dataset RetrieveMessages(IMansionContext context, string username)
 {
     var dataset = new Dataset();
     dataset.AddRow(new PropertyBag
                    {
                    	{"message", string.Format("Friends are like street lights, Along the road, they don't make the distance any shorter {0}.", username)}
                    });
     dataset.AddRow(new PropertyBag
                    {
                    	{"message", string.Format("On this auspicious Festival of lights May the glow of joys Prosperity and happiness Alluminate {0}.", username)}
                    });
     return dataset;
 }
		/// <summary>
		/// Gets the dataset.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			// create the dataset
			var dataset = new Dataset();

			// loop over all the CMS plugin types
			foreach (var plugin in typeService.Load(context, "CmsPlugin").GetInheritingTypes(context).Select(type =>
			                                                                                                 {
			                                                                                                 	// get the plugin descriptor
			                                                                                                 	CmsPluginDescriptor descriptor;
			                                                                                                 	if (!type.TryGetDescriptor(out descriptor))
			                                                                                                 		throw new InvalidOperationException(string.Format("Type '{0}' does not contain a CMS-plugin", type.Name));

			                                                                                                 	// return the model
			                                                                                                 	return new
			                                                                                                 	       {
			                                                                                                 	       	Type = type,
			                                                                                                 	       	Descriptor = descriptor
			                                                                                                 	       };
			                                                                                                 }).OrderBy(plugin => plugin.Descriptor.GetOrder(context)))
			{
				// create the plugin row
				var row = new PropertyBag
				          {
				          	{"type", plugin.Type.Name}
				          };

				// add the row to the dataset
				dataset.AddRow(row);
			}

			return dataset;
		}
		/// <summary>
		/// Gets the dataset.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			var dataset = new Dataset();
			foreach (var name in applicationResourceService.EnumeratorFolders(context, GetAttribute<string>(context, "path")))
			{
				dataset.AddRow(new PropertyBag
				               {
				               	{"name", name}
				               });
			}
			return dataset;
		}
		/// <summary>
		/// Gets the dataset.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			// get the attributes
			var input = GetAttribute(context, "input", string.Empty) ?? string.Empty;

			// create a dataset
			var dataset = new Dataset();
			foreach (var part in input.Split(new[] {GetAttribute(context, "separator", ",")}, StringSplitOptions.RemoveEmptyEntries))
			{
				dataset.AddRow(new PropertyBag
				               {
				               	{"value", part}
				               });
			}
			return dataset;
		}
		/// <summary>
		/// Constructs this provider with the specified <paramref name="children" />.
		/// </summary>
		/// <param name="children">The <see cref="XElement" />s from which to get the values.</param>
		public ChildXmlDatasetProvider(IEnumerable<XElement> children)
		{
			// validate arguments
			if (children == null)
				throw new ArgumentNullException("children");

			// create the dataset
			dataset = new Dataset();

			// loop over all the children and get the content of its children
			foreach (var child in children)
			{
				var properties = new PropertyBag();
				foreach (var contentChild in child.Elements())
					properties.Set(contentChild.Name.LocalName, contentChild.Value);
				dataset.AddRow(properties);
			}
		}
		/// <summary>
		/// Gets the dataset.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			// get the resource properties
			var resource = GetRequiredAttribute<ProtectedResource>(context, "source");

			// create the dataset
			var dataset = new Dataset();

			// loop over all the operations
			foreach (var operation in resource.Operations)
			{
				// add the resource to the dataset
				dataset.AddRow(PropertyBagAdapterFactory.Adapt(context, operation));
			}

			// return the set
			return dataset;
		}
		/// <summary>
		/// Gets the facet <see cref="Dataset"/> from a given <see cref="Nodeset"/>.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			// get the nodeset
			var nodeset = GetRequiredAttribute<Nodeset>(context, "source");

			// create the facet dataset
			var dataset = new Dataset();

			// add the facets to the dataset
			foreach (var result in nodeset.Facets.OrderBy(facet => facet.FriendlyName))
			{
				// add the row to the dataset
				dataset.AddRow(PropertyBagAdapterFactory.Adapt(context, result));
			}

			// return the dataset
			return dataset;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="attributes"></param>
		/// <returns></returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			var jobNode = GetRequiredAttribute<Node>(context, "source");
			var dataset = new Dataset();
			var typeService = context.Nucleus.ResolveSingle<ITypeService>();
			var type = typeService.Load(context, jobNode.Type);
			var descriptors = type.GetDescriptors<RegisterTaskDescriptor>().Select(descriptor => descriptor);

			foreach (var descriptor in descriptors)
			{
				
				var taskProperties = new PropertyBag
				{
					{ "name", descriptor.TaskType.Name},
					{ "type", descriptor.TaskType.ToString()},
					{ "label", descriptor.TaskLabel}
				};
				dataset.AddRow(taskProperties);
			}
			
			return dataset;
		}
		/// <summary>
		/// Gets the dataset.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="attributes">The attributes of this tag.</param>
		/// <returns>Returns the result.</returns>
		protected override Dataset Get(IMansionContext context, IPropertyBag attributes)
		{
			// create the dataset
			var dataset = new Dataset();

			// loop over all the types
			foreach (var type in typeService.LoadAll(context))
			{
				// if the type does not have a security descriptor ignore it
				SecurityDescriptor securityDescriptor;
				if (!type.TryGetDescriptor(out securityDescriptor))
					continue;

				// get the resource model
				var resource = securityDescriptor.GetResource(context);

				// add the resource to the dataset
				dataset.AddRow(PropertyBagAdapterFactory.Adapt(context, resource));
			}

			// return the set
			return dataset;
		}
Exemple #10
0
		/// <summary>
		/// Gets the loop set.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <returns>Returns the <see cref="Dataset"/> on which to loop.</returns>
		protected override Dataset GetLoopset(IMansionContext context)
		{
			// get the range
			var start = GetRequiredAttribute<int>(context, "start");
			var end = GetRequiredAttribute<int>(context, "end");

			// validate arguments
			if (start < 0)
				throw new AttributeOutOfRangeException("start", this);
			if (end < 0 || end < start)
				throw new AttributeOutOfRangeException("end", this);

			Start = start;
			End = end;

			// create the dataset
			var dataset = new Dataset();

			// fill the dataset
			for (var index = start; index <= end; index++)
				dataset.AddRow(new PropertyBag());

			return dataset;
		}
        /// <summary>
        /// Retrieves the crumb dasaset.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private static Dataset RetrieveCrumbSet(IMansionContext context)
        {
            // retrieve the content and page node
            var contentIndexRootNode = context.Stack.Peek<Node>("ContentIndexRootNode");
            var siteNode = context.Stack.Peek<Node>("SiteNode");
            var contentNode = context.Stack.Peek<Node>("ContentNode");
            var pageNode = context.Stack.Peek<Node>("PageNode");

            // nodeset in which to store the
            var crumbSet = new Dataset();

            // retrieve page node parent nodes
            var pageParentNodeset = context.Repository.RetrieveNodeset(context, new PropertyBag
                                                                         {
                                                                         	{"childSource", pageNode},
                                                                         	{"depth", "any"},
                                                                         	{"sort", "depth asc"},
                                                                         });

            // start from the sitenode and take while the page node has not been reached
            foreach (var parentNode in pageParentNodeset.Nodes.SkipWhile(candidate => candidate.Pointer != siteNode.Pointer))
                crumbSet.AddRow(parentNode);

            // if the content node is not equal to the page node, the content node is not under the current site
            if (contentNode.Pointer != pageNode.Pointer)
            {
                // retrieve content node parent nodes
                var contentParentNodeset = context.Repository.RetrieveNodeset(context, new PropertyBag
                                                                                {
                                                                                    {"childSource", contentNode},
                                                                                    {"depth", "any"},
                                                                                    {"sort", "depth asc"},
                                                                                });

                // start from the content index root node
                foreach (var parentNode in contentParentNodeset.Nodes.SkipWhile(candidate => !candidate.Pointer.IsChildOf(contentIndexRootNode.Pointer)))
                    crumbSet.AddRow(parentNode);
            }

            // finally add the content node itself
            crumbSet.AddRow(contentNode);
            return crumbSet;
        }
        /// <summary>
        /// Renders the crumb trail.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="trail"></param>
        /// <returns></returns>
        private string RenderTrail(IMansionContext context, IEnumerable<Crumb> trail)
        {
            // validate arguments
            if (context == null)
                throw new ArgumentNullException("context");
            if (trail == null)
                throw new ArgumentNullException("trail");

            // create a dataset from the trail
            var dataset = new Dataset();
            foreach (var crumb in trail)
                dataset.AddRow(PropertyBagAdapterFactory.Adapt(context, crumb));

            // create a buffer in which to store the output
            var templateBuffer = new StringBuilder();
            using (var templateBufferPipe = new StringOutputPipe(templateBuffer))
            using (context.OutputPipeStack.Push(templateBufferPipe))
            using (templateService.Render(context, "CrumbTrail", TemplateServiceConstants.OutputTargetField))
            {
                // create the loop
                var loop = new Loop(dataset);
                using (context.Stack.Push("Loop", loop))
                {
                    // render the leafs recursively
                    foreach (var crumb in loop.Rows)
                    {
                        using (context.Stack.Push("CrumbProperties", crumb))
                            templateService.Render(context, "CrumbTrailItem").Dispose();
                    }
                }
            }

            // return the contents of the buffer
            return templateBuffer.ToString();
        }
 /// <summary>
 /// Retrieves the all messages.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="username"> </param>
 /// <returns></returns>
 public Dataset RetrieveMessages(IMansionContext context, string username)
 {
     var dataset = new Dataset();
     dataset.AddRow(new PropertyBag
                    {
                    	{"message", string.Format("Stop wastin' me time an' put somethin' in th' box {0}!", username)}
                    });
     dataset.AddRow(new PropertyBag
                    {
                    	{"message", string.Format("What else ye got {0}? An' be quick about it, I be shippin' out soon!", username)}
                    });
     return dataset;
 }
		/// <summary>
		/// Retrieves a <see cref="Dataset"/> using <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="query">The query which to execute.</param>
		/// <returns>Returns a <see cref="Dataset"/> containing the results.</returns>
		/// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
		public Dataset RetrieveDataset(IMansionContext context, string query)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (string.IsNullOrEmpty(query))
				throw new ArgumentNullException("query");

			// create the connection and the transaction
			using (var connection = CreateConnection())
			using (var command = connection.CreateCommand())
			{
				// prepare the command
				command.Connection = connection;
				command.CommandText = query;
				command.CommandType = CommandType.Text;

				// execute the command
				using (var reader = command.ExecuteReader(CommandBehavior.CloseConnection))
				{
					var dataset = new Dataset();

					// looop over all the results
					while (reader.Read())
					{
						// create the row
						var row = new PropertyBag();

						// map all the properties
						for (var index = 0; index < reader.FieldCount; index++)
							row.Set(reader.GetName(index), reader.GetValue(index));

						// add the row to the dataset
						dataset.AddRow(row);
					}

					return dataset;
				}
			}
		}