SPSRollUpCalendar

- 2 mins read

(Beta Documentation)

Included in version 2 of SPSRollUp there is a new webpart to roll up data and show it using the SharePoint calendar view.

SPSRollUpCalendar has a similar operation to the SPSRollUp and SPSRollUpChart, and this means that it tracks sites and lists collecting information, the collected data is transformed using XSLT to generate XML as SPSRollUpChart does. The result XML is a description of the events to show in a calendar view.

With SPSRollUp you can also aggregate content from Picture Libraries, this is a little sample that shows you how to do it.

Select the desired lists that you want to aggregate and add the fields in the fields list, the most important field here is the EncodedAbsThumbnailUrl, this field contains the Url where the thumbnail image is stored. Other fields that we are using in the example are Title, Description and Keywords.

A common recurrence task in SharePoint is to locate the last modified files. SPSRollUp can help to you in this task.

You can use SPSRollUp to retrieve items from a document library as it is shown in the image.

You are supposed to select in the lists the document libraries in which you want crawl the results, and, in the fields you must select:

FileRef: That is the file name with full path. LinkFileName: That is the file name, without path. EncodedAbsUrl: That is the full path of the file, without file name. Modified: The date and time when the document was modified. Created: The date and time when the document was created.

You can add a simple CAML query in order to hide the expired elements.

Use:

<Where>
  <Geq>
    <FieldRef Name=”Expires” />
    <Value Type=”DateTime”>
      <Today />
    </Value>
  </Geq>
</Where>

This query show only items which Expiration date is greater or equal than today date.

If you want use also the hour, you can use

<Where> 
  <Geq> 
    <FieldRef Name=”Expires” /> 
    <Value Type=”DateTime” IncludeTimeValue=”TRUE”> 
      <Today /> 
    </Value> 
  </Geq> 
</Where>

In this sample we load a DropDown list with values from a list and we will use the selected value to filter another SPSRollUp.

Select a List and a Site from which we load data, and fill the SPSRollUp properties.

Use the next XSL to render the DropDown list, (we are using the field Title in the example)

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:sps="http://schemas.spsprofessional.com/WebParts/SPSXSLT" 
                exclude-result-prefixes="sps">
  <xsl:output method="html" />

  <xsl:param name="CurrentRow" />
  
  <xsl:template match="/">
    <![CDATA[
    <script type="text/javascript">
      function combo_onchange(oSelect)
      {
      if(oSelect.selectedIndex != -1)
      {
      var selected = oSelect.options[oSelect.selectedIndex].value;
      ]]><xsl:value-of select="sps:EventJS('Select','selected')" /><![CDATA[
      }
      }
    </script>
     ]]>
    Select a value
    <select id="a1" name="combo" onchange="javascript:combo_onchange(this);" class="ms-input">
      <option value="" />
      <xsl:for-each select="Rows/Row">
        <xsl:sort select="Title" />
        <xsl:element name="option">
          <xsl:attribute name="value">
            <xsl:value-of select="_RowNumber"/>
          </xsl:attribute>
          <xsl:if test="_RowNumber=$CurrentRow">
            <xsl:attribute name ="selected" />
          </xsl:if>
          <xsl:value-of select="Title" />
        </xsl:element>
      </xsl:for-each>
    </select>
  </xsl:template>
</xsl:stylesheet>

This XSL render the DropDown list, generating an option for each row returned in XML. When you select an option the javascript onchange event, send all row values using the provider interface.

This is a small trick to show the entries classic list in months and years that can be found in blogs.

To produce a data input such as this one we must count the number of entries occurred in a given month and year.

This is a complex result from the point of view of an XSLT transformation, but here we will see how we can use JavaScript alongside with our transformation to produce the necessary results.

An ActionGrid connected to an ActionViewChart to show in graph form all products and your quantity ordered by a customer

ActionViewChart XML Configuration

<?xml version="1.0" encoding="utf-16"?>
<SPSActionViewConfig>
  <DataBase ConnectionString=" ... " />
  <Query SelectCommand="SELECT SUM([Order Details].Quantity) AS Quantity, 
                               Products.ProductName
                        FROM   [Order Details] 
                        INNER JOIN Orders 
                              ON [Order Details].OrderID = Orders.OrderID 
                        INNER JOIN Products 
                              ON [Order Details].ProductID = Products.ProductID
                        WHERE Orders.CustomerID=@CustomerID  
                        GROUP BY Products.ProductName" />
  <Filter>
    <Param Name="CustomerID" Type="NChar" Default="" />
  </Filter>
</SPSActionViewConfig>

ActionViewChart XSLT

First images of ActionView and ActionViewChart webparts.

With the ActionView web part you can get data from your SQL Server Data Base and render the data using XSLT.

ActionViewChart web part permits show the data using graphs.

Both web parts are in a new package called ActionPack, that would be released at the end of June.

  • XML Configuration
<?xml version="1.0" encoding="utf-16"?>
<SPSActionViewConfig>
  <DataBase 
    ConnectionString="Data Source=W2K3;Initial Catalog=Northwind; .." />
  <Query SelectCommand=
        "SELECT CategoryID, CategoryName, SUM(ProductSales) AS Total
         FROM   [Sales by Category]
         GROUP BY CategoryName, CategoryID" />
</SPSActionViewConfig>
  • XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
                xmlns:sps="http://schemas.spsprofessional.com/WebParts/SPSXSLT" 
                exclude-result-prefixes="msxsl sps">
  <xsl:output method="xml" indent="yes" />
  <xsl:template match="@* | node()">
    <!-- Graph -->
    <graph caption="Title" 
           xAxisName="Products" 
           yAxisName="Sales" 
           decimalPrecision="0" 
           formatNumberScale="0">
      <xsl:apply-templates />
    </graph>
  </xsl:template>
  <!-- Each row -->
  <xsl:template match="Row">
    <!-- Put here your fields -->
    <set name="{CategoryName}" value="{Total}" color="{sps:GetFcColor()}" />
  </xsl:template>
</xsl:stylesheet>

Format vs Concat

- 1 min read

Esto post es para recordar simplemente que concatenar cadenas con String.Format es una mala práctica y para eso tenemos ese gran olvidado que es String.Concat.

Y como muestra un ejemplo…

public void Format()
{
    for (int i = 0; i < 1000; i++)
    {
        String.Format("{0},{1}", "Test", "Test");
    }
}
 
public void Concat()
{
    for (int i = 0; i < 1000; i++)
    {
        String.Concat("Test",",", "Test");
    }
}