Posts

Showing posts from 2015

Update Windows Form UI thread from another class c#

delegate void UpdateLabelDelegate(string LabelText); public partial class Form1 : Form {         private Class1 _class;         UpdateLabelDelegate ULD;         Dispatcher uiDispatcher;             public void UpdateLabel(string LabelText)         {             lbl_ClientCount.Text = LabelText;                   }         public void UpdateThread(string LabelText)         {             uiDispatcher.Invoke(ULD, new object[] { LabelText });         }                         public Form1()         {             InitializeComponent();             _clas...

Export records from SqlServer to Text file

The fastest way to export records form SQL Server table to a text file is to use BCP command. Step 1:  First step will be to enable XP_CMDSHELL. Use Master GO EXEC master.dbo.sp_configure 'xp_cmdshell', 0 RECONFIGURE WITH OVERRIDE GO EXEC master.dbo.sp_configure 'show advanced options', 0 RECONFIGURE WITH OVERRIDE GO Query Output: Configuration option 'xp_cmdshell' changed from 1 to 0. Run the RECONFIGURE statement to install. Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install. Step 2: Execute the following given query below EXEC xp_cmdshell 'bcp "SELECT ColumnName FROM [DataBaseName].[Schemas].[TableName]" queryout "C:\Temp\CountryRegion.txt" -T -c -t,'

select element after split in c#

string yourstring = "1:2:3";                                                                                                                        yourstring .Split(':').AsEnumerable().ElementAt(1);                                                                                output : 2 

post json to solr in C# using HttpPost

                string path = "http://localhost:8080/solr/collection1/update/json?commit=true";                 var httpWebRequest = (HttpWebRequest)WebRequest.Create(path);                 httpWebRequest.ContentType = "application/json";                 httpWebRequest.Method = "POST";                 using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))                 {                     string json = "[{\"id\":\"5\", \"title\":\"Testing JsonSolr\"}]";                     streamWriter.Write(json);                     streamWriter.Flush();       ...

Remove last char of string c#

YourString = YourString . Remove ( YourString . Length - 1 );

SolrNet error message : Object of type 'System.Collections.ArrayList' cannot be converted to type 'System.String'.

Consider SorlSearchResult as your class public class SolrSearchResult     {         [SolrUniqueKey("id")]         public string Id { get; set; }                  [SolrField("title")]         public string title { get; set; }         [SolrField("author")]         public string author { get; set; }     } Your issue is that the  title   field in your  SorlSearchResult  class is defined as a string, yet in solr schema.xml you have defined the title field as  multiValued="true"  which allows for multiple entries in the solr document and is shown in your solr return value.  <field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>                     The error message is...

how to Setup Apache Solr in tomcat

Image
>>  Go hear  to download the latest Java SE Runtime. >>  Download Apache TomCat >> Test tomcat server on your browser, it'll look this way >> Configure tomcat server, goto start  > Monitor TomCat >>  Stop Tomcat server, goto Start > Monitor Tomcat > General Tab> Stop >> Setup Solr Home Directory Download Latest Release of Solr  and unzip it in your local directory i.e. C:\Solr-4.6.0. Go to downloaded Solr folder above (step 1) and Copy solr.war file to Apache webapps folder. I.e. Copy C:\solr-4.6.0\dist\ solr-4.6.0.war  file  to  C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps folder (rename solr-4.6.0.war to solr.war). Create an empty Solr home folder. i.e. C:\solr Go to downloaded Solr folder above (step 1). Copy all files from C:\solr-4.6.0\solr-4.6.0\example\solr folder to C:\solr (Solr home folder). This will be your Solr home folder. Look into ...

SolrException: Unknown commit parameter 'waitFlush'

this problem was there with the older version of SolrNet, please  see this It's the zip file under artifacts.

jQuery Scroll to Top of Page on button click

$("#button").click(function(){ $ ( 'html, body' ). animate ({ scrollTop : '0px' }, 300 ); }); Note : 300 is given to slow down the scroll effect

jQuery AutoComplete Replace Text with Html

$("textbox").autocomplete({                                 minLength: 3,                                 delay: 1000,                                 source: function (request, response) {                                     $.ajax({                                         type: "GET",                                         url: "use your url here",                               ...

Block enter key

function stopRKey(evt) {     var evt = (evt) ? evt : ((event) ? event : null);     var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);     if ((evt.keyCode == 13) && (node.type == "text")) { return false; } } document.onkeypress = stopRKey;

Trigger submit button on enter key press from textbox

$(function(){     $('#textbox').keypress(function (e) {         var key = e.which;         if (key == 13)  // the enter key code         {             $('#submit').click();             return false;         }     }); });

Set or Override Browser Mode and Document mode IE

There are two ways we can achieve it 1. Using meta tag inside <head> tag      < meta http - equiv = "X-UA-Compatiable" content = "IE=edge" > 2. From Web.Config        < system . webServer > <httpProtocol> <customHeaders> < add name = "X-UA-Compatible" value = "IE=edge" /> </ customHeaders > </ httpProtocol > </ system . webServer > Note : Above give code is for IE9