Archive

Posts Tagged ‘sharepoint’

Access to an external Sharepoint List with Sharepoint Client API

Do you need to access a Sharepoint List from a NonSharepoint Application???! With Sharepoint 2010 it is extremely easy… you can benefit of the Sharepoint Client API and it would be extremely easy to control resource hosted on SharePoint external list.
Obviously, whenever it is possible, I would suggest to cache the Sharepoint List in your application cache layer to avoid performance issues….

 public static ListItemCollection GetClientList(string listPath)
  {
  string url = ConfigurationManager.AppSettings["sharepointConfigSite"];
  using (Microsoft.SharePoint.Client.ClientContext ctx = new Microsoft.SharePoint.Client.ClientContext(url))
     {
        var list = ctx.Web.Lists.GetByTitle(listPath);
       ctx.Load(list);
       CamlQuery camlQuery = new CamlQuery();
       camlQuery.ViewXml = "<View/>";
       ListItemCollection listItems = list.GetItems(camlQuery);
        ctx.Load(listItems);
        if (ConfigurationManager.AppSettings["sharepointUserConfigSite"] != null)
          {
           string username = ConfigurationManager.AppSettings["sharepointUserConfigSite"];
           string pwd = ConfigurationManager.AppSettings["sharepointPwdConfigSite"];
            string domain = ConfigurationManager.AppSettings["sharepointDomConfigSite"];
            var cred = new System.Net.NetworkCredential(username, pwd, domain);
            ctx.Credentials = cred;
           }   else  {
                    ctx.AuthenticationMode = ClientAuthenticationMode.Anonymous;
                }
            ctx.ExecuteQuery();
            return listItems;
      }
 }
Categories: DEV, Infrastructure Tags: ,

how to get ApplicationID in Sharepoint

To retrieve your applicationId you need to run it in the Sharepoint management shell

$w=Get-SPWebApplication(“http://xxxxxxx&#8221;)
$w.ID

or if you are into a Sharepoint WebContext you can use the following code…

string webId = SPContext.Current.Site.WebApplication.Id.ToString(“B”);

Categories: DEV Tags:

12 and 14 hive on command prompt

Bored to type 12 and 14 hive path in the command prompt????

you can hack you registry…
http://blogs.msdn.com/jb/archive/2007/09/19/12-folder-from-here.aspx

or simpy add an environment path variable….

Categories: Infrastructure Tags: