Sunday, October 31, 2010

Mobile applications developers needed

Location : Egypt
PiTechnologies is a fast growing company announcing its need to hire part-time
and freelancer mobile application developers . If you can see that you are
qualified to join the team , Kindly read the following vacancy and apply as it is required below

Vacancies
1.IPHONE Developeris required (Part time -Freelance) Reference Number M0
Qualifications :
- good command of English written and spoken
- experience in IPHONE application development (0-2) years
- bachelor degree is required
Job Description :
- would be responsible for analysing customer requirements and make design
document
- would be responsible for designing , coding , commenting code and testing
functions of the application as it is noted in the design document .
- would be responsible for fixing any bugs appears during the delivery period
2. Blackbery Developer is required (Part time -Freelance) Reference Number
M002
Qualifications :
- good command of English written and spoken
- experience in BlackBerry application development (0-2) years
- bachelor degree is required
Job Description :- would be responsible for analysing customer requirements and make design
document
- would be responsible for designing , coding , commenting code and testing
functions of the application as it is noted in the design document .
- would be responsible for fixing any bugs appears during the delivery period
3. Android Developeris required (Part time -Freelance) Reference Number M003
- good command of English written and spoken
- experience in Blackbery application development (0-1) years
- bachelor degree is required
Job Description :
- would be responsible for analysing customer requirements and make design
document
- would be responsible for designing , coding , commenting code and testing
functions of the application as it is noted in the design document .
- would be responsible for fixing any bugs appears during the delivery period
How to apply
To apply to any of the above vacancies you need to
1. Send your updated CV
2. Send another document that contains :
>Summery of your previous work in a separated file , sample code and screen shots will be a plus .
>Number of hours / each day in the week you would be available to work and the total number of hours per week .
ex : Sunday : 5 hours , Monday : 3 hours , Thursday : 0 hours ... total : 12
hours
All documents are to be attached in a mail with the job ref in the subject and
sent to
careers@pitechnologies.net

A Fast CSV Reader

To Download Sources Go to this Link

Introduction

One would imagine that parsing CSV files is a straightforward and boring task. I was thinking that too, until I had to parse several CSV files of a couple GB each. After trying to use the OLEDB JET driver and various Regular Expressions, I still ran into serious performance problems. At this point, I decided I would try the custom class option. I scoured the net for existing code, but finding a correct, fast, and efficient CSV parser and reader is not so simple, whatever platform/language you fancy.

I say correct in the sense that many implementations merely use some splitting method like String.Split(). This will, obviously, not handle field values with commas. Better implementations may care about escaped quotes, trimming spaces before and after fields, etc., but none I found were doing it all, and more importantly, in a fast and efficient manner.

And, this led to the CSV reader class I present in this article. Its design is based on the System.IO.StreamReader class, and so is a non-cached, forward-only reader (similar to what is sometimes called a fire-hose cursor).

Benchmarking it against both OLEDB and regex methods, it performs about 15 times faster, and yet its memory usage is very low.

To give more down-to-earth numbers, with a 45 MB CSV file containing 145 fields and 50,000 records, the reader was processing about 30 MB/sec. So all in all, it took 1.5 seconds! The machine specs were P4 3.0 GHz, 1024 MB.

Supported Features

This reader supports fields spanning multiple lines. The only restriction is that they must be quoted, otherwise it would not be possible to distinguish between malformed data and multi-line values.

Basic data-binding is possible via the System.Data.IDataReader interface implemented by the reader.

You can specify custom values for these parameters:

  • Default missing field action;
  • Default malformed CSV action;
  • Buffer size;
  • Field headers option;
  • Trimming spaces option;
  • Field delimiter character;
  • Quote character;
  • Escape character (can be the same as the quote character);
  • Commented line character.

If the CSV contains field headers, they can be used to access a specific field.

When the CSV data appears to be malformed, the reader will fail fast and throw a meaningful exception stating where the error occurred and providing the current content of the buffer.

A cache of the field values is kept for the current record only, but if you need dynamic access, I also included a cached version of the reader,CachedCsvReader, which internally stores records as they are read from the stream. Of course, using a cache this way makes the memory requirements way higher, as the full set of data is held in memory.

Latest Updates (3.7 Release)

  • Breaking: Added more field value trimming options.

Benchmark and Profiling

You can find the code for these benchmarks in the demo project. I tried to be fair and follow the same pattern for each parsing method. The regex used comes from Jeffrey Friedl's book, and can be found at page 271. It doesn't handle trimming and multi-line fields.

The test file contains 145 fields, and is about 45 MB (included in the demo project as a RAR archive).

I also included the raw data from the benchmark program and from the CLR Profiler for .NET 2.0.

Using the Code

The class design follows System.IO.StreamReader as much as possible. The parsing mechanism introduced in version 2.0 is a bit trickier because we handle the buffering and the new line parsing ourselves. Nonetheless, because the task logic is clearly encapsulated, the flow is easier to understand. All the code is well documented and structured, but if you have any questions, simply post a comment.

Basic Usage Scenario

Collapse
using System.IO; using LumenWorks.Framework.IO.Csv;  void ReadCsv() {     // open the file "data.csv" which is a CSV file with headers     using (CsvReader csv =            new CsvReader(new StreamReader("data.csv"), true))     {         int fieldCount = csv.FieldCount;         string[] headers = csv.GetFieldHeaders();          while (csv.ReadNextRecord())         {             for (int i = 0; i < class="code-keyword" style="color: blue; ">string.Format("{0} = {1};",                               headers[i], csv[i]));              Console.WriteLine();         }     } }

Simple Data-Binding Scenario (ASP.NET)

Collapse
using System.IO; using LumenWorks.Framework.IO.Csv;  void ReadCsv() {     // open the file "data.csv" which is a CSV file with headers     using (CsvReader csv = new CsvReader(                            new StreamReader("data.csv"), true))     {         myDataRepeater.DataSource = csv;         myDataRepeater.DataBind();     } }

Complex Data-Binding Scenario (ASP.NET)

Due to the way both the System.Web.UI.WebControls.DataGrid and System.Web.UI.WebControls.GridView handleSystem.ComponentModel.ITypedList, complex binding in ASP.NET is not possible. The only way around this limitation would be to wrap each field in a container implementing System.ComponentModel.ICustomTypeDescriptor.

Anyway, even if it was possible, using the simple data-binding method is much more efficient.

For the curious amongst you, the bug comes from the fact that the two grid controls completely ignore the property descriptors returned bySystem.ComponentModel.ITypedList, and relies instead on System.ComponentModel.TypeDescriptor.GetProperties(...), which obviously returns the properties of the string array and not our custom properties. SeeSystem.Web.UI.WebControls.BoundColumn.OnDataBindColumn(...) in a disassembler.

Complex Data-Binding Scenario (Windows Forms)

Collapse
using System.IO; using LumenWorks.Framework.IO.Csv;  void ReadCsv() {     // open the file "data.csv" which is a CSV file with headers     using (CachedCsvReader csv = new            CachedCsvReader(new StreamReader("data.csv"), true))     {         // Field headers will automatically be used as column names         myDataGrid.DataSource = csv;     } }

Custom Error Handling Scenario

Collapse
using System.IO; using LumenWorks.Framework.IO.Csv;  void ReadCsv() {     // open the file "data.csv" which is a CSV file with headers     using (CsvReader csv = new CsvReader(            new StreamReader("data.csv"), true))     {         // missing fields will not throw an exception,         // but will instead be treated as if there was a null value         csv.MissingFieldAction = MissingFieldAction.ReplaceByNull;          // to replace by "" instead, then use the following action:         //csv.MissingFieldAction = MissingFieldAction.ReplaceByEmpty;          int fieldCount = csv.FieldCount;         string[] headers = csv.GetFieldHeaders();          while (csv.ReadNextRecord())         {             for (int i = 0; i < class="code-keyword" style="color: blue; ">string.Format("{0} = {1};",                               headers[i],                               csv[i] == null ? "MISSING" : csv[i]));              Console.WriteLine();         }     } }

Custom Error Handling Using Events Scenario

Collapse
using System.IO; using LumenWorks.Framework.IO.Csv;  void ReadCsv() {     // open the file "data.csv" which is a CSV file with headers     using (CsvReader csv = new CsvReader(            new StreamReader("data.csv"), true))     {         // missing fields will not throw an exception,         // but will instead be treated as if there was a null value         csv.DefaultParseErrorAction = ParseErrorAction.RaiseEvent;         csv.ParseError += new ParseErrorEventHandler(csv_ParseError);          int fieldCount = csv.FieldCount;         string[] headers = csv.GetFieldHeaders();          while (csv.ReadNextRecord())         {             for (int i = 0; i < class="code-keyword" style="color: blue; ">string.Format("{0} = {1};",                               headers[i], csv[i]));              Console.WriteLine();         }     } }  void csv_ParseError(object sender, ParseErrorEventArgs e) {     // if the error is that a field is missing, then skip to next line     if (e.Error is MissingFieldException)     {         Console.Write("--MISSING FIELD ERROR OCCURRED");         e.Action = eErrorAction.AdvanceToNextLine;     } }

SW Tester (Web) At Sahm Group

Location : Egypt
Sahm Group Inc. has been established in 2002 as a diversified group of Strategic Business Units (SBUs) working mainly in the ICMT field (Information, communication and Media Technologies).
The corporate achieves a very fast growth in its services and Business units.
Moreover, Sahm Group has a customer base in over 11 Countries (Egypt, UAE, KSA, Kuwait, Sudan, USA, UK, Panama, Holland, Jordan, and Syria)
Our diverse corporate structure delivers solutions in various Fields such as Business process management, tailored software solutions, operations Outsourcing, multimedia design, and TV productions.
www. sahmgroup.comSAHM is pleased to announce the coming vacant place:
- Web Tester(With At Least 3 Years Experience)
Main Tasks:- Creating and executing an efficient and effective test of the applications under various system performance scenarios and various development life cycles.
- Designing test cases/plans.
- Direct software system testing and validation procedures,
- Analyzing and operating software for the purpose of finding bugs.
- Instantly test to meet aggressive product delivery schedules, and enough qualified test that defects don’t escape to our customers
- Building product quality, identifying defects, pre-deployment checklist and more.
- Quick understanding to the testing process or methodology, test-program concerns including test environment, data management, trouble reporting and resolution, and test design and development.
- Your work may linked to the quality assurance as you may be assigned to monitor and improve the process, make sure that any agreed-upon standards and procedures are followed, and ensure that problems are found and dealt with: “It is oriented to prevention”.
- Satisfy customer through professional customer support procedures and communications.
Kindly, send your CV to:sahmawy1@ymail.com
Please, put position title in mail subject

Senior PHP Developers for immediate hiring

Location : Egypt
We need the following positions for immediate hiring, CVs should be sent to mailto:vacanciesavailable@live.co.uk with job code as a subject.
· Senior PHP Developers (CODE: FTSPD):
o Excellent leadership skills
o Excellent planning and delegation skills
o Excellent communication skills
o Extensive knowledge of OOP
o 2-3 years of experience developing PHP Enterprise applications
o Linux experience is a plus
General Requirements :
ü Ability to communicate in English (Reading and Writing) is crucial, please don’t apply if you can’t speak, read/write English
ü Excellent communication skills
ü We're looking for creative enthusiastic people who can take an idea seriously and develop it into a fully deployed project

PHP5/MySQL Developer

Location : Egypt
new company in maadi looking for 2 developers (well payed)
If you have 2+ years of professional PHP web development experience and got the required skills ... apply now !
Required: php5, mvc framework experience (symfony, zend or other ), mysql, js/ajax
Preferred: lamp, french
send your cv to samy@hatla2ee.com

Senior Sharepoint Developer:

Location : Egypt
For A Multinational Co. working in IT Field (Cairo Branch):
Must have 6-8 years exp. in the same field
If you are interested just send your c.v to cv@strategic.ws and write the name of the vacancy on subject

Thursday, October 28, 2010

Jobs available @ datagear

Location : Egypt
Write the Subject of the mail with the job Code any other Subject will be discarded


- Experience with Data stage IBM is must.
- Experience 1 Years in SQL.
- DWH Experience is a plus.
- Ability to work in team.
- Ability to Work under Pressure.
- Ability to research and learn new technologies.

Send CV ON jobs@...


ETL specialist (ETL45)

Job Vacancies

Location : Egypt
A reputable multinational IT company requires experienced qualified candidates
to join its work force as
Senior SharePoint Developer (3+ years of experience)
Candidates must have high experience in the following areas:
• SharePoint Object Model.
• SharePoint Designer.
• ASP.NET Custom Development
• SharePoint Administration and Configuration.
• SQL Server
Senior .Net Developer (3+ years of experience)
Candidates must have high experience in the following areas:
• ASP.NET
• HTML
• CSS
• JavaScript
• SQL Server

Senior Web Designer (3+ years graphic design web UI experience)
Candidates must have high experience in the following areas:
• Experience/comfort working in a team environment
• Strong knowledge of web and Internet technologies
• Expert knowledge of client side user interface technologies: HTML/XHTML, CSS
• Expert at web standards for CSS-driven layouts
• Experience with formal usability testing and knowledge of usability principles
• Expert knowledge developing cross platform/browser compatible front end User
interfaces
• knowledge of Javascript/jquery and AJAX
• Design talent with a good eye for aesthetics and details
• knowledge of Flash design and action script
• Candidates must have a ready portfolio of previous work to show upon request
The selected candidates will work in small groups on multiple software
development projects, and will work closely with the assigned Project Managers
to deliver quality solutions to our client companies

Additional Skills & Competencies:
• Building and facilitating effective project development teams or integrated
project teams.
• A self-starter who requires minimal supervision.
• Excellent interpersonal and organizational skills, ability to handle diverse
situations, multiple projects and rapidly changing priorities.
• Ability to communicate with clients at all levels.
• Ability to come up with the best solution for given requirements.
• Ability to provide reasonably accurate estimates for projects, based on
client-provided technical and functional requirements.
Resumes to be sent toT.Jobs.Opportunity@...

The XMLHttpRequest Object

The XMLHttpRequest Object

All modern browsers support the XMLHttpRequest object (IE5 and IE6 uses an ActiveXObject).

The XMLHttpRequest object is used to exchange data with a server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

Create an XMLHttpRequest Object

All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) have a built-in XMLHttpRequest object.

Syntax for creating an XMLHttpRequest object:

xmlhttp=new XMLHttpRequest();
Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object:

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
To handle all modern browsers, including IE5 and IE6, check if the browser supports the XMLHttpRequest object. If it does, create an XMLHttpRequest object, if not, create an ActiveXObject:

Example

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

Top 25 Programming Errors Highlight Application Security Challenges

The SANS Institute and nearly 30 other organizations joined together to release an updated list of the 25 most common programming errors. The list underscores the need to inject more security into the application development process, experts say.
Roughly 30 national and international cyber-security organizations released Feb. 16 an updated list of the 25 most dangerous programming errors as part of an effort to inject security into the development process
In addition to the most common programming errors, the group settled on a standard for contract language between software buyers and developers to ensure
the buyers are not held liable for buggy code. Such code is at the heart of many breaches, including the recent Google attacks, the group noted.

“The CWE/SANS Top 25 Programming Errors list provides critical inputs every software organization needs to incorporate into their quality and security processes,” said Bill Curtis, director of the Consortium for IT Software Quality (CISQ), in a statement. “CISQ will be working to incorporate defined patterns for recognizing these weaknesses into its standardization for security measurement."

The list was put together by representatives from various vendors and government agencies, including the SANS Institute, McAfee and the National Security Agency. The programming errors are separated into three general groups: insecure interaction between components, risky resource management and porous defenses. Much of the list will sound familiar—failure to preserve SQL query structure (SQL injection), buffer overflow and failure to preserve Web page structure (cross-site scripting).

Also included in the report is the "Focus Profiles" section, which features rankings of the top 25 errors and 16 others according to criteria such as programming language or technical impact. The new list also adds a small set of the most effective "Monster Mitigations" to help developers eliminate entire groups of bugs.

“Developers and security testers will find more value in the 2010 list,” Veracode CTO Chris Wysopal told eWEEK. “The focus profiles allow the list to be more useful from different perspectives, and the Monster Mitigations give great prescriptive advice for eliminating many of the Top 25 from software.”

Developers are becoming more aware of security flaws, Wysopal continued. Still, there is a long way to go to improve adoption.

“The impediment is getting security processes and technology embedded in the software development lifecycle,” he said. “It’s adoption and usage. … Training needs to be adopted more. I am hopeful that computer-based training tailored to a developer’s language and platform can up the pace of awareness

Wednesday, October 27, 2010

7 programming languages on the rise

From Ruby to Erlang, once niche programming language are gaining converts in today’s enterprise
By Peter Wayner | InfoWorld
Print | 4 comments
In the world of enterprise programming, the mainstream is broad and deep. Code is written predominantly in one of a few major languages. For some shops, this means Java; for others, it's C# or PHP. Sometimes, enterprise coders will dabble in C++ or another common language used for high-performance tasks such as game programming, all of which turn around and speak SQL to the database.

Programmers looking for work in enterprise shops would be foolish not to learn the languages that underlie this paradigm, yet a surprising number of niche languages are fast beginning to thrive in the enterprise. Look beyond the mainstays, and you'll find several languages that are beginning to provide solutions to increasingly common problems, as well as old-guard niche languages that continue to occupy redoubts. All offer capabilities compelling enough to justify learning a new way to juggle brackets, braces, and other punctuation marks.

[ Keep up on key application development insights with the Fatal Exception blog and Developer World newsletter. | See how the latest Python IDEs and PHP tools fared in our recent InfoWorld Test Center reviews. ]

While the following seven niche languages offer features that can't be found in the dominant languages, many rely on the dominant languages to exist. Some run on top of the Java Virtual Machine, essentially taking advantage of the Java team's engineering. And when Microsoft built C#, it explicitly aimed to make the virtual machine open to other languages. That detail may help make deployment easier, but it doesn't matter much to the programmer at creation time.

Either way, these seven languages are quickly gaining converts in the enterprise. Perhaps it's time to start investigating their merits.

Programming languages on the rise: Python
There seems to be two sorts of people who love Python: those who hate brackets, and scientists. The former helped create the language by building a version of Perl that is easier to read and not as chock-full of opening and closing brackets as a C descendant. Fast-forward several years, and the solution was good enough to be the first language available on Google's AppEngine -- a clear indication Python has the kind of structure that makes it easy to scale in the cloud, one of the biggest challenges for enterprise-grade computing.

[ For a look at the wide-ranging flock of Python IDEs, see "InfoWorld review: Nine fine Python development tools." ]

Python's popularity in scientific labs is a bit hard to explain, given that, unlike Stephen Wolfram's Mathematica for mathematicians, the language never offered any data structures or elements explicitly tuned to meet the needs of scientists. Python creator Guido von Rossum believes Python caught on in the labs because "scientists often need to improvise when trying to interpret results, so they are drawn to dynamic languages which allow them to work very quickly and see results almost immediately.

Tuesday, October 26, 2010

Send Email in Java

The JavaMail API is not part of core Java SE, but an optional extension. In addition, it is required in Java Enterprise Edition. The JavaMail packages can be accessed in two ways :
by placing j2ee.jar in the classpath
or, by placing both mail.jar and activation.jar in the classpathThe javax.mail API uses a properties file for reading server names and related configuration. These settings will override any system defaults. Alternatively, the configuration can be set directly in code, using the JavaMail API.
Example
An email configuration file (to run the example, substitute valid values for the uncommented items) :
# Configuration file for javax.mail # If a value for an item is not provided, then # system defaults will be used. These items can # also be set in code.
# Host whose mail services will be used # (Default value : localhost) mail.host=mail.blah.com
# Return address to appear on emails # (Default value : username@host) mail.from=webmaster@blah.net
# Other possible items include: # mail.user= # mail.store.protocol= # mail.transport.protocol= # mail.smtp.host= # mail.smtp.user= # mail.debug=
A class which uses this file to send an email : import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
/**
* Simple demonstration of using the javax.mail API.
*
* Run from the command line. Please edit the implementation
* to use correct email addresses and host name.
*/
public final class Emailer {
public static void main( String... aArguments ){
Emailer emailer = new Emailer();
//the domains of these email addresses should be valid,
//or the example will fail:
emailer.sendEmail(
"fromblah@blah.com", "toblah@blah.com",
"Testing 1-2-3", "blah blah blah"
);
}
/**
* Send a single email.
*/
public void sendEmail(
String aFromEmailAddr, String aToEmailAddr,
String aSubject, String aBody
){
//Here, no Authenticator argument is used (it is null).
//Authenticators are used to prompt the user for user
//name and password.
Session session = Session.getDefaultInstance( fMailServerConfig, null );
MimeMessage message = new MimeMessage( session );
try {
//the "from" address may be set in code, or set in the
//config file under "mail.from" ; here, the latter style is used
//message.setFrom( new InternetAddress(aFromEmailAddr) );
message.addRecipient(
Message.RecipientType.TO, new InternetAddress(aToEmailAddr)
);
message.setSubject( aSubject );
message.setText( aBody );
Transport.send( message );
}
catch (MessagingException ex){
System.err.println("Cannot send email. " + ex);
}
}
/**
* Allows the config to be refreshed at runtime, instead of
* requiring a restart.
*/
public static void refreshConfig() {
fMailServerConfig.clear();
fetchConfig();
}
// PRIVATE //
private static Properties fMailServerConfig = new Properties();
static {
fetchConfig();
}
/**
* Open a specific text file containing mail server
* parameters, and populate a corresponding Properties object.
*/
private static void fetchConfig() {
InputStream input = null;
try {
//If possible, one should try to avoid hard-coding a path in this
//manner; in a web application, one should place such a file in
//WEB-INF, and access it using ServletContext.getResourceAsStream.
//Another alternative is Class.getResourceAsStream.
//This file contains the javax.mail config properties mentioned above.
input = new FileInputStream( "C:\\Temp\\MyMailServer.txt" );
fMailServerConfig.load( input );
}
catch ( IOException ex ){
System.err.println("Cannot open and load mail server properties file.");
}
finally {
try {
if ( input != null ) input.close();
}
catch ( IOException ex ){
System.err.println( "Cannot close mail server properties file." );
}
}
}
}

Monday, October 25, 2010

Ajax

AJAX = Asynchronous JavaScript and XML.

AJAX is not a new programming language, but a new way to use existing standards.

AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.

AJAX is about updating parts of a web page, without reloading the whole page.


What You Should Already Know

Before you continue you should have a basic understanding of the following:

  • HTML / XHTML
  • CSS
  • JavaScript / DOM

If you want to study these subjects first, find the tutorials on our Home page.


What is AJAX?

AJAX = Asynchronous JavaScript and XML.

AJAX is a technique for creating fast and dynamic web pages.

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.

Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.


How AJAX Works

AJAX


AJAX is Based on Internet Standards

AJAX is based on internet standards, and uses a combination of:

  • XMLHttpRequest object (to exchange data asynchronously with a server)
  • JavaScript/DOM (to display/interact with the information)
  • CSS (to style the data)
  • XML (often used as the format for transferring data)

lamp AJAX applications are browser- and platform-independent!


Google Suggest

AJAX was made popular in 2005 by Google, with Google Suggest.

Google Suggest is using AJAX to create a very dynamic web interface: When you start typing in Google's search box, a JavaScript sends the letters off to a server and the server returns a list of suggestions.


Start Using AJAX Today

AJAX is based on existing standards. These standards have been used by developers for several years. Read our next chapters to see how it works!


Sunday, October 24, 2010

How To Create a Windows Event Log and Write your Custom Message as well

Introduction

This article will give you an idea about how to create a Windows event log and write your custom message into the event log.

Background

Most of the developers are very much familiar with the Windows event log API. When developers create a Windows based application, it may be an ActiveX component, any customized DLL library, a service application, etc.; it is a very common practice to write several types of information into the event log, which is generated by that particular application runtime so we can easily keep track of all the information.

Using the Code

Before we start understanding the code, we need a little concept on System.Diagnostics namespace. We will use the namespace to manage an event log. The namespace System.Diagnostics provides a class name as “EventLog” to create and write a message into the eventlog.

Let’s take an example, our goal is to write a simple C# .NET class which will create a new log name as “myEventLog” and write a message “I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.” as an information.

To achieve this, we need to use the following methods, properties and enum which will be found in the System.Diagnostics namespace.

Methods

  • SourceExists: Determines whether an event source is registered on the local computer or not.
  • CreateEventSource: Establishes an application as able to write event information to a particular log on the system.
    More details can be found at this link.
  • WriteEntry: Writes an entry in the event log, i.e., writes an information type entry, with the given message text, to the event log.
    More details can be found at this link.

Properties

  • Source: Gets or sets the source name to register and use when writing to the event log.
  • Log: Gets or sets the name of the log to read from or write to.

Enum

  • EventLogEntryType: Specifies the event type of an event log entry.
    More details can be found at this link.

Sample Code Example

Collapse | Copy Code
  public class ClsEventLog
{
public bool CreateLog(string strLogName)
{
bool Result = false;

try
{
System.Diagnostics.EventLog.CreateEventSource(strLogName, strLogName);
System.Diagnostics.EventLog SQLEventLog =
new System.Diagnostics.EventLog();

SQLEventLog.Source = strLogName;
SQLEventLog.Log = strLogName;

SQLEventLog.Source = strLogName;
SQLEventLog.WriteEntry("The " + strLogName + " was successfully
initialize component."
, EventLogEntryType.Information);

Result = true;
}
catch
{
Result = false;
}

return Result;
}
public void WriteToEventLog(string strLogName
, string strSource
, string strErrDetail)
{
System.Diagnostics.EventLog SQLEventLog = new System.Diagnostics.EventLog();

try
{
if (!System.Diagnostics.EventLog.SourceExists(strLogName))
this.CreateLog(strLogName);


SQLEventLog.Source = strLogName;
SQLEventLog.WriteEntry(Convert.ToString(strSource)
+ Convert.ToString(strErrDetail),
EventLogEntryType.Information);

}
catch (Exception ex)
{
SQLEventLog.Source = strLogName;
SQLEventLog.WriteEntry(Convert.ToString("INFORMATION: ")
+ Convert.ToString(ex.Message),
EventLogEntryType.Information);
}
finally
{
SQLEventLog.Dispose();
SQLEventLog = null;
}
}
}

Send Email in dotnet c# and vb


this the easy code to send email with .net in windows application
this a c# code u can easy convert it to vb
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("Someone @microsoft.com");
message.Subject = "This is the Subject line";
message.From = new System.Net.Mail.MailAddress("From@online.microsoft.com");
message.Body = "This is the message body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
smtp.Send(message)