2016-07-24

SharePoint CSOM

After I realised it was a not a very good idea to host my C# program at our SharePoint service provider, I googled around for options, I had only seen the Server Side Object Model, which require you develop your code on the SP server, or you install SP on your developer machine and you deploy your fully trusted code on the SP server. From an application developer's viewpoint the SSOM concept is horrible, and should only be used if there is no other viable alternatives. Actually it’s a horrible concept plain and simple and should be avoided.  I googled for options and almost immediately came across this MSDN video.
 

I also found discussions on other options JSOM (JavaScript) and REST interface. (And how to use Powershell scripts in visual studio utilizing the CSOM library.)  
With lots of help from a consultant I created my C# program using the CSOM model in visual studio on my PC with remote connection to SharePoint only. It was pretty straightforward, there are peculiarities with SP I do not like but it might be to my lack of SP experience. E.g. the custom lists are crap as a database, the CSOM calls are very very slow (I find them so in our environment), but for very small amounts of simple data SP is alright.
There is no truncate function for SP lists, if you want to empty a list you have to delete all the rows one by one and this is excruciatingly slow. The data I import to SP in my C# program is split into 4 lists, for a complete refresh I had to do this slow delete process one list after another. But after some googling I found the Parallel.ForEach capabilities in C#  which made it possible to delete rows for all lists in parallel effectively cutting the delete time down to just one fourth.
Here is the main section of my program with the Parallel.ForEach in the red square.

Next SP development project will probably be more visual including JavaScript, it will be similar to this application but in SP.
I am no longer a developer and haven’t worked as one for the last +15 years, but I believe if you do not know software development you cannot do a good job as an information or application IT architect. And if you do not regularly practice programming you do not understand software development well enough. But more important after some time with no development work I become a
 
yoshii-blog.blogspot.com

No comments:

Post a Comment