Wednesday, July 13, 2011

Showing and Hiding Windows Form in System Tray in VB .net

Show and Hide Windows Form in System Tray

How to show and hide your form in windows system tray.

1. Add NotifyIcon class in your project (System.Windows.Forms.NotifyIcon) and drag it into form.




2. Change NotifyIcon properties.

BalloonTipIcon = Info
BalloonTipText = Running
Change Icon
Text = Running Your Program
Visible = True






3. Add code in Event Form1_Resize.

Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Resize
' If minimize form that will show in system tray.
If System.Windows.Forms.FormWindowState.Minimized = WindowState Then
sysMonTray.ShowBalloonTip(5, "Running", "Running Your Program", ToolTipIcon.Info)
Me.Hide()
End If
End Sub


4. Add code in Event NotifyIcon_Click to hide and show form.

Private Sub sysMonTray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles sysMonTray.Click

If Me.Visible Then
Me.Hide()
Else
Me.Show()
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Normal
Me.StartPosition = FormStartPosition.CenterScreen
End If

End Sub



With Regards,
Er.Animesh Nanda
Manusis Technologies Pvt.Ltd.
Bengaluru,
Karnataka,INDIA.

Thursday, July 7, 2011

Sphinx Commands For Beginners

#INDEXER

Configuring single index
indexer --config /full path/sphinx.conf myindex
Configuring all indices
indexer --config /full path/sphinx.conf --all
Rotating single index
indexer --rotate myindex
Rotating all indices
indexer --rotate --all
No output on rotation
indexer --rotate --all --quiet
Not to display progress detail
indexer --rotate --all --noprogress

#SEARCHD

Help
searchd --help
Configuring searchd
searchd --config /full path/sphinx.conf
Configuring port
searchd --port 9313

Status
searchd --status

Checking Status
searchd --config /full path/sphinx.conf --status
IO status
searchd --config /full path/sphinx.conf --iostats
CPU status
searchd --config /full path/sphinx.conf --cpustats

Setting PID file
searchd --config /full path/sphinx.conf --pidfile /home/myuser/sphinx.pid
Forcing to search specified index
searchd --index myindex
Stopping search process
searchd --config /full path/sphinx.conf --stop
Killing all search process
killall searchd


STEPS TO DO IF SPHINX SEARCH IS NOT WORKING

1. killall searchd
2. searchd --config /full path/sphinx.conf --status
3. searchd --pidfile --config /fullpath/sphinx.conf
4. searchd --config /full path/sphinx.conf --status
5. indexer --config /full path/sphinx.conf --all
6. indexer --rotate --all

COMMAND TO SEARCH
search -i myindex -e 'test'

Search Attributes
1. Match modes (--any / --phrase / --boolean / --ext / --ext2 / --filter attr v)
2. Set Limit (--limit count)
3. Set offset value (--offset count)
4. Sort by group (--group attr)
5. Sort by ASC/DESC (--sortby clause)
6. Sort by timestamp attribute (--rsort)




With Regards,
Er.Animesh Nanda
Software Developer,
Manusis Technology Pvt. Ltd.
Bengaluru,Karnataka,INDIA.

Tuesday, July 5, 2011

How to write Sphinx confugiration file ?

Four Steps to create a sphinx confugiration file

STEP - 1
Create a file named as sphinx.conf

STEP - 2
Declare a source as per following.

source src1
{
type = mysql
sql_host = host name
sql_user = user name
sql_pass = password
sql_db = database name
sql_port = 3306 # optional, default is 3306
sql_query = sql query for fetching data
sql_attr_uint = unique column eg id #can use more than one sql_attr_uint
sql_attr_timestamp = date_added
sql_query_info = sql query for viewing in command prompt
}

STEP - 3
Declare an index as per following.

index test1
{
source = src1
path = /var/lib/sphinxsearch/data/test1
docinfo = extern
charset_type = sbcs
enable_star = 1
min_prefix_len = 1
}


indexer
{
mem_limit = 32M
}


STEP - 4
Declare a searchd function as per following.

searchd
{
port = 9312
log = /var/log/sphinxsearch/searchd.log
query_log = /var/log/sphinxsearch/query.log
read_timeout = 5 #return null if no results found for 5 secs
max_children = 30
#maximum result to show in a dropdown or autocomplete
pid_file = /var/run/searchd.pid
max_matches = 1000 #maximum matches to get from database
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
}



After each modification on sphinx.conf file, developer needs to rotate the index declared in the confugiration file.



With Regards,
Er.Animesh Nanda
Software Developer,
Manusis Technology Pvt. Ltd.
Bengaluru,Karnataka,INDIA.