Monday, February 9, 2015

Basic operations with the SharePoint .NET client object model

When you create an App for SharePoint 2013 project in Visual Studio 2012, references to the .NET Framework assemblies,Microsoft.SharePoint.Client.Runtime.dll and Microsoft.SharePoint.Client.dll, are automatically added to the project.

The files are located on any SharePoint 2013 server at %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\15\ISAPI.

SharePoint client APIs

You can use the SharePoint client object model (CSOM) to retrieve, update, and manage data in SharePoint 2013. SharePoint 2013 makes the CSOM available in several forms.
  • .NET Framework redistributable assemblies
  • JavaScript library
  • REST/OData endpoints
  • Windows Phone assemblies
  • Silverlight redistributable assemblies

JavaScript provides 8 mathematical constants that can be accessed with the Math object

Math.E;         // returns Euler's numberMath.PI         // returns PIMath.SQRT2      // returns the square root of 2Math.SQRT1_2    // returns the square root of 1/2Math.LN2        // returns the natural logarithm of 2Math.LN10       // returns the natural logarithm of 10Math.LOG2E      // returns base 2 logarithm of EMath.LOG10E     // returns base 10 logarithm of E

Javascript Math object is to create a random number

Math.random();  

Thursday, February 5, 2015

asp.net serialized object in json

   //Group  data
                var lstGroupedPMs = (from lstPMItem in lstPMItemsDetails
                                     group lstPMItem by lstPMItem.KRAType
                                         into KRAMasterGroups
                                         select new
                                         {
                                             KRAType = KRAMasterGroups.Key,
                                             kraGroup = KRAMasterGroups,
                                             templateName = performancetemplatedata.TemplateName,
                                             positionID = performancetemplatedata.PositionID,
                                             designation = performancetemplatedata.Designation
                                         });


                json = JsonConvert.SerializeObject(lstGroupedPMs, Newtonsoft.Json.Formatting.Indented);
                jObject = JObject.Parse("{\"data\": " + json + "}");

asp.net get list of items from listitemcollection

List<CustomEntities.KRAMasterDetails> lstPMItemsDetails =
                    (from oKRAMasterItem in oPMItems.AsEnumerable()
                     select new CustomEntities.KRAMasterDetails
                     {
                         KRAName = null == oKRAMasterItem[Constant.KRAMaster.KRAName.ToString()] ? string.Empty :
                         oKRAMasterItem[Constant.KRAMaster.KRAName.ToString()].ToString(),

                         //added by shekhar 4/2/2015
                         KRADescription = null == oKRAMasterItem[Constant.KRAMaster.KRADescription.ToString()] ? string.Empty :
                         oKRAMasterItem[Constant.KRAMaster.KRADescription.ToString()].ToString(),

                         KRAMeasuringCriteria = null == oKRAMasterItem[Constant.KRAMaster.KRAMeasuringCriteria.ToString()] ? string.Empty :
                         oKRAMasterItem[Constant.KRAMaster.KRAMeasuringCriteria.ToString()].ToString(),
                         //End of added by shekhar 4/2/2015

                         KRAType = null == oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] ? string.Empty :
                         (oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] as FieldLookupValue).LookupValue,

                         KRASubType = null == oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] ? string.Empty :
                         (oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] as FieldLookupValue).LookupValue,

                         //Updated by shekhar/vikas 3/2/2015
                         KRATypeID = null == oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] ? 0 :
                         (oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] as FieldLookupValue).LookupId,

                         KRASubTypeID = null == oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] ? 0 :
                         (oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] as FieldLookupValue).LookupId


                     }).ToList();

asp.net get item from listitemcollection

 performancetemplatedata.TemplateName = (oPMDataItems[0][Constant.PerformanceTemplateData.TemplateName.ToString()]).ToString();
                performancetemplatedata.Designation = (oPMDataItems[0][Constant.PerformanceTemplateData.PositionID.ToString()] as FieldLookupValue).LookupValue;
                performancetemplatedata.PositionID = (oPMDataItems[0][Constant.PerformanceTemplateData.PositionID.ToString()] as FieldLookupValue).LookupId;