Hi,
Played with sharepoint today - scanned the codebank for help - didnt find much so thought would post my attempt..
All its functionalilty is web enabled via webservices. Just a demo of creating a custom list within sharepoint then pulling the data into you app.
assume you have a sppsv2 site at the follwoing address - http://dmn.teamsites.company.com/sites/mysitename/
Go into the "documents and lists" area, create a custom list (eg "team members", add a few columns and create a few entries. - I assume here that the first column is called "Title" (sharepoint defaults the first col to this name)
ok so far.
now we want to pull this into our app.
kick open vs.net and create a console app. (i assume your ok with console apps and xml) - the first sharepoint specific thing we will want to do is add a web-reference via the project menu.
this will ask for a url, specify you sites url but append /_vti_bin/Lists.asmx to the end - eg "http://dmn.teamsites.company.com/sites/mysitename/_vti_bin/Lists.asmx"
when vs has finished click the add-reference button
now, in you class put in the following code
ensure any "dmn.teamsites.company.com/sites/mysitename" are changed to your site url/sitename and also the the list ("Team Members" in my case) is updated to your list name.Code:using System; using System.Xml; using System.Web.Services; using System.Data; /// using System.Windows.Forms; namespace ConsoleApplication1 { /// <summary> /// Summary description for Class1. /// </summary> class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { try { /// message as we are starting... System.Console.WriteLine("-Start-"); System.Console.WriteLine(" "); /// web reference built from url - http://dmn.teamsites.company.com/sites/mysitename/_vti_bin/Lists.asmx /// get this from the solution explorer - in the web references /// set up the webservice lists object com.company.teamsites.dmn.Lists listService = new com.company.teamsites.dmn.Lists(); /// use my current logon from the credetial chase listService.Credentials = System.Net.CredentialCache.DefaultCredentials; /// setup the xml doc fields XmlDocument doc = new XmlDocument(); XmlNode Query = doc.CreateNode(XmlNodeType.Element,"Query",""); XmlNode ViewFields = doc.CreateNode(XmlNodeType.Element,"ViewFields", ""); XmlNode QueryOptions = doc.CreateNode(XmlNodeType.Element,"QueryOptions",""); /// call the webservice System.Xml.XmlNode nodeDataback = listService.GetListItems("Team Members", null, Query, ViewFields, null, QueryOptions); /// copy the xml structure to a dataset DataSet objDataSet = new DataSet(); XmlNodeReader ObjXmlreadrer = new XmlNodeReader(nodeDataback); objDataSet.ReadXml(ObjXmlreadrer); /// dump out the returned fields from the dataset System.Console.WriteLine("-Columns-"); System.Console.WriteLine(" "); foreach(DataColumn col in objDataSet.Tables[1].Columns) { System.Console.WriteLine("col = " + col.ColumnName.ToString()); } System.Console.WriteLine(" "); /// dump out the title (name) System.Console.WriteLine(" "); System.Console.WriteLine("-Data- 'ows_Title' -"); foreach(DataRow row in objDataSet.Tables[1].Rows) { System.Console.WriteLine(row["ows_Title"].ToString()); } /// that it - done System.Console.WriteLine(" "); System.Console.WriteLine("-done-"); } catch(Exception errorObject) { /// on error - dump it out with an alert /// MessageBox.Show(errorObject.ToString()); System.Console.WriteLine(errorObject.ToString()); } } } }
compile and run from an open cmd-prompt - eg
job done....Code:C:\Visual Studio Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug>consoleapplication1.exe -Start- -Columns- col = ows_ID col = ows_Title col = ows_Modified col = ows_Created col = ows_Author col = ows_Editor col = ows_owshiddenversion col = ows_Attachments col = ows__ModerationStatus col = ows_LinkTitleNoMenu col = ows_LinkTitle col = ows_SelectTitle col = ows_Order col = ows_GUID col = ows_Nationality col = data_Id -Data- 'ows_Title' - joe bloggs arch stanton alistair crowley ivor cutler -done- C:\Visual Studio Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug>
now download the sdk's and play with the query and viewfields nodes to change which records/what cols are returned etc...
http://msdn.microsoft.com/library/de...SV01017094.asp
have a play, its quite easy...
cheers AJP.


Reply With Quote