Thursday 2 February 2017

Demo-javascript - search highlight, next, previous functionality for mobile, web,UIWebView, html - Demo

This is continue from out blogs Part1, this is demo for the Searching text in html DOM using JavaScript,

Sample Text below


Microsoft Certified Professional Developer (MCPD 100%)Praveen
SharePoint Online /Office 365 /SharePoint 2013 / SharePoint 2010
SOM, CSOM ,REST, SPSservices, Praveen Events, Custom timer jobs, custom webparts, OOB webpart, Client object model (JS/C#), Designer, Infopath, BCS and Search, PowerShell ,Deployment , installation configuration, C#, ASP.NET, JavaScript, CSS, HTML,JQuery and Angular JS.
Actively involved and have lead end Praveen to end project life cycle, Requirement understanding, Designing, Effort estimation, project delivery, Sing offs and team management. hands-on, C#, C, HTML, JavaScript, invoice in JAVA, MySql, DBMS. Always interested in new innovative idea and to learn new technologies, as well keeps close interaction about developing new applications in SharePoint

and some more Praveen text
Notifications have always been a key use case for Pebble, and we are excited by this
new feature which is going to change the way you look at notifications. With
actionable  notifications Pebble not only informs you about relevant events, users
can now interact with them and choose Praveen from actions you as an Android developer
attach to them





    



--
Comments & Feedback are welcome, and yeah don't forget to share this make short link.



Wednesday 1 February 2017

javascript - search highlight, next, previous functionality for mobile, web,UIWebView, html - Code

The Searching text in html DOM using JavaScript, like html but its not html as it is in mobile application WebView /UIWebView. well its not too tough. Recently I helped one of my closest friend in her Mobile Application, She wants to give functionality to Search any of text and highlight all texts, as well as give option to navigate next and previous searched string by tapping on tables screen.
She got some code from internet, but that was just to search text that too in reverse / random order (as used recursion). I just help her to fex the issue by adding Nxt, Prv, SetStatusText, SetSequencing etc.

below is thee code here, you can click here to see the Demo.


1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE>
<html>
<script type="text/javascript" >

var totalsearchResultsFoundCount = 0;
var currentCount = -1;
var defaultSelectionColor = "#87CEFA";
var selectedSelectionColor = "#FFDEAD";
var keyNameHighlight = "IdhighlightMe";
var NxtHitCount = -1;

var nxtPrvColor = "red";
var arraySequenceId = 0;
var objSearchItems =  {};

function setStatusText(){
    var sts = document.getElementById("statusText");
    if(totalsearchResultsFoundCount>0)
    sts.innerHTML = (arraySequenceId+1)+ " of "+totalsearchResultsFoundCount;   
    else sts.innerHTML = "";
}

function SetSequencing(){
   
    var x = document.getElementsByClassName(keyNameHighlight);   
    for(var i = 0; i < x.length; i++){  
        for(var seq = 0; seq < objSearchItems.length; seq++){
            if(objSearchItems[seq].id == x[i].id){               
                objSearchItems[seq].ActualSequenceNumber = i;
                console.log(objSearchItems[seq].id + " " + x[i].id + " updated "+ objSearchItems[seq].ActualSequenceNumber);
            }
        }       
    }
}

function GetIdAndHighlight(){
    var span = document.getElementById(keyNameHighlight+"0");
    for(var seq = 0; seq < objSearchItems.length; seq++){
        var span = document.getElementById(objSearchItems[seq].id);
        if(objSearchItems[seq].ActualSequenceNumber == arraySequenceId)
        {
            span.style.backgroundColor = nxtPrvColor;
        }
        else{
            span.style.backgroundColor = defaultSelectionColor;       
        }
    }
    return span;
}

function Prv() {
   
    if(arraySequenceId <= 0){
        arraySequenceId = (totalsearchResultsFoundCount-1);
    }
    else if (arraySequenceId > 0) {
          --arraySequenceId;         
    }
    GetIdAndHighlight();
    setStatusText();
    //scrollView();
}

function Nxt(){   
    if(arraySequenceId < (totalsearchResultsFoundCount-1)){
        ++arraySequenceId ;
    }
    else if(arraySequenceId >= (totalsearchResultsFoundCount-1)){
        arraySequenceId = 0;
    }
    GetIdAndHighlight();setStatusText();
    //scrollView();
}

// helper function, recursively searches in elements and their child nodes
function GetAllOccurencesOfTextForElement(element,keyword) {
    if (element) {
        if (element.nodeType == 3) {        // Text node
            while (true) {
                var value = element.nodeValue;  // Search for keyword in text node
              
                var idx = value.toLowerCase().indexOf(keyword);
                if (idx < 0) break;             // not found, abort
              
                var span = document.createElement("span");
                var text = document.createTextNode(value.substr(idx,keyword.length));
                span.appendChild(text);
                var str1 = keyNameHighlight+totalsearchResultsFoundCount;
                span.setAttribute("class", keyNameHighlight);
                span.setAttribute("id", str1);
                span.style.backgroundColor = defaultSelectionColor;
                span.style.color = "black";
                text = document.createTextNode(value.substr(idx+keyword.length));
                element.deleteData(idx, value.length - idx);
                var next = element.nextSibling;
                element.parentNode.insertBefore(span, next);
                element.parentNode.insertBefore(text, next);
                element = text;
                totalsearchResultsFoundCount++;  // update the counter
               
                objSearchItems.push({id:str1,IsSelected:false,searchResultSerial:totalsearchResultsFoundCount,ActualSequenceNumber:-1});               
                //console.log(objSearchItems);
            }
        } else if (element.nodeType == 1) { // // Element node - Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
            if (element.style.display != "none" && element.nodeName.toLowerCase() != 'select') {
              
                for (var currentElement = element.childNodes.length-1; currentElement >= 0; currentElement--) {
                    GetAllOccurencesOfTextForElement(element.childNodes[currentElement],keyword);
                }
            }
        }
    }
}

function GetAllOccurencesOfText(keyword) {
  
    removeExistingHighlights();
   
    keyword = document.getElementById('txt').value ;
   
    objSearchItems = new Array();
   
    GetAllOccurencesOfTextForElement(document.body, keyword.toLowerCase());
   
    SetSequencing();
   
    GetIdAndHighlight();
   
    setStatusText();
       
}

// helper function, recursively removes the highlights in elements and their childs
function removeExistingHighlightsForElement(element) {
    if (element) {
        if (element.nodeType == 1) {
            if (element.getAttribute("class") == keyNameHighlight) {
                var text = element.removeChild(element.firstChild);
                element.parentNode.insertBefore(text,element);
                element.parentNode.removeChild(element);
                return true;
            } else {
                var normalize = false;
                for (var currentElement = element.childNodes.length-1; currentElement >= 0; currentElement--) {
                    if (removeExistingHighlightsForElement(element.childNodes[currentElement])) {
                        normalize = true;
                    }
                }
                if (normalize) {
                    element.normalize();
                }
            }
        }
    }
    return false;
}

// the main entry point to remove the highlights
function removeExistingHighlights() {
    totalsearchResultsFoundCount = 0;
    currentCount = -1;
    arraySequenceId = 0;
    removeExistingHighlightsForElement(document.body);
}

function scrollView() {
     
}  

</script>
<body>

<article type="article" id="v9s28660" language="eng-EN">
   <title>
      Search - Praveen Text
   </title>
   <text>

         <p class="lvl-01"> 

Microsoft Certified Professional Developer (MCPD 100%)Praveen 
SharePoint Online /Office 365 /SharePoint 2013 / SharePoint 2010
SOM, CSOM ,REST, SPSservices, Praveen Events, Custom timer jobs, custom webparts, OOB webpart, Client object model (JS/C#), Designer, Infopath, BCS and Search, PowerShell ,Deployment , installation configuration, C#, ASP.NET, JavaScript, CSS, HTML,JQuery and Angular JS.
Actively involved and have lead end  Praveen to end project life cycle, Requirement understanding, Designing, Effort estimation, project delivery, Sing offs and team management. hands-on, C#, C, HTML, JavaScript, invoice in JAVA, MySql, DBMS. Always interested in new innovative idea and to learn new technologies, as well keeps close interaction about developing new applications in SharePoint

and some more Praveen text
Notifications have always been a key use case for Pebble, and we are excited by this
 new feature which is going to change the way you look at notifications. With 
actionable Praveen notifications Pebble not only informs you about relevant events, users
 can now interact with them and choose Praveen from actions you as an Android developer 
attach to them


</p>     
   </text>
</article>  
    <input type='text' id='txt' value='Praveen' />
    <br><br>
    <input type=button onclick='GetAllOccurencesOfText();' value='Search'>;
    <input type=button onclick='Prv();' value='P-Prv'>;
    <input type=button onclick='Nxt();' value='P-Nxt'>;
    <span id='statusText'/>
</body>

</html>


--
Comments & Feedback are welcome, and yeah don't forget to share this make short link.

Sunday 4 December 2016

PowerShell - how to Read write csv file


Recently Some one has asked me about Reading and writing text file of csv file using powershell, its pretty simple and streght forward, but I think I should write it down that will help beginners.

Below is the code, let's have overview before jumping in to the code.

First We are loading SharePoint dll, it is require if you are performing any action related to SharePoint, if not, please remove those lines (line number 5 to 18)

Than we are checking if file exist of not,

If file exist we will laod the file using Import-CSV cmdlets

and than itarateusinf forwach loop to read all the rows.
You can read current rows specified columns value like $row."ColumnName"



1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#Created by Praveen to import items in SharePoitn list 
#uploaded 18728 items in minutes 4.5 minutes
#Code is free to use, but don't forget to put Author's name

# Setup the correct modules for SharePoint Manipulation
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
   Add-PsSnapin Microsoft.SharePoint.PowerShell
}
$host.Runspace.ThreadOptions = "ReuseThread"

#Open SharePoint List

 $SPAppList="MyListName"
 $spWeb = Get-SPWeb "http://ServerSiteUrl/sites/ABC"
 $spData = $spWeb.Lists[$SPAppList]
 $InvFile="C:\Data_T9078.csv" 

 # Get Data from Inventory CSV File
 $FileExists = (Test-Path $InvFile -PathType Leaf)
 if ($FileExists) {
    "Loading $InvFile for processing..."
    $tblData = Import-CSV $InvFile
 } else {
    "$InvFile not found - stopping import!"
    exit
 }

 # Loop through Applications add each one to SharePoint

 "Uploading data to SharePoint...."
 $count=1;
 foreach ($row in $tblData)
 {
    "$count) Adding entry for "+$row."ColumName1".ToString()
    $spItem = $spData.AddItem()
    $spItem["Title"] = $row."ColumName1".ToString()
    $spItem["Project"] = $row."Project".ToString()
    $spItem["Category"] = $row."Category".ToString()
    $spItem["Details"] = $row."Details".ToString()
    $spItem.Update()
    ++$count;
 }

 write-host "---------------"
 write-host "Upload Complete"

 $spWeb.Dispose()

CSV file format



You can also Export data to the CSV by refering below line of code.


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
$csvFile = "C:\DataExport_Pra09098.csv" 

#Array to Hold Result - PSObjects
$ListItemCollection = @()
"Starting export...."
$count=1; 

 #Get All List items where task date is before 2014
 $list.Items |  Where-Object { $_["Created"] -le "12/31/2014"} | foreach {
 $ExportItem = New-Object PSObject 
 $ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $_["Title"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Project" -value $_["Project"]
 $ExportItem | Add-Member -MemberType NoteProperty -Name "Category" -value $_["Category"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Author" -value $_["Author"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Editor" -value $_["Editor"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Created" -value $_["Created"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Modified" -value $_["Modified"]
 $ListItemCollection += $ExportItem
 write-host "$count) Getting Item ID "$_["ID"] ;++$count;
 } 
 #Export the result Array to CSV file
 $ListItemCollection | Export-CSV $csvFile -NoTypeInformation                       


--
Comments & Feedback are welcome, and yeah don't forget to share this make short link.
Praveen

Tuesday 15 November 2016

SharePoint Interview Questions and Answers


SharePoint interview question and answers Part 1

1. What all are new OOB Webparts/Apps

o   SharePoint 2013 Minimal Download Strategy
o   Promoted Links App
o   Design Manager
o   Remote event receivers
o   Cross-site publishing
o   SharePoint 2013 Service Application Databases
o   Timeline web part
o   FAST Query Language (FQL) features that are deprecated
o   OAuth in SharePoint 2013
o   PDF file support
o   Shredded Storage
o   Image Renditions
o   New master pages
o   Mobile Apps
o   Audio and Video Content Type
o   TilesViewWebPart

2. SharePoint 2013 come with some new delegate controls 
  1. SuiteBarBrandingDelegate delegate Control
  2. SuiteLinksDelegate delegate Control
  3. PromotedActions Delegate Control etc.
3.  News Feeds, Tags, Follow etc. and what are the social feature you have worked?

4.  What is Design Manager, SharePoint Designer and InfoPath Designer? 

5.  What is OData and OAuth

o   OAuth is to authorize requests by an app for SharePoint to access SharePoint resources on behalf of a user and also OAuth used to authenticate apps in the Office Store, an app catalog.
o   Producers expose their data in a structured way via a web service. Examples include SharePoint Foundation 2010, SharePoint Server 2010, SQL Azure, Windows Azure Table Storage, Windows Azure Marketplace, SQL Server Reporting Services, Microsoft Dynamics CRM 2011, and Windows Live. 

6. What is Pages layouts and how can we use it?

o   In a page layout, you are essentially telling SharePoint what it should fill all those empty bookshelves with. You declare a control (a certain shelf), and then tell SharePoint what goes inside

7. What is cross site publishing SharePoint 2013 and how / why to use it?
o   Cross-site publishing feature is used to store and maintain content in one or more authoring site collections and display the content in one or more publishing site collections. Cross-site publishing will make life easy for you as it:

1.       Can be used across site collections, web applications, and even across farms.
2.       Separates content authoring from branding and rendering, meaning how you author content has nothing to do with how it is displayed to users.
3.       Allows you to mix pages and catalog content. 

8. SharePoint services names and what are Newly introduced?

o   Access Service , Access Service 2010
o   App Management Service
o   Business Data Connectivity Service
o   Excel Services Application
o   Machine Translation Service
o   PerformancePoint Service
o   PowerPoint Automation Service
o   Managed Metadata Service
o   Search Service
o   Secure Store Service
o   State Service
o   User and Health Data Collection Service
o   User Profile Service
o   Visio Graphics Service
o   Word Automation Services
o   Work Management Service
o   Microsoft SharePoint Foundation Subscription Settings Service

9. Managed metadata services, term set, how to import term set, how to create and manage term set (example country-state-city)

o   The managed navigation feature in SharePoint Server 2013 enables you to build navigation for a publishing site that is derived from a SharePoint managed metadata taxonomy. In SharePoint Server 2010, by default, you could base navigation only on the structure of a site. To create site navigation based on any data structure, you had to create a custom navigation provider. By using managed navigation, you can design site navigation around important business concepts. Managed navigation also lets you create friendly URLs without changing the structure of your site. In SharePoint Server 2010, all publishing site URLs contained a reference to the Pages library and any folders within that library — for example, http://contoso.com/Pages/AboutUs.aspx. In SharePoint Server 2013, you can create URLs that are better for Search Engine Optimization (SEO), and easier for site visitors to read — for example, http://contoso.com/AboutUs.

10. How to configure Managed Meta data Navigation?
11. What is USerProfile service, how to consume it and how many ways you can consume it?
o   User Service side code, Client side code, InfoPath forms , Designer we can consume UPSA

12.   Improvements in SharePoint Search / what is FAST Search?

13.   What is Workflow Manager and Improvements in current version? (architecture, Service and commands)

14. What is webpart life cycle,

o   OnInit – Configuration values set using WebBrowsable properties and those in web part task pane are loaded into the web part.
o   OnLoad
o   CreateChildControls – All the controls specified are created and added to controls collection. When the page is being rendered for the first time the method generally occurs after the OnLoad() event. In case of postback, it is called before the OnLoad() event. We can make use of EnsureChildControls() – It checks to see if the CreateChildControls method has yet been called, and if it has not, calls it.
o   LoadViewState – The view state of the web part is populated over here.
o   OnPreRender – Here we can change any of the web part properties before the control output is drawn.
o   RenderContents – Html Output is generated.
o   OnUnload(EventArgs e)
o   Dispose()

15. SharePoint 2013 Authentication

o   Windows claims
o   Security Assertion Markup Language (SAML)-based claims
o   Forms-based authentication claims
 
16. What is Distributed caching?

o   A new service called Distributed Cache. The Distributed Cache service is built on Windows Server AppFabric, which implements the AppFabric Caching service. Windows Server AppFabric installs with the prerequisites for SharePoint Server 2013.

The Distributed Cache service provides in-memory caching services and does not have a dependency on databases for several features in SharePoint Server 2013. Some of the features that use the Distributed Cache service include:
      • Newsfeeds
      • Authentication
      • OneNote client access
      • Security Trimming
      • Page load performance
o   When the service is enabled, these features use the Distributed Cache for quick data retrieval. Blob Cache and Output Cache do not use a distributed caching service since these types of cache exist on each Web Front End server in the farm

17. Types of events available in SharePoint –
(Sync and aSync or Adding / Added)

o   Item Level
o   Security / Permission
o   List
o   Web
18. Remote event receiver.
o   By Client service in SharePoint (app- we use in provider hosted app).

19. Name the REST Api operation names?
o   GET, PUT, POST, Delete

20. What query string element enables a client webpart to talk back to the parent?
o   SenderId.

21. What is the PFX and CER cert ?
o   PFX is required by the App and the CER is needed by SharePoint

22. What is .App file? What it contains?
o   It is like .zip file

23.   What API do Apps use? (both REST and CSOM)

24.   Where will you find the necessary DLLs to refer? (15/16 hive ISAPI folder)

25.   What serialization formats are used with REST in SharePoint?(JSON and ATOM)

26.  What are Ghosted pages and Unghosted pages?
       The pages those are stored in File system are Ghosted pages which are faster and UnGhosted pages are those are being stored in SharePoint Database and comparative slower in rendering. 

27. What is SharePoint Object Hierarchy?

  • SPFarm
  • SPWebApplication
  • SPSiteCollection
  • SPWeb
  • SPList
  • SPListItemCollection
  • SPListItem, SPField


Recommends reading below points (search over internet)



1.       How to Configure Search Service Application? How to Create/Config its Databases, Crawls and scopes?
2.       What is Display templates, how to you use?
3.       What all are the new features of SharePoint?
4.       What is Image rendition and Shredded storage?
5.       How to improve SharePoint site performance?
6.       What is Site Ribbon- how to add option in it? And how to hide it from specific site.
7.       How to create or Override - delegate controls
8.       Master pages creation/ branding, Important/Required control name those needs to be added in MasterPage.
9.       How to create Responsive SharePoint site? (bootstrap in html5 and css3)
10.   PDF file support, what is I Filter PDF?
11.   Feature stapling, and how and why to do it?
12.   Sandbox solution-2013 supported? on Which Process is run and why? – SPUCWorkedProcess.exe – rest search it over internet
13.   SPQuery vs SiteDataQuery
14.   Can we user list Joins in SharePoint? How to apply joins, tell me important tag names?
15.   One Issuer ID can be setup for hosting multiple clients/apps in provider hosted apps?
16.   What is JSON and ATOM format?
17. What is Reusable Workflows
18. SharePoint Permission Hierarchy?
19. Content and Config DataBase Difference?
20. BCS service, operation names and how to Configure it.