Who’s the Man Blog


RSS Yahoo Weather Feed and Sharepoint WSS 3.0 / MOSS 2007
June 17, 2008, 2:00 am
Filed under: Sharepoint, Uncategorized | Tags: , , , ,

As part of my recent Sharepoint work I worked on finding a good Weather webpart the best that I could find was the following from http://blogs.msdn.com/ketaanhs/archive/2008/03/22/showing-weather-web-part-using-rss-weather-yahoo-com-in-sharepoint-2007.aspx

The RSS feed I used was:

http://weather.yahooapis.com/forecastrss?p=01541

And used the following XSL Spreadsheet:

<?xml version=”1.0″ encoding=”ISO-8859-1″?>

<xsl:stylesheet version=”1.0″
xmlns:xsl=”
http://www.w3.org/1999/XSL/Transform” xmlns:yweather=”http://xml.weather.yahoo.com/ns/rss/1.0” xmlns:geo=”http://www.w3.org/2003/01/geo/wgs84_pos#”>
<xsl:output method=”html” indent=”yes”/>

<xsl:template match=”/”>

<xsl:variable name=”scale”>
    <xsl:value-of select=”rss/channel/yweather:units/@temperature”/>
</xsl:variable>

<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”3″ class=”Normal”>
  <tr bgcolor=”#075C70″>
    <td colspan=”2″><strong><font color=”white”>Weather Report – <xsl:value-of select=”rss/channel/item/title”/></font></strong></td>
  </tr>
  <tr>
    <td><strong><font size=”4″><xsl:value-of select=”rss/channel/item/yweather:condition/@temp”/><xsl:text>°</xsl:text><xsl:copy-of select=”$scale” /></font></strong><br/>
      High <xsl:value-of select=”rss/channel/item/yweather:forecast/@high”/> <xsl:text>°</xsl:text><xsl:copy-of select=”$scale” /> <br/>
      Low <xsl:value-of select=”rss/channel/item/yweather:forecast/@low”/> <xsl:text>°</xsl:text><xsl:copy-of select=”$scale” /> </td>
    <td>
      <xsl:text disable-output-escaping=”yes”><img src=”
http://us.i1.yimg.com/us.yimg.com/i/us/we/52/</xsl:text>
      <xsl:value-of select=”rss/channel/item/yweather:condition/@code”/>
      <xsl:text disable-output-escaping=”yes”>.gif”/></xsl:text>
      <br/>
      <xsl:value-of select=”rss/channel/item/yweather:condition/@text”/></td>
  </tr>
  <tr bgcolor=”#075C70″>
    <td colspan=”2″><strong><font color=”white”>2 Day Forecast</font></strong></td>
  </tr>
  <tr>
    <td colspan=”2″><table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”3″ class=”Normal”>
      <xsl:for-each select=”(rss/channel/item/yweather:forecast)[position() < 3]“>
        <tr>
          <td><xsl:value-of select=”@day”/></td>
          <td>
            <xsl:text disable-output-escaping=”yes”><img src=”
http://us.i1.yimg.com/us.yimg.com/i/us/we/52/</xsl:text>
        <xsl:value-of select=”@code”/>
        <xsl:text disable-output-escaping=”yes”>.gif”/></xsl:text>
          </td>
          <td><xsl:value-of select=”@text”/><br/>High: <xsl:value-of select=”@high”/>
            <xsl:text>°</xsl:text><xsl:copy-of select=”$scale” />
             Low: <xsl:value-of select=”@low”/><xsl:text>°</xsl:text><xsl:copy-of select=”$scale” />
          </td>
        </tr>
       </xsl:for-each>
      </table></td>
  </tr>
 
</table>

</xsl:template>

</xsl:stylesheet>

 

And you end up with this:

 

 weatherpart

 Both WSS and MOSS versions of the webpart are uploaded to http://10235.freesharepoint2007.com/Downloads/Forms/AllItems.aspx



Sharepoint 3.0/MOSS 2007 and Whats Up Professional w/ MSDE or SQL 2005 Express
June 17, 2008, 1:43 am
Filed under: Uncategorized | Tags: , , , , ,

 As part of a implementation at work I have been trying to integrate applications (mainly SQL backend) applications into Windows Sharepoint Services 3.0 and MOSS 2007. While What’s Up uses SQL it comes with either MSDE 2000 or SQL 2005 Express in order to access it via the network you will need t enable TCP/IP access. I used Sharepoint Designer 2007 and created a data view on a test page and then exported the web part and imported into our layout based main page(a good way to get a custom web part into a ghosted/attached layout page). The problem was finding the correct SQL query to generate a table of down devices from Whats Up Gold here is the query I used at first which just gives the device and how long it has been down which is just the default query from What’sUp Dynamic Groups.

SELECT DISTINCT Device.nDeviceID FROM Device JOIN MonitorState ON Device.nWorstStateID = MonitorState.nMonitorStateID WHERE Device.bRemoved = 0 AND MonitorState.nInternalMonitorState = 1

Here is the webpart it displays the time down is different colors yellow for currently down, orange for 2 mins, and red for 5 mins or more to customize to your enviroment replace whatsupserver with your server name and username and password with yours:

<webParts>
  <webPart xmlns=”http://schemas.microsoft.com/WebPart/v3“>
    <metaData>
      <type name=”Microsoft.SharePoint.WebPartPages.DataFormWebPart, Microsoft.SharePoint,

Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name=”PageSize” type=”int”>-1</property>
        <property name=”HelpMode” type=”helpmode”>Modeless</property>
        <property name=”Height” type=”string” />
        <property name=”SampleData” type=”string” null=”true” />
        <property name=”AllowConnect” type=”bool”>True</property>
        <property name=”CatalogIconImageUrl” type=”string” />
        <property name=”XslLink” type=”string” null=”true” />
        <property name=”AllowClose” type=”bool”>True</property>
        <property name=”Hidden” type=”bool”>False</property>
        <property name=”MissingAssembly” type=”string”>Cannot import this Web Part.</property>
        <property name=”TitleIconImageUrl” type=”string” />
        <property name=”ChromeState” type=”chromestate”>Normal</property>
        <property name=”FireInitialRow” type=”bool”>True</property>
        <property name=”Description” type=”string” />
        <property name=”AllowMinimize” type=”bool”>True</property>
        <property name=”Xsl” type=”string”>

<xsl:stylesheet xmlns:xs=”http://www.w3.org/2001/XMLSchema

xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata” version=”1.0″ exclude-result-prefixes=”xsl

msxsl ddwrt” xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime

xmlns:asp=”http://schemas.microsoft.com/ASPNET/20

xmlns:__designer=”http://schemas.microsoft.com/WebParts/v2/DataView/designer

xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:msxsl=”urn:schemas-microsoft-com:xslt”

xmlns:SharePoint=”Microsoft.SharePoint.WebControls” xmlns:ddwrt2=”urn:frontpage:internal”>
 <xsl:output method=”html” indent=”no”/>
 <xsl:decimal-format NaN=”"/>
 <xsl:param name=”dvt_apos”>’</xsl:param>
 <xsl:variable name=”dvt_1_automode”>0</xsl:variable>
 
 <xsl:template match=”/” xmlns:xs=”
http://www.w3.org/2001/XMLSchema

xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata”

xmlns:asp=”http://schemas.microsoft.com/ASPNET/20

xmlns:__designer=”http://schemas.microsoft.com/WebParts/v2/DataView/designer

xmlns:SharePoint=”Microsoft.SharePoint.WebControls”>
  <xsl:call-template name=”dvt_1″/>
 </xsl:template>
 
 <xsl:template name=”dvt_1″>
  <xsl:variable name=”dvt_StyleName”>RepForm1</xsl:variable>
  <xsl:variable name=”Rows” select=”/dsQueryResponse/NewDataSet/Row” />
  <xsl:variable name=”dvt_RowCount” select=”count($Rows)” />
  <xsl:variable name=”IsEmpty” select=”$dvt_RowCount = 0″ />
  <table border=”0″ width=”100%”>
   <xsl:call-template name=”dvt_1.body”>
    <xsl:with-param name=”Rows” select=”$Rows” />
    
    </xsl:call-template>
  </table>
  </xsl:template>
 <xsl:template name=”dvt_1.body”>
  <xsl:param name=”Rows” />
  <xsl:for-each select=”$Rows”>
     <xsl:call-template name=”dvt_1.rowview”

/></xsl:for-each>
 </xsl:template>
 <xsl:template name=”dvt_1.rowview”>
  <tr>
   <td width=”100%” colspan=”2″ class=”ms-vb”>
    
   </td>
  </tr>
  <tr>
   <td width=”100%” colspan=”2″ class=”ms-vb”>
    <a

href=”http://whatsupserver/NmConsole/Workspace/DeviceStatus/DeviceStatus.asp?nDeviceID={@nDeviceID

}”><xsl:value-of select=”@sDisplayName” /></a>
    <xsl:text

xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime

ddwrt:nbsp-preserve=”yes” disable-output-escaping=”yes”>&amp;nbsp;
    
    </xsl:text>- <span>
    <xsl:attribute name=”style”>
     <xsl:if test=”normalize-space(@sStateName) =

‘Down’”>color: #FFFF00;</xsl:if>
     <xsl:if test=”normalize-space(@sStateName) = ‘Down at

least 2 min’”>color: #FF9900;</xsl:if>
     <xsl:if test=”normalize-space(@sStateName) = ‘Down at

least 5 min’ or normalize-space(@sStateName) = ‘Down at least 20 min’”>color: #FF0000;

font-size: inherit;</xsl:if>
    </xsl:attribute>
    <xsl:value-of select=”@sStateName”

disable-output-escaping=”yes” />
    </span><br /></td>
  </tr>
  <xsl:if test=”$dvt_1_automode = ‘1′” ddwrt:cf_ignore=”1″>
   <tr>
    <td width=”100%” colspan=”2″ class=”ms-vb”>
     <span ddwrt:amkeyfield=”nDeviceID,nMonitorStateID”

ddwrt:amkeyvalue=”concat(ddwrt:EscapeDelims(string(@nDeviceID)),’,',ddwrt:EscapeDelims(string(@n

MonitorStateID)))” ddwrt:ammode=”view” />
    </td>
   </tr>
  </xsl:if>
 </xsl:template>
 </xsl:stylesheet> </property>
        <property name=”ListName” type=”string” null=”true” />
        <property name=”ChromeType” type=”chrometype”>Default</property>
        <property name=”AllowEdit” type=”bool”>True</property>
        <property name=”ShowWithSampleData” type=”bool”>False</property>
        <property name=”Direction” type=”direction”>NotSet</property>
        <property name=”DataFields”

type=”string”>@nDeviceID,nDeviceID;@sDisplayName,sDisplayName;@nMonitorStateID,nMonitorStateID;@

sStateName,sStateName;@nInternalMonitorState,nInternalMonitorState;@nInternalStateTime,nInternal

StateTime;@nStateFillColor,nStateFillColor;@nStateLineColor,nStateLineColor;@nShapePoints,nShape

Points;@nShapeInnerRadius,nShapeInnerRadius;@nShapeOuterRadius,nShapeOuterRadius;@nShapeDirectio

n,nShapeDirection;@bSystemType,bSystemType;</property>
        <property name=”ViewContentTypeId” type=”string” />
        <property name=”Width” type=”string” />
        <property name=”CacheXslTimeOut” type=”int”>86400</property>
        <property name=”TitleUrl” type=”string” />
        <property name=”DataSourceID” type=”string” />
        <property name=”HelpUrl” type=”string” />
        <property name=”CacheXslStorage” type=”bool”>True</property>
        <property name=”DataSourcesString” type=”string”><%@ Register TagPrefix=”sharepoint”

Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=12.0.0.0,

Culture=neutral, PublicKeyToken=71e9bce111e9429c” %><sharepoint:SPSqlDataSource

runat=”server” AllowIntegratedSecurity=”False” ConnectionString=”Data

Source=whatsupserver\whatsup;User ID=username;Password=password;Initial Catalog=WhatsUp;”

ProviderName=”System.Data.SqlClient” SelectCommand=”SELECT DISTINCT Device.nDeviceID,

Device.sDisplayName, MonitorState.*  FROM         Device INNER JOIN                       

MonitorState ON Device.nWorstStateID = MonitorState.nMonitorStateID  WHERE     (Device.bRemoved

= 0) AND (MonitorState.nInternalMonitorState = 1)”

ID=”WhatsUp_x0020_Server_x0020_Down_x0020_Devices1″></sharepoint:SPSqlDataSource>
</property>
        <property name=”ExportMode” type=”exportmode”>All</property>
        <property name=”AllowZoneChange” type=”bool”>True</property>
        <property name=”Default” type=”string” />
        <property name=”UseSQLDataSourcePaging” type=”bool”>True</property>
        <property name=”ParameterBindings” type=”string”>
       <ParameterBinding Name=”dvt_apos”

Location=”Postback;Connection”/>
       <ParameterBinding Name=”UserID”

Location=”CAMLVariable” DefaultValue=”CurrentUserName”/>
       <ParameterBinding Name=”Today”

Location=”CAMLVariable” DefaultValue=”CurrentDate”/>
      </property>
        <property name=”DisplayName” type=”string” />
        <property name=”NoDefaultStyle” type=”string”>TRUE</property>
        <property name=”Title” type=”string”>WhatsUp Server Down Devices</property>
        <property name=”AllowHide” type=”bool”>True</property>
        <property name=”ViewFlag” type=”string”>0</property>
      </properties>
    </data>
  </webPart>
</webParts>

And you end up with something that looks like this:

 

whatsupwebpart

 I hope this helps someone besides myself.