Thursday, December 4, 2008

Remoting in C#

Remoting is a framework built into Common Language Runtime (CLR) in order to provide developers classes to build distributed applications and wide range of network services. Remoting provides various features such as Object Passing, Proxy Objects, Activation, Stateless and Stateful Object, Lease Based LifeTime and Hosting of Objects in IIS. I'm not going into detail of these features

Remoting Object

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace RemotingSamples
{
public class RemoteObject : MarshalByRefObject
{

public RemoteObject()
{
Console.writeline("Remote object activated");
}

///return message reply
public String ReplyMessage(String msg)
{
Console.WriteLine("Client : "+msg);//print given message on console
return "Server : Yeah! I'm here";
}
}
}
and wide range of network services. Remoting provides various features such as Object Passing, Proxy Objects, Activation, Stateless and Stateful Object, Lease Based LifeTime and Hosting of Objects in IIS. I’m not going into detail of these features because it will take 3 to 4 tutorials. Here I’m presenting a simple client/server based application in order to provide you easy and fast hands on Remoting.


This is the object to be remotely access by network applications. The object to be accessed remotely must be derived by MarshalByRefObject and all the objects passed by value must be serializable.

The remote object must be compiled as remoteobject.dll which is used to generate server and client executable.


Server

This is the server application used to register remote object to be access by client application. First, of all choose channel to use and register it, supported channels are HTTP, TCP and SMTP. I have used here TCP. Than register the remote object specifying its type.
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace RemotingSamples
{
public class Server
{
public Server()
{
}
public static int Main(string [] args)
{
//select channel to communicate
TcpChannel chan = new TcpChannel(8085);
ChannelServices.RegisterChannel(chan); //register channel
//register remote object
RemotingConfiguration.RegisterWellKnownServiceType(
Type.GetType("RemotingSamples.RemoteObject,object"),
"RemotingServer",
WellKnownObjectMode.SingleCall);
//inform console
Console.WriteLine("Server Activated");

return 0;
}
}
}

Client

This is the client application and it will call remote object method. First, of all client must select the channel on which the remote object is available, activate the remote object and than call proxy’s object method return by remote object activation.
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using RemotingSamples;

namespace RemotingSamples
{
public class Client
{

public Client()
{
}
public static int Main(string [] args)
{
//select channel to communicate with server
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
RemoteObject remObject = (RemoteObject)Activator.GetObject(
typeof(RemotingSamples.RemoteObject),
"tcp://localhost:8085/RemotingServer");
if (remObject==null)
Console.WriteLine("cannot locate server");
else
remObject.ReplyMessage("You there?");

return 0;
}
}
}

C# Send E-Mail


Here's the code to send an e-mail using .Net 2.0's System.Net.Mail namespace. Your SMTP server address is specified in the SmtpClient object's constructor. If you don't know your server address you may be able to find it in your e-mail client's configuration.
Note: the .Net 1.1 System.Web.Mail namespace is obsolete as of .Net 2.0. Use the System.Net.Mail namespace in .Net 2.0 apps.


using (MailMessage mailMessage = new MailMessage(new MailAddress(fromTextBox.Text), new MailAddress(toTextBox.Text))){ mailMessage.Body = bodyTextBox.Text; mailMessage.Subject = subjectTextBox.Text; try { SmtpClient smtpClient = new SmtpClient(serverAddressTextBox.Text); smtpClient.Send(mailMessage); } catch (Exception ex) { MessageBox.Show(ex.Message, "EMail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }}

SQL server(T-Sql) optimization Tips

Use views and stored procedures instead of heavy queries.
It reduces network traffic, coz client will send to server only stored procedure or view name (in certain cases heavy-duty queries might degrade performance upto 70%) instead of large heavy-duty queries text. This also facilitates permission management as you can restrict user access to table columns .
Use constraints instead of triggers
Constraints r much more efficient than triggers and can boost performance. So use constraints instead of triggers, whenever possible.
Use table variables instead of temporary tables.
Table variables require less locking and logging resources than temporary tables, so table variables should be used whenever possible (available in SQL Server 2000 only).
Use UNION ALL statement instead of UNION, whenever possible.
The UNION ALL statement is much faster than UNION, because UNION ALL statement does not look for duplicate rows, and UNION statement does look for duplicate rows, whether or not they exist.
Try to avoid using the DISTINCT clause, whenever possible.
Because using the DISTINCT clause will result in some performance degradation, you should use this clause only when it is necessary.
Try to avoid using SQL Server cursors, whenever possible.
SQL Server cursors can result in some performance degradation in comparison with select statements. Try to use correlated sub-query or derived tables, if you need to perform row-by-row operations.
Try to avoid the HAVING clause, whenever possible.
The HAVING clause is used to restrict the result set returned by the GROUP BY clause. When you use GROUP BY with the HAVING clause, the GROUP BY clause divides the rows into sets of grouped rows and aggregates their values, and then the HAVING clause eliminates undesired aggregated groups. In many cases, you can write your select statement so, that it will contain only WHERE and GROUP BY clauses without HAVING clause. This can improve the performance of your query. If you need to return the total table's row count, you can use alternative way instead of SELECT COUNT(*) statement.There r 2 ways to do thisSELECT COUNT(*) statement makes a full table scan to return the total table's row count, it can take very many time for the large table. There is another way to determine the total row count in a table. You can use sysindexes system table, in this case. There is ROWS column in the sysindexes table. This column contains the total row count for each table in your database. So, you can also use the following select statement instead of
SELECT COUNT(*)
:
SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name')
So, you can improve the speed of such queries in several times. Use SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a T-SQL statement.This can reduce network traffic, because your client will not receive the message indicating the number of rows affected by a T-SQL statement.
Use the WHERE clause.
Results in good performance benefits, because SQL Server will return to client only particular rows, not all rows from the table(s). This can reduce network traffic and boost the overall performance of the query.
Use the select statements with TOP keyword or the SET ROWCOUNT statement, if you need to return only the first n rows.
Can improve performance of your queries coz smaller result set will be returned. This can also reduce the traffic between the server and the clients.
Try to return only the particular columns from the table, not all table's columns.
Gives u good performance benefits, because SQL Server will return to client only particular columns, not all table's columns. This can reduce network traffic and boost the overall performance of the query.

Message

40 sacked for fudging travel bills: Satyam

Close on the heels of giving pink slips to a few hundred of its associates, Satyam Computer Services has sacked 40 employees on the allegations that they fudged travel bills.
“We take a strong view on this issue. We reimburse employees’ travel costs as they go on trips and relocate. When they are not using the bookings done at the company offices, they submit bills given by the service providers,” a Satyam spokesperson said.

“In this case, we found that the bills were fudged over a period of three months,” the spokesperson added.
The idea is to send a strong message to the staff on this issue, keeping in mind the increasing travel costs.

Source: Sify.com

IT Industry News

Activision inks deal with Microsoft unit

Activision Blizzard Inc. has signed a deal with Microsoft Corp. subsidiary Massive Inc. allowing Massive to provide a platform for dynamic, in-game advertising for 18 of Activision's titles, including "Guitar Hero: World Tour" and "James Bond: Quantum of Solace." The two companies have worked on other games in the past, such as "Guitar Hero III: Legends of Rock" and "Tony Hawk's Proving Ground."

The multi-year agreement covers the titles on the PC and Xbox 360 platforms. In a separate agreement, the two companies will partner for ads on Activision's Battle.net Web service, which fosters massive online play for such games as "World of Warcraft."

Source: bizjournals.com

Oracle buys Tacit’s IP
Plans to integrate Tacit Software into Oracle Beehive a secure, integrated, standards-based enterprise collaboration platform

Oracle reports it has purchased Tacit Software’s intellectual property (IP) and hired its software engineers. Tacit is well known for automated profiling technology, and its expertise location solution helps organizations uncover new opportunities for collaboration. Financial details of the transaction were not disclosed.

Oracle plans to integrate Tacit Software into Oracle Beehive, a secure, integrated, standards-based enterprise collaboration platform. The combined solution is expected to enable enterprises to make effective and immediate use of the knowledge present in their people, messaging and content.

Source: kmworld.com

IBM Introduces a Smarter Way to Manage Talent

IBM announced the first holistic offering in the talent management marketplace, combining world-class human capital software, consulting services and information technology integration to enable enterprises to implement globally integrated workforce and talent management.

The new offering, IBM Workforce and Talent Solutions, will help companies become smarter and more integrated in all aspects of managing the human capital lifecycle to create measurable improvements in people and business productivity. Driving efficiency and effectiveness in people -- one of the largest assets and costs in a business -- is increasingly important to achieving competitive advantage and to manage the effects of the downturn in the global economy. It is a combination of world-class human capital consulting services, IBM software assets: Cognos, Lotus, IBM Research and market leading human capital software: Saba and SuccessFactors.

According to a recent study by IBM and the Human Capital Management Institute, companies that apply effective and integrated workforce and talent management strategy and practices demonstrate significantly better financial performance compared to their industry peers.

Source: marketwatch.com



ITC, Infosys to set up mini sanitary napkin making units for rural India

India's multi-business conglomerate ITC Limited and Infosys, a leading technology service provider would soon be setting up mini sanitary napkin making machines at various locations in the country to generate rural employment. As part of the companies' corporate social responsibility (CSR), the corporate houses would be installing the innovative machines created by Coimbatore-based A Muruganandam, who has already installed 57 units in seven states across the country. What's more, the innovator is also in talks with Ahmedabad-based Self Employed Women's Association, which is keen on setting up similar units in Gujarat

Source: Business Standard

Satyam plans to send staff on sabbatical to trim costs
Planning to shift employees to take up social activities relating to its own corporate social responsibility programs

Satyam Computer Services, the country’s fourth-largest services exporter, is taking a cue from its rival Infosys to trim costs as the global slowdown could impact revenues.

The company is looking at sending its employees on a sabbatical, but will take a final decision depending on the third-quarter results. Satyam has already scaled down its hiring projections for the current fiscal to around 8,000-10,000 compared to 15,000 that it had earlier projected.

“We are looking at various options to reduce costs and sabbatical is one such option. We will be able to shift our employees to take up social activities relating to our own corporate social responsibility programs. Employees can also look at working with NGOs during the time of sabbatical. But, they will have to compromise on their salary during sabbatical as the pay structure will be lower than what they are currently drawing,” said SV Krishnan, global head (HR), Satyam Computer Services.

Source: The Economic Times

TCS reviewing capex plans: Ramadorai

Tata Consultancy Services Ltd (TCS) is in the process of reviewing its capital expenditure plans for the current year due to the global economic crisis.

Speaking to the media on the sidelines of the Internet Governance Forum 2008 here, the Chief Executive Officer and Managing Director of TCS, S. Ramadorai, said, “We may shift the capex plans in terms of delays in technologies, strategy and infrastructure plans.” He said the financial crisis was for real and it had impacted not just one country or company, but the entire world.

According to him, TCS was taking cost cutting measures in terms of productivity improvement, improving utilisation rates of its employees, power, and travel, apart from capex reduction. “Last quarter, the utilisation rates were around 81 percent, but now we hope to enhance it to between 82 and 83 percent,” he said.

Source: The Hindu Business Line

Wipro tech seeks to end job row
Wipro Technologies, met the West Bengal information technology (IT) minister Debesh Das and a section of students in Kolkata, to clear the row over delay or termination of campus recruitments

According to Pradeep Bahirwani, VP-talent acquisition, Wipro Technologies, “We made offers to 13,500 students in 2007-08 for joining our centres in 2008-09. Around 98 percent of the students have accepted our offers. Only a section of students were confused about the changes stated in letters we sent to them last week. Today we met them to clarify that they may join us as technical support engineers at our BPO division, instead of joining as project engineers. The salaries stated in the offer letter remain unchanged irrespective of which department they join.”

“When we recruited last year, the situation was different as the global recession had not set in. But now we are going to reevaluate our hiring plans according to demand,” Bahirwani said.

Source: Business Standard

Infosys: difficult days ahead

It’s now clear that for many of corporate India larger companies, earnings for 2008-09 will barely grow. For some — in sectors such as automobiles — they could fall. The picture gets worse for many in 2009-10 when the economy is expected to grow at only 6- 6.5 percent.

While Infosys may scrape through this year, brokerage CLSA believes that the Bangalore-headquartered firm may not be so lucky in 2009-10 and could see its revenues in dollar terms increase by just about 3 percent.

That could mean a fall in the earnings which, the report says, could set in at the operating profit level itself. Given the financial crisis in the US this is not really surprising; the environment is worsening and pricing could be under pressure. The banking and financial services vertical, to which Indian tech firms have a relatively high exposure, must be the culprit.

Source: Business Standard


IT Cos with BPO arms to steal show
Having won more than half of large BPO contracts announced during past one year, leading software services firms with back-office arms are set to become bigger players in the BPO market, says Datamonitor

Companies such as Tata Consultancy Services (TCS) and Cognizant also accounted for almost 80 percent of the total value of large BPO contracts awarded in the past one year. According to Datamonitor, 54.3 percent of all large BPO deals were signed by IT services vendors having BPO arms, and not specialist BPO firms.

"While the BPO players did account for 44.7 percent of all announced deals, their cumulative contract value reflects only 19.5 percent of overall deal value," said Vamshi Krishna Mokshagundam, analyst with Datamonitor India. "BPO services are being increasingly signed on as part of a bigger IT services contract."

Source: The Economic Times

NASSCOM pushes for changes in IT act
In the wake of security threat to data and personnel both, the IT Act 2000 will be amended to make it stronger, facilitating speedy trials and convictions

With heightened threat to cyber security, more so in the aftermath of the Mumbai blasts, it is likely that the IT Act 2000 will be amended to make it stronger, facilitating speedy trials and convictions. While the Cabinet has already approved it, the Bill for amending it is likely to be tabled in the coming winter session of the Parliament, Som Mittal, president of Nasscom, said at the Nasscom-DSCI Information Security Summit 2008 here on Tuesday.

Further, the National Skills Registry (NSR), an online database of IT professionals which potential employers use to verify the credentials of job seekers, will be linked to university registrations from next year so as to enable a better check on fake CVs by candidates and also cyber terror, Mittal said. Nasscom also expects IT companies to make it mandatory for employees to register with NSR, given the increased security concerns. Currently the NSR has a measly registration of 3.7 lakh candidates of the 20 lakh IT professionals in the country. Only about 69 firms are part of the NSR, as against 1,200 firms that are members of Nasscom. The registry was set up by Nasscom in association with the National Securities Depository in Mumbai in 2006.

Source: The Times of India

Meltdown and the spiral effect
Except Govt. sector rest of all industry sectors to face major effect of meltdown

Until now, the banking, financial services & insurance (BFSI) vertical was seen as the proverbial pot of gold for the Indian IT industry. With 30-40% of Indian IT services revenues emanating from the lucrative vertical, bellwethers in the tech industry ruled the roost.

That was then. As the magnitude of the global economic meltdown becomes clearer with each passing day, it is becoming evident that the BFSI vertical could well become the biggest casualty. And the likes of Tata Consultancy Services (TCS) or Infosys stand most exposed to uncertainties in the market. TCS gets around 43% of its revenues from BFSI, while the percentage for Infosys is at 33%.

Spillover of the negative sentiment does not stop at the BFSI vertical alone. Impact of the slowdown could percolate to other verticals as well.

Failed to access IIS metabase.

Solution : Put this in Start->Run :-"%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i"