Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
2
Erster Beitrag:
vor 1 Jahr, 1 Monat
Letzter Beitrag:
vor 1 Jahr, 1 Monat
Beteiligte Autoren:
Peter Holemans

[WD2x] DotNet - Use Sharepoint Client Object Model to integrate

Startbeitrag von Peter Holemans am 05.10.2016 14:19

Hi,

I'm working on a SharePoint 2013 integration of some functionality. What can be done in couple of lines of code in VS seems pretty hard in WX.

  • Looked at using SOAP web services which works fine out of the box but lacks the possibility to use 'InnerXML' style SOAP variable assignments without having the WX runtime break the the SOAP XML being sent.
  • Looked at SharePoint REST API's but that seems even more complex with V20 or V21 than the SOAP stuff
  • Finally looking at the Sharepoint Client Object Model which allows to integrate with SharePoint form a client based model by using two DotNet assemblies: Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime


Next I have a very basic simple piece of CS code that gets all the items from a SharePoint list and I'm trying to get it to translate it to WX code but I'm getting compile errors all of the time...

CS Source:

// Starting with ClientContext, the constructor requires a URL to the
// server running SharePoint.
ClientContext context = new ClientContext("http://SiteUrl";);

// Assume the web has a list named "Announcements".
List announcementsList = context.Web.Lists.GetByTitle("Announcements");

// This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll"
// so that it grabs all list items, regardless of the folder they are in.
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
ListItemCollection items = announcementsList.GetItems(query);

// Retrieve all items in the ListItemCollection from List.GetItems(Query).
context.Load(items);
context.ExecuteQuery();
foreach (ListItem listItem in items)
{
// We have all the list item data. For example, Title.
label1.Text = label1.Text + ", " + listItem["Title"];
}


WX Translation trial (with login which is required and works):

SPLogin is System.Net.NetworkCredential
SPLogin.UserName = "domain\username" //Domain credentials
SPLogin.Password = "password"

SPContext is Microsoft.SharePoint.Client.ClientContext("https://test.company.com/sites/ap/";)
SPContext.Credentials = SPLogin

SPList is Microsoft.SharePoint.Client.List dynamic
SPList = SPContext.web.lists.GetByTitle("AP")

SPListItems is Microsoft.SharePoint.Client.listItemCollection dynamic
SPListItems = SPList.GetItems()

SPCamlQuery is Microsoft.SharePoint.Client.CamlQuery dynamic
//CAN'T GET THE BELOW TO WORK
SPCamlQuery = Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery(100)
//-> Error:The identifier 'Microsoft' is unknown or inaccessible.

SPContext.Load(SPListItems,Null)
SPContext.ExecuteQuery()

SPListItems is Microsoft.SharePoint.Client.listItemCollection dynamic
SPListItems = SPList.GetItems(SPCamlQuery)

//CAN'T GET THE BELOW TO WORK
SPContext.Load(SPListItems)
//-> Error:No syntax of Load is compatible.

SPContext.ExecuteQuery()

//NEXT: How should I do the for each loop like in the CS example?


Any help/hints of DotNet gurus more than appreciated...

Cheers,

Peter Holemans

Antworten:

Nobody?

TIA,

Peter

von Peter Holemans - am 07.10.2016 07:06
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.