Posts

Showing posts from August, 2014

XML file creating and reading in C#

To create an XML File from C# code side you can write down a small function that would take input parameters of the values that you want be insert in as values of  an XML File. public static bool CreateXml( string JuiceName, string CookieName, int NoOfBreadPackets, int NoOfEggs) { bool IsCreated = false ; try { XmlDocument doc = new XmlDocument(); XmlNode docNode = doc.CreateXmlDeclaration( "1.0" , "UTF-8" , null ); doc.AppendChild(docNode); XmlNode MainNode = doc.CreateElement( "GroceryItems" ); doc.AppendChild(MainNode); XmlNode Node1 = doc.CreateElement( "Juice" ); string str1 = Convert.ToString(JuiceName); Node1.InnerXml = str1; MainNode.AppendChild(Node1); XmlNode Node2 = doc.CreateElement( "

SharePoint Content Search

Content searching in documents write this code snippet in ASP.NET WCF service. public MethodResponse<ClientResult<ResultTableCollection>> SearchDocuments( string text, string token) { MethodResponse<ClientResult<ResultTableCollection>> response = new MethodResponse<ClientResult<ResultTableCollection>>(); UserCredential userCredential = new UserCredential(); try { userCredential = VerifyToken(token); if (userCredential != null ) { _ctx = GetClientContext(userCredential); if (_ctx != null ) { KeywordQuery keywordQuery = new KeywordQuery(_ctx); keywordQuery.QueryText = Convert.ToString(text); SearchExecutor searchExecutor = new SearchExecutor(_ctx); ClientR

SharePoint People Search

Searching of all user profiles in SharePoint 2013 by WCF CSOM service. In SharePoint for searching users by CSOM can be performed by writing the below code by creating a WCF service. Note:  1. 'MethodResponse' is a custom object to store list of string 2. 'token' is a unique string to verify stored UserCredentials public MethodResponse<List< string >> GetPeoples( string text, string token) { MethodResponse<List< string >> response = new MethodResponse<List< string >>(); List< string > lstMetadata = new List< string >(); UserCredential userCredential = new UserCredential(); try { userCredential = VerifyToken(token); if (userCredential != null ) { _ctx = GetClientContext(userCredential); if (_ctx != null ) {