Monday, September 27, 2010

SharePoint Jokes.

Light travels faster than sound. This is why some SharePoint consultants appear bright until you hear them speak.


A good SharePoint consultant is someone who can tell you to go to hell in such a way that you look forward to the trip.


SharePoint work is something you do that nobody notices until you don't do it.


I should've known it wasn't going to work out between my ex-girlfriend and me. After all, I'm a SharePoint and she's a Documentum.


Kerberos with SharePoint is sort of like a bird, it's pretty cute until it shits on your head.


The secret to success as a SharePoint consultant is knowing who to blame for your failures.


SharePoint Consultant to client - 'We don't have a SharePoint performance problem; You have a perception problem.'


SharePoint analyst to programmer: "You start coding. I'll go find out what they want."


The first half of my life was ruined by my parents, and the second half by SharePoint.


TIP: If you are a SharePoint admin and you think nobody cares if you're alive, try missing a couple of SharePoint service packs.


I want to die peacefully in my sleep, like my grandfather.. Not screaming and yelling like SharePoint end users.


I like SharePoint, It fascinates me. I sit and look at it for hours.


What did one sharepoint site say to another sharepoint site?  
    Hey, aren't we called webs?


What did the end user say to the developer?
    Oh, I didn't create that column, I was smart, I just renamed the "title" column!


What did one sharepoint web developer say to the asp.net developer?
    Why me?


What did the production portal say to the author portal?
    I'm sorry, I can't seem to find your object!


What did the parent content type say to the child content type?
    I won't give you my jeans, but I'll buy you another pair just like them and we can share! 


How many people does it take to create a web part?
    two, one to write the code, another to figure out the permissions problem in production!


How many times does it take to create a Shared Service Provider?
    3, one time to screw it up without knowing it, twice to do it because sharepoint won't do right the second time and
the third after you have blown away everything and started over!


What did the server admin say to the sharepoint web developer?
    Why can't we just do this with static html?


what did the sharepoint 2003 environment tell the sharepoint 2007 environment?
    Don't worry, reboot will still fix everything.


What did the sharepoint admin do to fix an "Unexpected Error has occured"
    Delete sharepoint and start again!


What did one w3wp process say to the other?
    Hey, can I borrow one of your SPSite's?  You have plenty!        


One day a user called the helpdesk, no one answered.  Being that he was in the helpdesk office he walked down and asked the admin why they weren't answering. 
She simply stated, they quit when they heard we were implementing sharepoint!


A consultant was asked to build an estimate for a SharePoint two layer approval workflow with SharePoint Designer.  
The consultant never replied.  When asked "why", he simply stated, "Impossible".


Updating the data from XML to Sharepoint List

With the use of Sharepoint List Webservice i am going to populate the xml data into the list. for this you need to create a list and also the columns. with nodes in the XML.

In this i m a  going to hard the Webservice Url, but you can add the app.config and can adda new key and value . which it reference in the code using Cofiguration Settings.by inheriting the System.Configuration.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Net;
using System.IO;

namespace XMLtoSPList
{
    class Program
    {
        static void Main(string[] args)
        {

            try
            {
                ReferenceToWebService.Lists ListsService = new ReferenceToWebService.Lists();
                ListsService.Credentials = new NetworkCredential("XXXX", "YYYYYY", "ZZZZZZ");
                //ListsService.Credentials = System.Net.CredentialCache.DefaultCredentials;

                string _listservURL = string.Empty;
                Console.WriteLine("Enter the SiteCollection Url :", _listservURL);
                _listservURL = Console.ReadLine();
                ListsService.Url = "http://servername/_vti_bin/lists.asmx";

                //ListsService.Url = "http://myserver:6580/Docs/_vti_bin/lists.asmx";
                XmlTextReader textReader = new XmlTextReader("C:\\myxml.XML");
                textReader.Read();



                XmlDocument doc = new XmlDocument();


                XmlElement batch = doc.CreateElement("Batch");

                batch.SetAttribute("OnError", "Continue");
                batch.SetAttribute("ListVersion", "1");


                XmlDocument doc1 = new XmlDocument();
                doc1.Load("C:\\Duplicate Vendor Additions.XML");
                int i = 1;
                try
                {
                    ListsService.GetList("RECORDS");
                    System.Xml.XmlNode ndListView = ListsService.GetListAndView("RECORDS", "");
                    XmlNode node1 = ndListView.ChildNodes[1];
                    XmlNode node2 = node1.ChildNodes[1];
                    XmlNodeList node3 = node2.ChildNodes;
                    int count = 0;
                  
                  
                    string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
                    foreach (XmlNode nd in doc1.DocumentElement.SelectNodes("RECORD"))
                    {
                        try
                        {
                            string Duplicates = nd.ChildNodes[0].InnerText;
                            batch.InnerXml = "" +
                                "" + i.ToString() + "" +
                                "" + nd.ChildNodes[0].InnerText.Trim() + "" +
                                   "" + nd.ChildNodes[1].InnerText.Trim() + "" +
                                     "" + nd.ChildNodes[2].InnerText.Trim() + "" +
                                       "" + nd.ChildNodes[3].InnerText.Trim() + "" +
                                         "" + nd.ChildNodes[4].InnerText.Trim() + "" +
                                 "" + nd.ChildNodes[5].InnerText.Trim() + "" +
                                 "" + nd.ChildNodes[6].InnerText.Trim() + "" +
                                 "";
                        }
                        catch (Exception ex)
                        {
                            Trace(DateTime.Now.ToString() + " A record with " );
                            Trace(nd.InnerXml);
                            Trace("is not inserted.");
                        }
                        //ListsService.UpdateListItems(strListID, batch);


                        Console.WriteLine(nd.ChildNodes[0].InnerText);
                        i++;
                    }
                }
                catch(Exception ex)
                {
                   Trace(DateTime.Now.ToString()+"---No List Found.");
                }
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            Console.WriteLine("Done");
            string exit = string.Empty;

            Console.WriteLine("Press X to exit"+exit);
            if (exit == "x")
            {
                exit = "exit";
                exit = Console.ReadLine();
            }
            Console.Read();


        }
    }
}

Hiding Sharepoint Controls in the List

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

public partial class hellol : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void CreateChildControls()
{
foreach (Control ctrl in this.Page.Controls)
{
CheckControl(ctrl);
}
base.CreateChildControls();
}

private void CheckControl(Control ParentControl)
{
try
{
foreach (Control childControl in ParentControl.Controls)
{

if (childControl.ToString().ToUpper() == "Microsoft.SharePoint.WebControls.ActionsMenu".ToUpper())
{

ActionsMenu Menu = (ActionsMenu)childControl;
Menu.Visible = false;
break;
}
CheckControl(childControl);
}
foreach (Control childControl in ParentControl.Controls)
{

if (childControl.ToString().ToUpper() == "Microsoft.SharePoint.WebControls.SettingsMenu".ToUpper())
{
SettingsMenu Menu = (SettingsMenu)childControl;
Menu.Visible = false;
}
if (childControl.ToString().ToUpper() == "Microsoft.SharePoint.WebControls.NewMenu".ToUpper())
{
NewMenu Menu = (NewMenu)childControl;
Menu.Visible = false;
}
CheckControl(childControl);
}

}

catch { }

}

}

Working with BDC picker Control in SharePoint Programatically

  By this you can use the customized  BDC picker entity. by developing the BDC picker control. The event Load will fetch the data and also connect to the instance which is ther ein the Respetive Shared service  related to the current webapplication.
    

       BDCEntityPickerID = new Microsoft.SharePoint.Portal.WebControls.ItemPicker();
            BDCEntityPickerID.ID = "BDCEntityPickerID";
            BDCEntityPickerID.AllowTypeIn = true;
            BDCEntityPickerID.AllowEmpty = false;
            BDCEntityPickerID.AutoPostBack = true;
            BDCEntityPickerID.MultiSelect = false;
            BDCEntityPickerID.Load += new EventHandler(BDCEntityPickerID_Load);
           Controls.Add(BDCEntityPickerID);


  protected void BDCEntityPickerID_Load(object sender, EventArgs e)
        {
            // Set extended data

            BDCEntityPickerID.ExtendedData = GetExtendedData("MyInstance", "Tablename", "ColumnName_picker");

            // Set other properties


        }


protected Portal.ItemPickerExtendedData GetExtendedData(string lobInstanceName, string entityName, string titleFieldName)
        {
            // Create a new ExtendedData object
            Portal.ItemPickerExtendedData data = new Portal.ItemPickerExtendedData();
            // Get the LOB Instance
            LobSystemInstance lob = ApplicationRegistry.GetLobSystemInstanceByName(lobInstanceName);
            data.SystemInstanceId = lob.Id;
            // Get the entity
            Entity entity = lob.GetEntities()[entityName];
            data.EntityId = entity.Id;

            // Set the primary column id (the id of the "Title" field)
            FieldCollection fields = entity.GetSpecificFinderView().Fields;
            List secondaryColumnIds = new List();

            foreach (Field field in fields)
            {
                if (string.Equals(field.Name, titleFieldName, StringComparison.OrdinalIgnoreCase))
                {
                    data.PrimaryColumnId = field.TypeDescriptor.Id;

                }
                else
                {
                    secondaryColumnIds.Add(field.TypeDescriptor.Id);
                }
            }

            data.SecondaryColumnsIds = secondaryColumnIds.ToArray();

            return data;


        }