Arranging web parts in JQuery tabs

From past couple of weeks I’m thoroughly working on designing custom SharePoint sites which should look untraditional SharePoint site in all the way. Most of the time users ask to put lots of libraries web part on the home page which looks cluttered and dirty with scroll bars. So I thought why don’t I try with tab table and jQuery was my first preference. Here is how I achieved using SharePoint designer 2010

  • Open your SharePoint site in SharePoint designer 2010 and Download following JQuery JS files and keep into SharePoint site for reference.

Here are the locations,

http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css
http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
  • Add new ASPX page into your site.

  • Open newly created aspx page in design mode and add following code in head section,
<link href="/path$/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script type="text/javascript" src="/path$/jquery.min.js"></script>
  <script type="text/javascript" src="/path$/jquery-ui.min.js"></script>

  <script type="text/javascript">
  $(document).ready(function() {
    $("#tabs").tabs();
  });
 </script>
  • Add following code in body section of the form , Comments shows where web part zone will be added.
<div id="tabs">

    <ul>
        <li><a href="#tab-1"><span>Announcements</span></a></li>
        <li><a href="#tab-2"><span>Events</span></a></li>
        <li><a href="#tab-3"><span>Tasks</span></a></li>
        <li><a href="#tab-4"><span>Shared Documents</span></a></li>

    </ul>

    <div id="tab-1">
        <!-- Web part Zone -->
    </div>

    <div id="tab-2">
       <!-- Web part Zone -->
    </div>

    <div id="tab-3">
         <!-- Web part Zone -->
    </div>

    <div id="tab-4">
        <!-- Web part Zone -->
    </div>

</div>
  • Add web part zone in each DIV . It should be like,

  • Save the form and hit F12. You can able to see the tab table like,

  • Time to link Master page into this aspx page. To do that, Go to Style tab and select master page to attach. View the page on the browser and add web parts to the zone. Here is the final output,


Merging document libraries using C#

To continue with my last post about using Content Query web part to merge libraries in same site collection. We didn’t find this solution a elegant one due to lack of control on functionality and styling. For example, My user asks to sort the merge library on document creation date and apply grouping.Though it’s possible if you are very good in XML/XSLT and willing to write ton of code.I have followed custom coding path using C# and here is the solution.

  • Create new Visual Web Part project in Visual Studio 2010 with C# and .NET Framework 3.5
  • Add SPGridView control on UserControl.ascx page,
<SharePoint:SPGridView
  runat="server"
  ID="spLibraryView"
  AutoGenerateColumns="false"
  RowStyle-BackColor="#DDDDDD"
  AlternatingRowStyle-BackColor="#EEEEEE" />
  • Add following code on UserControl.ascx.cs page
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data;
using Microsoft.SharePoint.Utilities;

namespace WebPartDisplaySiteData.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
         protected void Page_Load(object sender, EventArgs e)
        {
            getData();
        }

         public void getData()
         {
             DataTable dt = new DataTable();
             DataRow dr;
             DataColumn dc;

             SPSite curSite = SPContext.Current.Site;
             SPWebCollection subSites = curSite.AllWebs;

             dc = new DataColumn("Title", Type.GetType("System.String"));
             dt.Columns.Add(dc);
             dc = new DataColumn("ReferenceNo", Type.GetType("System.String"));
             dt.Columns.Add(dc);
             dc = new DataColumn("Domain", Type.GetType("System.String"));
             dt.Columns.Add(dc);
             dc = new DataColumn("Created", Type.GetType("System.DateTime"));
             dt.Columns.Add(dc);
             dc = new DataColumn("SiteUrl", Type.GetType("System.String"));
             dt.Columns.Add(dc);

             for (int i = 0; i < subSites.Count; i++)
             {
                 SPListCollection lists = subSites[i].Lists;

                 foreach (SPList list in lists)
                 {
                     if (list.Title == "Published Documents")
                     {
                         SPQuery myquery = new SPQuery();

                         myquery.Query = "<GroupBy><FieldRef Name='Domain' />
                                         </GroupBy><OrderBy><FieldRef Name='Domain' /></OrderBy>";

                         SPListItemCollection items = list.GetItems(myquery);

                         foreach (SPListItem item in items)
                         {
                             if (item != null)
                             {
                                 dr = dt.NewRow();

                                 dr["Title"] = item["Title"];
                                 dr["ReferenceNo"] = item["ReferenceNo"];
                                 dr["Domain"] = item["Domain"];
                                 dr["Created"] = item["Created"];
                                 dr["SiteUrl"] = subSites[i].Url + 
                                 "/Published documents/Forms/DispForm.aspx?ID=" 
                                 + item["ID"].ToString(); ;

                                 dt.Rows.Add(dr);
                             }
                         }
                     }
                 }
             }

             dt.DefaultView.Sort = "Domain";

             HyperLinkField colTitle = new HyperLinkField();
             colTitle.HeaderText = "Title";
             colTitle.DataTextField = "Title";
             string[] SiteUrl = { "SiteUrl" };
             colTitle.DataNavigateUrlFields = SiteUrl;
             colTitle.NavigateUrl = "SiteUrl";
             spLibraryView.Columns.Add(colTitle);

             BoundField colReferenceNo = new BoundField();
             colReferenceNo.DataField = "ReferenceNo";
             colReferenceNo.HeaderText = "ReferenceNo";
             spLibraryView.Columns.Add(colReferenceNo);

             BoundField colDomain = new BoundField();
             colDomain.DataField = "Domain";
             colDomain.HeaderText = "Domain";
             spLibraryView.Columns.Add(colDomain);

             BoundField colCreated= new BoundField();
             colCreated.DataField = "Created";
             colCreated.HeaderText = "Created";
             spLibraryView.Columns.Add(colCreated);

             spLibraryView.AllowGrouping = true;
             spLibraryView.AllowGroupCollapse = true;
             spLibraryView.GroupField = "Domain";

             spLibraryView.DataSource = dt;
             spLibraryView.DataBind();
         }
    }
}
  • Build and deploy the project. Add this web part and you should see the output like,

Note: I’m looping all sites in current site collection and reading only specific library which is “Published Documents” . Modify logic based on requirement.


Merging document libraries using Content Query Web Part

Recently I had an requirement to merge more than one document library in same site collection. My first attempt was to find “no code” solution and use SharePoint built in capabilities. After some Google attempt found we can accomplish this using Content Query Web Part or Data View Web Part. There are plenty of posts which explains “connecting another document library using data view web part in SharePoint Designer 2007” but they are irrelevant for SharePoint Designer 2010 ( or Am I missing something ? ). Why ? Because SharePoint Designer 2010 data source picker is missing important feature Connect to another library link.

Some says it can now achieved using SOAP Service Connection and REST Service Connection in SharePoint Designer 2010 but I’m not able to merge though I can get the library from other sites.

At the end I realized only Content Query Web Part may help me to accomplish this. However, I don’t find any help over Internet which explains start to end steps which I can follow and accomplish this ( or I’m poor Googler ). Most important point I was missing is to merge libraries using “CQWP” you must have one common content type for all those libraries which you want to merge. Let’s move on and see how it can be done ..

  • First create new content type which will use by my libraries later.To do so, Go to Site Settings-Galleries-Site content types and Create new Content type. Here is my Customer content type,

  • Created two Customer libraries in two different sites using above content type and added some documents.

  • Add Content Query web part on the page and click Edit Web part link to customize it. Expand Query section and select top level site collection.

  • Under List Type, Select Custom List and choose the content type.

  • Save the settings and documents from both the the libraries will appear like,

By default you can see only Title column until you modify ItemStyle.xsl file . To do so you should follow the Heather Solomon’s article about customizing content query web part.

http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx

So here is my customize ItemStyle.xsl ,

<xsl:template name="ConsolidateListStyle" match="Row[@Style='ConsolidateListStyle']" 
mode="itemstyle">

		<xsl:variable name="SafeLinkUrl">
            <xsl:call-template name="OuterTemplate.GetSafeLink">
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="SafeImageUrl">
            <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
                <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="DisplayTitle">
            <xsl:call-template name="OuterTemplate.GetTitle">
                <xsl:with-param name="Title" select="@Title"/>
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="LinkTarget">
            <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
        </xsl:variable>

      	 <table cellpadding="7" cellspacing="7" border="1" width="100%">
        	<tr>
           	   <td valign="top" style="width:25%;">
	             <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
                	<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">
                     	<xsl:value-of select="$DisplayTitle"/>
                	</a>
                </td>
                 <td valign="top" style="width:25%;">
                   	<xsl:value-of select="@Customer_x005F_x0020_Name" />
            	</td>
	            <td  valign="top" style="width:25%;">
                   	<xsl:value-of select="@Country" />
            	</td>
            	<td valign="top" style="width:25%;">
                   	<xsl:value-of select="@Phone" />
            	</td>
            </tr>
          </table>   

  </xsl:template>
Here is the result,

When I presented this solution to my manager he said “Let’s group the docs on Country” :). Now I don’t want to dig more in customizing xsl so decided to write custom C# code for the same. It’s going to be my next article 🙂


				

Business Connectivity Services (BCS) with Oracle using Visual Studio 2010 – Part 1

In my last post I’ve explained steps to connect SQL Server using BCS and SharePoint Designer 2010. However, SPD 2010 doesn’t provide such option to connect Oracle. Here we require Visual Studio 2010 to create BDC model which connects Oracle. Here are the steps,

  • Create new project selecting Business Data Connectivity Model template .

  • Provide location of your SharePoint server

  • Rename the entity model with appropriate name ,

  • Open Solution Explorer and rename ( optional ) Entity.cs to Training.cs and add your properties ,

  • In ReadItem section, Modify identifier1 to DOCID and update returnParameter section with actual properties added in above step. Make sure to update Name and TypeName properties as per Training.cs.

  • In ReadList section, Remove existing Entity1 section and copy ReadItemEntity section from ReadItem section.

  • Make sure to change the Identifier1 to DOCID, here is my complete BDC model

  • Open Solution Explorer and add Oracle.DataAccess dll in References.

  • Open TrainingEntityService.cs file and add your code for ReadItem and ReadList functions . Here is my code for the same,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oracle.DataAccess.Client;

namespace BdcTrainingModel.BdcModel1
{
    /// <summary>
    /// All the methods for retrieving, 
    ///updating and deleting data are implemented in this class file.
    /// The samples below show the finder and specific finder method for Entity1.
    /// </summary>
    public class TrainingEntityService
    {
        /// <summary>
        /// This is a sample specific finder method for Entity1.
        /// If you want to delete or rename the method think 
        ///about changing the xml in the BDC model file as well.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Entity1</returns>
        public static Training ReadItem(string id)
        {
            Training evt = null;
            string connectionstr= "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)
                                  (HOST=server_name)(PORT=1569))
                                  (CONNECT_DATA=(SERVICE_NAME=service_name)));
                                  user id=user;password=password;";
            OracleConnection con = new OracleConnection(connectionstr);

            string sqlQuery = "SELECT * FROM T_TRAINING WHERE DOCID='"+id+"'";

            try
            {
                evt = new Training();
                OracleCommand thisCommand = new OracleCommand(sqlQuery, con);
                con.Open();
                thisCommand.ExecuteNonQuery();

                using (OracleDataReader thisReader = thisCommand.ExecuteReader())
                {
                    if (thisReader.Read())
                    {
                        evt.DOCID = thisReader.GetValue
                                  (thisReader.GetOrdinal("DOCID")).ToString();
                        evt.DOCAUTHOR = thisReader.GetValue
                                  (thisReader.GetOrdinal("DOCAUTHOR")).ToString();
                        evt.RKPI_CONDUCTEDLEDBY = thisReader.GetValue
                                  (thisReader.GetOrdinal("RKPI_CONDUCTEDLEDBY")).ToString();
                        evt.RKPI_TYPE = thisReader.GetValue
                                  (thisReader.GetOrdinal("RKPI_TYPE")).ToString();
                        evt.RKPI_SUMMARY = thisReader.GetValue
                                  (thisReader.GetOrdinal("RKPI_SUMMARY")).ToString();
                        evt.RKPI_DATE = DateTime.Parse(thisReader.GetValue
                                  (thisReader.GetOrdinal("RKPI_DATE")).ToString());
                    }

                }

                return (evt);
            }
            catch (Exception ex)
            {
                evt.DOCID = id;
                evt.DOCAUTHOR = ex.Message;
                evt.RKPI_TYPE = ex.Message;
                evt.RKPI_SUMMARY = ex.Message;
                evt.RKPI_DATE = DateTime.MinValue;
                evt.RKPI_CONDUCTEDLEDBY = sqlQuery;
                return (evt);
            }
            finally
            {
                con.Dispose();
            }
        }
        /// <summary>
        /// This is a sample finder method for Entity1.
        /// If you want to delete or rename the method think
      /// about changing the xml in the BDC model file as well.
        /// </summary>
        /// <returns>IEnumerable of Entities</returns>
        public static IEnumerable<Training> ReadList()
        {
            string connectionstr= "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)
                                  (HOST=server_name)(PORT=1569))
                                  (CONNECT_DATA=(SERVICE_NAME=service_name)));
                                  user id=user;password=password;";

            OracleConnection con = new OracleConnection(connectionstr);

            string sqlQuery = "SELECT * FROM T_TRAINING";

            List<Training> allEvents;
            try
            {
                allEvents = new List<Training>();
                OracleCommand thisCommand = new OracleCommand(sqlQuery, con);
                con.Open();
                thisCommand.ExecuteNonQuery();

                using (OracleDataReader thisReader = thisCommand.ExecuteReader())
                {
                    // Always call Read before accessing data.
                    while (thisReader.Read())
                    {
                        Training evt = new Training();

                        evt.DOCID = thisReader.GetValue
                                   (thisReader.GetOrdinal("DOCID")).ToString();
                        evt.DOCAUTHOR = thisReader.GetValue
                                   (thisReader.GetOrdinal("DOCAUTHOR")).ToString();
                        evt.RKPI_CONDUCTEDLEDBY = thisReader.GetValue
                                   (thisReader.GetOrdinal("RKPI_CONDUCTEDLEDBY")).ToString();
                        evt.RKPI_TYPE = thisReader.GetValue
                                   (thisReader.GetOrdinal("RKPI_TYPE")).ToString();
                        evt.RKPI_SUMMARY = thisReader.GetValue
                                   (thisReader.GetOrdinal("RKPI_SUMMARY")).ToString();
                        evt.RKPI_DATE = DateTime.Parse(thisReader.GetValue
                                    (thisReader.GetOrdinal("RKPI_DATE")).ToString());
                        allEvents.Add(evt);
                    }
                }

                //thisReader.Close();

                Training[] eventList = new Training[allEvents.Count];
                for (int evtCounter = 0;
                  evtCounter <= allEvents.Count - 1;
                  evtCounter++)
                {
                    eventList[evtCounter] = allEvents[evtCounter];
                }
                return (eventList);
            }
            catch (Exception ex)
            {
                Training[] errEventList = new Training[1];

                Training errEvt = new Training();
                errEvt.DOCID = ex.Message;
                errEvt.DOCAUTHOR = ex.Message;
                errEvt.RKPI_TYPE = ex.Message;
                errEvt.RKPI_SUMMARY = ex.Message;
                errEvt.RKPI_CONDUCTEDLEDBY = ex.Message;
                errEvt.RKPI_DATE = DateTime.MinValue;
                errEventList[0] = errEvt;

                return (errEventList);
            }
            finally
            {
                con.Dispose();
            }
        }
    }
}
  • Build and deploy the project . If you get following error while deployment ,

Error occurred in deployment step ‘Add Solution’: The default web application could not be determined. Set the SiteUrl property in feature BdcTrainingModel_Feature1 to the URL of the desired site and retry activation.

Add following line in Feature1.Template.xml file

 <Property Key=’SiteUrl’ Value=’your_site_url’/>

  • Once successfully deployed, Go to SharePoint central administration and set required permissions for your newly deployed Business Data Connectivity Service Application

  • Finally create new External list and verify the solution . Here is the result,

You may notice Edit item button is disabled, It’s because I haven’t added any Update method. I will add create,update and delete methods in next part of this series.

Drop me an e-mail if anyone is interested in project source files.


Displaying Data from Oracle using Visual Web Part

This article going to demonstrate about creating visual web part which displays Oracle data on .NET Grid view.

  • Create new SharePoint web part project in Visual Studio 2010 and choose SharePoint site for deployment.

  • Add Reference of Oracle.DataAccess dll in the project.

  • Open “VisualWebPart1UserControl.ascx” and add Grid view with desire layout. So here is the my design,

<%@ Assembly Name=”$SharePoint.Project.AssemblyFullName$” %>
<%@ Assembly Name=”Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”Utilities” Namespace=”Microsoft.SharePoint.Utilities” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”asp” Namespace=”System.Web.UI” Assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ %>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<%@ Register Tagprefix=”WebPartPages” Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Control Language=”C#” AutoEventWireup=”true” CodeBehind=”VisualWebPart1UserControl.ascx.cs” Inherits=”PrismAuditWebPart.VisualWebPart1.VisualWebPart1UserControl” %>

<asp:ScriptManagerProxy ID=”ScriptManagerProxy1″ runat=”server”>
</asp:ScriptManagerProxy>

<asp:UpdateProgress ID=”UpdateProgress1″ runat=”server” AssociatedUpdatePanelID=”UpdatePanel1″>
<progresstemplate>
<asp:Label id=”lblProgress” runat=”server” Text=”Loading,Please wait….” Width=”200px” BackColor=”#FFFF80″ ForeColor=”Maroon” Font-Bold=”True” Style=”padding: 5px”></asp:Label>
</progresstemplate>
</asp:UpdateProgress>
<div class=”clear”>
<br />
</div>
<asp:UpdatePanel ID=”UpdatePanel1″ runat=”server”>
<contenttemplate>
<asp:GridView ID=”GridView”
runat=”server”
CellPadding=”4″
PageSize=”15″
AllowPaging=”True”
onpageindexchanging=”GridView_PageIndexChanging”
AutoGenerateColumns=”False”
Width=”900px” EnableModelValidation=”True” ForeColor=”#333333″
GridLines=”None”>

<AlternatingRowStyle BackColor=”White” ForeColor=”#284775″ />

<Columns>

<asp:BoundField DataField=”RKPI_DATE” HeaderText=”Date”>
<HeaderStyle HorizontalAlign=”Left” />
</asp:BoundField>

<asp:hyperlinkfield DataTextField=”DOCAUTHORNAME” HeaderText=”Author” datanavigateurlfields=”DOCID” datanavigateurlformatstring=”show_detailse.aspx?DOCID={0}” >
<HeaderStyle HorizontalAlign=”Left” />
</asp:hyperlinkfield>

<asp:BoundField DataField=”RKPI_CONDUCTEDLEDBY” HeaderText=”Conducted By”>
<HeaderStyle HorizontalAlign=”Left” />
</asp:BoundField>

<asp:BoundField DataField=”RKPI_TYPE” HeaderText=”Type”>
<HeaderStyle HorizontalAlign=”Left” />
</asp:BoundField>

<asp:BoundField DataField=”RKPI_SUMMARY” HeaderText=”Summary”>
<HeaderStyle HorizontalAlign=”Left” Width=”200px” />
</asp:BoundField>
</Columns>
<EditRowStyle BackColor=”#999999″ />
<FooterStyle BackColor=”#5D7B9D” Font-Bold=”True” ForeColor=”White” />
<HeaderStyle BackColor=”#5D7B9D” Font-Bold=”True” ForeColor=”White” />
<PagerStyle BackColor=”#284775″ ForeColor=”White” HorizontalAlign=”Center” />
<RowStyle BackColor=”#F7F6F3″ ForeColor=”#333333″ />
<SelectedRowStyle BackColor=”#E2DED6″ Font-Bold=”True” ForeColor=”#333333″ />
</asp:GridView>
</contenttemplate>
</asp:UpdatePanel>

  • Open “VisualWebPart1UserControl.ascx.cs” page and add following C# code to connect and fetch details from Oracle.
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Oracle.DataAccess.Client;
using System.Data;

namespace AuditWebPart.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
               doBindGrid();

        }

        protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView.PageIndex = e.NewPageIndex;
            doBindGrid();
        }

        public void doBindGrid()
        {

            string connectiostr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=server)
                                  (PORT=1569))(CONNECT_DATA=(SERVICE_NAME=service)))
                                  ;user id=user;password=pass;";

            OracleConnection oraCon = new OracleConnection(connectiostr);

            string sqlQuery = "SELECT * FROM T_AUDIT";

            try
            {
                oraCon.Open();

                OracleCommand oraCommand = new OracleCommand(sqlQuery, oraCon);

                OracleDataAdapter oraAdaptor = new OracleDataAdapter(oraCommand);

                DataSet oraDataSet = new DataSet();

                oraAdaptor.Fill(oraDataSet);

                GridView.DataSource = oraDataSet;

                GridView.DataBind();

                oraAdaptor.Dispose();
            }
            catch (Exception ex)
            {
                status.Text = ex.Message;
            }
            finally
            {
                oraCon.Dispose();
            }

        }
    }
}
  • Once done build and deploy the project.
  • On successful deployment of the web part , you should see your web part under “Custom” category,

  • Result should be something like that,


SharePoint 2010 and JQuery Slideshow

SharePoint doesn’t provide very good slide show functionality which end users ask oftentimes.It can be done using custom JavaScript but I believe JQuery best suited on this scenario. Here is the simple code,

  • Add “Content Editor” web part on the page and modify HTML with following code ,
<IMG ID=”slideshowPicturePlaceholder” src=”/_layouts/images/GEARS_AN.GIF” style=”display:none”/>
<center><div id=”slideshowContentArea” style=”display:none”>&nbsp;</div></center>
<script type=”text/javascript” src=”http://server_path/Configurations/jquery.min.js”></script&gt;
<script type=”text/javascript” src=”http://server_path/Configurations/jquery.cycle.all.2.72.js”></script&gt;
<script>
function GetAllImages()
{
$(“#slideshowPicturePlaceholder”).css(“display”, “block”);
var soapEnv = “<soapenv:Envelope xmlns:soapenv=’http://schemas.xmlsoap.org/soap/envelope/’><soapenv:Body><GetListItems xmlns=’http://schemas.microsoft.com/sharepoint/soap/’>&#8221;;
//The name of the image library is called ‘SlideShow’. Replace the name bewlo with the name of your image library
soapEnv += “<listName>SlideShow</listName>”;
soapEnv += “<query><Query><OrderBy Override=’TRUE’><FieldRef Name=’Created’ Ascending=’FALSE’ /></OrderBy></Query></query>”;
soapEnv += “<viewFields><ViewFields><FieldRef Name=’Title’/><FieldRef Name=’ows_FileLeafRef’/></ViewFields></viewFields><rowLimit></rowLimit>”;
soapEnv += “</GetListItems></soapenv:Body></soapenv:Envelope>”;
var port = window.location.port;
if (port.length <= 0)
port = “”;
else
port = “:”+port;
var webservice = window.location.protocol+”//”+window.location.hostname+
port+L_Menu_BaseUrl+”/_vti_bin/lists.asmx”;
$.ajax({
url: webservice,
type: “POST”,
dataType: “xml”,
data: soapEnv,
complete: processQueryResults,
contentType: “text/xml; charset=utf-8”,
error: function(xhr) {
alert(‘Media Library error : Unable to retrieve pictures ‘);}
});
}
function processQueryResults(xData, status)
{
var port = window.location.port;
if (port.length <= 0)
port = “”;
else
port = “:”+port;
//Change the below to point to your image library
var imageURL = window.location.protocol+”//”+window.location.hostname+port+L_Menu_BaseUrl+”/SlideShow/”;
var itemURL = window.location.protocol+”//”+window.location.hostname+port+L_Menu_BaseUrl+
“/SlideShow/Forms/DispForm.aspx?ID=”;
$(“#slideshowContentArea”).html(“”)
$(xData.responseXML).find(“z\\:row”).each(function() {
var title = $(this).attr(“ows_Title”);
var imageLink = imageURL+$(this).attr(“ows_FileLeafRef”).substring($(this).attr(“ows_FileLeafRef”).indexOf(‘#’)+1);
var itemLink = itemURL+$(this).attr(“ows_ID”);
var liHtml = “<div style=’padding: 10px;border:0px solid #FFFFFF;background-color:#FFFFFF;width:250px;height: 250px;top:0;left: 0;’><a href='”+itemLink+”‘ target=’_blank’ border=’0′><img width=’250′ height=’250′ src='” + imageLink +”‘/></a><p align=’center’>”+ title + “</p></div>”;
$(“#slideshowContentArea”).append(liHtml);
});
$(“#slideshowPicturePlaceholder”).css(“display”, “none”);
$(“#slideshowContentArea”).css(“display”, “block”);
$(‘#slideshowContentArea’).cycle({
fx: ‘fade’,
speed: 600,
timeout: 3000,
next: ‘#slideshowContentArea’,
pause: 1
});
}
GetAllImages();
</script>
 
Don’t forget following ,
 
  • Correct the path of “jquery.min.js” and “jquery.cycle.all.2.72.js” files in above code.
  • Change the picture library name as per actual , above it’s “Slide Show”.

Here is my slide show web part, Sorry you can see only still image but believe me it’s perfect for your end users.


Connecting Oracle using ODP.NET on Windows x64

Recently I’ve worked very hard to find correct package and working solution to connect Oracle database using ODP.NET on Windows x64. I wish others won’t get the same pain as I had so documenting what I’ve done for the same.

If you are doing fresh installation then you may skip this cleaning steps otherwise you should consider cleaning up Oracle completely from your workstation. To do so,

  • Use Oracle uninstaller to remove Oracle from your machine.
  • In case you don’t have uninstaller remove Oracle directory manually from your machine including registry keys, Path environment variable , Oracle services from registry . You can get plenty of post on Internet for the same. Once done restart your machine.
  • Next to find out number of Oracle ODP.net dlls,policy file still registered in GAC , To do so try following script  ,

gacutil /l | find /i “Oracle” > c:\Oracle_versions\oracle.txt

             Once executed you will get list of dlls,policy files registered in your machine.

  • It’s time to remove all old GAC entries , To do so try something like ( Replace with actual dll and policy file name )

gacutil /u Oracle.DataAccess
gacutil /u Policy.9.2.Oracle.DataAccess
gacutil /u Policy.10.1.Oracle.DataAccess
gacutil /u Policy.10.2.Oracle.DataAccess

OR,

gacutil /u “Oracle.Management.Omo, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86”
gacutil /u “Oracle.VsDevTools, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86”
gacutil /u “Oracle.Web, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86”
gacutil /u “Policy.2.102.Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86”
  • Once done , restart your machine.

Now it’s time to install Oracle client and ODP.NET . Here are recent compatible version with Windows x64

To get Oracle ODP.NET and .NET Application running on Windows x64 machine for x86 application

  • Install Oracle client “Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64) “ from here ,

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html

Select “Run Time” option while installing

  •  Install ODAC 32 bit driver “ODAC 11.2 Release 3 and Oracle Developer Tools for Visual Studio (11.2.0.2.1)” from here ,

http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html 

( While installing Windows will complaint “ You are installing unsupported version of software” , don’t listen it and just go with installation ) Compile .NET application with “Any CPU” or “x86” processor type and application should able to connect Oracle. ( I assume before installing above prior versions of Oracle dlls from GAC, policy files , registry cleanup , and machine.config is done ) To get Oracle ODP.NET and .NET Application running on Windows x64 machine for x64 application ( In case of SharePoint deployment )

  •  Install Oracle client “Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64) “ from here ,

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html 

Select “Run Time” option while installing

  • Install ODAC 64 bit driver “64-bit ODAC 11.2 Release 3 (11.2.0.2.1) for Windows x64 “ from here ,

http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html

( Select the same Oracle home as of above client.It’s command based installation so make sure you use file path correctly ).On my machine this installation is like , Client_1 is for Oracle client and Client_2 for ODAC)