Archive

Archive for November, 2010

Windows Web Services API / WWSAPI

November 30th, 2010 No comments

With the Windows Web Services API (WWSAPI), you can connect your C/C++ client applications with web services. You can also create C/C++ server-side web service end-points. WWSAPI is new with Windows 7 (client) and Windows Server 2008 R2 (server). WWSAPI is also back-ported to all formally supported versions of Windows (client and server). The WWSAPI runtime library (WebServices.dll) is a native-code implementation of WS-* family of protocols for SOAP based web services.

More reading here: http://code.msdn.microsoft.com/wwsapi

VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
Categories: Architecture, DOTNET, News

Cron Task–sync files to an FTP folder

November 30th, 2010 1 comment

This script I had to write to sync one folder with a remote FTP folder. I used this as a cron task.

<?php
	set_time_limit(3600);
 
	// Connection details and folder details here
	require_once("ftpconnection.php"); 
 
	$ftp = ftp_connect($ftphost, $ftpport);
	if (!ftp_login($ftp, $ftpuser, $ftppass)) die("Could not connect!");
 
	// Check if files exists on local share, if exists then move to remote ftp
 
	if ($localdir = opendir($localshare)) {
		while (false !== ($file = readdir($localdir))) {
			$filename = $localshare . "\\" . $file;
			// I do not want to sync folders :)
			if (!is_dir($filename)) { 
				// Backup files -in case if the files gets corrupted
				$backupfilename = $localbackup . "\\" . $file; 
				$uploaded = ftp_put($ftp, $file, $filename, 
									FTP_BINARY);
				if ($uploaded) {
					// This line is used for "moving" files 
									to backup
					rename($filename, $backupfilename); 
				}
			}
		}
	}
 
	ftp_close($ftp);
?>
VN:F [1.9.18_1163]
Rating: 4.8/5 (5 votes cast)
Categories: PHP

Hate store procedures to use with .NET?

November 25th, 2010 No comments

Not a good idea though!

It is okay to use multi lines queries with ADO.NET. May people do not know about this. Only confusion is about the parameters. You simply ignore the ALTER/CREATE statements and DECLARE portion of parameters on the actual stored procedure. Parameters you can add to a command object just like you do it for a stored procedure. Consider below sample code:

using System;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
 
namespace sqltest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            string constr =
                "Data Source=blah;Initial Catalog=blah;User Id=blah;Password=blah;";
 
            SqlConnection con = new SqlConnection(constr);
 
 
            string qry = @"SELECT @UserID=UserID FROM dbo.Events WHERE 
			HexNumber = @HexNumber; 
 
			if (@UserID='') 
				Begin 
					Select @UserID=('CKU' + convert(varchar(10), 
					(select top 1 UserAutoID 
					from dbo.Users order by UserAutoID desc)+1));
					Insert into dbo.Users (UserID) values 
					(@UserID);
					insert into dbo.Events(HexNumber, UserID) 
					values (@HexNumber,@UserID);
					SELECT UserID, Score='0' 
					from dbo.Events WHERE HexNumber = @HexNumber;
				End					
			Else 
				SELECT UserID, Score from dbo.Events where 
				HexNumber=@HexNumber;";
 
 
            SqlCommand cmd = new SqlCommand(qry);
            cmd.Parameters.Add(new SqlParameter("@HexNumber","4501"));
            cmd.Parameters.Add(new SqlParameter("@UserID", ""));
 
            cmd.Connection = con;
            cmd.CommandType = CommandType.Text;
 
            con.Open();
            SqlDataReader reader = cmd.ExecuteReader();
 
            while (reader.Read())
            {
                listBox1.Items.Add(reader[0] + " | " + reader[1]);
            }
 
            con.Close();
        }
 
    }
}
VN:F [1.9.18_1163]
Rating: 5.0/5 (1 vote cast)
Categories: C#, SQL

Web Designers vs. Web Developers

November 23rd, 2010 No comments

 

Source: http://sixrevisions.com/infographics/web-designers-vs-web-developers-infographic/

VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
Categories: General

Implementing Process in a company

November 22nd, 2010 No comments

What are the challenges you will have to face when you try to set some process in place?

  • Issues from Employees
  • Issues from Management
  • Lack of Time etc.

There is no any company exists without any process. So, we need to say it is “changing a process” rather than implementing a process.

Believe me, the biggest challenge will be to educate the management.

I remember a story telephone. When the telephone department got their first button based phones, they decided to give first to the shops/markets in the city. But the next day of their installation, they got request to change the phones back to their old-rotary-dial phones complaining the new phones are slowing down their business.

The same case will happen to the new environment also. Usually management will not be interested in a sudden decrease of their income unless they got multiple businesses to balance with. So a better approach for them is to start implementing the process “gradually”. They must trust the people who are responsible for the implementation and should not criticize. Implementers also should try their best to help the management understand what are the benefits they will achieve by doing a task. But once the company do not show trust to their employees, it becomes a difficult thing to implement a process. They should not expect a “magic” or a quick change. I know many companies who hire senior people with the intention to change the process from day X. They should let the person – give time – to learn the current system in the company, plan how to change, etc.

Granting freedom and resource is an important thing. If one person want to introduce a bug tracking system and management delays the decision, what will happen? as a side effect, the person who try to implement this will get bored and stop initiating such requests.

Micro-Management – Senior people usually do not like this. Instructions must be communicated but micro-instructions will always let the guy think “then why I am here?”.

It is impossible to implement a ready-made process in an environment. The particular form of process must be customized based on various criteria then only it will suit there. So it takes time and all are brain-works. So give them some time and freedom.

Employees usually love a change in their environment always. Only problems there may occur are emotional problems like egos, jealousy, superiority complex etc. which will get eliminated automatically when the time is running and all these properties are inevitable for any professional environment.

VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
Categories: Project Management

Star rating with PHP–without using JavaScript/Ajax

November 18th, 2010 No comments

Old school logic, but still relevant at least for Face Book applications Winking smile

<?php
	if (isset($_POST["s1_x"]) || isset($_POST["s2_x"]) 
		|| isset($_POST["s3_x"])) {
 
		$rating = 0;
		if (isset($_POST["s1_x"])) {
			$rating = 1;
		} else if (isset($_POST["s2_x"])) {
			$rating = 2;
		} else if (isset($_POST["s3_x"])) {
			$rating = 3;
		}
 
		// Change this to database call
		file_put_contents("rating.ini", $rating);
 
	}
 
	// Change this to database call
	$str = file_get_contents("rating.ini");
 
	$s1 = $s2 = $s3 = "star1";
 
	switch ($str) {
		case 3:
			$s3 = "star2";
		case 2:
			$s2 = "star2";
		case 1:
			$s1 = "star2";
	}
?>
<form action="index.php" method="post">
<table border="0">
  <tr>
    <td> <input type="image" src="&lt;?= $s1 ?&gt;.gif" name="s1" /></td>
    <td><input type="image" src="&lt;?= $s2 ?&gt;.gif" name="s2" /></td>
    <td><input type="image" src="&lt;?= $s3 ?&gt;.gif" name="s3" /></td>
  </tr>
</table>
</form>
VN:F [1.9.18_1163]
Rating: 3.8/5 (150 votes cast)
Categories: PHP

Just crossed 800th post on k-mug

November 11th, 2010 No comments

After revamping the website, the technical community forums – http://k-mug.org, I just touched 800th post which is the highest contributed count.

On previous website also I was the top person. That time I had around 1700 posts If I remember correctly.

VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
Categories: General

Web Camps India – Nov 16th to Dec 3, 2010

November 11th, 2010 No comments

Read more details here – http://www.microsoft.com/india/events/webcamps2010/default.aspx

@ Bangalore | Hyderabad | Chennai | Pune

Register Now!.

VN:F [1.9.18_1163]
Rating: 5.0/5 (1 vote cast)
Categories: News

Free ebook: Programming Windows Phone 7, by Charles Petzold

November 9th, 2010 No comments

- News URL here.

- Download URL here.

- Download Sample code in book here.

VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
Categories: DOTNET, News

Microsoft Lync 2010

November 3rd, 2010 No comments

Home

 

Microsoft Lync (old Microsoft Office Communicator) is an instant messaging client used with Microsoft Lync Server and is the replacement for Windows Messenger which was used with Exchange Messaging Server. Compared to Windows Live Messenger (previously known as MSN Messenger) it has an expanded feature set that is targeted toward corporate (enterprise) environments.

 

More reading here.

VN:F [1.9.18_1163]
Rating: 0.0/5 (0 votes cast)
Categories: News