ĐÀO TẠO DOANH NGHIỆP : SỞ KHOA HỌC CÔNG NGHỆ TỈNH ĐỒNG NAI

ENTERPRISE TRAINING: DONG NAI DEPARTMENT OF SCIENCE AND TECHNOLOGY.

HÌNH ẢNH TẬP HUẤN LỚP SHAREPOINT WORKFLOW VÀ KIẾN TRÚC SHAREPOINT

PHOTOS OF SHAREPOINT WORKFLOW AND ARCHITECTURE CLASS.

HÌNH ẢNH TẬP HUẤN LỚP SHAREPOINT WORKFLOW VÀ KIẾN TRÚC SHAREPOINT

PHOTOS OF SHAREPOINT WORKFLOW AND ARCHITECTURE CLASS.

Sunday, October 30, 2016

PowerShell script for adding multiple WSP solutions

$names = get-childitem C:\WSP
foreach ($solution in $names) {Add-SPSolution -LiteralPath ("C:\WSP\" + $solution.Name) }

Wednesday, October 5, 2016

Create, Update, Delete a List Item Using COM

Using C# console


Add reference to dll: Microsoft.SharePoint, Microsoft.SharePoint.Client, Microsoft.SharePoint.Client.Runtime

For Create action:


using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasicOperationUsingCSOM
{
    class Program
    {
        static void Main(string[] args)
        {
            string siteUrl = "http://web";
            ClientContext clientContext = new ClientContext(siteUrl);
            List oList = clientContext.Web.Lists.GetByTitle("MyCustomList");
            ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
            ListItem oListItem = oList.AddItem(itemCreateInfo);
            oListItem["Title"] = "My New Item!";
            oListItem["Description"] = "Hello World!";
            oListItem.Update();
            clientContext.ExecuteQuery();
        }
    }
}

For Update:

using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasicOperationUsingCSOM
{
    class Program
    {
        static void Main(string[] args)
        {
            string siteUrl = "http://web";
            ClientContext clientContext = new ClientContext(siteUrl);
            List oList = clientContext.Web.Lists.GetByTitle("MyCustomList");
            ListItem oListItem = oList.GetItemById(1);
            oListItem["Title"] = "Hello World Updated!!!";
            oListItem["Description"] = "Hello World Updated!!!";
            oListItem.Update();
            clientContext.ExecuteQuery();
        }
    }
}


For Delete:

using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasicOperationUsingCSOM
{
    class Program
    {
        static void Main(string[] args)
        {
            string siteUrl = "http://web";
            ClientContext clientContext = new ClientContext(siteUrl);
            List oList = clientContext.Web.Lists.GetByTitle("MyCustomList");
            ListItem oListItem = oList.GetItemById(1);
            oListItem.DeleteObject();
            clientContext.ExecuteQuery();
        }
    }
}


Monday, September 26, 2016

Using PowerShell to find site/subsite/list/library size in SharePoint


Size of Site collection and all subsites


#Get Size of all Sub-sites in a Site Collection
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

# Function to calculate folder size
Function CalculateFolderSize($Folder)
{
    [long]$FolderSize = 0
 
    foreach ($File in $Folder.Files)
    {
   #Get File Size
        $FolderSize += $file.TotalLength;
   
  #Get the Versions Size
        foreach ($FileVersion in $File.Versions)
        {
            $FolderSize += $FileVersion.Size
        }   
    }
 #Iterate through all subfolders
    foreach ($SubFolder in $Folder.SubFolders)
    {
  #Call the function recursively
        $FolderSize += CalculateFolderSize $SubFolder
    }
    return $FolderSize
}

 
$SiteURL = "http://yoursite"
$Site = new-object Microsoft.SharePoint.SPSite($SiteURL)
  #Array to Hold Result - PSObjects
  $ListItemCollection = @()
 
  foreach($Web in $Site.AllWebs)
  {
    $ExportItem = New-Object PSObject
    #Call function to calculate Folder Size
    [long]$WebSize = CalculateFolderSize($Web.RootFolder)
   
    #Get Recycle Bin Size
    foreach($RecycleBinItem in $Web.RecycleBin)
        {
           $WebSize += $RecycleBinItem.Size
        }
        $Size = [Math]::Round(($WebSize/1024)/1024, 2)
        Write-Host  $web.Url ":`t" $Size "MB"
        $ExportItem | Add-Member -MemberType NoteProperty -name "Web URL" -value $web.Url
        $ExportItem | Add-Member -MemberType NoteProperty -name "Web Size" -value $Size
        $ListItemCollection += $ExportItem
    #Dispose the object
    $web.dispose()
   }
  
   $ListItemCollection | Export-CSV C:\allsubsitesof.csv -NoTypeInformation

Size of Lists and Libraries include version

#Set variables
$siteURL = "http://yoursite"
$site = new-object Microsoft.SharePoint.SPSite($siteURL)

$ListItemCollection = @()
foreach ($web in $site.AllWebs)
{
  foreach ($list in $web.Lists)
   {
   $ExportItem = New-Object PSObject
           $listSize = 0
           foreach ($item in $list.items)
            {
            $listSize += ($item.file).length
            foreach($FileVersion in $item.File.Versions) 
                {
                   $listSize += $FileVersion.Size
                }               
            }
            $Size = [Math]::Round(($listSize/1024)/1024, 2)
            Write-Host  $web.Title ":`t" $list.Title ":`t" $listSize   
            $ExportItem | Add-Member -MemberType NoteProperty -name "WebTitle" -value $web.Title
            $ExportItem | Add-Member -MemberType NoteProperty -name "WebURL" -value $web.URL
            $ExportItem | Add-Member -MemberType NoteProperty -name "WebDescription" -value $web.Description
            $ExportItem | Add-Member -MemberType NoteProperty -name "List_Library_Name" -value $list.Title
            $ExportItem | Add-Member -MemberType NoteProperty -name "Size (MB)" -value $Size
        $ListItemCollection += $ExportItem
    }
   
}
$ListItemCollection | Export-CSV C:\sizeoflistsandlibrary.csv -NoTypeInformation
$Site.Dispose()

Tuesday, March 8, 2016

SharePoint 2010 get list items using list.asmx service using Jquery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script src="/Style%20Library/DownloadDocuments/jquery.SPServices-2014.02.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function popupCenter(title, w, h, url) {
            var url = "/SitePages/Download.aspx?ID=" + url;
            var left = (screen.width / 2) - (w / 2);
            var top = (screen.height / 2) - (h / 2);
            var win = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
            win = null;
            return false;
        }


        function GetSoapQuery() {
            var soapEnv =
                "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>ListOfDownloadDocument</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='ID' />\
                               <FieldRef Name='Title' />\
                               <FieldRef Name='LinkToDocument' />\
                               <FieldRef Name='IsShow' />\
                               <FieldRef Name='DisplayOrder' />\
                           </ViewFields> \
                        </viewFields> \
                        <query> \
                         <Query> \
                           <Where> \
                              <Eq> \
                                 <FieldRef Name='IsShow' /> \
                                 <Value Type='Integer'>1</Value> \
                              </Eq> \
                           </Where> \
                           <OrderBy> \
                               <FieldRef Name='DisplayOrder' Ascending='true'/> \
                           </OrderBy> \
                </Query> \
             </query> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";
            return soapEnv;
        }

        $(document).ready(function () {
            var soapEnv = GetSoapQuery();
            $.ajax({
                url: "http://ServerName/_vti_bin/lists.asmx",
                type: "POST",
                dataType: "xml",
                data: soapEnv,
                complete: processResult1,
                contentType: "text/xml; charset=\"utf-8\""
            });
        });


        function processResult1(xData, status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function () {
                var id = $(this).attr("ows_ID");
                /*alert("ID:" + id);*/
                var title = $(this).attr("ows_Title");
                /*alert("Title:" +title);*/
                var linkToDocument = $(this).attr("ows_LinkToDocument");
                var hyperLink = linkToDocument.split(',')[1];
                /*alert("hyperLink:" +hyperLink);*/

                /*$("#download").append('<li><p><a href="javascript:void(0);" onclick="popupCenter(&#39;myPop1&#39;,450,200,&#39;' + hyperLink + '&#39;);">' + title + '</a></p></li>');*/
                $("#download").append('<li><p><a href="javascript:void(0);" onclick="popupCenter(&#39;myPop1&#39;,450,200,' + id + ');">' + title + '</a></p></li>');
            });
        }   
 
    </script>
   
   
    <h1>List of download document</h1>
        <ul id="download">
        </ul>
    </div>