Friday, October 22, 2010

Site Definition in Microsoft SharePoint Server 2007

Following steps are included in creating a custom site definition:

  • Create a folder named “mySiteDef” at C:Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Site Templates\ 
  • Create a subfolder “XML” and create the onet.xml in it. The following kinds of tasks can be performed in a custom Onet.xml to create a custom site definition: 
    • Specify an alternate cascading style sheet (CSS) file, JavaScript file, or ASPX header file for a site definition.
    • Modify navigation areas for the home page and list pages
    • Add a list definition as an option to the Create page
    • Add a document template for creating document libraries
    • Define one or more configurations for the site definition, specifying the lists, modules, files, and Web Parts that are included when a site definition configuration is instantiated
  • It contains the following tags to define various items in a site definition. A sample onet.xml can be found at 12\TEMPLATE\SiteTemplates\SPS\XML folder in sharepoint farm (Same can be done through by copy existing site definition).
  • Within the “C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/Templates/1033/XML” directory create a new file called webtempSiteMinder.XML. At run time the compiler will merge the information contained in this file with the information contained in the original WEBTEMP.XML file to specify which site templates are available for creating new sites
  • Enter the following XML into the webtempSiteMinder file as follows to create the new site definition.
<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="12.0.4518" _dal="1" -->
<!-- _LocalBinding -->
<Templates xmlns:ows="Microsoft SharePoint">
<Template Name="MYSITEDEF" ID="325202">
<Configuration ID="1" Title="MYSITEDEF" Hidden="FALSE" ImageUrl="/_layouts/images/blogprev.png" Description="MYSITEDEF Subsite" DisplayCategory="Custom" > </Configuration>
</Template>
</Templates>

  • Each WEBTEMP.XML file contains a collection of Template elements and Configuration sub-elements, which identify to the compiler all the site definitions that can be instantiated. The Configuration elements define a title, a description, and a URL for the image displayed in the user interface, properties common to each Web Site created using the site definition.
  • It is important to make sure that each Template element defined in the WEBTEMP file contains the identical Name in all capital letters that is assigned to the new folder created above. Also, as a best practice when creating new templates to avoid conflicts with existing sites use a unique value that is greater than 10,000 for the ID attribute.
  • Once created the various site elements can be edited using Microsoft office sharepoint designer.

Tuesday, September 28, 2010

Scoping Master Pages in SharePoint

Master pages provide the look and feel and standard behavior that you want for all of the pages in your site. Together with content pages, they produce output that combines the layout of the master page with content from the content page. 
Because Windows SharePoint Services is built on top of Microsoft ASP.NET 2.0, it supports master pages for defining elements that are common to all pages. You can specify all of the shared elements of your site in the master page or pages, and add content page-specific elements to content pages.

Master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.
Windows SharePoint Services pages that end users can customize—list view pages, list form pages, and Web Part Pages—are content pages that contain the content to display. When a user requests a content page, it is merged with a master page to produce output that combines the layout of the master page with the content from the content page.
All content pages share the same page structure—the global breadcrumb, site title area, top navigation, page title area, and left navigation bar. In Windows SharePoint Services, this shared page structure is moved into a master page called default.master, which is used by all content pages, including the following:
  1. default.aspx
  2. AllItems.aspx, DispForm.aspx, NewForm.aspx, and EditForm.aspx: for all lists 
  3. Upload.aspx and Webfldr.aspx: for all document libraries 
  4. Any new content pages that are created in this site
 
There are three levels to attach content pages to a master page:
  • At the page level: you can use a page directive in each content page to bind it to a master page, as in the following code example. 
  • At the application level: By making a setting in the pages element of the application's configuration file (Web.config), you can specify that all ASP.NET pages (.aspx files) in the application automatically bind to a master page. The element might look like the following. If you use this strategy, all ASP.NET pages in the application that have Content controls are merged with the specified master page. (If an ASP.NET page does not contain Content controls, the master page is not applied.)
  • At the folder level: This strategy is like binding at the application level, except that you make the setting in a Web.config file in one folder only. The master-page bindings then apply to the ASP.NET pages in that folder.

Monday, September 27, 2010

Important Considerations for SharePoint Master Pages

Consider the following when you are working with master pages in Windows SharePoint Services:

1. Compilation mode for master pages works like the compilation mode for any other .aspx page. You can change the compilation mode at any time, and you can combine compilation modes for master and content pages, for example, a compiled master page and a content page that is not compiled. Remember, however, that although compiled master pages can contain inline script, after that page is customized in Office SharePoint Designer, or a similar tool, the page is no longer compiled and script no longer runs. For that reason, it is recommended that you do not include inline script in your master pages.

2. By default, Windows SharePoint Services does not use nested master pages, but does not block users from using them. You can create master pages at any level, and have a master page that refers to another master page. For example, you can reference one master page from another master page using the following directive:

<%@ Master master=MyParent.master %>

Some page editors may not effectively support nested master pages.

3. You cannot add Web Parts in zones to a master page. You can add static Web Parts (parts outside of a zone) to a master page, but you cannot add dynamic Web Parts to master pages. You can add zones to master pages and later add Web Parts to the zone in the browser, but the Web Parts are associated with the content page.

Sunday, August 1, 2010

Few notes about Abstract class and Interfaces...

when you believe that derive class behavior & action would be similar to base in most of the case you use abstract; and when you think that behavior is same but action can change for different derived classes you use interface.

Abstract base class shows is-a relationship while interface shows "can do" relationship for ex: humans and fish can swim while human and horse can run and human, horse and fish are (is a) animals.

So abstract class Animal can be a base class inherited by all humans, horse and fish. While animal itself doesn't represent any physical entity so abstract. A behavior "breath" will be applied to all in animals if defined in animal abstract class itself. May be later on you may want to add "Eat" behavior in abstract class which would not create any consequences on derived class. Or you might support another version of animal which can represent the abstract properties of aliens too.

while Interface IRun will be inherited by human and horse only while ISwim can be inherited by human and Fish only and all these derived classes will define their own style of swimming and running while if you add another behavior in same interface you have to define it in all the derived class.

Sample implementation will be like

Class Human: Animals, IRun, ISwim{}

Class Horse: Animals, IRun{}

Class Fish: Animals,ISwim{}

Class Bird: Animals, IFly{}

later on updated versions of animal

Class Alien: Animals, IFly, ISwim, IRun, ISpace {} //though hypothetical considered just for example :)
REF: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/0ab0d038-61b6-43e0-82da-33338f52f3bf

Why abstract allows constructor? What is the use of it?

So that derived class can call it where creating it's object and abstract base class can initialize it's members.

"Because abstract classes should never be instantiated, it is important to correctly define their constructors. It is also important to ensure that the functionality of your abstract class is correct and easily extended. The following guidelines help ensure that your abstract classes are correctly designed and work as expected when implemented.

Do not define public or protected internal (Protected Friend in Visual Basic) constructors in abstract types &define a protected or an internal constructor in abstract classes:

Constructors with public or protected internal visibility are for types that can be instantiated. Abstract types can never be instantiated. If you define a protected constructor in an abstract class, the base class can perform initialization tasks when instances of a derived class are created. An internal constructor prevents the abstract class from being used as the base class of types that are not in the same assembly as the abstract class. "

http://msdn.microsoft.com/en-us/library/ms229047.aspx

REF: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/175aad18-4514-4320-8195-be480dee4627

Why use reference of abstract class to create object

It is more related to OOPS concept rather than how we do it C#. Liskov substitution principle explain the relation in the best way

"Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T". Here you can assume T as TextWriter and S as Stream Writer

http://en.wikipedia.org/wiki/Subtype#Subtyping_schemes

In Particular to .net concept TextWriter is more generic offer basic functionality to write Streams (StreamWriter) and strings (StringWriter) to a file

REF: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/aa53228f-6d2d-4475-8d7c-8081057f22f9

Friday, July 30, 2010

Why Feature stapling in SharePoint

sometimes you may want to attach your feature with site definition i.e. whenever someone create a site using particular site definition you might want to activate the feature by default, and in same scenario it may be possible that you do not own the site definition hence cannot modify the existing site definition to attach feature (like SharePoint default site def e.g. team site\publishing\collaboration).

In these cases you can write a feature and can attach the feature itself with the site definition.

From MSDN :
"Causes the attachment of a Feature to all new instances of sites that use a given site definition, without modifying the site definition or creating code routines to activate the Feature on each site. Also known as a feature site template association"

Following is an example of feature stapling that associates the Feature with only the STS site definition template

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="STS#0" />
</Elements>

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/5e27a15b-5ceb-4706-b660-aadad03e0f3c

Wednesday, June 16, 2010

DataTable To String Array in C# without using a for Loop

Many time we need need to get data from dataset\Datatable to array to pass it to some function or third API like x axis or y axis series of chart controls or to some other reporting or data binding control may be dropdown. it becomes difficult to get the data of a column(s) in array and finally we end up writing a for loop. here is a sample example by which we can simply get array of a column(s) with out a for loop
public static string DataRowToString(DataRow dr)
{
       return dr["columns"].ToString();
}
public string [] DataTableToArray(DataTable dt)
{
     DataRow[] dr = dt.Select();
     string [] strArr= Array.ConvertAll(dr, new Converter(DataRowToString));
     return strArr;
}

Array.ConvertAll() function simply converts the array of one to another so here in above example we are passing dr as an araay of datarows in first arguments. second argument is a Converter delegate type which convert one type to another so in this we will pass a link to delegate which is DataRowToString() function ,the delegate should know the input datatype and output datatype which is datatrow and string in this case respectively. function DataRowToString noe simply takes a datarow and return the string value for the column specified. which can be extended for multiple columns also.

Ref: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/46ef6ca8-7f66-489a-a0f6-b6b7c4200d16

Thursday, May 6, 2010

WSS3.0\MOSS2007 and "Integrated managed pipeline mode" of IIS7

Problem Description:
SharePoint site is on WIN2k8\IIS7\WSS3.0-SP2 and you have created a sample web app (blank site) which is running well with IIS7 "Classic managed pipeline mode" but when you change it to "Integrated managed pipeline mode", It does not work and throws an error message "500 internal server Error".
Discussion ,Action taken and Results:
As discussed, MOSS 2007 use “Classic application pool mode” in IIS 7 for the SharePoint site since MOSS 2007 use IIS 6.0/ISAPI functionality through an ISAPI module and that is part of “Classic application pool mode” .
If we will use the “ Integrated Request Pipeline” for the SharePoint 2007 site you will not be able to browse to the site.
Following is the TechNet article which talk about that SharePoint use “Classic application pool mode” for the Application pool.
1: http://msdn.microsoft.com/en-us/library/bb909693.aspx (How to: Verify or Correct the IIS Configuration for an Application Pool)
Details are:
1. On the Application Pools page, review all application pools for Team Foundation.
• Under .NET Framework Version, verify that v2.0 appears.
• Under Managed Pipeline Mode, verify that Classic appears.
2: http://technet.microsoft.com/en-us/library/cc262485.aspx (Determine hardware and software requirements (Office SharePoint Server))
Details are:
Windows components
After you have installed the operating system and applied all critical updates, you must configure the computer to be a Web server by enabling Internet Information Services (IIS) 6.0, including:
• Common files
• WWW
• Simple Mail Transfer Protocol (SMTP)
You must configure the server to use IIS 6.0 worker process isolation mode. This is the default setting in new installations. However, if you have upgraded from IIS 5.0 on Windows Server 2000, Run WWW in IIS 5.0 isolation mode is enabled, and you must change this setting to use IIS 6.0 worker process isolation mode.
To enable e-mail notifications, you need to configure incoming and outgoing e-mail settings. To configure sending e-mail alerts and notifications, you must specify an SMTP e-mail server. To configure your installation so that your SharePoint sites can accept and archive incoming e-mail, you must install the IIS SMTP service

Additional info:
Integrated Request Pipeline:
Think of the integrated request pipeline as the essential set of linear steps that must occur every time a page is served up (as seen in Figure 2). Typically, some sort of authentication must take place, followed by authorization to retrieve content, determination and execution of the handler needed for that content, performance of any necessary logging, and finally sending a response. The integrated request pipeline provides IIS 7.0 the flexibility to run different application frameworks at the same time. For example, you can run Forms authentication on top of PHP content with a custom logging module, all together in the same pipeline.

Each Web site on the server has an integrated request pipeline and can be run in one of two modes, Integrated and Classic. Integrated, the default, allows particular pieces of functionality to be plugged into the pipeline, giving you granular control over the request process. For compatibility, Classic mode reproduces IIS 6.0/ISAPI functionality through an ISAPI module into the pipeline. This is very helpful when migrating your applications to IIS 7.0.
More info : http://technet.microsoft.com/en-us/magazine/2008.03.iis7.aspx
Classic application pool mode:
When an application pool is in Classic mode, IIS 7 handles requests as in IIS 6.0 worker process isolation mode. ASP.NET requests first go through native processing steps in IIS and are then routed to Aspnet_isapi.dll for processing of managed code in the managed runtime. Finally, the request is routed back through IIS to send the response.
This separation of the IIS and ASP.NET request-processing models results in duplication of some processing steps, such as authentication and authorization. Additionally, managed code features, such as forms authentication, are only available to ASP.NET applications or applications for which you have script mapped all requests to be handled by aspnet_isapi.dll.

Tuesday, April 6, 2010

A HTML Table based Chart control in ASP.NET\MOSS 2007

Content:
  • Introduction
  • Various options to display charts on web
  • Code Walkthrough
  • Advantages
  • Limitation
Introduction:
A chart is a visual representation of data represented in various code\colors. It represents the summary of large chunk of unorganized data in an easy to understand manner which becomes very helpful in analysis, decision making and trend setting. The extensive usage of data over the web makes it very important control nowadays. Most of the modern web2.0 websites uses charts as one of the techniques to convey data to site visitors.
The article below gives a summary to create a 3d column charts in asp.net which can be modified and used in various other web supported platforms

Various options to display charts on web
Following are options to use chart on web in .net plateform
Microsoft chart controls:
Microsoft recently launched the rich functionality chart controls for asp.net to work with .net framework 3.5. It can be downloaded from the link below and used as any other controls in asp.net
http://www.microsoft.com/downloads/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C
These chart controls will be part of visual studio 2010 release.
GDI+ charts:
GDI+ charts are traditionally used chart controls over the web. It uses various drawing API of com\.net to draw a picture at server end first and then transfer the picture on the web. These controls are very complex and resources consuming.
Creating 3d and nice look and feel also bit cumbersome
HTML Table based Charts:
The technique used below is to generate line charts with the help of html tables and 3d images. It draws the table calibrate a 3d image to fit in the row as per the given x\y axis value. Hence become very lightweight and supported on any .net framework\ other platforms. Below is the sample screen shot.
Code Walkthrough: There are mainly two code files in this project. A chart user control and a web page to host\call chart
Chart controls expose various properties to set the different parameters of chart like width, column height, y axis values, x axis values etc. DrawGraph() is called to draw chart based on the x axis and y axis values set in the properties. It normalize the values provides for x axis and resize it as per the chart width. Below are the algorithm steps.
  • Define the color image array to denote the x axis values
  • Find out the max value in the x axis collection
  • Get the mod by dividing chart width with max value
  • Draw a table and draw a row for each value
  • For each value in the collection multiply the mod with value to expand and divide chart width with standard param to contract
  • Set this value as the length of image
  • Repeat the colors if color array is less than the value specified
  • Emit the constructed html on div\label tag
 Advantages:
  • It really simple, lightweight, 3d bar chart with nice look and feel
  • The code\logic can be modified to work on any other platform\language
  • A html table base web chart renders well on all type of browsers
  • It can be used in any .net framework\SharePoint
  • Can be customized easily based on the requirements
Limitation:
  • Can’t use similar technique to draw pie charts
code available on request

Monday, March 15, 2010

Best Coding Practices For Using Sharepoint Object Model

Content:
  • Introduction
  • Using objects in event receivers
  • Disabling Event Firing
  • Working with folders and lists
  • Using SPQuey Objects
  • Dispose WSS Objects
  • Subfolder creation in a list 
Introduction:
WSS provides a highly structured server-side object model that makes it easy to access objects that represents the various aspects of a SharePoint Web site. From higher-level objects, we can drill down through the object hierarchy to obtain the required object to be used in our code.
Diagram depicting the WSS site architecture in relation to the collections and objects of the Microsoft. SharePoint namespace is as follows:

While creating a new application or to improve the performance, extensibility and scalability of existing application it is important to understand how to make the SharePoint object model work efficiently, and how to apply general programming techniques to the SharePoint platform specifically. These common best coding practices can make it easier to design our applications correctly, find and fix problem areas in our code, and avoid known pitfalls of using the SharePoint object model.

Using Objects in Event Receivers:

SPWeb, SPSite, SPList, or SPListItem objects should not be instantiated within an event receiver. Within Event Receivers instead of using these objects event properties should be used otherwise following problems may occur:

• They incur significant additional roundtrips to the database. (One write operation can result in up to five additional roundtrips in each event receiver.)

• Calling the Update method on these instances can cause subsequent Update calls in other registered event receivers to fail.

Disabling Event firing:
Event handlers are fired synchronously or asynchronously for every addition, update, and deletion etc. if also that is not required from different code execution and it can cause performance degradation and unnecessary execution of event handlers code. So these event handlers must be disabled whenever not required. Code for this is:

public static void EnableEventFiring()
{
SetEventFiringSwitch(false);
}
public static void DisableEventFiring()
{
SetEventFiringSwitch(true);
}
private static void SetEventFiringSwitch(bool value)
{
PropertyInfo pi = EventManagerType.GetProperty(_eventFiringSwitchName, System.Reflection.BindingFlags.Static
System.Reflection.BindingFlags.NonPublic);
pi.SetValue(null, value, null);
}
private static bool GetEventFiringSwitchValue()
{
PropertyInfo pi = EventManagerType.GetProperty(_eventFiringSwitchName, System.Reflection.BindingFlags.Static
System.Reflection.BindingFlags.NonPublic);
object val = pi.GetValue(null, null);
return (bool)val;
}
private static Type GetEventManagerType()
{
_eventManagerType = typeof(SPList).Assembly.GetType(_className, true);
return _eventManagerType;
}
Working with folders and lists:
Working with large lists and folders needs conventional design change to optimize performance which is as follows:

  • Instead of using SPList.Items use SPList.GetItems(SPQuery query) and apply appropriate filter on query to make it more efficient. If list contains more than 2000 items then paginate the list in increments of no more than 2000 items.
  • Instead of using SPList.Items.GetItemById use SPList.GetItemById.
  • While adding a new item in a list instead of using SPList.Items.Add use SPList.GetItems(q).Add where q is empty query. Code for this is:- const
string EmptyQuery = "0";
SPQuery q = new SPQuery { Query = EmptyQuery };
SPListItem item = List.GetItems(q).Add();
  • Do not enumerate entire SPList.Items collections or SPFolder.Files collections.
  • While retrieving SPList object instead of getting it by using list’s name use its GUID or URL of the list.
Using SPQuery Objects:
When SPQuery returns large result sets than that can cause performance problem so points to keep in mind while designing query are as follows:
  • Use RowLimit between 1 and 2000 for SPQuery and paginate through the list if required.
  • If List Item URL is known than query list by using FileRef like SPWeb.GetListItem(string strUrl, string field1, params string[] fields).
  • Whenever possible use indexed columns in where clause of SPQuery.

Dispose WSS Objects:
WSS object model contains objects that implement the IDisposable interface. The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used. It is not known that when garbage collector will execute. Furthermore, the garbage collector has no knowledge of unmanaged resources. So Dispose method of this interface should be explicitly called to release unmanaged resources in conjunction with the garbage collector.

SPSite and SPWeb objects are managed objects but use unmanaged code and memory to do majority of their work. The managed part of the object is much smaller than the unmanaged part. Because the smaller managed part does not put memory pressure on the garbage collector, the garbage collector does not release the object from memory in a timely manner. The object's use of a large amount of unmanaged memory can cause some of the unusual behaviors like poor performance, application crash, high memory use of IIS worker process. Calling applications that work with IDisposable objects in Windows SharePoint Services must dispose of the objects when the applications finish using them. We should not rely on the garbage collector to release them from memory automatically.
We can employ certain coding techniques to ensure object disposal. These techniques include using the following in our code:
  • Dispose method
  • using clause
  • try, catch, and finally blocks
Subfolder Creation in a list:
If list size exceeds 2000 items then Microsoft recommends having subfolders for every 2000 items in a list. Then use SPQuery.ViewAttributes = "Scope=\"Recursive\"" for querying data through SPQuery and if possible than query only from subfolder by giving its name.

Thursday, March 4, 2010

Context sensitive help in SharePoint

Context sensitive help is key part of any product now Days. Product companies don’t want their customers to search for a particular help in entire help system and it becomes really difficult in case of online help where you may want to redirect your customer to some online help article

You must have seen such scenarios in many Microsoft products. The one I can remind now is code analysis tool or FxCop
Below is the sample steps of context sensitive help implemented in a SharePoint product, which can be implemented in ASP.NET or any other technology

Step 1: define a content placeholder in master page of the application (as top right corner the default location in SharePoint)

Step 2: now from each page add an image button on which you will attach a javascript function to call help page. Add any standard help image on this button

Step 3: prepare an xml file on which define key value pair for each page.where key will be the page context and value will be the respective URL

Step 4: onload of each page attach a java script function to help image button onclick event which will find the URL from defined xml file

Step 5: prepare a separate help system such as .chm file and publish help content as per the associated links

Step 6: host all the pages in the web server incase of SharePoint I posted all these files which include .htm\.jpg\.css etc in a form library

Step 7: run the application and you will be able to access your help system in context of the current page

I will post the respective code for this soon
Reach me for more detail explanation.

Monday, January 4, 2010

Content migration from documents to wiki (MediaWiki)

This article will cover following topics
• Statement of problem
• Feasible solutions to achieve the goal
• Automating conversion of documents using VBA macros
       o What are VBA macros
       o Functional details
• Technical aspects
       o Technology used
       o Class details
       o IO/user interface
• Configuration
       o How to use the application
       o Extend the application to web or windows
       o Exception
       o Limitation and support
Statement of problem:
To convert documents (doc/pdf/excel) to wiki formatted text so that it can be directly hosted on a wiki server and a mass import of content or document import to wiki can be achieved.
Feasible solutions to achieve the goal: The following two approaches can be followed to achieve the solution.
• Automating conversion of the documents in wiki text, using VBA macros (preferred)
• Reading the entire content with inline formatting and applying wiki syntax to it.
Automating conversion of documents using VBA macros:
• What are VBA macros: Macros are Code written in VBA ,is compiled[ to a proprietary intermediate language called P-code (packed code), which is stored by the hosting applications (Access, Excel, Word) as a separate stream in Structured storage files (e.g. doc or xls) independent of the document streams. The intermediate code is then interpreted.
• Functional details: following steps are mentioned below:
     o Write a macro for each document type as excel, word or ppt which can convert the content in wiki format by persisting the data/formatting and save the output temporarily in the same file
     o Save the macro in .bas format (change/set the extension to .bas)
     o Automate the office documents using .net libraries which can attach the corresponding macro to the document and execute the macro on the documents.
     o Read the output (wiki formatted text) generated by macro and publish it to the hosted wiki using the Mediawiki API’s for .net

Technical aspects:


Technology used: Asp.net, VBA Macros, PHP, Media Wiki, IIS, apache web server
       o write macro for each excel and word documents to convert in wiki formatted text
       o create .net based class library to convert PDF to word document
       o create .net based class library to automate the office application which can add and execute the macro
Class details: project contains a class library (wikiconversion) to automate the document conversion, media wiki API’s (wikiaccess) and a console program to invoke the application


IO/user interface: the project includes a console application by which the application can be simulated, hence there is no visible UI design. It takes input from the folder Documents read all documents in the folder and hosts the doc and excel type in media wiki. An output file is generated in the Output folder under Documents with the current timestamp with the status of documents processed. (Same library can be extended for any web or window application as needed)


Configuration: Following configuration required to run the application

1. A Mediawiki hosted on apache server (mediawiki should support the call From API e.g. $wgEnableAPI=true in localSettings.php file)
2. All the documents that has to be converted must be in documents folder of the application
3. Macros folder which consist macros for word and excel file, should be in the application with relevant word and excel macros. For further details on macro please follow this link http://en.wikipedia.org/wiki/Visual_Basic_for_Applications
4. Wikiconversion.config must be updated with relevant config values like mediawiki server name and various files path

o How to use the application: set the configuration values in config file appropriately, place the file to be converted in documents folder and run the content import project

o Extend the application to web or windows: Create a web or window application, and call the various functions available in wikiconversion class (refer the code written in Main function for more details)

o Exception: Any corrupted file or very big file in size might take either too long to host on wiki or fail to do so. Accuracy of Conversion from documents to wiki depends on the macros placed in application Macro can be replaced for better output as further if available. Current macros convert the most of features/format appropriately still some issues can be there in word macro.

o Limitation and support: currently application support only MS-Word and MS-Excel file to convert and host in media wiki but the same can be extended to PDF,HTML,PPT by converting them to MS-word documents.URL generated in output file might mislead sometimes

References: http://www.mediawiki.org/wiki/API

Introduction to Web Parts in ASP.NET/MOSS 2007

Content:

• Introduction
• System requirement
• Web part framework
• Comparing with asp.net
• Creating a new web part solution
• Deploying and debugging



Introduction:

Microsoft ASP.NET 2.0 provides a Web Part infrastructure that helps you build custom Web Parts and deploy them to Web sites built using Microsoft Windows SharePoint Services 3.0. This article provides a walkthrough how to build custom Web Parts that work in both standard ASP.NET 2.0 Web sites and Windows SharePoint Services 3.0.



Web part framework:

A Web Part is an ASP.NET server control designed to be edited and modified by users in the browser. It works as a component of a SharePoint site that presents information pulled from multiple data sources. Web Part pages allows to personalize information relevant to the needs by updating the value of specific Web Part properties. SharePoint Web Parts are UI elements that support both customization and personalization.

The Web Part infrastructure in Microsoft Windows SharePoint Services 2.0 and Microsoft Office SharePoint Portal Server 2003 provides a framework to build custom Web Parts targeted to Microsoft SharePoint Products and Technologies by using managed code.

ASP.NET 2.0 includes a new Web Part control set that allows site customization and personalization on custom Web sites that are independent of MOSS. The Web Part infrastructure in Windows SharePoint Services 3.0 exists on a layer above the ASP.NET 2.0 Web Part infrastructure.






Comparing with asp.net:


Office SharePoint Server 2007 and Windows SharePoint Services 3.0 are built on top of the ASP.NET 2.0 Framework. Windows SharePoint Services 3.0 uses the ASP.NET 2.0 Web Part infrastructure to take advantage of features such as master pages and custom Web Part development while providing a complete set of Windows SharePoint Services features, such as document services, events, workflow, search, site columns, content types and more.

We can build Web Parts for Windows SharePoint Services 3.0 in two ways:

• Create custom ASP.NET 2.0 Web Parts.
• Create SharePoint-based Web Parts.

The following table provides a decision matrix to help you choose the best option depending on your business needs.


Creating a new web part solution:
 
To create a new Web Part solution
o Open VS 2005 > File menu> click New, and then select Project.
o In Project types, select Visual C#, and then select SharePoint.


o In Templates, select Web Part.


o Specify a new name, location, or solution name of Web Part, and then click OK. The extensions create a new Web Part solution project, which includes the following:

 References to the Microsoft.sharepoint

 AssemblyInfo.cs, a file that enables you to specify company and product information for the Web Part assembly, and version information

 Temporary.snk, a temporary signature key file for the Web Part assembly

 A Visual C# code file for the Web Part, named the same as the Web Part name

 By default, the code file for the Web Part contains the following:

 using statements for the necessary System and Windows SharePoint Services namespaces, such as Microsoft. SharePoint, Microsoft.SharePoint.WebControls, and Microsoft.SharePoint.WebPartPages

 An empty Web Part class that inherits from System.Web.UI.WebControls.WebParts.WebPart

o Add the code you want to the Web Part class.



Customizing the Web Part Solution Package


The Web Part project template automatically generates the XML files needed to package your Web Part as a MOSS 2007 feature for deployment and activation. The required GUIDs contained in the XML files are also generated automatically.

The extensions generate a .webpart file as the element.xml file for the Feature containing the Web Part. Every Web Part should have a .webpart file, which is an XML file that describes the Web Part. The .webpart file also makes your Web Part appear in the Web Part gallery in MOSS 2007.

we can customize the information in these XML files by editing solution, Feature, and element properties on the SharePoint Solution tab in project's Properties dialog box, as follows:



o Solution Information in this node is written into the manifest.xml file for the Feature. You can set the following solution property:

o Name The name of your Web Part solution.

o Feature Information in this node is written into the feature.xml file for the Feature. You can set the following feature properties:

o Folder Name The name of the folder to contain the files for this Feature.

o Title The title of the Feature. Limited to 255 characters.

o Description A longer representation of what the Feature does.

o Version Specifies a System.Version-compliant representation of the version of a Feature. This can be up to four numbers delimited by decimals that represent a version.

o Scope The Feature scope. Can contain one of the following values: Farm (farm), WebApplication (Web application), Site (site collection), or Web (Web site).

o Hidden Hides the feature. This attribute is FALSE by default.

o Default Resource File Indicates a common resource file for retrieving Feature XML resources.

o Element Information in this node is written into the element.xml file for the Feature. As mentioned earlier, this file contains the information usually contained in a .webpart file. You can set the following element properties:

o Title The title of your Web Part on web page.

o Description The description of your Web Part that you want to appear in the Windows SharePoint Services user interface.

o ImportErrorMessage The error string to display if Windows SharePoint Services is unable to import your Web Part solution.


Customizing the Web Part solution feature package


o In Solution Explorer, right-click the Web Part project, and then select Properties.

o In the Properties window, select SharePoint Solution. This tab lists the nodes that contain the properties for the solution package that the extensions will generate.

o Expand the Solution node, and then expand the Feature node and the Element node.

o To edit properties for a node, click a node, and then edit the properties. For example, click the Element node, and then edit the values for the Title, Description, and ImportErrorMessage keys.

o To commit your changes for a node, click in the Description value field.




Deploying and debugging:

We can deploy and start debugging of the Web Part simply by pressing F5.

When you press F5, the extensions automatically build, deploy, and initiate debugging of Web Part solution Feature. To accomplish this, the extensions perform the following actions automatically:

o Build the Web Part assembly.

o Package the Web Part solution as a Windows SharePoint Services Feature.

o If this Web Part solution was deployed previously, the extensions retract the previous version of the Web Part solution Feature.

o Install your Web Part assembly to the global assembly cache using gacutil utility

o Deploy and activate your Web Part solution Feature in Windows SharePoint Services.

o Add your Web Part to the Safe Controls list.

o Restart Microsoft Internet Information Services (IIS) by invoking the iisreset command.

o Attach to the w3wp processes to enable debugging.