I am working on project where I have to access SharePoint data in C#.
I've never done this before; and have the following questions?
How would I access SharePoint data from C#? What API do I use? Are there any tutorials out there that will help me get started?
There two ways in which you can access Sharepoint data:
By Using Microsoft.Sharepoint.dll
In this case you need to do coding on same machine (windows server).
Second way is to use Sharepoint Web Services.
This will allow developer to do developement work on different machine.
The SDK is a good place to start. The real crux of question lies in whether you are writing code which will live in a SharePoint environment, or writing code which will consume SharePoint data in an external application.
In the case of the former, SharePoint has its own API which you gain access to by simply referencing the appropriate DLL.
For the latter, SharePoint comes with a set of web services which allow external applications to consume its data. Either these or a set of custom services (running in the SharePoint environment) will be your entry point into SharePoint.
This is how you would do it in PowerShell which is very similar in how you would do it in in C#:
# Lets reference the assembly / GAC that we need for this
function getUsers
{
param ([string] $verify_sitepath="https://extranet.something.com")
$verify_site=new-object Microsoft.SharePoint.SPSite($verify_sitepath)
$verify_web=$verify_site.Rootweb
$verify_web.site.url
$verify_groups = $verify_web.groups | ? {$_.Name -match "^.*$CurrentGroup" }
foreach($verify_group in $verify_groups)
{
foreach($verify_user in $verify_group.users)
{
$verify_user = $verify_user -replace "WRKGRP\\",""
Write-Output "$verify_user" | Out-File -filepath "$splist$currentGroup.txt" -append
}
}
}
What this does is gets all the users from SharePoint that are in a text file. Hopefully this gets you at least thinking about how SharePoint is set up.
A great resource is the MSDN page with all the functions. They provide a lot of programming samples in C#!
Start at the Sharepoint SDK page. Download the SDK, and look at the sample code on MSDN.
Added later: according to MS, this is a better site for all things related to Sharepoint development.
You have to install VS 2005 or VS 2008 extensions for sharepoint. Intsllaing them on xp can be tricky and this page should hep you with that.
you should also CAML Query which you should know to query data from sharepoint lists
you can make use of such a tool http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx
To me it sounds like you should use the Out Of The Box SharePoint web services. There is no reason why you should have to learn the entire SharePoint API when you could get along just talking to the web service.
This primer on InfoQ is good, but do a seach on SharePoint Web Services and you will find plenty of sources
Related
I'm new to the SharePoint 2013 .Net Client API. I want to programmatically crawl all of a SharePoint site. I want to fully extract lists, document, pages, everything!
Ideally I want to start with the root of the website and crawl everything from there.
Can someone give a high-level overview of the basic steps involved? For example, do I need to create a catalog, or can I simply crawl if I have the admin credentials?
I'm using C#, .Net 4.0, and the Client runtime API (not REST).
Some of the links that were helpful for me :
1. Crawling with Rest API or PowerShell - Start a crawl manually via SOAP or REST WebService
2. Recrawling using code - http://sebastian.expert/force-web-whole-list-library-re-crawled-search-sharepoint-2013-using-api/
I believe that everything in SharePoint lives under a List. Essentially, I fetch the Lists belonging to a Web and fetch all the ListItems from those. I ignore Folder and File collections as these are duplicates.
I am currently developing an application using Sharepoint 2010 Web services to access data from a Sharepoint server. Im using ListData.svc to get items of a particular list of documents saved in the SP server, and my aim is to be able to search through this list, including its documents contents. I have been researching through options, and have seen stuff like asmx, enterprise search API, query services, etc., but I am not quite sure if this would really crawl through the file contents.
Can you enlighten me on what web service to use to be able to search through a particular list of files-- all its properties and file contents? Similar to the search option in an actual Sharepoint site?
Thanks!
Id expect a quick google on "Sharepoint 2010 search api" to yield up https://msdn.microsoft.com/en-us/library/office/websvcspsearch(v=office.14).aspx which says "Search in Microsoft SharePoint Foundation 2010 exposes its search functionalities through the Query Web service. This allows you to access SharePoint Foundation Search results from client applications and Web applications outside of the context of a SharePoint site."
I guess if you read those docs, the solution will be in there.
We have an Enterprise application written in C# that we well to customers. The server runs in our data center and the customers connect via a windows application also written in C#. Pretty standard.
Management would like a dashboard added to our application. I was told to look into using sharepoint to somehow add a sharepoint dashboard to the main screen of our client application (winforms).
Is this possible? The client application would have to somehow show a web page from the sharepoint server which I guess is no problem using a html componenent. But I'm more worried about getting sharepoint to work with our existing data (sql server 2008).
I suggested just writing the dashboard ourselves and avoiding sharepoint. But management would like to add more 'Business Intelligence' to our application. I know that is the way of the future but I'm worried about the complexity of integration with sharepoint.
There are various options for integrating SharePoint into a windows forms application. The simplest is embedding a web browser control and point it to the page with the dashboard set up.
Alternatively you could use the SharePoint client object model (2)(make calls to the SharePoint server) and retrieve data (and potentially pages) from SharePoint to put into your dashboard.
I would recommend to management that we can display SharePoint through our current application, and we can demonstrate with a simple dashboard part (eg chart control) to demonstrate how we can make the dashboard integrate more naturally over time piece by piece. This would minimise risk by displaying from SharePoint, while being able to show the potential advantages of using the SharePoint data and creating a customised windows forms dashboard.
SharePoint does a good job of going either way with information via BCS, assuming you would want to show LOB data in a SharePoint deployment.
However, since you want to go the other way, the Client Object Model works well with this. Seeing as how it is a .NET application, I can site specific times where we have used the built in REST services to get information from lists in our enterprise SharePoint deployments.
Security will need to be addressed as well, so don't forget about that. If you have AD groups already set up for your enterprise application, you can most likely reuse some of those in SharePoint. If you don't, you will have to now manage how data will be secured. You may also end up getting prompted for a log in to SP which is never a good user experience.
Good luck!
I'd like to fetch some files from a SharePoint site, however I do not want to use the web services as a) I want to be compatible with both 2007 and 2010 and b) I'm not sure if Web Services can give me all files on a site.
SharePoint Designer can do that, and it seems to use FrontPage Server Extensions using _vti_bin/Author.dll. Also, I can access it in Windows using Map Network Drive -> Map Web Site, which I think is using WebDAV.
Is there any C# implementation of either a WebDAV Client or a Author.dll Client?
You could change this code to download. http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html. Just search around for different upload code and mess with it. I would give you my code for uploading files but I am on vacation and I promised myself that I would not log into work :). That link should get you pointed in the right direction.
I have just completed my first aspx/c# project using Visual Web Developer Express and consuming some custom controls and external web services. It runs fine on my development machine.
If I now want to test this on a shared hosting account, do I just upload all the files with the current project structure? Will there be any problem uploading the DLLs to a shared Windows hosting account? Anything I should be aware of or changes to be made to the code? Can anyone recommend a cheap and good provider (this is just for testing - no mssql required yet).
Thanks!
Does visual web developer have a "publish website" menu item under the Build menu?
If you want to pre-compile your site and publish it with all dependencies the easiest way I've found. You can then choose to publish it to either an FTP site or the file system. I usually choose the filesystem and then FTP it up myself to make sure I don't overwrite any config files.
If I'm working on a low volume site for a client and performance isn't a problem, I'll just upload my working directory right up to the server so I don't have to deliver the source code separately and I know they won't loose it.
Oh, and one other thing, if you don't configure it special, I would expect you will have to upload your site to the root directory of your hosting account. GoDaddy does have the ability to specify certain directorys as their own ASP.NET application. If you do that you can put your app in a sub-dir of your choosing.
-Al
It would depend on your website provider. You need to get one that supports the .NET runtime. Once you have that, then you simply upload your code and all should work. I personally use www.godaddy.com. You can see an example ASP.NET site hosted by them at www.chessbin.com.
I hope this helps.
Adam
The hosting companies may vary on what they require, but I would think a simple xcopy deploy would be sufficient for most. Here's a link to one that seems to have good prices (disclaimer: I have never used them)
http://www.reliablesite.net/v3/index.asp