Monday 30 June 2014

SharePoint File Read and Write using CSOM

using (System.IO.FileStream objFileS = new System.IO.FileStream(@"D:\myexcel.xlsx", System.IO.FileMode.Open))
{
SP.FileCreationInformation objFileC = new SP.FileCreationInformation();
objFileC.ContentStream = objFileS;
objFileC.Url = System.DateTime.Now.ToLongTimeString().Replace(':',' ') + ".xlsx";
objFileC.Overwrite = true;
SP.List objLib = clientContext.Web.Lists.GetByTitle("MyLibrary");
SP.File uploadFile = objLib.RootFolder.Files.Add(objFileC);
clientContext.Load(uploadFile);
clientContext.ExecuteQuery();
}

SharePoint 2010 Preferred Server for Timer Jobs


 
GO to Central Administration
 
under "Application Management"  select "Manage content databases"
 
Select web application which you want.
Click on Database name
You will see-Preferred Server for Timer Jobs
in the dropdown, select server which want.

HCL informatica Interview

What is session?
What is workflow?
What is worklet?
Which ETL tool is more preferable Informatica or Data Stage and why?
What is a mapplet?
What is the use of auxiliary mapping?
What is authenticator?
How do we create primary key only on odd numbers?
What is the difference between source qualifier transformation and application source qualifier transformation?
What are the types of loading in Informatica?
What is the use of control break statements?
What is the difference between active transformation and passive transformation?
What are the various types of transformation?
What is the use of tracing levels in transformation?
What is the difference between a Database and a Datawarehouse?
What are the different types of OLAP TECHNOLOGY?

Abstract and Sealed Classes and Class Members (C# Programming Guide)

Abstract and Sealed Classes and Class Members (C# Programming Guide)
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.
The sealed keyword enables you to prevent the inheritance of a class or certain class members that were previously marked virtual.
Classes can be declared as abstract by putting the keyword abstract before the class definition. For example:
public abstract class A
{
// Class members here.
}
An abstract class cannot be instantiated. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. For example, a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class.
Abstract classes may also define abstract methods. This is accomplished by adding the keyword abstract before the return type of the method. For example:
public abstract class A
{
public abstract void DoWork(int i);
}
important Notes:
(a)Any Class with abstract method or property in it must be declared abstract
(b)Attempting to instantiate an object of an abstract class retults in a compilation error
Abstract methods have no implementation, so the method definition is followed by a semicolon instead of a normal method block. Derived classes of the abstract class must implement all abstract methods. When an abstract class inherits a virtual method from a base class, the abstract class can override the virtual method with an abstract method. For example:
// compile with: /target:library
public class D
{
public virtual void DoWork(int i)
{
// Original implementation.
}
}
public abstract class E : D
{
public abstract override void DoWork(int i);
}
public class F : E
{
public override void DoWork(int i)
{
// New implementation.
}
}
If a virtual method is declared abstract, it is still virtual to any class inheriting from the abstract class. A class inheriting an abstract method cannot access the original implementation of the method—in the previous example, DoWork on class F cannot call DoWork on class D. In this way, an abstract class can force derived classes to provide new method implementations for virtual methods.
Abstract classes normally contain one or more abstract methods or abstract properties, such methods or properties do not provide implementations, but our derived classes must override inherited abstract methods or properties to enable obejcts ot those derived classes to be instantiated, not to override those methods or properties in derived classes is syntax error, unless the derived class also is an abstract class
Sealed Classes and Class Members
Classes can be declared as sealed by putting the keyword sealed before the class definition. For example:
public sealed class D
{
// Class members here.
}
A sealed class cannot be used as a base class. For this reason, it cannot also be an abstract class. Sealed classes prevent derivation. Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster.
A class member, method, field, property, or event, on a derived class that is overriding a virtual member of the base class can declare that member as sealed. This negates the virtual aspect of the member for any further derived class. This is accomplished by putting the sealed keyword before the override keyword in the class member declaration. For example:
public class D : C
{
public sealed override void DoWork() { }
}
Classes and Structs (C# Programming Guide)
Classes and structs are two of the basic constructs of the common type system(CTS) in the .NET Framework
C# Programming Guide
http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx

How to: Host an ASP.NET Web Service Outside of IIS

The Web Services Enhancements for Microsoft .NET Framework (WSE) enables ASP.NET Web services to be hosted in console applications, Windows services, COM+ components or Windows Forms applications and then be called using the TCP protocol or any custom transport protocol written for WSE.
Host an ASP.NET Web service in a Windows service
1. Open Visual Studio 2005.
2. Create an ASP.NET Web service.
1. On the File menu, choose New Web Site.
2. In the New Web Site dialog box, select the ASP.NET Web Service icon.
3. Enter the address of the Web server on which you will develop the XML Web service and directory name. For this procedure specify http://localhost/WSEHostedWebService.
4. Click OK to create the project.
3. Add code to implement the Web service.
By default there is a HelloWorld Web service method in a class named Service. The default Service class is used by this procedure.
4. Create a Windows service.
1. On the File menu, choose New Project.
2. In the New Project dialog box, select the Windows Service icon.
3. Enter the name of the Windows service. For this procedure, specify WindowsServiceToHostASMXWebService.
4. Click OK to create the project.
This creates a Windows service project and closes the Web service project.
5. Add references to the Microsoft.Web.Services3, System.Web.Services, and System.Web assemblies.
1. On the Project menu, click Add Reference.
2. Click the .NET tab, select Microsoft.Web.Services3.dll, System.Web.dll, and System.Web.Services.dll, and then click OK.
6. Add the source file and configuration files for the Web service.
1. When the Web service has a configuration file, in Solution Explorer, right-click the project name, point to Add, and choose Existing Item.
2. When the Web service has a configuration file, navigate to the folder containing the Web service, change the Files of type to All Files (*.*), select Web.config, and click Add.
3. In Solution Explorer, right-click the project name, point to Add, and choose Existing Item.
4. Navigate to the App_Code child folder of the folder containing the Web service, select the source file (Service1.vb or Service1.cs), and click Add.
7. When the Web service has a configuration file, rename the web.config file to app.config.
1. In Solution Explorer, right-click web.config, and choose Rename Item.
2. In the edit box, type app.config.
8. Open the source for the Windows service.
1. In Solution Explorer, right-click the file containing the Windows service, and then click View Code.
9. Add using or Import directives to the file containing the Windows service.
Visual Basic
Imports System.ServiceProcess
Imports Microsoft.Web.Services3
Imports Microsoft.Web.Services3.Addressing
Imports Microsoft.Web.Services3.Messaging
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using Microsoft.Web.Services3;
using Microsoft.Web.Services3.Addressing;
using Microsoft.Web.Services3.Messaging;
10. When the class implementing the Windows service doesn't derive from ServiceBase, derive from ServiceBase and be a partial class.
The following code example changes the name of the class to WindowsServiceToHostASMXWebService and derives it from System.ServiceProcess.ServiceBase.
Visual Basic
Partial Public Class WindowsServiceToHostASMXWebService
Inherits ServiceBase
C#
public partial class WindowsServiceToHostASMXWebService : ServiceBase
{
11. In the OnStart method of the Windows service, add code to host the ASP.NET Web service.
To host the ASP.NET Web service, call the Add method and supply the endpoint and type for the Web service.
The following code example specifies that the Web service named Service is to be hosted at the soap.tcp://localhost/Service endpoint.
Visual Basic
Protected Overrides Sub OnStart(ByVal args() As String)
' Start a listener for the ASP.NET Web service named Service.
Dim Address As New Uri("soap.tcp://localhost/Service")
SoapReceivers.Add(New EndpointReference(Address), GetType(Service))
End Sub
C#
protected override void OnStart(string[] args)
{
Uri address = new Uri("soap.tcp://localhost/TestService");
SoapReceivers.Add(new EndpointReference(address), typeof(Service ));
}
12. In the OnStop method for the Windows service, add code to stop hosting the ASP.NET Web service.
To stop hosting the ASP.NET Web service, call the Clear method.
The following code example stops hosting of the ASP.NET Web service.
Visual Basic
Protected Overrides Sub OnStop()
' Stop hosting the ASP.NET Web service.
SoapReceivers.Clear()
End Sub
C#
protected override void OnStop()
{
SoapReceivers.Clear();
}
13. Edit the Main method to create an instance of WindowsServiceToHostASMXWebService. When you renamed the service in step 10, the class name was not modified in the Main method.
When a Web service is hosted outside of IIS, some of the programming elements that are specific to HTTP are not available. The System.Web.HttpContext.Current property is one example of this. The following paragraphs summarize the other elements that are not available.
The following properties of the System.Web.Services.WebMethodAttribute attribute cannot be used by a Web service that is hosted outside of IIS.
o BufferResponse
o CacheDuration
o EnableSession
o TransactionOption
The following configuration elements cannot be used by a Web service that is hosted outside of IIS.
o
o
o
o
o
Visual Basic
' The main entry point for the process
_
_
Shared Sub Main()
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
' More than one NT Service may run within the same process. To add
' another service to this process, change the following line to
' create a second service object. For example,
'
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
'
ServicesToRun = New System.ServiceProcess.ServiceBase() {New WindowsServiceToHostASMXWebService}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End Sub
C#
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
// Change the following line to match.
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new WindowsServiceToHostASMXWebService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
14. Specify that the startup object for the project is the Windows service.
0. In Solution Explorer, right-click the project name, and choose Properties.
1. In Startup object, select WindowsServiceToHostASMXWebService.
15. Install the Windows service.
Unlike most projects you create in Visual Studio, Windows Service projects cannot be run directly from the development environment by pressing F5. This is because the service in the project must be installed before the project can run. For details about installing the Windows service, see the How to: Install and Uninstall Services topic in the .NET Framework SDK documentation.
Example
The following code example creates a Windows service named WindowsServiceToHostASMXWebService that hosts a Web service named Service at the soap.tcp://localhost/Service endpoint.
Visual Basic
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
_
_
_
Public Class Service
Inherits System.Web.Services.WebService
_
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
...
Imports System.ServiceProcess
Imports Microsoft.Web.Services3
Imports Microsoft.Web.Services3.Addressing
Imports Microsoft.Web.Services3.Messaging
Partial Public Class WindowsServiceToHostASMXWebService
Inherits ServiceBase
Protected Overrides Sub OnStart(ByVal args() As String)
' Start a listener for the ASP.NET Web service named Service.
Dim Address As New Uri("soap.tcp://localhost/Service")
SoapReceivers.Add(New EndpointReference(Address), GetType(Service))
End Sub
Protected Overrides Sub OnStop()
' Stop hosting the ASP.NET Web service.
SoapReceivers.Clear()
End Sub
End Class
C#
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using Microsoft.Web.Services3;
using Microsoft.Web.Services3.Addressing;
using Microsoft.Web.Services3.Messaging;
namespace WindowsServiceToHostASMXWebService
{
public partial class WindowsServiceToHostASMXWebService : ServiceBase
{
public WindowsServiceToHostASMXWebService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
Uri address = new Uri("soap.tcp://localhost/TestService");
SoapReceivers.Add(new EndpointReference(address), typeof(Service ));
}
protected override void OnStop()
{
SoapReceivers.Clear();
}
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
// Change the following line to match.
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new WindowsServiceToHostASMXWebService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
}
}

How to Convert dd/MMM/yyyy to MM/dd/yyyy

Error: not able to convert string to DateTime
How to Convert dd/MM/yyyy to MM/dd/yyyyHow to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy
Normally we will face some problem with datetime control in any application because of local datetime formats. It will differ for each user how they have configured in the local computer. Now i am giving a generic solution for any type of datetime formats in the local system.
string date=System.DateTime.Now.ToString();
CultureInfo info = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
info.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
System.Threading.Thread.CurrentThread.CurrentCulture = info;
Response.Write(Convert.ToDateTime(date));

XSLT Definitions


This topic very briefly introduces XSLT. It covers:
• An Introduction
• A listing of all Basic XSLT Functionality
• Basic XSLT Algorithm
Introduction
The XSLT (Extensible Stylesheet Language Transformation) Definition sets-out the rules for translating the XML schema into HTML or another XML set. The basic capabilities of XSLT includes:
• Generating constant text
• Filtering out content - only displaying information that is relevant to the reader
• Change tree ordering - remember XML is a hierarchical data definition in which the nodes can be reorganized
• Duplicating nodes
• Sorting nodes
• Any programmatic interpretation and processing of the input data
Fig. 1. XSLT Processing
In the simplest terms the XML Processor uses the XSLT declaration to interpret the Input XML file to produce a specific output file. The following example shows how the data contained in the original file is modified to produce the final HTML file. Code Samples sourced from the posting on Wikipedia at http://en.wikipedia.org/wiki/XSLT (accessed September 2005)
Example XSLT


h1 { padding: 10px; padding-width: 100%; background-color: silver }
td, th { width: 40%; border: 1px solid silver; padding: 10px }
td:first-child, th:first-child { width: 20% }
table { width: 650px }

 

The following host names are currently in use at

Host nameURLUsed by


 
!--'Used by' column-->

Input XML File


www World Wide Web site
java Java info
www World Wide Web site
validator web developers who want to get it right
Output XHTML File

,br> h1 { padding: 10px; padding-width: 100%; background-color: silver }
td, th { width: 40%; border: 1px solid silver; padding: 10px }
td:first-child, th:first-child { width: 20% }
table { width: 650px }

Sun Microsystems Inc.

The following host names are currently in use at sun.com
Host nameURLUsed by
wwwhttp://www.sun.comWorld Wide Web site
javahttp://java.sun.comJava info

The World Wide Web Consortium

The following host names are currently in use at w3.org
Host nameURLUsed by
wwwhttp://www.w3.orgWorld Wide Web site
validatorhttp://validator.w3.orgweb developers who want to get it right
Basic XSLT Functionality
XSLT functionality is accessed using:
• XSLT elements
• XPath Node Axes
• XSL Functions
The tables listed below have been extracted almost exactly as presented in:
Benz, B.; Durant, J.R.; XML Programming Bible; Wiley Publishing Incorporated; Indianapolis, USA; 2003
XSLT Elements
The table below lists all the elements available to XSLT stylesheet developers:
W3C XSLT Elements
Element Description
stylesheet Defines the root element of a stylesheet. Can be used interchangeably with transform
transform Defines the root element of a stylesheet. Used to replace stylesheet, when stylesheet cannot be used
output Defines the format of the output document.html, xml and text are defined. html includes rtf and pdf documents. If output is not specified the XSLT parser checks the document to see if its html based. Various options can be specified - including encoding, document indentation, etc.
namespace-alias Replaces the source document namespace with a new namespace in the output node tree. (Must be a child of the stylesheet element)
preserve-space Defines whitespace preservation for elements. (Must be a child of the stylesheet element)
strip-space Defines whitespace removal for elements. (Must be a child of the stylesheet element)
key Adds key values to each node, using XPath functions. (Must be a child of the stylesheet element)
import Imports and external stylesheet into the current stylesheet. The current stylesheet takes precedence if there is any conflict. (Must be a child of the stylesheet element)
apply-imports Applies templates to all the children of the current code or a specified node set (select).
include Includes an external stylesheet in the current one if there are any conflicts the XSLT parser needs to decide which takes precedence. (Must be a child of the stylesheet element)
template Applies rules in a match or select action. Optional attributes can be used for defining a node-set by match, template name, processing priority and an optional QName for a subset of nodes in the node set
apply-templates Applies a template to all children of the current node, or a specified node set using the optional select attribute. Parameters can be passed using the with-param element
call-template Calls a template by name. Parameters can be passed using the with-param element. Results can be assigned to a variable
param Defines a parameter and default value in a stylesheet template. A global parameter can be defined as a child of the stylesheet element
with-param Passes a parameter value to a template when call-template or apply-template is used
variable Defines a variable in a template or a stylesheet template. A global variable can be defined as a child of of the stylesheet element
copy Copies the current node and related namespace only. Output matches the current node (element, attribute, text, processing instruction, comment or namespace)
copy-of Copies the current node, namespaces, descendant nodes and attributes. Scope can be controlled with a select attribute
if Conditionally applies a template if the test attribute expression evaluates to true
choose Makes a choice based on a multiple options. Used with when and otherwise
when Defines an action for the choose element
otherwise Defines the default action for the chooseelements. (Must be a child of the choose element)
for-each Iteratively processes each node in a node-set defined by an XPath expression
sort Defines a sort key used by apply-templates to a node-set and by for-each to specify the order of iterative processing of a node set
element Adds an element to the output node tree. The details of the element can be set using the names, namespaces and use-attribute-sets
attribute Adds an attribute to the output node tree. (Must be a child of an element)
attribute-set Adds a list of attributes to the output node tree. (Must be a child of an element)
text Adds text to the output node tree
value-of Retrieves a string value of a node and writes it to the output tree
decimal-format Specifies the format of numeric characters and symbols when converting to strings. Used with the format-number function only
number Adds a sequential number to the nodes of the node-set, based on the value attribute. Can also define the number format of the current node in the output node tree
fallback Defines alternatives for instructions that the current XSL processor does not support
message Adds a message to the output node tree. This element can also optionally stop processing ona stylesheet with the terminate attribute. Mostly used for debugging
processing-instruction Adds a processing instruction to the output node tree
comment Adds a comment to the output node tree
XPath Node Axes
XPath Node axes facilitate the navigation of the input and output node trees. They are centered on the current node and radiate out to locate parents, ancestors, children, descendents and siblings
XPath Node Axes
Axis Description
self The current node.
XPath Location Operator: . - the current node
ancestor Parents and other predecessor nodes (not including the current node)
ancestor-or-self The current node and all predecessor nodes
attribute Attributes of the current node.
XPath Location Operator: @ - attribute identifier
child Children (direct descendents) of the current node.
XPath Location Operator: * - all child nodes
descendant Children and other succeeding (coming after) nodes (not including the current node).
XPath Location Operator: // - all descendents
descendant-or-self The current node and all succeeding nodes
following The next node in the document order, including all descendents of the next node; excluding the current node descendents and ancestors
following-sibling The next sibling (child of the same parent node as the current node) in the document order, including all descendents of the sibling node; excluding the current node descendents and ancestors
namespace All nodes that share the same namespace as the current node
parent The parent (the immediate predecessor) node of the current node
XPath Location Operator: .. - the parent node
XPath Location Operator: / - the root node
preceding The previous node in the document order, including all descendents of the previous node; excluding the current node descendents and ancestors
preceding-sibling The previous sibling (child of the same parent node as the current node) in the document order, including all descendents of the sibling node; excluding the current node descendents and ancestors
XSL Functions
XSL stylesheets support several functions for each data type:
XSL Functions by Data Type
Function Description
Boolean Functions
boolean() Converts an expression to a Boolean data type value and returns true or false
true() Binary true
false() Binary false
not() Reverse binary true or false. e.g.not(true expression)=false; not(false expression)=true
Number Functions
number() Converts an expression to a numeric data type value
round() Rounds a value up or down to the nearest integer e.g.round(45.49)=45; round(45.50)=46
floor() Rounds a number down to the nearest integer e.g.floor(45.49)=45; floor(45.50)=45
ceiling() Rounds a number up to the nearest integer e.g.floor(45.49)=46; floor(45.50)=46
sum() Sums the numeric values in a node set
count() Counts the nodes in a node-set
String Functions
string() Converts an expression to a string data type value
format-number() Converts a numeric value to a string data type value using the decimal-format element values as a guide (if present in the stylesheet)
concat() Converts two or more expressions into a concatenated string data type
string-length() Counts the characters in a string data type value
contains() Checks for a substring in a string. Returns a Boolean true or false
starts-with() Checks for a substring at the beginning a string. Returns a Boolean true or false
translate() Replaces an existing substring with a specified substring in a specified string
substring() Retrieves a substring from a specified string, starting at a numeric character position and optionally ending after a specified length (number of characters)
substring-after() Retrieves a substring of all characters, in a string, after a specified numeric character position
substring-before() Retrieves a substring of all characters, in a string, before a specified numeric character position
normalize-space() Replaces any tab, new line or carriage return in a string with spaces; and then removes any leading or tailing spaces from the new string
Node Set Functions
current() Returns the current node in a single node node-set
position() Returns the position of the current node in a node-set
key() Returns the node-set defined by the key element
name() Returns the name of the selected node
local-name() Returns the name of a node without a prefix, if the prefix exist
namespace-uri() Returns the full URI of a node prefix, if the prefix exists
unparsed-entity-uri() Returns the URI of an unparsed entity based on a reference to the source document, based on the entity name
id() Returns a node-set with nodes that match the id value
generate-id() Generates a unique string for a selected node in a node-set. The syntax follows well-formed XML rules (see XML Basics)
lang() Returns a Boolean true or false depending on if the xml:lang attribute for the selected node matches the language identifier provided in an argument
last() Returns the position of the last node in the node-set
document() Builds a node tree from an external XML document when provided with a valid document URI
External Object Functions
system-property() Returns information about the processing environment. Useful when building multi-version and multi-platform stylesheets in conjunction with the fallback element
element-available() Returns a Boolean true or false indicating if a processing-instruction or extension element is supported by the XSLT processor or not
system-property() Returns a Boolean true or false indicating if a function is supported by the XSLT processor or not
Basic XSLT Algorithm
XSLT declarations define a set of rules and guidelines that are applied during processing according to a predefined algorithm. Each XSLT processor appears to follow these steps:
1. The XSLT stylesheet content is converted into a tree of nodes (according to the XPath model), the stylesheet tree - information from included or imported other files is also interpreted to construct a complete tree
2. The input XML file is interpreted into a data node-tree (according to the XPath model) - the source tree
3. Whitespace only text elements are stripped from the stylesheet tree. Descendents of xml:text elements are not removed
4. Strip the whitespace from the source tree (if xsl:strip-space is specified in the stylesheet)
5. Any templates added to the stylesheet are interpreted and the appropriate actions taken on the output tree, alternatively the default template rules ar added to provide the default behavior for all node types:
• Root node and element node: processor continues on and processes all child nodes
• Attribute node and text node: processor makes a copy of the node in the result (output) node-tree
• Comment node and processing instruction: Processor takes no action
6. Process the root node of the source tree
7. Serialize the output tree according to the instructions provided in xml:output
Nodes are processed in two steps:
1. The best matching template rule for the node is found
2. The contents of the template rule are instantiated

GetList Item Count WebServices

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Microsoft.SharePoint;
using System.DirectoryServices;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class SPWebService : System.Web.Services.WebService
{
public SPWebService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string GetSPList()
{
int count;
using (SPSite site = new SPSite(“http://URL/”))
{
using (SPWeb web = site.OpenWeb())
{
SPList ServiceList = web.Lists["MyListName"];
if (ServiceList != null)
{
count = ServiceList.ItemCount;
}
else
{
count = 0;
}
}
}
return count.ToString();
}
//Get Role form Active Directory
[WebMethod]
public string GetRoles(string FQN) {
string EmailID = string.Empty;
DirectorySearcher UserSearch = new DirectorySearcher(“(mailNickName= ” + FQN + “)”);
SearchResult mYResult = UserSearch.FindOne();
if (mYResult == null)
{
return EmailID;
}
DirectoryEntry EmployeeName = mYResult.GetDirectoryEntry();
EmailID =Convert.ToString(EmployeeName.Properties["Title"].Value);
return EmailID;
}
[WebMethod]
public string DoesUserExists(string UserName, string GroupName)
{
string Exists = “True”;
UserGroup.UserGroup webService = new UserGroup.UserGroup();
NetworkCredential mycredentials = new NetworkCredential(“blackPoint”, “B@Point”, “scsdomhyd01?);
webService.Credentials = mycredentials;
XmlNode UserGroups = webService.GetGroupCollectionFromUser(UserName);
foreach (XmlNode node in UserGroups.FirstChild.ChildNodes )
{
string SPGroupName = node.Attributes["Name"].Value.ToLower();
if (GroupName.ToLower() == SPGroupName)
{
break;
}
else
{
Exists = “False”;
}
}
return Exists;
}
}
Why won’t InfoPath work with SharePoint Web Services? It comes down to the fact that InfoPath doesn’t recognize that some web services, such as Lists.asmx’s GetListItems requires strings (which InfoPath handles just fine) and XmlNodes (which InfoPath can’t seem to figure out). If you try to use this web service as a data connection, you’ll get error messages, such as “Root Element is Missing” or, if you try to add some XML code to one of the fields, you’ll get “Element of parameter query is missing or invalid.”
The solution? Create a Proxy Web Service that takes in strings representing the Xml code and create XmlNodes from them.
Here’s the code to create such as proxy:
[WebMethod]
public XmlNode GetListItems(string listName, string viewID, string query, string viewFields, string rowLimit, string queryOptions, string webID)
{
// Create an instance of the SharePoint Lists Web Service
ListsWebService.Lists listService = GetListsServiceClient();
// Create the XmlNodes from the given innerXml strings
XmlNode queryElement = CreateNode(“Query”, query);
XmlNode viewFieldsElement = CreateNode(“ViewFields”, viewFields);
XmlNode queryOptionsElement = CreateNode(“QueryOptions”, queryOptions);
// Execute the SharePoint Lists Web Service
return listService.GetListItems(listName, viewID, queryElement, viewFieldsElement, rowLimit, queryOptionsElement, webID);
}
private ListsWebService.Lists GetListsServiceClient()
{
ListsWebService.Lists listService = new ListsWebService.Lists();
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
listService.Url = SPContext.Current.Web.Url + “/_vti_bin/Lists.asmx”;
return listService;
}
private XmlNode CreateNode(string name, string innerXml)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode element = xmlDoc.CreateElement(name);
element.InnerXml = innerXml;
return element;
}
Ref:http://msdn.microsoft.com/en-us/library/ms464040.aspx
[WebMethod]
public XmlDocument GetAuthorByAuthorID(string authorID)
{
XmlDocument doc = new XmlDocument();
DataSet authorsDataSet = new DataSet(“Authors”);
using (SqlConnection conn = new
SqlConnection(“server=localhost;uid=sa;pwd=thiru;database=Pubs”))
{
SqlDataAdapter adapter = new SqlDataAdapter(“Select au_id,
au_lname, au_fname,
phone from authors
Where au_id = ‘” +
authorID + “‘” ,conn);
adapter.Fill(authorsDataSet,”Author”);
}
doc.LoadXml(authorsDataSet.GetXml());
return doc;
}
[WebMethod]
public XmlDocument GetAllAuthors()
{
XmlDocument doc = new XmlDocument();
DataSet authorsDataSet = new DataSet(“Authors”);
using (SqlConnection conn = new
SqlConnection(“server=localhost;uid=sa;pwd=thiru;
database=Pubs”))
{
SqlDataAdapter adapter = new SqlDataAdapter(“Select au_id,
au_lname, au_fname,
phone from authors ” ,conn);
adapter.Fill(authorsDataSet,”Author”);
}
doc.LoadXml(authorsDataSet.GetXml());
return doc;
}

SPQuery Join

SPQuery query = new SPQuery();
query.Query = "[YOUR CAML QUERY HERE]";
query.Joins = "[YOUR JOIN CAML HERE (See above for example)]";
query.ViewFields = "[SAME AS BEFORE]";
SPListItemCollection items = myList.GetItems(query);
foreach(SPListItem item in items)

TCS cognos Interview questions


Can you tell me the steps for migrate reports to cognos 8 from previous versions?
What is the importance of Dimension in the cognos.?
How can we improve performance of the reports?
What r the filters in fwm and report studio?
How can I change reports to another package???
What is difference between content store and content manager?
what is stitched query???
how to connect datamarts?
how to merge 2 crosstabs thans?
How u will design the report if the objects are available?

Infopath Date difference

Infopath get the no of days.
different b/w selected date to today.
Take Two Controls
DateRequesteddt- date time picker
NODopen- textbox, it will show different b/w selected date to today.
In Data time picker:
Add Rule
Condition 1
Today is not blank
Action
Then Set field NODopen=
0;4096
==============================
Add rules to NODopen
Rule 1
Condition 1
The expression
xdDate:AddDays(../my:DateRequesteddt, substring-before(., ";")) != ../my:Today
and
Condition 2
NODopen is contains ;
Action
Then Set field NODopen=
concat(substring-before(., ";") + substring-after(., ";") * ((translate(addDays(DateRequesteddt, substring-before(., ";")), "-", "") < translate(Today, "-", "")) * 2 - 1), ";", substring-after(., ";") / 2)
Rule 2
Condition 1
NODopen is contains ;
Action
Then Set field NODopen=
substring-before(., ";")

USING SMARTOBJECTS IN INFOPATH FORMS TO UPLOAD FILE ATTACHMENTS TO SHAREPOINT


CREATING UP THE SHAREPOINT DOCUMENT LIST
I’ll first create up a new document library to store my file attachments.
View All Site ContentCreateDocument Library
Name: FileAttachments
CREATE THE FILE ATTACHMENT SMARTOBJECT
Site Actions --> K2 Site Settings --> K2 SmartObject Site Lists and Libraries (SmartObject Management)
Select document library and click create
You can test Smart Object using ServiceBroker
c:\Program Files\K2 blackpearl\ServiceBroker
1. Let’s create up blank form template.
2. Now I am going to create up a couple of fields that I need in my main data source. Click on Data Source on the side pane.
3. First create the repeating node for the file attachment. Right click on the myFields node and select Add Field or Group. Create the repeating node as shown on the right. I am calling it fileAttachment.
4. Next add a file attachment field. I am calling mine file.
5. Next add a field for the URL link to the document after we upload it to SharePoint. I am calling this urllink.
6. The last field we add is used as a trigger field to fire the SmartObject call for each line item when we submit the form. I’ll call this field trigger and set an initial value of 0 to it.
7. I am then going to drag the file field to the form as a repeating file attachment control. I’ll also add a button control to do the form submission.
8. I’ll drag the urllink to the bottom of the form as a repeating expression. This will be used to show how the URLs are created after the submission. Now note that in a real life case, the URL listing would be on the approval view.
9. Now let’s add the SmartObject integration to the form. First save and close the form. Then right click on the form and select Integrate with SmartObject
10. Now add in the Create method for the SmartObject we created earlier.
11. Click Finish to complete the SmartObject integration.
12. Now right click on the template file and select Design. First change the Submit button rules to set the trigger field to 1 when clicked on. This is one part of the trick to cause the rule processing to fire for each row.Go to Button Properties.
13. Under Rules, configure an action to set the trigger field to 1.
14. Next let’s set a rule under the trigger field properties.
15. Click the Add button to add a rule.
16. Under the condition, configure the rule to only fire when trigger is equal to 1. This is the other part of the trick which works in combination with the other rule that we created on the Submit button. So when we click on the Submit button, this rule will fire for every single line item in this repeating group.
17. Next configure the first action in the rule to copy the file attachment data to the input field of the SO create method data source. The field is called content.
18. The final setting should look like this. Click OK.
19. Next add an action to execute the SmartObject create function.
Next add an action to set the urllink field to contain the returned URL link. Note that we will use the following Formula to strip off the surrounding HTML tags that won’t be used.
20. substring-before(substring-after(LinkToItem_K2_ServiceDefined, ""),"")
21. Next add an action to remove the file data from the InfoPath form. Set the file field to an empty value. This is important as the file data will still be in the InfoPath form if you do not do this.
TESTING THE FORM
Now we have completed setting up the basic functionality of how we can upload multiple documents in the
InfoPath form to SharePoint using SmartObjects.
1. I first open up my form and I then attach 2 text files for testing.
2. Click Submit. Note the first time executing this might be a bit slower when the SmartObject web service is being called the first time (it should be quicker on the subsequent calls). Now notice how the two attachment files are removed and note the URL links listed under the Submit button.
3. Now if you look at the document library that created earlier. We can now see the 2 file attachments that uploaded via the form. Cool!

How to make sharepoint 2010 site public

First get your IP or Public URL or Host Name.
Open IIS (Click Run-->inetmgr-->Expand Sites)
Right click on web site which you want to make to Public
Click "Edit Binding"
Select your web site in the new window. Ex: if it is 80 port just select that..)
Click "Edit" option in the new window.
Provide the Host name: which collected in the Step1.
We have done Host name configuration in IIS
Now we have to do Alternate access map in sharepoint Central Admin
GO to Central Admin-->Application Management
Under Web Application
Select "Config Alternate Access Mappings"
Click on "Edit Public URLs"
In "Alternate Access Mapping Collection:" select web application which you have mapped Host Name in IIS
Provide all the Details and Save

http://technet.microsoft.com/en-us/sharepoint/Video/ff679917

Microsoft.Office.Server.UserProfiles.UserProfileApplicationNotAvailableException: This User Profile Application's connection is currently not available

Central Admin > Manage Services on Server
and check if the User Profile Service is started on the server or no, if it is not started, start the User Profile Service.
Restart SharePoint services
Do IISREST
If it is not solved, restart the server

was unable to process request. ---> Invalid text value A text field contains invalid data. Please check the value and try again. ---> Invalid text value A text field contains invalid data. Please check the value and try again.

Error: was unable to process request. ---> Invalid text value A text field contains invalid data. Please check the value and try again. ---> Invalid text value A text field contains invalid data. Please check the value and try again.
Error:
Invalid text value A text field contains invalid data. Please check the value and try again. —> Invalid text value A text field contains invalid data. Please check the value and try again.
Solution)
Please check the format of the input data value which is passing to sharepoint
or
Please increase the length of the column in sharepoint.

Sharepoint List Multiline text Filter web part

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.ComponentModel;
using System.Drawing;
namespace WebPart1
{
[Guid("bc7e8f82-29ef-447d-9276-c52cb98addd1")]
public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
TextBox txtSearch;
Label lblmsg;
Button btnFilter;
public WebPart1()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
lblmsg = new Label();
txtSearch = new TextBox();
btnFilter = new Button();
btnFilter.Text = "Filter";
btnFilter.Click += new EventHandler(btnFilterClick);
this.Controls.Add(txtSearch);
//this.Controls.Add(new LiteralControl("
"));
this.Controls.Add(btnFilter);
this.Controls.Add(new LiteralControl("
"));
this.Controls.Add(lblmsg);
//load all the data
string oquery = "";
try
{
SPContext.Current.Web.AllowUnsafeUpdates = true;
if (txtSearch.Text.Trim() != "")
{
oquery = "";
oquery += "" + txtSearch.Text.Trim() + "";
oquery += "";
}
Microsoft.SharePoint.SPViewCollection viewColl = SPContext.Current.Web.Lists["TestFilter"].Views;
for (int i = 0; i < viewColl.Count; i++)
{
Microsoft.SharePoint.SPView view = viewColl[i];
view.Query = oquery;
view.Update();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
SPContext.Current.Web.AllowUnsafeUpdates = false;
txtSearch.Text = "";
}
}
protected void btnFilterClick(object sender, EventArgs e)
{
if (txtSearch.Text.Trim() == "")
{
lblmsg.Text = "You must specify a value for this required field";
string oquery = "";
try
{
SPContext.Current.Web.AllowUnsafeUpdates = true;
if (txtSearch.Text.Trim() != "")
{
oquery = "";
oquery += "" + txtSearch.Text.Trim() + "";
oquery += "";
}
Microsoft.SharePoint.SPViewCollection viewColl = SPContext.Current.Web.Lists["TestFilter"].Views;
for (int i = 0; i < viewColl.Count; i++)
{
Microsoft.SharePoint.SPView view = viewColl[i];
view.Query = oquery;
view.Update();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
SPContext.Current.Web.AllowUnsafeUpdates = false;
txtSearch.Text = "";
}
}
else
{
string oquery = "";
try
{
SPContext.Current.Web.AllowUnsafeUpdates = true;
if (txtSearch.Text.Trim() != "")
{
oquery = "";
oquery += "" + txtSearch.Text.Trim() + "";
oquery += "";
}
Microsoft.SharePoint.SPViewCollection viewColl = SPContext.Current.Web.Lists["TestFilter"].Views;
for (int i = 0; i < viewColl.Count; i++)
{
Microsoft.SharePoint.SPView view = viewColl[i];
view.Query = oquery;
view.Update();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
SPContext.Current.Web.AllowUnsafeUpdates = false;
txtSearch.Text = "";
}
}
}
}
}

K2 Blackpearl enable Performance Counters

Go to this path:
C:\Program Files (x86)\K2 blackpearl\Host Server\Bin
Open: K2server.setup
Find: <PerfMonCounters Enable="False" Interval="15000" />
set Enable="True"
restar K2 Host Server Service

jQuery sessionStorage

if (sessionStorage.getItem("MySessionName") == null) {
//save a value
sessionStorage.setItem("MySessionName", "MySessionValue");
//retrieve item
var name = sessionStorage.getItem("MySessionName");
//get the key name for the first item
var key = sessionStorage.key(0);
//remove the key
sessionStorage.removeItem(key);
//check how many key-value pairs are present
var count = sessionStorage.length;
}

jQuery Mobile dynamic listview and validations



This may help the developers to implement the

  • Ø  Basic list view(without/with search/filter option)
  • Ø  How to create/develop Dynamic list view
  • Ø  how to call web service to get the json/jsonp data
  • Ø  How to bind json/jsonp data to the list view.



  • How to show the count of items in listview (on search also it works).
  • How to create/show validations on search if no match found.

This KB is simple and understandable for beginners too.
Brief on jQuery Mobile:
jQuery Mobile is a touch-friendly web UI development framework, can develop pages mainly using markup driven with minimal or no JavaScript.

Before going to see how to develop dynamic list view, brief introduction about basic listview given below.
ü  jQuery Mobile Basic list view with/without search
Below sample code is example for Listview without search.
To get the search/filter input box just add simple attribute as below ‘ data-filter="true" ‘.

Use <ol> >( ordered list)  instead <ul>( unordered list) to get the default serial numbers for the list view items.


ü  Dynamic listview
Take an empty/loaded list view with id ‘dynamiclist’.
Here list view  has one item with name ‘Item 1’.
Now list view has one item, now two more items will added dynamically on page load.
Add following script in <script> part as shown below.

ü  Dynamic listview using web services.
Call Web Service and bind data to the list view (format of data is jsonp).
(json- JavaScript Object Notation, jsonp-executes third-party javascript which should return a Javascript object)
Take an empty/loaded list view with id ‘dynamiclist’.
Now list view has no items, now call Web service to get the data to add new items dynamically.
Prerequisites for dynamic we list view

Add following script in <script> part as shown below.

Here in Ajax call some data need to provide to get the json data from the webservice,
url: address of the web service
type: GET/POST ( to get the data GET & to post/save data POST).
data: parameters can pass here
dataType: return data type
On Success of Ajax call, ‘data’ will be filled with return json data, then add dynamic items to the list view by giving dynamic data values. To read the json data use ‘this’ key word and property name as shown above code.
Dynamic items will be added to the listview as below.
Also refer how filter/search works in list view

ü  Count of list items before & after
To show the count of list view items, just take list-driver and give group id for that list-driver as below.

Then add below code,
First populate dynamic list view (populatelist () function), and write a function to count the items and then call the function at page load, on search, on clear search.



ü  search  displaying validations on search if no match found

Note: by default message of search input box is ‘Filter items’, list view has flexibility to change/set validations too.
Add data-filter-placeholder in

If no items match on filter of list items, to show the validations follow steps.
Add a dynamic list items with validations at the end ( means this would be last item), and hide this item by default on page load.
Add following code after all dynamic items added to the list view (i.e after for each )

Now add the following code to show the validations on search if no match found.


But when even click on close button of input search box to clear the filter string,  still validations displayed at end of the items.
To remove this, just add below code, this is event which works on clicking of clear button of search box.



Final code
Code includes following
ü  Develop dynamic listview with input search/filter option.
ü  How to call web service and how to use/bind json data.
ü  Displaying count of items on page load as well as on search too.
ü  Applying validations on search if no match found and also how to hide those validations messages when those are not required to display.
ü  How to add dynamic elements (as same as dynamic items of list).


Summary:

Developing jQuery Mobile Dynamic web list view   with json data and search with count of items & result set and display validation messages if no match found on search.

Wipro sharepoint interview questions

How to add people picker control in feature implementation.
Can we add event handlers in people picker control
how to fetch employee id phone number when people picker value changes.
Write custom workflow.
workflow feature using content type.
what are the authentication types in moss 2010.
what is sandbox solution.
what are the outofthebox features in moss 2010.
what are the advantages of infopath.
what is interface.
can we do multiple inheritance in .net
class will support multiple inheritance.

SharePoint 2010 GridView Visual WebPart

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using Microsoft.SharePoint;
namespace AjaxVWP.AjaxVisualWebPart
{
public partial class AjaxVisualWebPartUserControl : UserControl
{
List<PlayerStat> listOfPlayerStats = new List<PlayerStat>();
string mySiteURL = "http://SERVER:8888";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnDataGridLoad_Click(object sender, EventArgs e)
{
statDataGrid.Width = Unit.Percentage(100);
statDataGrid.CellPadding = 1;
statDataGrid.HeaderStyle.Font.Bold = true;
statDataGrid.HeaderStyle.CssClass = "ms-vh1";
statDataGrid.GridLines = GridLines.Horizontal;
statDataGrid.BorderWidth = Unit.Pixel(3);
statDataGrid.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
using (SPSite mySiteCollection = new SPSite(mySiteURL))
{
using (SPWeb web = mySiteCollection.OpenWeb())
{
SPList myList = web.Lists["Stats"];
foreach (SPListItem tempListItem in myList.Items)
{
PlayerStat tempStat = new PlayerStat();
tempStat.playerName = tempListItem["Title"].ToString();
tempStat.numOfGoals = tempListItem["Goals"].ToString();
tempStat.numOfAssists = tempListItem["Assists"].ToString();
tempStat.numOfPIM = tempListItem["PIM"].ToString();
tempStat.gamesPlayed = tempListItem["Games"].ToString();
tempStat.playerAVG = calcPlayerAverage(tempStat.gamesPlayed,
tempStat.numOfGoals, tempStat.numOfAssists);
listOfPlayerStats.Add(tempStat);
}
}
}
statDataGrid.DataSource = listOfPlayerStats;
statDataGrid.DataBind();
}
protected void btnAdd_Click(object sender, EventArgs e)
{
using (SPSite mySiteCollection = new SPSite(mySiteURL))
{
using (SPWeb web = mySiteCollection.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["Stats"];
SPListItem newStat = list.Items.Add();
newStat["Title"] = txtbxName.Text;
newStat["Goals"] = txtbxGoals.Text;
newStat["Assists"] = txtbxAssists.Text;
newStat["PIM"] = txtbxPIM.Text;
newStat["Games"] = txtbxGoals.Text;
newStat.Update();
web.AllowUnsafeUpdates = false;
}
}
}
protected void btnEdit_Click(object sender, EventArgs e)
{
txtbxName.Text = "";
txtbxGames.Text = "";
txtbxGoals.Text = "";
txtbxAssists.Text = "";
txtbxPIM.Text = "";
}
private string calcPlayerAverage(string games, string goals, string assists)
{
int numGames = Int32.Parse(games);
int numGoals = Int32.Parse(goals);
int numAssists = Int32.Parse(assists);
double avgStat = 0.00;
avgStat = (numGoals * 2) + (numAssists * 1) / numGames;
return avgStat.ToString();
}
}
}

SharePoint 2010 Grid View

Moving Site Template (.stp ) files to SharePoint 2010

.stp or Site Templates - If you are planning to import stp or site template files then you should know that the files with .stp are no longer supported in Sharepoint 2010.
well, so how do you import stp files? – To do this just go through the Steps below:
1. First you need to create a site in SharePoint 2007 using your .stp template.
2. Then, backup the database for that site and restore it on SharePoint 2010 enviornment.
3. After you do that just Open up the site and fix any issues ( like 12 hive refrencing files etc).
4. Now, you can Save this Site (from Settings page -> Save as Template) and it will give you a .wsp solution for the site.
This solution can then be re-used as a Site Template.
Side Note – If you want to deploy this Site template solution as a farm you will need to open the above .wsp solution in VS 2010 and
change the Scope as “Farm”.

CTS cognos Interview questions


WHAT SHOULD BE DONE WHEN A REPORT RUNNING TIME WILL TAKE LONG TIME IN CONGNOS?
WHAT STEPS SHOULD BE TAKEN BY A REPORT DEVELOPER TO INTERACT WITH THE
CLIENT SERVER?
What is Cardinality?
How u migrate the reports from impromptu to reportnet?
After applying date prompt and when we run the report we fet from date and todate prompts..so when we enter todate<fromdate its an error. How can we generate the user defined error message for this type of error?
How many types of models are present in cognos.?
i have one file i saved in csv how can i take these file into framework manager
can we create a chart without measure?
which type of project we r going to snowflake schema?

Content search web part in the SharePoint 2013

Content search web part in the SharePoint 2013
The Content Search Web Part (CSWP) is a Web Part introduced in SharePoint 2013 that uses various styling options to display dynamic content on SharePoint pages.
Content Search Web Part displays search results in a way that you can easily format. Each Content Search Web Part is associated with a search query and shows the results for that search query.
You can use display templates to change how search results appear on the page. Display templates are snippets of HTML and JavaScript that render the information returned by SharePoint. The information to be displayed gets inserted into the page in JSON format.
CSWP: Content Search Web part and CQWP: Content Query Web part
The CSWP can return any content from the search index. Use it on your SharePoint 2013 sites when you are connecting to a search service and want to return indexed search results in your pages.
The CSWP returns content that is as fresh as the latest crawl of your content, so if you crawl often, the content that the CSWP returns is more up-to-date than if you crawl infrequently. If you need to display instant content or the refreshed version of content, use the Content Query Web Part (CQWP) instead.
Search crawls only the major versions of content, never the minor versions. If you want to display the minor versions of your content, do that by using a CQWP.
Some site collection administrators mark sites to not be indexed. Content marked in this way is not available in a CSWP. If you want to return results from a site that is marked to not index, use the CQWP instead.
Add a Content Search Web Part to a page
To add a Content Search Web Part to a page
  1. Verify that the user account that performs this procedure is a member of the Designers SharePoint group on the publishing site collection.
  2. Browse to the page where you want to add the Web Part.
  3. Click the Settings menu, and then click Edit page.
  4. In the Web Part Zone where you want to add the Web Part, click Add a Web Part.
  5. In the Categories list, click Content Rollup.
  6. In the Parts list, click Content Search, and then click Add.
Content search web part in the SharePoint 2013
Content Search Webpart Content Search Webpart[/caption]

SharePoint 2013 : Set Content Search Web Part “QueryText” Attribute Programmatically

http://blogs.msdn.com/b/davidrei/archive/2012/12/27/sharepoint-2013-set-content-search-web-part-querytext-attribute-programmatically.aspx


SharePoint Add Link to Site Settings

SharePoint Add Link to Site Settings
Create a feature.
it will have elements.xml and feature.xml
[caption id="attachment_5245" align="alignnone" width="300"]Element xml Element xml[/caption][caption id="attachment_5246" align="alignnone" width="300"]Feature xml Feature xml[/caption]
Change Feature Id of feature.xml
Change customAction id of element.xml it should be assembly namesapce.
You can change the scope: it can be either farm, webapplication, site or web.

The search request was unable to connect to the search service

Solution:
Open SharePoint 2010 Central Administration Home page, click Application Management.
On the Application Management page, in the Service Applications section, click Configure service application associations.
On the Service Application Associations page, select Web Applications from the View drop-down menu.
Under Web Application / Service Application, select web application which you have create FAST Search site
Edit the following group of connections: Select "Custom"
"Search Service Application" should check.

[caption id="attachment_6553" align="alignnone" width="300"]The search request was unable to connect to the search service
The search request was unable to connect to the search service[/caption]

The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly


Solution:
Configure outgoing email server in central admin.
If still you are getting same error.
Please check the email body text, it should not have any spam content.

SharePoint Interview

What does AllowUnsafeUpdates do?
If your code modifies Windows SharePoint Services data in some way, you may need to allow unsafe updates on the Web site, without requiring a security validation. You can do by setting the AllowUnsafeUpdates property. C#:
view sourceprint?
using(SPSite mySite = new SPSite("yourserver"))
{ using(SPWeb myWeb = mySite.OpenWeb())
{
myWeb.AllowUnsafeUpdates = true;
SPList interviewList = myWeb.Lists["listtoinsert"];
SPListItem newItem = interviewList.Items.Add();
newItem["interview"] = "interview";
newItem.Update();
}
}


What does RunWithElevatedPrivileges do?
Assume that you have a Web Part in which you want to display information obtained through the Windows SharePoint Services object model, such as the name of the current site collection owner, usage statistics, or auditing information. These are examples of calls into the object model that require site-administration privileges. Your Web Part experiences an access-denied error if it attempts to obtain this information when the current user is not a site administrator. The request is initiated by a nonprivileged user. you can still successfully make these calls into the object model by calling the RunWithElevatedPrivileges method provided by the SPSecurity class. C#:
view sourceprint?
SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))
{
using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID))
{
string SiteCollectionOwner = ElevatedsiteColl.Owner.Name;
string Visits = ElevatedsiteColl.Usage.Visits.ToString();
string RootAuditEntries = ElevatedSite.RootFolder.Audit.GetEntries().Count.ToString();
}
}
});


- What is a SharePoint Feature? What files are used to define a feature?
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances.
Scopes include
• Farm
• WebApplication
• Site (site collection)
• Web (site)
Features have their own receiver architecture, which allow you to trap events such as when a feature is
• installing
• uninstalling
• activated
• deactivated
The element types that can be defined by a feature include
• menu commands
• link commands
• page templates
• page instances
• list definitions
• list instances
• event handlers
• workflows
The two files that are used to define a feature are
• feature.xml
• manifest file(elements.xml)
The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.
Common stsadm commands associated with feature are
• stsadm -o installfeature
• stsadm -o uninstallfeature
• stsadm -o activatefeature
• stsadm -o deactivatefeature


- What are content types ?
A content type is a flexible and reusable WSS type definition that defines the columns and behavior for an item in a list or a document in a document library.
For example,
-you can create a content type for a customer presentation document with a unique set of columns, an event handler, and its own document template.
-You can create a second content type for a customer proposal document with a different set of columns, a workflow, and a different document template.
Then you can attach both the contenttypes to a document library, which allows you to capture metadata based on the contenttype selected during creation of the document.


Content type can be created by the following
• from the rootweb of a site collection, go to Site Action > Site Settings > Galleries > Site content types
• using a feature


Workflow can be applied to what all elements of SharePoint ?
While workflow associations are often created directly on lists and document libraries, a workflow association can also be created on a content type that exists within the Content Type Gallery for the current site or content types defined within a list.
In short, it can be applied ...
• At the level of a list (or document library)
• At the level of a content type defined at site scope
• At the level of a site ( Sharepoint 2010 )


- What are the ways to initiate the workflow ?
• Automatic (on item added or item deleted)
• Manual (standard WSS UI interface)
• Manual (Custom UI Interface)
• Programatically through custom code


7. What are the types of input forms that can be created for a workflow ?
You can create four different types of input forms including an association form, an initiation form, a modification form, and a task edit form. Note that these forms are optional when you create a workflow template.


8. What are ways to create input forms for workflow ?
Two different approaches can be used to develop custom input forms for a WSS workflow template.
• You can create your forms by using custom application pages, which are standard .aspx pages deployed to run out of the _layouts directory. ( disadv: lot of code required when compared to Infopath approach)
• using Microsoft Office InfoPath 2007 (disadv: picks up a dependenct on MOSS, i.e. it cannot run in a standalone WSS environment)


9. What is the difference between method activity and event activity in WF ?
A method activity is one that performs an action, such as creating or updating a task. An event activity is one that runs in response to an action occurring.


10. What does SPWeb.EnsureUser method do?
Checks whether the specified login name belongs to a valid user of the Web site, and if the login name does not already exist, adds it to the Web site. e.g SPUser usr = myWeb.EnsureUser("mmangaldas");


11. While creating a Webpart, which is the ideal location to Initialize my new controls ?
Override the CreateChildControls method to include your new controls. To make sure that the new controls are initialized.. call 'EnsureChildControls' in the webparts Render method. You can control the exact Rendering of your controls by calling the .Render method in the webparts Render method.


12. How to query from multiple lists ?
Use SPSiteDataQuery to fetch data from multiple lists. more details..


13.How Does SharePoint work?
The browser sends a DAV packet to IIS asking to perform a document check in. PKMDASL.DLL, an ISAPI DLL, parses the packet and sees that it has the proprietary INVOKE command. Because of the existence of this command, the packet is passed off to msdmserv.exe, who in turn processes the packet and uses EXOLEDB to access the WSS, perform the operation and send the results back to the user in the form of XML.


14. What is the difference between Syncronous & Asyncronous events?
Syncronous calls ending with 'ing' E.g. ItemDeleting Event Handler code execute BEFORE action is committed WSS waits for code to return Option to cancel and return error code
Asyncronous calls ending with 'ed' E.g. ItemDeleted Event Handler code executes AFTER action is committed WSS does not wait for code to return Executed in its own Worker thread.


15. What is ServerUpdate() ?
Any changes in the list, i.e. new addition or modification of an item.. the operation is complete by calling the Update method.But if a List is set to maintain versions .. and you are editing an item, but don't want to save it as a new version, then use the SystemUpdate method instead and pass in 'false' as the parameter.


16. What is query.ViewAttributes OR how can you force SPQuery to return results from all the folders of the list?
If you use SPQuery on any SPlist .. it will bring back results from the current folder only. If you want to get results from all the folders in the list.. then you need to specify the scope of the query by the use of ViewAttributes..
e.g. query.ViewAttributes = "Scope=\"Recursive\"";


Business Impact with existing applications:
Slow responsiveness to business and user needs
Costly custom development and maintenance
Poor sharing inside and outside the organization
Difficult to find the right content, data, and people
Increasing information management risk
Solution for above problems…. MOSS 2007
A unified, enterprise-ready solution that boosts organizational
Effectiveness by:
• making information and knowledge sharing intuitive and easy
• controlling and reusing content while reducing information management risk
Enabling faster and more insightful decision making


Is there any way to send Email in sharepoint?
Ans) Using SPUtility we can send Emails, but we can’t set priority of the email.
We can send a email using Sysntem.Net.Mail.
SPUtility.SendEmail(site, false, false, "e-mail_address", "Web Discussion Report", Msg);
http://www.fpweb.net/support/sharepoint-hosting/
Web parts: http://www.fpweb.net/support/sharepoint-hosting/download-web-parts.asp

How to Change the Logo on Your SharePoint Site
Change the Header image:
1. Log in to your SharePoint Site
2. On the right, click Site Actions >> Site Settings
3. Under Look and Feel click Title, Description, and Icon
4. Skip down to the Logo URL and Description section.
5. In the URL field, enter the full URL for the logo image you want at the top of your SharePoint site.
NOTE: If it’s your own image, you can first upload it to a document library on your SharePoint Site and copy the URL.
6. Click Click Here to Test to ensure the image appears correctly.
7. If the imageappears correctly, enter an Alternative text description for the image. This text will appear when you hover over the picture.
8. Click OK to complete the process.
To change the Site Image
1. Log in to your SharePoint Site
2. On the right, click Site Actions >> Edit Page. You will now be in Page Editing Mode.
3. Above the Site Image, you’ll see a box that says Site Image with edit in the right corner. Click edit.
4. Click Modify Shared Web Part
5. In the first field, entitled Image Link, insert the URL of the image that you would like to use.
NOTE: If it’s your own image, you can first upload it to a document library on your SharePoint Site and copy the URL.
6. Click Test Link to ensure the image appears correctly
7. If the imageappears correctly, enter an Alternative text description for the image. This text will appear when you hover over the picture.
8. Change any other options on the appearance of your Site Image.
9. Click Apply to view the change or OK to complete the process.

How to Change the Title on Your SharePoint Site
The SharePoint title is the title at the top of your SharePoint site and also in the top bar of your Web browser when you access your SharePoint site. Changing the title is simple, however you must have full control permissions to do so. If you meet this criteria, simply follow the steps below.
1. Log in to your SharePoint site
2. Click Site Actions >> Site Settings
3. Under Look and Feel click Title, Description, and Icon
4. In the Title and Description section, fill in the Title.
5. Click OK.
Q. What are the data types which are supported as Lookup column in SharePoint.?
Ans). Only Single Line of Text and Calculated columns are supported as lookup columns.
Q: Name at least two shared services available in MOSS 2007
A: Shared Services Providers in MOSS 2007 can provide the following shared services:
• User Profiles
• Audiences
• Personal Sites
• Search
• Excel Services
• Forms Services
• Business Data Catalog (Requires Enterprise Edition)
Q: (i) Describe the purpose of a content type and; (ii) give an example of where they might be used.
A: (i) A content type groups a set of list columns together so that they can be reused in the same way across sites. (ii) They could be used as a set of metadata columns that need to be applied to every document in a site collection
Q: What is the performance impact of RunWithElevatedPrivileges?
A: RunWithElevatedPrivileges creates a new thread with the App Pool's credentials, blocking your current thread until it finishes
Q: Describe the difference between a list and a library.
A: Lists are collections of metadata or columns, which can have attached documents.
Libraries are collections of documents (Excel, InfoPath, Word, etc.) plus optional metadata.
Q: Why would you use a custom column?
A: It allows you to re-use the column in multiple libraries. Particularly useful if you use a Choice type to restrict the user input to a predefined set of answers, and when that list of answers will likely change.
Q. When modifying a list item, what is the "main" difference between using SPListItem.Update() and SPListItem.SystemUpdate()?
A. Using SystemUpdate() will not create a new version and will also retain timestamps.


Sharepoint document library source page on the server?
Ans)1
When you create a document library template files from the "12 hive" are ghosted into the SharePoint content database (SQL). The only proper way to edit those pages at that point is to use Microsoft SharePoint Designer.
Open SharePoint Designer and open the SharePoint web site in question and you will see your document library listed in the file explorer. Under your document library you will see a Forms folder, that Forms folder is what contains the source files that are rendered to the browser
Ans)2
SharePoint does not store the pages directly in the filesystem. The mechanism is a little less straightforward.
To understand this mechanism, You have to understand the concepts of Ghosting/Unghosting, and the ASP.NET Virtual Path Provider. The SharePoint stores the pages in the Database as BLOBS, and serves them up using the ASP.NET Virtual path provider.
The ASP.NET Virtual Path Provider provides an abstraction between ASP.NET and FileSystem. Instead of getting a System.IO.FileStream object directly from the filesystem, the provider uses MapPathBasedVirtualPathProvider and the MapPathBasedVirtualFile classes to get the FileStream object.
This abstraction allows ASP.NET to serve up pages from anywhere, without having to store the pages in an actual file system. This concept is used to implement Ghosting/Unghosting which basically means having a single copy of the page, and serving them up as different pages.
SharePoint leverages this new feature in ASP.NET 2.0, along with the improved BLOB storage functionality in SQL Server 2005 to serve up pages

Unable to get property 'TaxonomySession' of undefined or null reference


You are missing some of the below js files.
SP.Taxonomy.js
SP.Runtime.js
SP.js

How to use SharePoint Status Bar And Notification?

SP.UI.Status
SP.UI.Notify
Sharepoint 2010 have many new UI enhancements. Two enhancements are Status Bar and Notification Area. Both of these can be used to provide useful information to the users. Both of these appears under Ribbon Tab. Status Bar is mostly for something like permanent information. Notifications appears for certain period of time then disappears with some transition effects. Working with Status Bar  We can provide HTML content to the message. We can add images and styles. The status bar can have one of the pre defined colors(red, green, blue, yellow) depending on priority of the immage. For example if message is very important we can show it in red. Status bar is exposed SharePoint JavaScript API defined inside sharepointroot\templates\layouts\SP.js Methods exposed by SP.UI.Status
  • addStatus: Accepts three parameters Title, Message as HTML , show at begining as boolean. Returns status ID sid = SP.UI.Status.addStatus(strTitle, htmlMessage, boolatBegning)
  • removeStatus: removes status specified by status id. SP.UI.Status.removeStatus(sid)
  • removeAllStatus: Removes all Status bar messages. Pass true if you want to hide bar. removeAllStatus(true)
  • setStatusPriColor: Takes two parameter status id and colorsetStatusPriColor(sid,"red")
<script langauage="javascript"> var statusID; function ShowStatus() {    statusID = SP.UI.Status.addStatus("Information","This is my first status bar",true); } </script> The above script will show status bar in red.
SharePoint 2010 Status Bar
SharePoint 2010 Status Bar
We can show status bar in different colors depending on importance of message. If very important then use red, if warning message in then use yellow color. Working with Notifications Notification Area usually appears right corner below the ribbon. this is used when the users needs to to updated for the processes being performed. Like saving content, saved content. Methods exposed by SP.UI.Notify
  • addNotification: Accepts two parameters Message as html and a Boolean value indicating sticky or not. If second parameter is passed as false then notification disappears after 5 seconds. This method returns notification id.
  • removeNotification: Removes notification specified by notification id.
<script type="text/javascript">
notificationID = SP.UI.Notify.addNotification(
}
var notificationID;function ShowNotification() {"This is my first notification", true, " Tooltip", "Helloworld"); </script>
The above script will show sticky Notification. Pass second parameter as false in above script to hide Notification after 5 seconds.
SharePoint 2010 Notification
SharePoint 2010 Notification

WIPRO cognos Interview questions


diff b/w grouping and aggregation?
diff b/w dimension and regular dimension?
What is the use of Excel files in Cognos8?
WHAT STEPS SHOULD BE TAKEN BY A REPORT DEVELOPER TO INTERACT WITH THE
CLIENT SERVER?
What is Stich Query in Reportnet?
How can we improve performance of the reports?
What is parameter maps & Session parameter?
While running the reports how can we hide totals if the users do not require it?
What is the Main Difference between Conditional Block and Render Variable in Cognos. Both are used for Conditional rendering. But what is the Main Diff?
Can reportnet supports cubes?
How u provide security to reports??how u provide security to packages ?
How u migrate the reports from impromptu to reportnet?
How u will determine the performance tune will occur either in report or system?
Can reportnet supports cubes?
What is Report item?

TCS SSRS Interview

Question) Which versions of SSRS have you used?
Comment) Differences between 2005 and 2008 are quite big so if someone hasn't used 2008 or 2008 R2 before (or vice versa) than make sure you know this will require a few days to get up to speed with the
new/previous version. If the candidate used several versions ask to describe the differences between them.
Question) Have you got samples of your work?
Comment) If SSRS is main skills for the role than it is worth asking for samples (before interview) they will often tell you a lot about the candidate quality of work.
Question) Do you have Data Visualization skills? (optional)
Comment) If you need dashboards then it is worth asking this question (we will ask more specific questions later). This is also related to previous question. When you review samples ask the candidate or yourself two
questions) What is the purpose? and is it useful? Someone who does not know anything about data
visualization will usually use pie charts, gauges (exception is bullet chart which is classified as gauge in
SSRS, 3D effects, make colourful designs (without any colour meaning). Some candidates may mention
Stephen Few or Edward Tufte and this normally is a big plus.
Question) How have you learnt SSRS (on the job, articles, books, conferences)
Comment) The thing is that most people who read good books have usually an advantage over those who hasn't because they know what they know and they know what they don't know (but they know it exists and is available)…. Blog/Articles very in quality so best practise articles is a big plus+, conferences can be also a plus.
Question) Do you have certifications
Comment) This is rather disappointing point for me. Qualifications generally are welcome but unfortunately many people simply cheat. Companies run courses and then give questions and answers, or people find them on the internet. I've met people who had certification but knew very little, I've met people very experienced and knowledgeable without certification and people who have done certification for their selfsatisfaction and are experienced and knowledgeable. In other words be careful with certification…. It is easy to get misleading impression if you don't assess the candidate actual knowledge.
SSRS Development Questions
Question) How do you normally create reports (wizard/manually)?
Comment) If wizard in most cases then you got rather inexperienced person, if manually than it is usually good answer. The best answer is using a template. Generally developers create reports from scratch which is not bad but it is not very efficient either.
Question) Gives examples where you used parameters?
Comment) Typically you use parameters to filter data in datasets (or data on reports) but you can also use them to restrict values like the well-known make->model->year example. You can also have hidden and internal parameters which get very handy for more advanced stuff.
Question) Gives examples where you used parameters?
Comment) Typically you use parameters to filter data in datasets (or data on reports) but you can also use them to restrict values like the well known make->model->year example. You can also have hidden and internal parameters which get very handy for more advanced stuff.

Add New Item to List in Sharepoint using ClientContext

List list;
ListItem item;
string siteUrl = "http://sp2010";
private void ButtonCreate_Click(object sender, RoutedEventArgs e)
{
ClientContext spContext = new ClientContext(siteUrl);
Web oWebsite = spContext.Web;
ListCollection collList = oWebsite.Lists;
list = spContext.Web.Lists.GetByTitle("Announcements");
item = list.AddItem(new ListItemCreationInformation());
item["Title"] = "My new item";
item["Body"] = "My new Silverlight item.";
item.Update();
spContext.ExecuteQueryAsync(OnCreateSuccess, OnFailure);
}
private void OnCreateSuccess(object sender, ClientRequestSucceededEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("New Item Title: " + item["Title"]);
});
}
private void OnFailure(object sender, ClientRequestFailedEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("Request failed. " + args.Message + "\n" + args.StackTrace);
});
}

SharePoint 2010 Jquery Webpart


Create sharepoint blank solution
Add new webpart
Add below code in .cs file
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace CLIENTSIDE_JQueryWebPart.JQueryDemoWebPart
{
///
/// This Web Part renders client-side html and JavaScript that uses the jQuery
/// library. The jQuery code queries the SharePoint List Data web service to find the
/// items in the Announcements list in the intranet.contoso.com site.
///
///
/// It would be easier to do this in a Visual Web Part, because instead writing code
/// in the Render() method, you could just type the markup. However, Visual Web Parts
/// cannot be used in sandbox. By building a non-visual Web Part, you can distibute
/// your Web Part as a user control.
///
[ToolboxItemAttribute(false)]
public class JQueryDemoWebPart : WebPart
{
protected override void CreateChildControls()
{
}
protected override void Render(HtmlTextWriter writer)
{
//First, we must render a tag to link to jQuery. Because this is
//a demo, I've linked to the full version. To optimise production code, link to
//a minimised version such as jquery-1.6.3.min.js
writer.AddAttribute(HtmlTextWriterAttribute.Src, "http://ajax.microsoft.com/ajax/jquery/jquery-1.6.3.js");
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.RenderEndTag();
//Render the javascript getListItems() function
string functionJavaScript = @"
function getListItems() {
//Formulate a URL to the service to obtain the items in the Announcements list
//You must ammend this URL to match your site and list name
var Url = 'http://SERVER:9988/_vti_bin/ListData.svc/Announcements';
//call the jQuery getJSON method to get the Announcements
$.getJSON(Url, function (data) {
//Fomulate HTML to display results
var markup = 'Announcements:
';
//Call the jQuery each method to loop through the results
$.each(data.d.results, function (i, result) {
//Display some properties
markup += 'Title: ' + result.Title + '
';
markup += 'ID: ' + result.Id + '
';
markup += 'Body: ' + result.Body + '
';
});
//Call the jQuery append method to display the HTML
$('#JQueryDisplayDiv').append($(markup));
//Disable HyperLink
$('#ClickHere').attr('disabled', 'disabled');
});
}";
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.Write(functionJavaScript);
writer.RenderEndTag();
//Render the display html.
//First an h2 tag
writer.RenderBeginTag(HtmlTextWriterTag.H2);
//Then a hyperlink that calls the JavaScript method
writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:getListItems();");
writer.AddAttribute(HtmlTextWriterAttribute.Id, "ClickHere");
writer.RenderBeginTag(HtmlTextWriterTag.A);
writer.Write("Click Here to Obtain List Items");
writer.RenderEndTag();
//End the h2 tag
writer.RenderEndTag();
//Render a div to display results
writer.AddAttribute(HtmlTextWriterAttribute.Id, "JQueryDisplayDiv");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.RenderEndTag();
}
}
}

IBM cognos Interview questions


What is parameter maps & Session parameter?
What is the importance of Dimension in the cognos?
How to apply sorting to Crosstab report? If so please give me example? 2.How to create Report level Joins?explain with example?
After generating value prompt, when we run the report... then we will get the prompt in the output.. Along with that prompt we will get diff types of symbols highlighted......How can we hide those symbols?
How to limit the cut,copy and paste operations for an user in reportlevel? Can anyone please send me the steps as i am new to cognos?
what is the difference between aggregation and role up aggregation ?
How u will design the report if the objects are available?
How can I convert a list report/Cross tab Report in Cognos EP series into a bar chart or pie chart etc.?
What are the versions you have worked?
There are some reports,we have to provide security to that reports like the hr manager should have access to hr department reports only and the accountant should have access to accounts reports where as the CEO can have access to all the reports. How to deal with this situation using Cognos?