Tuesday, February 16, 2010

Getting columns name from a table in Sql Server

SELECT syscolumns.name FROM sysobjects, syscolumns WHERE sysobjects.id = syscolumns.id and sysobjects.name='Profile'

Thursday, August 20, 2009

Finding the failed feature-id in MOSS 2007

List featIDs = new List();
foreach (SPFeatureDefinition featdef in SPFarm.Local.FeatureDefinitions)
{
try
{
//db5c27c4-6f17-4296-bc05-bbe9978284b4
if (featdef.DisplayName.Contains("manoj"))
{
Console.WriteLine("{0}: {1}", featdef.Id, featdef.DisplayName);
break;
}
}
catch
{
//This code will be executed if the feature does not have the manifest file.
Console.WriteLine("################################################");
Console.WriteLine("Error Ocurrred! Attempting to get feature ID of the feature without manifest file...:");
Console.WriteLine(featdef.Id.ToString());
}

Friday, August 14, 2009

Content Types and Workflows

  • Workflows can be associated with content Type
  • Workflow tasks are special content type(0x010801)
  • Content types can have special new, display and edit forms.
  • Therfore, the task edit page for a workflow task can be customized
  • Thursday, August 6, 2009

    Finding MAC address in VB.Net

    Imports System.Management
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim mc As System.Management.ManagementClass
    Dim mo As ManagementObject
    mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
    Dim moc As ManagementObjectCollection = mc.GetInstances()
    For Each mo In moc
    If mo.Item("IPEnabled") = True Then
    ListBox1.Items.Add("MAC address " & mo.Item("MacAddress").ToString())
    End If
    Next
    End Sub
    End Class

    Tuesday, July 28, 2009

    Data Import to a Sharepoint List

    Example:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using Microsoft.SharePoint;
    namespace DataImport
    {
    class Program
    {
    static void Main(string[] args)
    {
    // Check there are enough command line parameters
    if (args.Length <>[ []]");
    return;
    } char[] splitArray = { ',' };
    int startRecord = 0;
    int endRecord = int.MaxValue;
    // Store the command line parameters.
    string paramFileName = args[0];
    string paramWeb = args[1];
    string paramList = args[2];
    // Get start record integer.
    if (args.Length > 3)
    {
    if (args[3] != String.Empty)
    {
    startRecord = Convert.ToInt32(args[3]);
    }
    // Get end record integer.
    if (args.Length > 4)
    {
    if (args[4] != String.Empty)
    { endRecord = Convert.ToInt32(args[4]);
    }
    }
    }
    // validate the start and end record
    if (endRecord < startRecord)
    {
    Console.WriteLine("End record parameter must be greater than start record parameter");
    return;
    }
    // open the CSV file for reading
    using (StreamReader fileRdr = File.OpenText(paramFileName))
    {
    // connect to the site collection
    using (SPSite spSite = new SPSite(paramWeb))
    {
    // open the root site
    using (SPWeb spWeb = spSite.OpenWeb())
    {
    // get the list from the site
    SPList spList = spWeb.Lists[paramList];
    // read the fields in the header
    string line = fileRdr.ReadLine();
    string[] fieldNames = line.Split(splitArray);
    // get an array of field from the list
    // this assumes the field names match
    // we need the field Id when inserting rows
    SPField[] spFields = new SPField[fieldNames.Length];
    for (int looper = 0; looper < fieldNames.Length; looper++)
    {
    string strName = fieldNames[looper];
    SPField field = spList.Fields.GetField(strName);
    spFields[looper] = field;
    }
    // get the next line
    line = fileRdr.ReadLine();
    // start counting from the 2nd line
    int lineCount = 0;
    // keep reading till we run out of file
    while (!fileRdr.EndOfStream)
    { // if we are past or on the start record then
    if (lineCount >= startRecord)
    { // a little bit of progress
    if (lineCount % 10 == 0)
    Console.Write(".");
    // get the values from the line
    string[] fieldValues = line.Split(splitArray);
    // create a new list item
    SPListItem newItem = spList.Items.Add();
    // populate the values in the item using the
    // SPFields we created earlier
    for (int looper = 0; looper < fieldValues.Length; looper++)
    {
    newItem[spFields[looper].Id] = fieldValues[looper];
    }
    // update the item to the list
    newItem.Update();
    }
    // see if we want to stop prematurely
    if (lineCount >= endRecord) break;
    lineCount++;
    //read the next line
    line = fileRdr.ReadLine();
    if (fileRdr.EndOfStream)
    { string[] fieldValues = line.Split(splitArray);
    // create a new list item
    SPListItem newItem = spList.Items.Add();
    // populate the values in the item using the
    // SPFields we created earlier
    for (int looper = 0; looper < fieldValues.Length; looper++)
    {
    newItem[spFields[looper].Id] = fieldValues[looper];
    }
    // update the item to the list
    newItem.Update();
    }
    }
    }
    }
    }
    }
    }
    }

    Monday, July 27, 2009

    Where to use WSS Object Model

    Object Models - Sharepoint

    Windows SharePoint Servies 3.0Microsoft Office SharePoint Server 2007
    Microsoft.SharePoint.dllMicrosoft.Office.Server.dll
    Microsoft.Office.Server.Publishing.dll
    Microsoft.Office.Server.Policy.dll
    Microsoft.Office.Server.Search.dll
    Microsoft.SharePoint.Portal.dll
    Microsoft.Office.Workflow.Tasks.dll
    Microsoft.SharePoint.Publishing.dll
    Microsoft.Sharepoint.Workflow.Actions.dll