Skip to main content

Posts

Showing posts from February, 2017

Update multi valued properties in SharePoint User Profile withSharePoint Object Model (SSOM)

I have a wrote post on updating SharePoint user profile with SharePoint Server Object model (SSOM) which is as below and this sample of code ellaborates on how you can update user profile properties of multi-valued.

Update below link with the latest 

https://kushanlahiru.wordpress.com/2017/02/11/update-all-user-profile-properties-in-sharepoint-server-side-object-model-ssom

Update multi valued property

<preclass="brush: csharp">

//Higher permissions requires anyway to access secure data! So elevate

SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPServiceContext serviceContext = SPServiceContext.GetContext(site);
UserProfileManager userProfileMgr = new UserProfileManager(serviceContext);
ProfilePropertyManager profilePropMgr = new UserProfileConfigManager(serviceContext).ProfilePropertyManager;

// Retrieve all properties for the "UserProfile" profile subtype,
// and retrieve the property values for a specific user to udpate
ProfileSubtypePropertyManager subtype…

Update all user profile properties in SharePoint Server side ObjectModel SSOM

using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using System;
using System.Data;

namespace SSOM_UserProfileUpdate
{
class Program
{
// Central Admin URL
static string siteUrl = "http://win2012:1412/";
static void Main(string[] args)
{

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteUrl))
{
try
{
SPServiceContext serviceContext = SPServiceContext.GetContext(site);
UserProfileManager userProfileMgr = new UserProfileManager(serviceContext);
ProfilePropertyManager profilePropMgr = new UserProfileConfigManager(serviceContext).ProfilePropertyManager;

Console.WriteLine("Start Working on update user profile poperties . . . ");
Console.WriteLine("");

#region Build profiles to update to Datatable
// This could be implemented with a CSV reading, reading Excel or any method you prefer
// Since Account name is act like primary key, it should the query key for the updates
DataTable dataTable = new DataTable…

SharePoint Framework (SPFx) Essentials

Yep this is in RC (Release Candidate)

Full Guide on SPFx

Microsoft SharePoint team will be discontinue the updates on msdn.com (i.e. Microsoft Developer Network) and will be move to office.com and techcommunity.microsoft.com for forums.

https://dev.office.com/sharepoint

SPFx Reference

https://dev.office.com/sharepoint/reference/spfx/sp-webpart-base-module

SPFx Samples

https://dev.office.com/patterns-and-practices-resources#?filters=sharepoint%20framework%20app

IoT Sample with NodeRed functions and HTTP request handlers

Scenario :

"/time" GET request returns server time in JSON format(Format: {"time" : "hh:mm"}).




"/random" GET request returns generated random number in JSON format(Format: {"random" : number}).




"/page" GET request returns last request date & time, generated last number in HTML format. Output values as below;


when the last time was requested
when the last random number was requested
the value of the last random number generated


Twist:


Work with HTTP requests and responses
Generate random numbers and work with those
Switch responses based on logic


Mustache view templating





Code as below:





[{"id":"ad8758cf.4b2dc8","type":"tab","label":"Flow 1"},{"id":"2b2cf6bf.d6f44a","type":"template","z":"ad8758cf.4b2dc8","name":"ContainsHistory","field":"payload","fieldType":"msg&…

NodeRED flow to generate a random number and logic based on that

Scenario


NodeRED flow to generate a random number between 0 and 10
Number generation start without user interaction and generated every 10 seconds
Generate condition for log to debug based on generated value
Message should be "Number <the generated random number> is a <Number status> number"
Logic : if number is less than 5 then <the generated random number> = "low" else it should be "high"






Sample code

[{"id":"ad8758cf.4b2dc8","type":"tab","label":"Flow 1"},{"id":"9cde778f.2b6da8","type":"inject","z":"ad8758cf.4b2dc8","name":"Inject","topic":"Random","payload":"","payloadType":"str","repeat":"5","crontab":"","once":true,"x":130,"y":60,"wires":[["6957bb9c.750024&q…

Communicate with cloud services from IoT device

Scenario:


Send sensor temperature to cloud through a gateway
If measured temperature is higher than 29ÂșC then switch warning light that is maroon lights switch on LED
If less than that, switch green LEDs
If no commands received from the cloud switch black LEDs
Show sensor temperature with silver color;
Number of tens in tens area i.e. if its 10 => 1 LED, if its 25 => 2 LEDs
First digit of the reading in units area i.e. 25 => 5 LEDs, 31 => 1 LED





Notes:


SenseHat has been used a sensor for temperature
RaspberryPI has been used as the gateway for the sensor
Bluemix is used for the back end cloud


Application architecture


Solution: Gateway workflow








Solution: Cloud flow








Node red export


Communicate with cloud services from IoT device-Gateway flow



Note: Copy below code in to import section in the NodeRed


[{"id":"f0c435a1.0388b8","type":"exec","z":"d94f3e5f.38adf","command":"vcgencmd","addpay":true,"ap…

Installation of Bot Framework (Preview) SDK to Visual Studio as a Template