About Me

My photo
a Dynamic and Energetic guy.....

Tuesday, January 31, 2017

Retrieving SPList Data From SharePoint Online Site using CSOM

using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SPOnlineDataAccess
{
    public partial class Form1 : System.Windows.Forms.Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void LoadDefaultValues()
        {
            txtSiteUrl.Text = "https://abc.sharepoint.com/sites/testsite";
            txtListName.Text = "OnlineList";
            txtUserEmail.Text = "user1@xyz.com";
            txtPassword.Text = "pass@123qaz";
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            DataTable dtResults = ReadSPList();
            dataGridView1.DataSource = dtResults;
        }


        private DataTable ReadSPList()
        {
            using (ClientContext clientContext = GetContextObject())
            {
                try
                {
                    DataTable dtListData = new DataTable();
                    //Creating DataTable Columns
                    dtListData.Columns.Add("Title", typeof(String));
                    dtListData.Columns.Add("Designation", typeof(String));
                    dtListData.Columns.Add("EmpID", typeof(String));

                    //Getting Data From SharePoint
                    Web web = clientContext.Web;
                    clientContext.Load(web, website => website.ServerRelativeUrl);
                    clientContext.ExecuteQuery();                  

                    //Read SPList called "OnlineList"
                    List myList = web.Lists.GetByTitle(txtListName.Text);

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

                    // Retrieve all items in the ListItemCollection from List.GetItems(Query).
                    clientContext.Load(items);
                    clientContext.ExecuteQuery();

                    for (int count = 0; count < items.Count; count++)
                    {
                        DataRow dr = dtListData.NewRow();
                        dr["Title"] = items[count]["Title"].ToString();
                        dr["Designation"] = items[count]["Designation"].ToString();
                        dr["EmpID"] = items[count]["EmpID"].ToString();

                        dtListData.Rows.Add(dr);
                    }
                    return dtListData;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return null;
                }
            }
        }

        private ClientContext GetContextObject()
        {
            string siteUrl = txtSiteUrl.Text;
            string userName = txtUserEmail.Text;
            string password = txtPassword.Text;
            SecureString _password = GetPasswordFromInput(password);

            ClientContext context = new ClientContext(siteUrl);
            context.Credentials = new SharePointOnlineCredentials(userName, _password);
            return context;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LoadDefaultValues();
        }

        private SecureString GetPasswordFromInput(string password)
        {
            //Get the user's password as a SecureString
            SecureString securePassword = new SecureString();
            char[] arrPassword = password.ToCharArray();
            foreach (char c in arrPassword)
            {
                securePassword.AppendChar(c);
            }

            return securePassword;
        }

    }
}


Wednesday, December 7, 2016

SharePoint Workflow Vs Microsoft Flow

Workflow
Microsoft Flow


Enterprise focused solutions
Focused on individual
Automation of business processes
Automate workflows connects with SaaS (Software As A Service)
Works within SharePoint framework
Integrate with business APPs
Can integrate with Visual Studio
Automated ACTIONS based on EVENTS
Permission based on list
Actions are intended to automate the personal processes of end users (Permission)
Workflows starts with an event within SharePoint
Flows are triggered by web hooks into external systems
Possible to debug / attach with processes
Flow can take data from External systems to SharePoint

Automate digital life while accessing data from social feed

Can use defined templates, expect new templates in future
Editable using SharePoint Designer
Browser based

Development / Administration knowledge is not necessary


Monday, October 17, 2016

Move SharePoint 2013 Search Index Location to a other location

When we setup SharePoint Search Service Application using Central Administration, there is no place to set INDEX LOCATION.

With the usage of CRAWLING, the location will be filled with INDEXED files.

If we want to change the location of INDEX folder, we have only 1 options. That is using POWERSHELL.

1) We have to create a new INDEX LOCATION

$IndexLocation = "H:\New_SearchIndex"
New-Item –ItemType Directory –Path $IndexLocation

2) Then we have to get current Search Service Application to a variable

$SearchServiceName = "SearchSer"
$SSA = Get-SPServiceApplication -Name $SearchServiceName; 

3) Then we get the current Search Service Instance to a variable

$Server = "SPDEV1APP"
$Instance = Get-SPEnterpriseSearchServiceInstance -Identity $Server;

4) Then we have to get current serach topology

$Current = Get-SPEnterpriseSearchTopology -SearchApplication $SSA -Active; 

we can current topology using Central Administration. Here we should have all the components in GREEN status.

5) Create a CLONE of current Search Topology

$Clone = New-SPEnterpriseSearchTopology -Clone -SearchApplication $SSA -SearchTopology $Current 

6) Now we SET new INDEX LOCATION

New-SPEnterpriseSearchIndexComponent -SearchTopology $Clone -IndexPartition 0 -SearchServiceInstance $Instance -RootDirectory $IndexLocation 

7) SET new one as ACTIVE

Set-SPEnterpriseSearchTopology -Identity $Clone

If we Type,
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa 
It will return 7 components including 2 INDEX COMPONENTS


================================================================

8) Then Gets the Search Topology again,

$SSA = Get-SPEnterpriseSearchServiceApplication
$Current = Get-SPEnterpriseSearchTopology -SearchApplication $SSA -Active

9) Creates a copy of the current Search Topolog again,

$Clone=New-SPEnterpriseSearchTopology -Clone -SearchApplication $SSA -SearchTopology $Current

10) Removes the old Index Component from the Search Topology, THIS IS THE MOST CRITICAL

Get-SPEnterpriseSearchComponent -SearchTopology $Clone | ? {($_.GetType().Name -eq "IndexComponent") -and ($_.ServerName -eq $($Instance.Server.Address)) -and ($_.RootDirectory -ne $IndexLocation)} | Remove-SPEnterpriseSearchComponent -SearchTopology $Clone -Confirm:$false

11) Sets our new Search Topology as Active

Set-SPEnterpriseSearchTopology -Identity $Clone

If we Type again,
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa 
It will return only 6 components including only 1 INDEX COMPONENT



It is set to new INDEX LOCATION. Now Do a CRAWL using Central Administration.


Thursday, September 22, 2016

Microsoft Windows Container Concept

With the increase of necessity of so much high end Servers for our deployments, a decade before we found a solution called VIRTULIZATION. Simply it allows admins to run a server on top of another server. With the high usage while having high productivity that concept has aroused so much and today, we all get the experience of Virtualization. While evolving the concept we had to face many challenges especially on hardware limitations, software cost and shortage of expert technical skills.
The architecture of virtualization is totally based on hardware sharing and never incorporated software sharing. In other words, we were unable to use HOST’s software inside a Virtual machine. Also we were unable to share OS files / kernel information with VM.

Traditional Virtualization




To overcome mentioned limitations, Microsoft tried to implement a virtualization concept that goes beyond hardware. The original concept initiated few years back, and Microsoft merged their concept with company named DOCKER and implemented Container Service. It is a features that comes with Windows Server 2016 and already implemented on Microsoft AZURE.
Azure Container Service aka ACS is introduced to create, configure and manage cluster of virtual machines in a configured environment using optimized performances. The container is the application piece which works as a virtual machine.

Containerization (aka OS Virtualization)


** Container runs an operating system, has a file system and can be accessed over a network.
With new concept, the HOST can handle many containers same as virtual machines. But the containers can share resources, OS files with the HOST as the diagram explained. With the sharing capability of Container based virtualization the container can run as LIGHT weight machine which enable efficiency. It will reduce loading time and will increase operation time.


Important Facts

1)      Releasing with Windows server 2016
2)      First we need to create a “CONTAINER HOST” (Windows HOST or a LINUX HOST) before start virtualization
3)      We can create 2 types of Containers
a.      Windows Server Containers (shares a kernel with the container host and all containers running on the host)
b.      Hyper-V Containers (container in a highly optimized virtual machine, valid only on-premise)
4)      Windows Server Container Efficiency is greater than Hyper-V Container, because of OS level virtualization
5)      Windows Server Container Security is lesser than Hyper-V Container, because of resource sharing

1)      Image is a Snapshot of a Container which includes the current status of running virtualized environment.
2)      Sandbox is the storage use to write changes in each container and can be committed to Image if wanted
1)      Container OS Image provides the operating system environment for Container, but this is Immutable.
2)      Container Repository to Keep local data including container specific installed software changes, file level changes and other OS level changes.
3)      Microservices architecture will be integrated with ACS,
a.      Container can have many micro-services (can call as SUB-SYSTEMS)
b.      Efficient and manageable resource allocation
4)      We can enable the feature using command of
 Install-WindowsFeature containers

WOW things

1)      “Docker image” can be created and it can be deployed to all environments (IDENTICAL environment of UAT, PRODUCTION)
2)      “Container Orchestration” is capable of handling,
a.      Tracking / managing containers
b.      Can CLUSTER containers for easy access
c.       Scheduling of maintenance tasks
d.      Constraint based deployments
3)      Docker template is available with visual studio 2015, we can create APPs directly to ACS
4)      Azure Container Service (ACS) is now available with on MARKETPLACE, we can create CONTAINERS on Azure
5)      REST API support to connect with third party tools
Portability among different platforms and environments 


Benefits

1)      With the use of ACS, the OS will be virtualized. Hence the amount of resources will be less and it will be a Financial benefit
2)      All the containers can use single base image and it will make all the environments are identical
3)      Easy to upgrade sever kernel as one unit
4)      Direct integration of Visual Studio with Azure


Friday, August 5, 2016

How to Solve the issue of "SharePoint Search Service is Stopped"


SharePoint Search is a critical Service, which needs to up and running for many things. If the Search is in PAUSED status, then we can't do a crawl.

First We have to verify All the necessary SERVICES are up and running. 
Then we have to make sure the account has permission to run a CRAWL.
Also we have to verify the Alternative Access Mapping is set.
If we cant resolve the issue, then have a look of EVENT VIEWER.

There we can see the "Content Plugin can not be initialized" error message. It makes little interesting and I had a look of SEARCH TOPOLOGY.
Then it shows as "Unable to Retrieve Topology Component". Then we can assume PERMISSION issue somewhere.

Then I have found that the Service called "Windows Service - Search Host Controller Service".
That Account is responsible of working with NODE RUNNER and setting up the SharePoint farm topology. So that account needs LOCAL ADMIN privileges. After I have set the PERMISSION for the account,
The Topology Starts working and fine. It displayed all the COMPONENTS correctly with GREEN color.
Then I was able to see CRAWLING options in front of CONTENT SOURCES.

  


 It makes all other related issues sorted and works fine.

Wednesday, August 3, 2016

Workflow Initiation is Failing on SharePoint Farm and Solution

My SharePoint farm was integrated with Workflow Service and worked fine till a restart.
All of sudden it failed to start new workflows. Then I tried to start a WF manually.
Still It failed.

Then I have opened the "Workflow Manager Powershell" and tried to get the current status of the WF farm. (get-WFfarmStatus)
Surprisingly, the WorkflowServiceFrontEnd service was stopped.
With commands we cant start the WorkflowServiceFrontEnd.

First we have to STOP Backend service using,
net stop WorkflowServiceBackend
Then We have to START the Backend Service using,
net start WorkflowServiceBackend

Now we can check the STATUS again,
Both Services are RUNNING smoothly.
Now we can start Workflows.







My Masters