Tuesday, June 29, 2010

Google Search Appliance in Sharepoint !

Built-In Search Experience Features

Without any administrator intervention, the Google Search Appliance provides a rich search experience by using its built-in search features. The following table lists these built-in search features.

Feature Description
Automatic spell check The search appliance automatically suggests spelling corrections accurately, even on company-specific words and phrases. The spell checker can suggest corrections in multiple languages, including U.S. English, French, Italian, German, Spanish, Portuguese, and Dutch.
Sorting search results based on relevance The search appliance finds the highest quality and most relevant documents for a search query; Google factors in more than 100 variables for each query.
Automatic filtering of duplicate snippets If multiple documents contain identical titles, as well as the same information in their snippets, only the most relevant document of that set is displayed in the results.
Automatic filtering of duplicate directories If there are many results in a single web directory, then only the two most relevant results for the directory are displayed. An output flag indicates that more results are available from that directory.
Automatic filtering of languages Limits search to a specified language, as determined by the majority language used in the web document body.
Dynamic page summaries Users can judge relevance of results more easily with dynamically generated snippets showing a query in the context of the page.
Results grouping- Users can navigate search results easily and clearly using intelligent grouping of documents residing in the same narrow subdirectories.
Cached pages Users can view search results even when the sites are down by using cached copies of pages included in the search results.
Highlighted query terms User can quickly find the most relevant section of a document by using the highlighted query terms displayed on cached documents.
View as HTML Users can display documents without needing the original client application of the file format because the search appliance automatically converts over 220 file formats into HTML.
Sort by date User can access time-sensitive information first by using date sorting.
Advanced Search page Users can perform complex and sophisticated queries with over 10 special query terms, including Boolean AND, OR, and NOT searches.


The following are the links related to GSA (Very useful)


GSA complete tutorials (** Webinar And Video Courses ** )


Customizing the User Interface in GSA


Advanced Customization in GSA


Learn More about Front Ends in GSA


Faceted Seach in GSA
Faceted Search in GSA

Content Deployment – Step By Step Tutorial !

Create Production Site Collection

When setting up a content deployment path, the site collections must be in separate content databases so that the unique identifiers (GUIDs) do not conflict. The easiest way to ensure that the production site collection is in a different content database is to create it in a new web application.
Open Central Administration:
Under Application Management:
Select Create or extend Web application:
Select Create a new Web Application:
Choose an easy to remember port number, such as 12345:
Type in a user name and credentials to create a new app pool:
Type in a descriptive database name such as MOSS_PRODUCTION:
Leave all other settings at the default and click OK, then wait for the Web application to be created:
Click Create Site Collection:
Ensure that your new Web Application is selected:
Type in any name for the Title (it will be overwritten later):
Select "Blank Site" as the template. This step is IMPORTANT, because Blank Site is the only template that you can import any other template into:
Type in the names for the site collection owners:

Click OK.

Allow Incoming Content Deployment Jobs on the Production Site

Select Operation:
Select Content deployment settings:
Select Accept incoming content deployment jobs:
Select Do not require encryption and click OK:

Create Content Deployment Path from Staging to Production

Select Content deployment paths and jobs:
Click New Path:
Type a descriptive name for the path. Select the web application and site collection for the staging site. Then type in the URL of the Central Administration web site of the production site. Since we are putting both of our sites on the same server farm, the URL is the farm that we are on now.
Click Connect:
Once you see "Connection succeeded", select the web application and site collection that you created for production. You can also choose to deploy user names and security if you want the new site to have the same users and permissions.
Click OK.

Create Content Deployment Job

Click New Job:
Type a name, and then select the path you created:
Keep all other default values, and click OK.

Run Content Deployment Job

Refresh the page, and then click on the text Running:
Watch the status of the job:
When the status changes to Succeeded, you can click on the URL to the production site to verify that the content was deployed.

Run Quick Deploy Job

Select Quick Deploy Settings from the Quick Deploy context menu:
Select Allow Quick Deploy jobs along this path, and set the schedule to check every 10 minutes, then click OK:
Visit the staging site and edit a page:
Make some changes:
Publish the page:
Show the page editing toolbar:
From the Tools menu, select Quick Deploy:
The changes will be picked up and deployed to production within 10 minute:

Monday, June 28, 2010

Making "Post" and "Get" forms from SharePoint’s pages !

If you’ve tried to insert a form into a sharepoint’s page you mus have been disappointed. The form just didn’t work. You can’t make the form to post or get to some url, because the whole SharePoint’s page is one big <form> element.


So I went a bit deeper on how Microsoft guys are doing it on their spaces site (blog this functionality makes a post to a certain url) and based on this, I’ve made this simple script to make “forms” to post and to submit.


First thing: Insert your form as it should be


<form action="http://www.somesite.com/somepage.aspx" method="post">
<input name="name"/>
... etc. with all the fields you need.
<input type="submit" value="Submit"/>
</form>

Before you save the page or the content editor webparts, make the three changes:


1. Remove the <form> tags and replace them with <div id=”contactForm”>


<div id="contactForm">
<input name="name"/>
... etc. with all the fields you need.
<input type="submit" value="Submit"/>
</div>

2. Add the following script before the form


<script type="text/javascript">
function submitForm(containerElement) {
var theForm = document.createElement("form");
theForm.action = 'http://www.somesite.com/somepage.aspx';
theForm.method = "post";
theForm.innerHTML = document.getElementById(containerElement).outerHTML;
var formToSubmit = document.body.appendChild(theForm);
formToSubmit.submit();
}
</script>

Note: be sure to correct the theForm.action and theForm.method to appropriate url and method (for your form)


3. Change the submit button with


<button onclick="submitForm('contactForm')>Submit</button>

Note: Make sure you copy the ID of the layer (in the sample above is the contactForm) to the parameter of the submitForm function.


the end code would look something like below:


<script type="text/javascript">
function submitForm(containerElement) {
var theForm = document.createElement("form");
theForm.action = 'http://www.somesite.com/somepage.aspx';
theForm.method = "post";
theForm.innerHTML = document.getElementById(containerElement).outerHTML;
var formToSubmit = document.body.appendChild(theForm);
formToSubmit.submit();
}
</script>
<div id="contactForm">
<input name="name" type="text"/>
... etc. with all the fields you need.
<button onclick="submitForm('contactForm')>Submit</button>
</div>

Update (5.11.): Unfortunately this method works straight only in IE, because it’s the only one that coppies the innerHTML with the changes (input data). So to get this method to work in FF, Chrome, Safari, Opera,.. you have to copy the field values. Here’s how


After the line


var formToSubmit = document.body.appendChild(theForm);

add code similar to the one below for copying the values for each of the input fields


document.getElementsByName('name')[1].value = document.getElementsByName('name')[0].value;

Apply the similar methodology for other types of fields. I’ll try to come up with a universal script to copy values.



*******************************************************************************************



OnePlaceMail: Outlook to SharePoint Integration !

Scinaptic OnePlaceMail provides integration between Microsoft Outlook and SharePoint to facilitate the transfer of business knowledge from personal mail boxes to a shared centrally managed, secure repository.

Drag & Drop Emails

  • Easily drag & drop emails or attachments from Outlook to SharePoint Libraries and Lists
  • Automatic capture of email attributes/metadata
  • Option to drag & drop one or more specific attachments from an email
  • Highly streamlined File Upload Window for capturing additional destination library/list column metadata
  • Option for a one step (auto upload) process (with support for Outlook rules)
  • Ability to rename files at the point of upload
  • Support for multiple Content Types
  • Support for deep level Folder Structures
  • Storage of emails in .msg format
  • Support for Document Libraries, Picture Libraries and Lists (e.g. Announcements, Tasks, Issues, Custom Lists)
  • Supports SharePoint configurations and security permissions
  • One step 'Email as Attachment' feature for external email capabilities

Access to SharePoint directly from Outlook

  • Access SharePoint content directly from Outlook
  • Option to provide a 'minimised view' of Library/List content
  • Full access to SharePoint views and search capabilities

Desktop Integration: Windows Explorer (Right Click Send To)

  • Send files from the Windows desktop / Network drive directly to SharePoint
  • Apply destination library/list metadata at the point of upload

Deployment / Performance

  • Simple to deployment via MSI file (Outlook Add-in)
  • Support for WSS v3, MOSS 2007, Outlook 2003, Outlook 2007
  • Roaming User/Terminal Server support
  • Powerful pre and post central deployment and configuration
  • High performance navigation of large SharePoint environment
  • High performance navigation of large library/list folder structures
  • No impact on Microsoft Outlook start-up or general use performance
  • Plug-in architecture to integrate with other 3rd party solutions
  • Demonstration Site and Email Library Template with email Columns/Views provided

OnePlaceMail screencasts and much more information is available at the company site.







OnePlaceMail: Outlook to SharePoint 2010 Integration !

Deploying files using Mapped Folders in Sharepoint 2010 !

With Visual Studio 2010 SharePoint Developer Tools, the concept of the Mapped Folder was introduced. A mapped folder is a convenient way for developers to specify a location for any files that need to be deployed on to the SharePoint file system, all from within in a Visual Studio solution. Mapped folders can be included as part of a deployment package (.WSP) and the files will get copied to the correct location when the WSP is installed on to the server.


Let’s take a quick look at how a developer might use a mapped folder. Say a developer wants to develop a custom application page for their SharePoint site that will consume a custom image. The SharePoint server has a designated location for both application pages and images. With mapped folders, the developer can ensure that their files will be deployed to the correct location. Here’s an example:


First we need to create a project. In this example, we will start by creating an Empty SharePoint project (Installed Templates->Visual Basic/C#->SharePoint->2010).



Next, we’ll create our custom image that we want to display. First, let’s setup a mapped folder to the Images directory on the SharePoint farm. To do this, we simply right-click on the project node and select “Add->SharePoint “Images” Mapped Folder”:



This will create a mapped folder named “Images” in our project. (You can also create it via the “Project->Add SharePoint “Images” Mapped Folder on the main menu bar”)


In the Solution Explorer, mapped folders look very similar to normal folders but have a small green globe in the bottom right corner of the icon. You’ll notice that underneath the mapped folder there is a sub folder with the same name as the project. This is to help organize images specific to your project and keep developers from inadvertently overwriting another item with the same name.



Also, if you select the mapped folder and open the property window (F4), you’ll see two entries: Folder Name and Deployment Location. The Deployment Location indicates the location relative to the SharePoint root directory ({SharePointRoot}) on the SharePoint farm.



Now that we have our mapped folder, we can right-click on the project directory underneath it and add our image file (“Add->New Item’). In this example, I’ve added a bitmap image named ”Bob.bmp”.


The next step is to create the application page and modify it to show our image. To start, right-click on the project node in the Solution Explorer and select “Add->New Item”. When the Add New Item dialog appears, the “2010” node under SharePoint will be selected. From the list of templates, select the “Application Page” item, give it the name you want, and click “Add”. You’ll notice that when the application page is added to the project, it automatically gets created under the “Layouts” mapped folder, which is the default location on the SharePoint file system for application pages:



Following its creation, the .aspx file we just added should be opened in the designer. Locate the <asp:Content> element with the ID equal to “Main”. Within that element add an image element and set the ImageUrl attribute to point to the image in your product. It should look like this:

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label" Font-Size="Medium">This is Bob.......</asp:Label>
<asp:Image ID="Image1" runat="server" ImageUrl="~/_layouts/Images/SharePointProject1/Bob.bmp" />
</asp:Content>



The last thing we’ll want to do to make testing our project easier is to set the application page to be our startup item when we F5. To do this, select the project node in the Solution Explorer and open the property window (F4). In the property window, select the “Startup Item” property and choose our application page from the drop down list. Now when we F5, it will take us right to our application page:



A couple of things to know about mapped folders. First, since mapped folders effectively deploy files onto the SharePoint file system, they are only allowed in farm level solutions. Sandboxed solutions are restricted to only deploying content to the content database on the server. In VS, when you try add a mapped folder to a sandboxed solution, the package validation will generate an error regarding this.


Second, as you saw when we added the application page, some items go into certain mapped folders by default when they are added to the project. Another example is User Control items (.ascx) which are automatically placed into the User Control mapped folder. While these are the SharePoint “default” locations, there may be times you need to place one of these files in a different location, and this can be done by mapping the folder to a different location.


Finally, you can create a mapped folder to any folder under the SharePoint root on the farm by opening the Add SharePoint Mapped Folder dialog (Project->Add SharePoint Mapped Folder… from main menu, Add->SharePoint Mapped Folder… from project context menu:



For instance, if you had a custom web service you wanted to deploy to the SharePoint server, you could simply add a mapped folder that points to the ISAPI directory on the SharePoint file system and dropped the web service in there. Then, when the package gets deployed to the server, the web service will automatically be placed in the ISAPI directory and available for consumption.


Surfacing Business Data in a Web Part that you Create by Using SharePoint Tools in Visual Studio !

So you add a Visual Web Part to your SharePoint solution and you want the Web Part to show some data. No problem. I’ll show you three ways to do it. This post shows you how to surface data in your Visual Web Part by performing the following tasks:

  • Binding data to a GridView at design time.
  • Binding data to a GridView by using LINQ to SQL code.
  • Binding data to a GridView by querying the Business Data Catalog.

I have also published a sample that shows these tasks here. For now, let’s make some data appear!

Binding Data to a GridView at Design Time

1. In Visual Studio, create a Visual Web Part project.

2. From the Toolbox, drag a GridView to the designer.

3. Attempt to configure a data source for the GridView. Wait! Where can I select Database? I only see XML File. Could this be a bug?

original[1]

Nope. This is not a bug. The ability to configure other data sources by using the Data Source Configuration Wizard is a feature that has not been implemented in the Visual Web Designer for SharePoint projects in Visual Studio. You have two options.

· Write XML that defines the data source in the Source view of the designer (Not fun).

· Configure your data source in an ASP.NET project and then copy over the data source object (fun).

For this post, I’ll configure a SQLDataSource object in an ASP.NET project. Then, just copy control over to my Visual Web Part project. Then, I will bind the GridView to that control.

1. In Visual Studio, create a new ASP.NET Web Application project.

2. From the Toolbox, drag a SQLDataSource control to the designer of any page.

original[1]

3. Configure the control by using the Data Source Configuration Wizard (Shown earlier). Use the wizard to generate create, update, delete, and select commands.

4. In the designer of the ASP.NET project, copy the SQLDataSource control.

original[1]

5. In the designer of the Visual Web Part project, paste the SQLDataSource control.

6. Bind the GridView to that data source.

original[1]

7. In the GridView Tasks dialog box, select Enable Editing, and Enable Deleting. Selecting these options will add Edit and Delete links to the GridView.

original[1]

8. Finally, add the name of the primary key column of your database table to the DataKeyNames property of the GridView.

original[1]

9. Design the rest of the GridView (look and feel etc.).

If you open the designer in Source view, your GridView should look something like this:

GridView

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="CustomerID" PageSize="3" EnableModelValidation="True">
  <Columns>
    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
  </Columns>
</asp:GridView>


SQLDataSource



<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>" ProviderName="System.Data.SqlClient"
  SelectCommand="SELECT TOP 3 [CustomerID], [FirstName], [MiddleName], [LastName] FROM [SalesLT].[Customer]"
  DeleteCommand="DELETE FROM [SalesLT].[Customer] WHERE [CustomerID] = @CustomerID"
  InsertCommand="INSERT INTO [SalesLT].[Customer] ([FirstName], [MiddleName], [LastName]) VALUES (@FirstName, @MiddleName, @LastName)"
  UpdateCommand="UPDATE [SalesLT].[Customer] SET [FirstName] = @FirstName, [MiddleName] = @MiddleName, [LastName] = @LastName WHERE [CustomerID] = @CustomerID">
  <DeleteParameters>
    <asp:Parameter Name="CustomerID" Type="Int32" />
  </DeleteParameters>
  <InsertParameters>
    <asp:Parameter Name="FirstName" Type="String" />
    <asp:Parameter Name="MiddleName" Type="String" />
    <asp:Parameter Name="LastName" Type="String" />
  </InsertParameters>
  <UpdateParameters>
    <asp:Parameter Name="FirstName" Type="String" />
    <asp:Parameter Name="MiddleName" Type="String" />
    <asp:Parameter Name="LastName" Type="String" />
    <asp:Parameter Name="CustomerID" Type="Int32" />
  </UpdateParameters>
</asp:SqlDataSource>


A Quick note about Connection Strings



Notice the following line in the above source:



ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>"



This line grabs the connection string from the web.config file of the root site. This is one way to persist a connection string. There are other ways to do this as well. You can read about them in the MSDN topic Managing Application Configuration.



The sample contains code that adds the connection string to web.config by using code in the feature receiver of the Visual Web Part project.



Bind Data to a GridView by using LINQ to SQL Code



There are probably a dozen ways to structure this. Here is one way to do it.



· Create a class library.



· Generate objects to access the data.



· Add methods that retrieve, edit, and delete the data.



· Bind the GridView to those methods.



Create a Class Library



1. Add a Class Library project to your solution.



2. Compile the project.



3. Strong name sign the assembly of the project. You can read more about how to do that here.



4. Add the assembly to the package manifest. You can read more about how to do that here.





Generate objects to access the data



1. Add a new data source to the Class Library project. You can read more about how to do that here.



2. Add a LINQ to SQL Classes item to the Class Library project.



original[1]



3. In Server Explorer, drag a table onto the O/R Designer.



This creates an Entity that represents the table. Your code will read, edit, and delete data by using the entity not the actual table.



original[2]



Add methods that retrieve, edit, and delete the data





1. In the class file of the Class Library project, add code to retrieve, update and delete data.



Example:



public class DAL
{
  public static AdventureWorksDataContext GetDataContext()
  {
    string strConnString = ConfigurationManager.ConnectionStrings["AdventureWorksConnectionString"].ConnectionString;
    return new AdventureWorksDataContext(strConnString);
  }
  public static IEnumerable<Customer> GetCustomers()
  {
    AdventureWorksDataContext dataContext = GetDataContext();
    IEnumerable<Customer> myCustomers = from customers in dataContext.Customers.Take(3)
                                        select customers;
    return myCustomers;
  }
  public static void UpdateCustomer(int customerID, string firstName, string middleName, string lastName)
  {
    AdventureWorksDataContext dataContext = GetDataContext();
    var CustomerToUpdate = (from Customers in dataContext.Customers
                            where Customers.CustomerID == customerID
                            select Customers).Single();
    
    CustomerToUpdate.CustomerID = customerID;
    CustomerToUpdate.FirstName = firstName;
    CustomerToUpdate.MiddleName = middleName;
    CustomerToUpdate.LastName = lastName;
    dataContext.SubmitChanges();
  }
  public static void DeleteCustomer(int CustomerID)
  {
    AdventureWorksDataContext dataContext = GetDataContext();
    Customer Customer =(from Customers in dataContext.Customers.AsEnumerable().Take(5)
                        where Customers.CustomerID == CustomerID
                        select Customers).Single();
    dataContext.Customers.DeleteOnSubmit(Customer);
    dataContext.SubmitChanges();
  }
}


Binding the GridView to your methods





1. In the designer of your Visual Web part, create event handlers for the RowCancelingEdit, RowDeleting, RowEditing, and RowUpdating events of the GridView.



original[2]



2. Right-click the designer and then click View Code.



3. Add code for each of the event handlers.



Example:



public partial class VisualWebPart1UserControl : UserControl
{
  protected void Page_Load(object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      BindGridView(GridView2);
    }
  }
  private void BindGridView(GridView GridView)
  {
    GridView.DataSource = DAL.DAL.GetCustomers();
    GridView.DataBind();
  }
  protected void GridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
  {
    GridView TempGridView = (GridView)sender;
    TableCell cell = TempGridView.Rows[e.RowIndex].Cells[1];
    DAL.DAL.DeleteCustomer(Convert.ToInt32(cell.Text));
    BindGridView(TempGridView);
  }
  protected void GridView_RowEditing(object sender, GridViewEditEventArgs e)
  {
    GridView TempGridView = (GridView)sender;
    TempGridView.EditIndex = e.NewEditIndex;
    BindGridView(TempGridView);
  }
  protected void GridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
    int CustomerID = 0;
    string FirstName ="";
    string MiddleName="";
    string LastName="";
  
    GridView TempGridView = (GridView)sender;
    GridViewRow gvr = TempGridView.Rows[e.RowIndex];
    for (int i = 0; i < gvr.Cells.Count; i++)
    {
      switch (TempGridView.HeaderRow.Cells[i].Text)
      {
        case "CustomerID":
          CustomerID = Convert.ToInt32(((TextBox)(gvr.Cells[i].Controls[0])).Text);
          break;
        case "FirstName":
          FirstName = ((TextBox)(gvr.Cells[i].Controls[0])).Text;
          break;
        case "MiddleName":
          MiddleName = ((TextBox)(gvr.Cells[i].Controls[0])).Text;
          break;
        case "LastName":
          LastName = ((TextBox)(gvr.Cells[i].Controls[0])).Text;
          break;
        default:
          break;
       }
    }
    DAL.DAL.UpdateCustomer(CustomerID, FirstName, MiddleName, LastName);
    TempGridView.EditIndex = -1;
    BindGridView(TempGridView);
  }
  protected void GridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
  {
    GridView TempGridView = (GridView)sender;
    e.KeepInEditMode = false;
    TempGridView.EditIndex = -1;
  }
  protected void GridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
  {
    GridView TempGridView = (GridView)sender;
    TempGridView.EditIndex = -1;
    BindGridView(TempGridView);
  }
}




Binding Data to a GridView by Querying the Business Data Connectivity Service



Perhaps your organization has a bunch of data in the Business Data Connectivity Service in SharePoint. No problem. You can bind your GridView to that too.



<Quick Shameless Plug>



If you are not familiar with the Business Data Connectivity Services in SharePoint, it is the coolest thing since ice cubes. You can read more about it here. Visual Studio has a project template to help deploy data models to the service. You can read more about that here.



</Quick Shameless Plug>



1. Add a class to your Class Library project.



2. Add a reference to the Microsoft.BusinessData assembly. Unfortunately, you won’t find that assembly in the .NET tab of the Add Reference dialog box. I found it by browsing to this location - C:\program files\common files\microsoft shared\web server extensions\14\ISAPI\Microsoft.BusinessData.dll.



3. In your class, add the following using (or for VB Imports) statements:



using Microsoft.SharePoint;



using Microsoft.SharePoint.BusinessData.SharedService;



using Microsoft.BusinessData.MetadataModel;



using Microsoft.SharePoint.Administration;



4. Add code.



Example:



class BDC_DAL
{
  const string nameSpace = "AdventureWorksCustomers.BdcModel1";
  const string entityName = "Customer";
  
  private static IMetadataCatalog GetCatalog()
  {
    BdcService service = SPFarm.Local.Services.GetValue<BdcService>(String.Empty);
    IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(
    SPServiceContext.Current);
    return catalog;
  }
  public static object GetCustomers()
  {
    IMetadataCatalog catalog = GetCatalog();
    IEntity entity = catalog.GetEntity(nameSpace, entityName);
    ILobSystemInstance LobSysteminstance = entity.GetLobSystem().
    GetLobSystemInstances()[0].Value;
    IMethodInstance methodInstance = entity.GetMethodInstance("ReadList", MethodInstanceType.Finder);
    object result = entity.Execute(methodInstance, LobSysteminstance);
    return result;
  }
  public static void UpdateCustomer(int CustomerID, string FirstName, string MiddleName, string LastName)
  {
    IMetadataCatalog catalog = GetCatalog();
    IEntity entity = catalog.GetEntity(nameSpace, entityName);
    ILobSystemInstance LobSysteminstance = entity.GetLobSystem().
    GetLobSystemInstances()[0].Value;
    IMethodInstance methodInstance = entity.GetMethodInstance ("Update", MethodInstanceType.Updater);
    object[] args = { CustomerID, FirstName, MiddleName, LastName };
    entity.Execute(methodInstance, LobSysteminstance, ref args);
  }
  public static void DeleteCustomer(int CustomerID)
  {
    IMetadataCatalog catalog = GetCatalog();
    IEntity entity = catalog.GetEntity(nameSpace, entityName);
    ILobSystemInstance LobSysteminstance = entity.GetLobSystem().
    GetLobSystemInstances()[0].Value;
    IMethodInstance methodInstance = entity.GetMethodInstance("Delete", MethodInstanceType.Deleter);
    object[] args = { CustomerID };
    entity.Execute(methodInstance, LobSysteminstance, ref args);
  }
}


5. Now, just call these methods from the event handlers of your GridView.



Surfacing data in a Visual Web Part, application page, or a user control, is not a whole lot different than the way that you do this in a plain vanilla ASP.NET Web application. Here a few take-away points:



· You can configure data sources visually by using an ASP.NET project and port over your data source object. – or – you can just write XML that describes the data source yourself.



· If you use a separate assembly for your data access code, make sure to sign the assembly and add that assembly to the package manager.



You can get to data described in the Business Data Connectivity service by using the Business Data Connectivity services object model.

SharePoint 2010, A Business Collaboration Platform !

SP2010_overview.jpg
SharePoint 2010

If you compare these two diagrams, what you see is that it becomes less about the technology capabilities (i.e. content management, collaboration, search, business intelligence) and more about how these technologies support the user or the business: communities, content, insights.

Does this mean there's a big difference between SharePoint 2010 and SharePoint 2007? Time will tell. But if you watched the overview video, you'd see things have certainly improved in many instances. Here's what we took away from the overview of SharePoint 2010.

UI Improvements

SP2010_view1.jpg
SharePoint 2010

Multi-Browser Support

Microsoft says they recognize the need to support multiple browsers such as Safari and FireFox. The video even demos SharePoint in FireFox, so you know it's not all talk.

Ribbon

You first saw the introduction of the ribbon UI in Office 2007 and although it took a little getting use to, it grew on you. That ribbon UI is part of SharePoint 2010. It's contextual, so it changes as required and it grays out the options in the ribbon that you may not have access to.

SP2010_imageribbon.jpg
SharePoint 2010 Ribbon UI

Of course, if you don't like it, you can choose to use the old UI from SharePoint 2007.

Dialogs

Now SharePoint will have real dialog boxes, instead of redirects to another web page with your dialog box options. The background is grayed out when a dialog box pops up. Much more in tune with the way web applications work today.

Live Preview & Themes

The ability to set a theme for your look and feel within SharePoint is improved. Included is the ability to take your PowerPoint theme and upload and apply it to your SharePoint site.

If you are modifying a web page, you now have Live Preview capability, so you can see how the change will look before you actually accept it.

Silverlight

SharePoint 2010 comes with out of the box Silverlight web parts, making the inclusion of Silverlight apps much easier. Note the change to the how you can select new web parts for your pages, much improved. 

SP2010_SelectWebParts.jpg
SharePoint 2010 - Silverlight Web Parts

Empowering the Business

There are a couple of different ways to look at SharePoint 2010. Although the developer perspective is important, maybe the most critical is how it makes the lives of business users easier and lets them do more without the need for IT assistance.

Visio Integration

Use Visio 2010 for documenting and describing business processes? Now you can publish those diagrams directly to SharePoint with the back end connection remaining intact. So the view of the diagram is real time. What's nice about this capability is that not everyone needs to have a license for Visio to see the diagram.

SP2010_visio.jpg
SharePoint 2010 Visio Integration

SharePoint Designer

It's still free, but looks very much improved with new modeling capabilities and enhanced workflow.

SP2010_SPDesigner.jpg
SharePoint Designer 2010

Now if you are one of those who worry about the power SharePoint Designer provides the power user, this may worry you more. We need to get a closer look at this tool to see if any of these concerns have been eased. This overview doesn't provide that warm and fuzzy feeling.

Business Connectivity Services

The evolution of the BDC, the BCS is very much improved enabling you to connect Line of Business applications, web services and databases to SharePoint easily using the new SharePoint Designer, as well as Visual Studio 2010.

SP2010_SPD_VCS.jpg
SharePoint 2010 - Business Connectivity Services

You can even take this a step further and connect your Office 2010 applications to the BCS providing a tightly integrated connection with business data.

SharePoint Workspace

Take your SharePoint content offline with the SharePoint Workspace (formerly Groove), a rich client to work with while you aren't connected.

SP2010_SPWorkspace.jpg
SharePoint 2010 - Workspaces

Search

The addition of FAST to SharePoint gives a much improved search experience. Microsoft says their goal is to help you get the "right results on the first page". Those results include not only SharePoint content, but possibly business data and people — the Rich People Search Function from SharePoint 2007 will comes with SharePoint 2010.

Community Feedback

Despite this look into the SharePoint 2010, it seems to be very quiet so far in the greater SharePoint community. Sure, lots of people are pointing to the videos, some even saying things are looking pretty good, but we've haven't been able to dig up any real reviews or thoughts.

Perhaps many are waiting until the CTP arrives sometime this fall before they dig and really say what they think. Or maybe they are waiting for even more details to come from the SharePoint Conference in October. Truth is, although this is nice look into SharePoint 2010, much of what they talk about we already knew was coming in the first place.

There are three video to look at. This is just a snapshot of things in the overview video. Discussing Developer and IT improvements deserves its own article. Stay tuned.

 

Editor's Note: When you've finished with this review, head over and read about some of the IT professional and developer changes for SharePoint 2010.


Thursday, June 24, 2010

Rounded Corners in SharePoint !

Rounded corners have become a staple in website design. But they come with a price. Don't get me wrong I really like the look of them and they really help soften the look of the site.

In most cases you can create this look by using the method below. Later on in this post I will highlight some of the things you can do and some of the things not technically possible without major custom development.

Design 1: Rounded corners to frame a site:

  1. Open up your master page and add 1 <div> tag right before the ms-main table to represent the site container (This is used to position the site and give it its width)
  2. Add 4 more <div> tags before the ms-main table to represent your 4 corners (top left, top right, bottom left, bottom right)
  3. <div id="xyz-content-corner-tl">
    <div id="xyz-content-corner-tr">
    <div id="xyz-content-corner-bl">
    <div id="xyz-content-corner-br">
  4. Add in the following to CSS attributes to represent the 4 corners

#xyz-content-corner-tl{
background-image: url(/_layouts/images/xyz/xyz_content_corner_tl.gif);
background-position:left top;
background-repeat: no-repeat;
background-color: #ffffff;
}
#xyz--content-corner-tr{
background-image: url(/_layouts/images/xyz/xyz_content_corner_tr.gif);
background-position:right top;
background-repeat: no-repeat;
}
#xyz--content-corner-bl{
background-image: url(/_layouts/images/xyz/xyz_content_corner_bl.gif);
background-position:left bottom;
background-repeat: no-repeat;
height: 100%;
}
#xyz--content-corner-br{
background-image: url(/_layouts/images/xyz/xyz_content_corner_br.gif);
background-position:right bottom;
background-repeat: no-repeat;
height: 100%;
}

Example: Please note that the shadow effect is a bit more complex and requires two more <div> tags to represent the right side repeat and the bottom repeat.

image

Design 2: Rounded corners to frame content

  1. This approach can achieved the same way as per above with 4 <div> tags but just needs to included around the <asp:ContentPlaceHolder id="PlaceHolderMain" runat="server"> control within the master page.

Example:

image

Design 3: Rounded corners around individual web parts

  1. Now this one has some tricky elements that I am still trying to work out.
  2. My Original thought was to use the approach above and simply add the 4 <div> tags around each individual webpart zone in a page layout. But there is a catch…
  3. Normally webpart zones are wrapped in a <td> that has an id of "_invisibleIfEmpty" There is some java script that basically hides that zone from rendering on the page if there is no content in it.
  4. However if you place those 4 div tags within that <td> you would assume that it would still hide that zone. But no basically its like a buffer and that JavaScript no longer thinks that zone is empty and it shows it on the page even if there is no webpart in that zone. So you end up with something like below: Notice that below the two web parts on the right there are two empty white containers with nothing in them.

Example:

image

So all in all its fairly easy to add in rounded corners to different areas within your design by using the approach above but there is still a need to have individual web parts with a container all for themselves.

If anyone out there has any ideas on either modifying the JavaScript to ignore the div tags and hide the empty zones or have any other approaches that have worked for them please don't hesitate to comment.

Thanks!




SharePoint 2010 Content Query for Blog Posts !

I hope this post will help many of you feel comfortable with using the Content Query Web Part.

In this post I will walk you through the process of creating a content query web part and configuring it to show custom field types. I will also give details on how to use XSLT to stylize and format the data being pulled.

I will be using the following scenario as an example. Say that you had a site collection with a top level publishing site. This publishing site would display a the most recent blog posts from all blog sites within its own site collection.

To solve this problem we will use a Content Query Web Part and a customized ItemStyle.xsl using XSLT.

Please note that the “SharePoint Server Publishing Infrastructure” needs to be enabled at the site collection to display the content query web part.

Step 1: Add a Content Query Web Part to Page

  • Navigate to the site that you want the blog posts to show up and click on edit page.
  • Under Editing Tools in the Ribbon, Click on insert > Web Part
  • Under the Content Rollup Category Click on Content Query
  • Then Click on the Add Button
  • Now that you have a CQWP on the page edit the web part

image

  • Expand open the “Query” properties
  • Since we will be just showing blog post in this query choose the following
    • List Type: Posts
    • Content Type Group: List Content Types
    • Content Type: Post
  • You should get a result like the following.

image

  • Next we will configure the web part to pull in additional values from the blog posts.
    • Title – linked to post
    • Date – with standard formatting
    • Body – Rich text
    • Author
    • Number of Comments
    • Categories

Step 2: Configure Web Part

  • Click on web part arrow and choose “Export”
  • Save the .webpart file to your desktop
  • Edit the “Content_Query.webpart” file in Notepad
  • Search for "CommonViewFields”
  • Replace the default “<property name="CommonViewFields" type="string" />” with the following:

<property name="CommonViewFields" type="string">Title, Text;PublishedDate, DateTime;Body, RichHTML;Author, Text;NumComments, Lookup;PostCategory, Lookup;</property>

  • Here are the available Field Types that can be used
    • Text
    • Note
    • Number
    • Currency
    • Integer
    • Boolean
    • DateTime
    • Threading
    • Lookup
    • Choice
    • URL
    • Counter
    • RichHTML
    • Image
  • When creating your own there are a few rules.
    • First off you need to separate each custom field type by a semi colon (Ex: Title, Text;Editor, Text)
    • There cannot be a space after the semi colon
  • Save the .webpart file
  • Edit the page again and choose Inster Web Part
  • It’s a little hard to find but click on the Upload a Web Part and browse for the custom .webpart file.

image

  • Click on Upload
  • Now when you click on Insert webpart you will see a category of imported webparts.
  • Click on Add button.
  • Now you will not see a difference but now the webpart has been configured to display these custom columns.

Step 3: Configure ItemStyle.xsl

  • Click on View All Site Content > Style Library > XSL Style Sheets
  • Download the itemstyle.xsl file
  • Add the following to the top of the file

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

  • At the very bottom of the xsl file add the following template

  <xsl:template name="BlogPost" match="Row[@Style='BlogPost']" 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="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>
        <div class="custom_posttitle">
            <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
            <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
              <xsl:if test="$ItemsHaveStreams = 'True'">
                <xsl:attribute name="onclick">
                  <xsl:value-of select="@OnClickForWebRendering"/>
                </xsl:attribute>
              </xsl:if>
              <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
                <xsl:attribute name="onclick">
                  <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
                </xsl:attribute>
              </xsl:if>
              <xsl:value-of select="$DisplayTitle"/>
            </a>
        </div>
    <xsl:variable name="StartDate">
        <xsl:value-of select="ddwrt:FormatDateTime(string(@PublishedDate), 1033, 'g')" />
    </xsl:variable>
    <div class="custom_date">
            <xsl:value-of select="$StartDate" />
    </div>
    <div class="custom_description">
            <xsl:value-of select="@Body" disable-output-escaping="yes" />
    </div>
    <div>
        <table class="custom_postdetails" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td class="custom_author">
                        By: <xsl:value-of select="@Author" /> |
                </td>
                <td class="custom_comments">
                        Comments: <xsl:value-of select="@NumComments" /> |
                </td>
                <td class="custom_category">
                        Category: <xsl:value-of select="@PostCategory" />
                </td>
            </tr>
        </table>
    </div>
  </xsl:template>

  • Save the file and upload it to back up to the style library

Step 4: Apply Custom XSL style to content query

  • Modify the Content Query Web Part again
  • Expand open The Presentation Category
  • Choose the custom “BlogPost” style
  • Save the page and you should now see the blog post with the following data and format.

image

Here are the files so that you don’t have to go through the whole process. Happy SharePointing!