Home RSS 2.0 ATOM 1.0  CDF  
 
CodeSegment - Carlos Segura Sanz (blog)
 

Some time ago I write a post with a little trick to add this "missed" option ["View all folders" in Document Libraries]. Now I have needed it in all my documents libraries and the best option is as always modify the list schema file.

Each list definition contains a schema.xml that defines the views, forms, toolbar, and special fields in a list definition. In my production server I have modified the DOCLIB template in "web server extensions\60\TEMPLATE\3082\STS\LISTS\DOCLIB"

Using your favorite CAML Editor .... :-) adds the next code after first HTML Tag under Toolbar (relatedtasks) tag entry.

<HTML>
    <![CDATA[
     <script language="Javascript">
    function LayoutsLink(aspxFullUrl)
    {
       var rootFolder = GetUrlKeyValue("RootFolder");
       if (rootFolder != "")
           aspxFullUrl += "&RootFolder=" + rootFolder;
       window.location.href = aspxFullUrl;
    }
    </script>
    <tr> 
    <td style="padding-left: 2px;padding-bottom: 2px" width=100%&gt; 
    &lt;table border=0 cellpadding=0 cellspacing=0 width=100%&gt; 
    &lt;tr> 
    <td width=100% class="ms-unselectednav" colspan=2> 
    <table cellpadding=0 cellspacing=0 border=0> 
    <tr> 
    <td valign=top> 
    <img src="/_layouts/images/rect.gif">&nbsp; </td> 
    <td>
    <A ACCESSKEY="p" ID="diidFolderListButton" HREF="javascript:" onClick="javascript:LayoutsLink(']]>
</HTML>
 
<HTML>
   <![CDATA[/_layouts/<%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%>/folders.aspx?List=]]>
</HTML>
 
<HTML>
   <![CDATA[');javascript:return false;">]]>
</HTML>
 
<HTML>Ver todas las carpetas</HTML>
 
<HTML>
   <![CDATA[</A></td> </tr> </table> </td> </tr> </table> </td> </tr>]]>
</HTML>

The final result is as shown in the image.

            and the folder view 

Tuesday, January 31, 2006 12:39:18 AM (Hora estándar romance, UTC+01:00)   #    Comments [0]    | 

Part 2

Changing the dav web query, you can get more data (see urn:content-classes:message and Default Exchange Store Namespaces for other namespaces) now to complete the sample the new query is

SELECT "urn:schemas:httpmail:datereceived", 
"DAV:href",
"urn:schemas:httpmail:sendername",
"urn:schemas:httpmail:subject"
FROM scope('shallow traversal of ') WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False

And to watch the xml results obtained by the query we can modify the checkState function. 

function checkState()

{
  if (xmlHttpReq.readyState == 4)
  {
    divOutput.innerText = xmlHttpReq.ResponseXML.xml;
  }
}

Better than parse DOM to get the results I prefer use XSL, now I can copy the XML results in my favorite XSLT editor and map the data. After I can add the xsl to the page and transform the xml usig it. The final result is as shown in the image.

 

<script language=javascript>
var sUser = "USERNAME";
var sExchangeServer = "http://SERVER";
var sFolder = "FOLDER";
 
var xmlHttpReq;
 
function getMessages()
{
    .....
     
        var sDavQuery = 'SELECT  "urn:schemas:httpmail:datereceived", ' +
                              '"urn:schemas:httpmail:sendername", ' +
                              '"DAV:href", ' +
                              '"urn:schemas:httpmail:subject" ' +
                        ' FROM scope(\'shallow traversal of "' + sURL + '"\' )' +
                           ' WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False ';
                           
    .....
}
 
 
function checkState()
{
  if (xmlHttpReq.readyState == 4)
  {
    var xml = xmlHttpReq.ResponseXML;
    divOutput.innerHTML = xml.transformNode(xslTemplate.documentElement);        
  }
}
getMessages();
 
</script>
<div id='divOutput'></div>
 
<xml id='xslTemplate'>
 
   <xsl:template xmlns:xsl='uri:xsl' xmlns:a='DAV:' xmlns:d='urn:schemas:httpmail:'>
      <table>
      
          <tr class="ms-TPHeader">
            <td> Date </td>
            <td> From </td>
            <td> Subject </td>
          </tr>
          
         <xsl:for-each select='a:multistatus/a:response/a:propstat/a:prop'>
            <tr class="ms-WPBody">
               <td>
                  <xsl:value-of select='d:datereceived' />
               </td>
               <td>
                  <xsl:value-of select='d:sendername' />
               </td>
               <td>
                  <a>
                     <xsl:attribute name='href'>
                     <xsl:value-of select='a:href' />
 
                     /?Cmd=open</xsl:attribute>
 
                     <xsl:attribute name='target'>_blank</xsl:attribute>
 
                     <xsl:value-of select='d:subject' />
                  </a>
               </td>
            </tr>
         </xsl:for-each>
      </table>
   </xsl:template>
 
</xml>
Friday, January 27, 2006 11:03:30 PM (Hora estándar romance, UTC+01:00)   #    Comments [0]   SharePoint  | 

We can use asynchronous data retrieval, inside of a WebContent webpart, this is a little sample of how to do it.

Part 1

Querying an exchange server and retry results inside of sharepoint webpart, this first sample use the Search web dav method using XMLHTTP request (Exchange Store WebDAV Protocol), query the last five elements from user inbox and gets the date received, the sender name and the subject.

SELECT "urn:schemas:httpmail:datereceived", 
"urn:schemas:httpmail:sendername",
"urn:schemas:httpmail:subject"
FROM scope('shallow traversal of ') WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False


In the code, replace the sUser, sExchangeServer and sFolder vars, add a web content webpart and paste the code inside.

<script language=javascript>
 
var sUser = "USERNAME";
var sExchangeServer = "http://SERVER";
var sFolder = "FOLDER";
 
var xmlHttpReq;
 
function getMessages()
{
   var sURL = sExchangeServer + "/exchange/" + sUser + "/" + sFolder;
    
    if (sUser!="" && sURL!="")
    {
      xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");  
    
      xmlHttpReq.open("SEARCH", sURL, true);
      xmlHttpReq.setRequestHeader("Content-type:", "text/xml");
      xmlHttpReq.setRequestHeader("Depth", "1");
     
      xmlHttpReq.onReadyStateChange = checkState;
     
      // Our webDav query
      var sDavQuery = 'SELECT "urn:schemas:httpmail:datereceived", ' +
                              '"urn:schemas:httpmail:sendername", ' +
                              '"urn:schemas:httpmail:subject" ' +
                           ' FROM scope(\'shallow traversal of "' + sURL + '"\' )' +
                           ' WHERE "DAV:ishidden"=False AND "DAV:isfolder"=False ';
 
      // The request package                           
      var sSearchRequest = "<?xml version='1.0' ?>" +
                           "<a:searchrequest xmlns:a='DAV:'><a:sql>" + 
                                 sDavQuery +     
                           "</a:sql></a:searchrequest>";
      
      // Max results
      xmlHttpReq.SetRequestHeader("Range", "rows=0-4");
    
      xmlHttpReq.Send(sSearchRequest);
    }
}
 
function checkState()
{
  if (xmlHttpReq.readyState == 4)
  { 
     var xml = xmlHttpReq.responseXML.documentElement;
    
     // Parse xml - table to present results 
     var xmlResults = xml.getElementsByTagName('a:prop');
        
     var domTableResults = document.createElement('TABLE');
        
     domTableResults.setAttribute('cellPadding',5);
        
     var tmp = document.createElement('TBODY');
        
     domTableResults.appendChild(tmp);
     var domTableRow = document.createElement('TR');
     domTableRow.setAttribute('class','ms-TPHeader;');
        
     // Table header
     for (j=0;j<xmlResults[0].childNodes.length;j++)
     {
        if (xmlResults[0].childNodes[j].nodeType != 1) 
            continue;
        
        var container = document.createElement('TH');
        var theData = document.createTextNode(xmlResults[0].childNodes[j].nodeName);
        
        container.appendChild(theData);
        domTableRow.appendChild(container);
     }
    
     tmp.appendChild(domTableRow);
        
     // Table rows
     for (i=0;i<xmlResults.length;i++)
     {
        var domTableRow = document.createElement('TR');
        domTableRow.setAttribute('class','ms-WPBody;');
            
        for (j=0;j<xmlResults[i].childNodes.length;j++)
        {
            if (xmlResults[i].childNodes[j].nodeType != 1) 
            continue;
            
          var container = document.createElement('TD');
          var theData = document.createTextNode(xmlResults[i].childNodes[j].firstChild.nodeValue);
                
          container.appendChild(theData);
          domTableRow.appendChild(container);
        }
            
        tmp.appendChild(domTableRow);
     }
    
     document.getElementById('divOutput').appendChild(domTableResults);
  }
}
getMessages();
</script>
<div id='divOutput'></div>

 

Thursday, January 26, 2006 8:20:36 PM (Hora estándar romance, UTC+01:00)   #    Comments [1]   SharePoint  | 

 

csegRollUp 3.1a

* Fixes

    - Queries with fields that contains spaces
    - Variables in caml queries
    - Other minor bugs

* Improvements (awaited :-))

    - Now there is a new property "From top level" where you can specify the starting point from which the csegrollup would gather the information, this url can be a site or a portal area. The format is an Url format (http://sever/sites/site or http://server/area), Now you can use csegRollUp in an area and rollup content from sites in other areas or others urls, also you can use csegRollUp in a site/subsite and agregate content from a top site.

  csegRollUp31a.zip (75,44 KB)

Tuesday, January 24, 2006 11:29:46 PM (Hora estándar romance, UTC+01:00)   #    Comments [31]   csegRollUp | SharePoint  | 

* Via Mart Muller este truco para mover un sitio de sharepoint a otro servidor

* Via ScottGu una utilidad escrita por Cristian Civera para examinar el viewstate en el servidor local. Imprescindible para debugear nuestra páginas asp.net 2.0

* Via Chris Crowe las utilidades de IIS han sido actualizadas, Debug Diagnostics, Trace Diag.

  (x86) Landing: http://www.microsoft.com/downloads/details.aspx?FamilyID=9BFA49BC-376B-4A54-95AA-73C9156706E7&displaylang=en

  (x64) Landing: http://www.microsoft.com/downloads/details.aspx?FamilyID=7e42b310-b2d1-496b-8005-9d91782b9995&DisplayLang=en

  (ia64) Landing: http://www.microsoft.com/downloads/details.aspx?FamilyID=13c1c5e5-592c-45bc-b5bb-c486b43eb539&DisplayLang

 

* Via Mart Muller nos cuenta que su colega Ferry ha hecho una estupenda biblioteca de símbolos para maquetar sitios de sharepoint en Visio, Descargar aquí.

 

* Microsoft Downloads, snippets para VSTO 2005

Sunday, January 22, 2006 11:03:29 PM (Hora estándar romance, UTC+01:00)   #    Comments [0]   SharePoint-es  | 

DIA 1

Estos días he estado probando algunas cosas con SharePoint, empecé instalando la versión inglesa del Business Scorecard Manager 2005 ya que no aguantaba más de esperar a la versión en castellano (las ayudas por lo menos están pero el programa no), después de instalar los requisitos necesarios en mi maquina de pruebas...

Probé a instalar el producto ... que fallaba estrepitosamente al crear la base de datos :-( probé después con un SQL Server 2000 y me seguía ocurriendo lo mismo, comprobé todos los permisos en uno y otro sitio y tras una hora conseguí que me creará la base de datos. Lo que hice fue instalarla directamente sobre el servidor SQL, instalando las opciones personalizadas diciéndole que no a todo excepto a la base de datos. Bien, ya tenía la BBDD instalada, ahora me quedaba instalar las webparts en el servidor (el resto de componentes de la instalación), no hubo suerte, tras indicar al programa de instalación dónde se encuentra en servidor SQL y el nombre de la BBDD me da un error tal que:

Product: Microsoft Office Business Scorecard Manager 2005 -- Error 26204.
Error -2147217900: failed to execute SQL string, error detail: El usuario o función 'SRVTEST\Administrador' no existe en la base de datos., SQL key: SQLWeb3 SQL string: USE ScorecardServer DECLARE @dbowner sysname SELECT @dbowner = SUSER_SNAME(sid) FROM master.dbo.sysdatabases WHERE name = 'ScorecardServer' IF NOT(@dbowner = 'SRVTEST\Administrador') EXEC sp_addrolemember 'BPMDeveloper', 'SRVTEST\Administrador'

Este es generalmente el momento en dónde debía haber desistido, al menos por el día. Bueno tras pasar un rato buscando información, sin éxito, me decido a borrar el usuario de la base de datos y volverlo a crear a ver si hay suerte. Cosas de la vida, la hubo. (Creo, no lo puedo asegurar que el usuario estaba creado como "Administrador", y tras mi alta/baja se creó como "SRVTEST\Administrador" ¿¿¿sería eso???), ya habían trascurrido casi tres horas desde el comienzo así que...

DIA 2

Continuo con el BSM 2005 a ver si sacamos algo en limpio, entre tanto se me ha ocurrido una idea para un simple webpart, para conectarme a través de los servicios de análisis sobre XML (esto ha interrumpido mi trabajo con el BSM), de modo que he probado ha hacer un pequeño webpart para conectarme a través de XMLA y ejecutar una MDX, para darle un poco de flexibilidad al asunto, el contenido XML será (¿como no?) transformado por un XSLT.

El resultado en media horita de codificación ha sido un éxito.

Lo primero que he hecho ha sido crear un interface para usar el XMLA, (se puede descargar una copia del WSDL para el  XML for Analysis SDK, desde aqui) una vez descargado he creado la interface para acceder al servicio web (wsdl VS7msxmlanalysis.wsdl) he añadido clase a mi proyecto, ahora  basta con usarlo.

   1:  private string ExecuteMdx(string Command, string Properties, string Url)
   2:  {
   3:      // Usamos la clase proxy para acceder al xmla               
   4:      MsXmlAnalysis xmlAnalysis = new MsXmlAnalysis();
   5:      
   6:      // Credenciales
   7:      xmlAnalysis.Credentials = CredentialCache.DefaultCredentials;  
   8:      
   9:      // Url del servicio (http://servidor de xmla/xmla/msxisapi.dll)
  10:      xmlAnalysis.Url = Url;
  11:   
  12:      XmlDocument xmlCommand = new XmlDocument();
  13:      XmlDocument xmlProperties = new XmlDocument();            
  14:      XmlElement  xmlResult;
  15:   
  16:      // El comando (MDX) debe ir precedido de <statement>
  17:      Command = "<Statement>" + Command + "</Statement>";
  18:      
  19:      // Cargamos el comando y los datos de la conexión
  20:      xmlCommand.LoadXml(Command);
  21:      xmlProperties.LoadXml(Properties);
  22:   
  23:      // Ejecutamos el método Execute
  24:      xmlResult = xmlAnalysis.Execute( 
  25:          (XmlElement) xmlCommand.FirstChild, 
  26:          (XmlElement) xmlProperties.FirstChild
  27:          );
  28:      
  29:      // Devolvemos el resultado XML
  30:      return xmlResult.InnerXml;
  31:  }

El webpart necesita la url del servicio XMLA, los datos de la conexión :

   1:  <PropertyList>
   2:     <DataSourceInfo>Provider=MSOLAP;Data Source=local</DataSourceInfo>
   3:   
   4:     <Catalog>FoodMart 2000</Catalog>
   5:   
   6:     <Content>Data</Content>
   7:   
   8:     <Format>Multidimensional</Format>
   9:   
  10:     <BeginRange>"1</BeginRange>
  11:   
  12:     <EndRange>-1</EndRange>
  13:  </PropertyList>

Y una MDX como

   1:  with member [Measures].[SalesRatio] as '([Store Sales] - [Store Cost]) / [Store Cost]', FORMAT_STRING = '##%' 
       select { [Store Sales], [Store Cost], [SalesRatio] } on COLUMNS, 
              Filter( [Product].[Brand Name].Members, [SalesRatio] > 1.60 ) on  ROWS 
       from Sales

El resultado a quedado bastante bien para media hora...

Saturday, January 21, 2006 6:48:49 PM (Hora estándar romance, UTC+01:00)   #    Comments [0]   SharePoint-es  | 

Lo primero advierto que esta practica no esta del todo recomendada. Pero seguro que en más de una ocasión os habéis encontrado con el problema que supone tener el campo Título pre-configurado por SharePoint, (por lo menos deja cambiarle el nombre) pero no deja de ser una limitación en muchos casos que el tipo predeterminado sea un campo alfanumérico de 255 caracteres.

La definición en CAML del campo Título es la siguiente:

<Field Type="Text" DisplayName="Título" MaxLength="255" Name="Title" ColName="nvarchar1" />

Algunas veces he editado este campo usando CAML y he cambiado el tipo (yo por el momento no he tenido problemas al hacerlo pero como he dicho al principio es una practica que no se aconseja). Hoy trasteando he recordado que alguien (no recuerdo quien si no lo pondría) había realizado un webpart para resetear el campo Título,  de manera que después se le pudiera cambiar el tipo. De modo que he echado mano de mi webpart csegScript, y en unos minutos he dado con el código.

imports Microsoft.SharePoint 
imports Microsoft.SharePoint.Utilities 
imports Microsoft.SharePoint.WebPartPages 
imports Microsoft.SharePoint.WebControls 
imports System.Web.UI 
imports System 
 
Module Script 
Public Sub Main() 
 
Dim site As SPSite = SPControl.GetContextSite(System.Web.HttpContext.Current) 
Dim allSites As SPWebCollection = site.AllWebs 
Dim subSite As SPWeb = allSites(0) 
 
if (Param1<>"") and (Param2<>"") then 
 
Dim list as SPList = subSite.Lists(Param1) 
Dim field As SPField = list.Fields(Param2) 
 
output.WriteLine("<br>Current SchemaXml:" + SPEncode.HtmlEncode(field.SchemaXml)) 
 
Dim schemaXML As String = "<Field Type=""Text""  DisplayName=""" & field.Title & 
                 """ MaxLength=""255"" Name=""" & field.InternalName  & """ ColName=""nvarchar2"" />" 
 
output.WriteLine("<pre>" & SPEncode.HtmlEncode(schemaXML) & "</pre>") 
output.flush() 
 
try 
 
field.SchemaXml = schemaXML 
'field.Update() 
output.WriteLine("<font color=red>Ok</font>") 
 
catch ex As Exception 
 
output.WriteLine("<font color=red>Error</font>") 
output.WriteLine(ex.Message) 
 
end try 
 
output.WriteLine("<table width='100%'><tr><td>Name</td><td>Description</td><td>InternalName</td><td>Type</td></tr>") 
 
output.WriteLine("<tr><td>"+
	SPEncode.HtmlEncode(field.Title)+"</td><td>"+
        SPEncode.HtmlEncode(field.Description)+"</td><td>"+
        SPEncode.HtmlEncode(field.InternalName)+"</td><td>"+
        SPEncode.HtmlEncode(field.TypeAsString)+"</td></tr>") 
 
output.WriteLine("</table>") 
 
End If 
 
End Sub 
End Module

Este script requiere el nombre de la lista como Param1 y el nombre del campo a resetear como Param2.

Después de ejecutar el script y entrar a modificar la configuración de la lista y el campo, podeís cambiarle el tipo.

 

Tuesday, January 17, 2006 10:27:17 PM (Hora estándar romance, UTC+01:00)   #    Comments [0]   csegScript | SharePoint-es  | 

Via Romeo Pruno este enlace a Sybari para poder descargar el antivirus Antigen

Serge van den Oever Makaw ha publicado la versin 1.0.0.1 del MacawSharePointSkinner este skinner permite hacer cambios en el aspecto y la funcionalidad de sharepoint sin alterar la configuracin de sharepoint, el funcionamiento viene aser el de un filtro que una vez configurado reemplazara el contenido de aquello que deseemos en base a una serie de reglas.

El equipo de desarrollo de SharePoint tiene su propio blog

PJ Hough nos ha dejado un buen articulo con algunos pantallazos de la v3.

 

Saturday, January 14, 2006 11:06:46 AM (Hora estándar romance, UTC+01:00)   #    Comments [0]   SharePoint-es  | 

I have a stopped project that I want release in the nexts weeks, it's called csegDocLibTools, this is a webpart to show a explorer like interface in document libraries and adds cut and paste features.

- SharePoint - Making document libraries a bit more explorer-like 
- SharePoint - Making document libraries a bit more explorer-like - csegDocLibTools 

Now here is the beta release, any feedback get will be great.

 csegDocLibToolsWebPart.zip (26,51 KB)

Note: To test this version, open a document library view (example: allitems.aspx) in FrontPage, put the webpart on top of ListViewWebPart and setup the correct properties.

Tuesday, January 10, 2006 7:55:31 PM (Hora estándar romance, UTC+01:00)   #    Comments [2]   csegDocLibTools  | 

Yesterday I got the email. I am very happy and honored to announce that I was awarded Microsoft’s Most Valuable Professional (MVP) for Microsoft Office SharePoint Portal Server. Thanks to everyone who got me nominated. I look forward to continuing to contribute to our community and strive to help it grow.

Bueno, parece ser que los reyes se han adelantado un día. Muchísimas gracias a todos los que me han nominado, a los que leen este blog y usan mis webparts. Gracias. Espero que este año podamos hacer más cosas interesantes juntos. Una vez más gracias.

Thursday, January 05, 2006 11:04:01 AM (Hora estándar romance, UTC+01:00)   #    Comments [8]   SharePoint | SharePoint-es  | 

First I want to thank to Josh Ledgard to allow to me test the first CTP of  MSBee. With MSBee you can build .NET 1.1 projects using Visual Studio 2005. MSBee is designed to use MSBuild and use a property to set the target framework. MSBee map assembly references from .NET 2.0 assemblies to their .NET 1.1 equivalents.

Installation and usage

This first release install unzipping four files in the MSBuild directory. These files contans the NET 1.1 target files and the small msbee.dll. After install you only need open a Visual Studio 2003 project with Visual Studio 2005, locate the project file (.csproj) and insert a line under

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

thats contains the new targets if MSBuild use EverettBuild = true (Everett was the code name of 1.1 framework)

<Import Project="$(MSBuildExtensionsPath)\Microsoft.Public.CSharp.targets" Condition=" '$(BuildingInsideVisualStudio)' == '' AND '$(EverettBuild)' == 'true' " />

Then you can call to MSBuild from a Visual Studio 2005 command prompt using

msbuild <your project here>.csproj /t:Rebuild /p:EverettBuild=true

I have added a new External Tool to run this command line from IDE  called MBSee (MSBuild 1.1) using

Command: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe
Arguments: $(ProjectFileName) /t:Rebuild /p:EverettBuild=true
Initial Directory:  $(ProjectDir)

Building my first webpart with Visual Studio 2005

Less than one minute to import the Visual Studio 2003 project in Visual Studio 2005 and modify the project line. Then Tools->MSBee MSBuild 1.1 and all is right. Usually I have a child project with the setup installation, I needed make it again.

Only a small inconvenience because the MSBee at moment doesn´t work with some additional tasks like Assembly Linking, to solve this I have needed to sign the assembly manually using the strong name utuility.

MSBee is an indispensable tool.

Wednesday, January 04, 2006 12:03:15 AM (Hora estándar romance, UTC+01:00)   #    Comments [1]   NET Development | SharePoint  | 


Copyright © 2008 Carlos Segura. All rights reserved.