What is the ASP.NET AJAX Control Toolkit?

ASP.NET AJAX Control Toolkit :
The ASP.NET AJAX Control Toolkit is an open-source project built on top of the Microsoft ASP.NET AJAX framework. It is a joint effort between Microsoft and the ASP.NET AJAX community that provides a powerful infrastructure to write reusable, customizable and extensible ASP.NET AJAX extenders and controls, as well as a rich array of controls that can be used out of the box to create an interactive Web experience.

The AJAX Control Toolkit contains more than 30 controls that enable you to easily create rich, interactive web pages.

What is 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.

What is Silverlight ?

Silverlight is a powerful development platform for creating rich media applications and business applications for the Web, desktop, and mobile devices.

Silverlight enables development of the next generation of Microsoft .NET-based media experiences and rich interactive applications (RIAs) for the Web. Silverlight is delivered as a cross-platform and cross-browser plug-in that exposes a programming framework and features that are a subset of the .NET Framework and Windows Presentation Foundation (WPF).

What is the difference between ExecuteQuery and Executenonquery?


ExecuteQuery():

Executes a SQL-Statement on the Database.
ExecuteQuery()------> To Execute SELECT Statement

ExecuteNonQuery():

The ExecuteNonQuery() is one of the most frequently used method in SqlCommand Object, and is used for executing statements that do not return result sets (ie. statements like insert data , update data etc.) .

Command.ExecuteNonQuery();

The ExecuteNonQuery() performs Data Definition tasks as well as Data Manipulation tasks also. The Data Definition tasks like creating Stored Procedures ,Views etc. perform by the ExecuteNonQuery() . Also Data Manipulation tasks like Insert , Update , Delete etc. also perform by the ExecuteNonQuery() of SqlCommand Object.

The following C# example shows how to use the method ExecuteNonQuery() through SqlCommand Object

SqlConnection cnn = new SqlConnection(connetionString);
cnn.Open();
SqlCommand cmd = new SqlCommand("insert into tablename(id,name) values(11,'naresh')", cnn);
cmd.ExecuteNonQuery();

WPF in .Net

Windows Presentation Foundation (WPF) is a .NET technology for building desktop
applications. The result of building a WPF application is an *.exe file that you can
run directly on your computer or deploy and run on any other computer that has .NET
installed. With WPF, you can add a graphical user interface (GUI), pronounced "Gooey,"
that makes it easier for users to work with your program.

What is SQL?

SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system. However, the standard SQL commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" can be used to accomplish almost everything that one needs to do with a database.

What is the difference between cookies and session?

Cookies :

1. Cookies can store only "string" datatype
2. They are stored at Client side
3. Cookie is non-secure since stored in text format at
client side
4. Cookies may or may not be individual for every
client
5. Due to cookies network traffic will increase.Size
of cookie is limited to 40 and number of cookies to be used
is restricted to 20.
6. Only in few situations we can use cookies because
of no security
7. We can disable cookies
8. Since the value is string there is no security
9. We have persistent and non-persistent cookies

Session :

1. Session can store any type of data because the
value is of datatype of "object"
2. These are stored at Server side
3. Session are secure because it is stored in binary
format/encrypted form and it gets decrypted at server
4. Session is independent for every client i.e
individual for every client
5. There is no limitation on size or number of
sessions to be used in an application
6. For all conditions/situations we can use sessions
7. we cannot disable the sessions.Sessions can be used
without cookies also(by disabling cookies)
8. The disadvantage of session is that it is a
burden/overhead on server
9. Sessions are called as Non-Persistent cookies
because its life time can be set manually

difference between application programming and system programming :

In application programming programmers build applications. Application programs include websites, video games, iPhone applications, Microsoft Word, Microsoft Excel, Web browsers and other programs that people use for entertainment, communications, accessing information, organizing, and getting work done. Application software interacts with people or users.

Systems programming is creating technology that programmers use to build applications. In order for an applications programmer to build an application, he needs an operating system, a programming language, and other tools to get the application built, tested, and working.

System programming includes creating and working on:

operating systems database systems programming languages software libraries software that controls hardware very directly Software exists in layers. Application software runs on top of and interacts with system software. System software runs on top of and interacts with the physical hardware. Another way of looking at it: People make application software do work. Application software makes system software do work. System software makes the physical machine do work.

Sending email through Gmail SMTP server with C#



public int SendMail()
    {
        int i = 0;
        //System.Web.Mail.MailMessage objMsg = new System.Web.Mail.MailMessage();
        try
        {
            // Smtp configuration
            string smtpServer = ConfigurationManager.AppSettings["SmtpServer"];
            int smtpserverport = Convert.ToInt32(ConfigurationManager.AppSettings["smtpserverport"]);
            string userName = ConfigurationManager.AppSettings["FromMailId"];
            string password = ConfigurationManager.AppSettings["FromIdPassword"];
            int Port = Convert.ToInt32(ConfigurationManager.AppSettings["Port Number"]);
            string SMTPserverUserName = ConfigurationManager.AppSettings["SMTPServerUserName"];
            string SMTPserverPwd = ConfigurationManager.AppSettings["SMTPServerPassword"];

            // Mail initialization
            System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage();
            mailMsg.From = new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings["FromMailId"], "HIHL-1056", System.Text.Encoding.UTF8);
            // mailMsg.mail
            mailMsg.To.Add("From Address");
            mailMsg.Subject = @"XYZ";
            mailMsg.Body = "Body";
            //MailAttachment att = new MailAttachment("C:\\Documents and Settings\\xxx.doc");
            //mailMsg.Attachments.Add(att);
            mailMsg.BodyEncoding = System.Text.Encoding.UTF8;
            mailMsg.IsBodyHtml = true;
            mailMsg.Priority = System.Net.Mail.MailPriority.High;

            //The SMTP requires Authentication so the credentials has to be sent

            System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential("Usrename", "password");

            //Add the Creddentials

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Port = smtpserverport;
            client.Host = smtpServer;
            client.EnableSsl = false;
            client.UseDefaultCredentials = false;
            client.Credentials = mailAuthentication;
            //client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
            //client.SendCompleted += new System.Net.Mail.SendCompletedEventHandler(client_SendCompleted);
            object userState = mailMsg;
            try
            {
                client.Send(mailMsg);
                //MessageBox.Show("Emailsend successfully");
                i = 1;
                return i;

            }
            catch (System.Net.Mail.SmtpException exx)
            {
                i = 0;
                return i;
            }


        }
        catch (Exception ex)
        {


        }
        return i;
    }



Difference between .Net 4.0 and .Net 3.5

Difference between .NET 3.5 and .NET 4.0

› The web installers for .NET 4.0 are below 1MB in size and faster internet connection is required to download the bits.

› In .NET 3.5, there is no direct method for accessing data whereas there is an in-built feature for data access in .NET 4.0.

› Enableviewstage property has two values in .NET 3.5 as “True” and “False” whereas in .NET 4.0, this property has three values as Inherit, Disable and Enable.

› .NET 4.0 is the most improved version of .NET 3.5 and now it is widely used in IT industry by large organizations.



.Net Framework 4.0 comes up with some of major changes as compare to previous versions of .Net Framework 3.5 and 2.0

Following are list of Major Changes in .Net 4.0



  • ControlRenderingCompatabilityVersion Setting in the Web.config File
  • ClientIDMode Changes
  • HtmlEncode and UrlEncode Now Encode Single Quotation Marks
  • ASP.NET Page (.aspx) Parser is Stricter
  • Browser Definition Files Updated
  • System.Web.Mobile.dll Removed from Root Web Configuration File
  • ASP.NET Request Validation
  • Default Hashing Algorithm Is Now HMACSHA256
  • Configuration Errors Related to New ASP.NET 4 Root Configuration
  • ASP.NET 4 Child Applications Fail to Start When Under ASP.NET 2.0 or ASP.NET 3.5 Applications
  • ASP.NET 4 Web Sites Fail to Start on Computers Where SharePoint Is Installed
  • The HttpRequest.FilePath Property No Longer Includes PathInfo Values
  • ASP.NET 2.0 Applications Might Generate HttpException Errors that Reference eurl.axd
  • Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode Changes to the ASP.NET Code Access Security (CAS) Implementation
  • MembershipUser and Other Types in the System.Web.Security Namespace Have Been Moved
  • Output Caching Changes to Vary * HTTP Header
  • System.Web.Security Types for Passport are Obsolete
  • The MenuItem.PopOutImageUrl Property Fails to Render an Image in ASP.NET 4
  • Menu.StaticPopOutImageUrl and Menu.DynamicPopOutImageUrl Fail to Render Images When Paths Contain Backslashes

Export Datatable to Excel in asp.net


public void ExportToExcel(DataTable dt, string name, HttpResponse res)

    {
        string attachment = "attachment; filename=" + name;


        res.ClearContent();
        res.AddHeader("content-disposition", attachment);
        res.ContentType = "application/vnd.ms-excel";
        string tab = "";
        int colcount = 0;
        foreach (DataColumn din in dt.Columns)
        {

            // Response.Write(tab + dc.ColumnName.Remove(0, dc.ColumnName.IndexOf("-") + 1));
            res.Write(tab + din.ColumnName);
            tab = "\t";
            colcount++;
        }
        res.Write("\n");

        int i;
        foreach (DataRow dr in dt.Rows)
        {
            tab = "";
            for (i = 0; i < dt.Columns.Count; i++)
            {
                res.Write(tab + dr[i].ToString());
                tab = "\t";
            }
            res.Write("\n");
        }
        res.End();
    }



Sql Helper Class in asp.net


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Web.UI.WebControls;
using System.Web.UI;


///
/// Summary description for Dal
///
public class Dal
{

    string ConnectionString = string.Empty;
    static SqlConnection con;

    public Dal()
    {
        ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        con = new SqlConnection(ConnectionString);
    }

    public void SetConnection()
    {
        if (ConnectionString == string.Empty)
        {
            ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        }
        con = new SqlConnection(ConnectionString);
    }

    public DataSet ExecuteProcudere(string procName, Hashtable parms)
    {
        DataSet ds = new DataSet();
        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da = new SqlDataAdapter();
        cmd.CommandText = procName;
        cmd.CommandType = CommandType.StoredProcedure;
        if (con == null)
        {
            SetConnection();
        }
        cmd.Connection = con;

        if (parms.Count > 0)
        {
            foreach (DictionaryEntry de in parms)
            {
                cmd.Parameters.AddWithValue(de.Key.ToString(), de.Value);
            }

        }
        da.SelectCommand = cmd;

        da.Fill(ds);
        return ds;
    }

    public int ExecuteQuery(string procName, Hashtable parms)
    {
        SqlCommand cmd = new SqlCommand();

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = procName;
        if (parms.Count > 0)
        {
            foreach (DictionaryEntry de in parms)
            {
                cmd.Parameters.AddWithValue(de.Key.ToString(), de.Value);
            }

        }
        if (con == null)
        {
            SetConnection();
        }
        cmd.Connection = con;
        if (con.State == ConnectionState.Closed)
            con.Open();

        int result = cmd.ExecuteNonQuery();

        return result;

    }


    public int ExecuteQuerywithOutputparams(SqlCommand cmd)
    {
        if (con == null)
        {
            SetConnection();
        }
        cmd.Connection = con;
        if (con.State == ConnectionState.Closed)
            con.Open();

        int result = cmd.ExecuteNonQuery();

        return result;

    }

    public int ExecuteQueryWithOutParam(string procName, Hashtable parms)
    {
        SqlCommand cmd = new SqlCommand();
        SqlParameter sqlparam = new SqlParameter();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = procName;
        if (parms.Count > 0)
        {
            foreach (DictionaryEntry de in parms)
            {
                if (de.Key.ToString().Contains("_out"))
                {
                    sqlparam = new SqlParameter(de.Key.ToString(), de.Value);
                    sqlparam.DbType = DbType.Int32;
                    sqlparam.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(sqlparam);
                }
                else
                {
                    cmd.Parameters.AddWithValue(de.Key.ToString(), de.Value);
                }
            }

        }
        if (con == null)
        {
            SetConnection();
        }
        cmd.Connection = con;
        if (con.State == ConnectionState.Closed)
            con.Open();

        int result = cmd.ExecuteNonQuery();

        if (sqlparam != null)
            result = Convert.ToInt32(sqlparam.SqlValue.ToString());
        return result;
    }
}

Creating Logs and Error Handling methods in asp.net


using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Net;


namespace ACLData
{
    ///
    /// Summary description for ErrorHandler.
    ///
    public class clsErrorHandlerALL
    {
        //public void LoginFile(string SystemName,string Errordes ,long Errorno, string Errorsource, string Classname, string methodname);
        public clsErrorHandlerALL()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region Member Functions
        // This method creates text file and allows entry for Errors in runtime
        // Errordes:type of Exeption and its description
        // ErrorSorce:This is string of class name and method name where exeption has originated

        public enum Logtype
        {
            None = 0,
            file = 1,
            Database = 2,
            Mail = 3,
            SMS = 4,
            FileandDatabase = 5,
            All = file | Database | Mail | SMS,
        }

        public void ErrorsEntry(string Errordes, string Errorsource, long Errorno, string Classname, string Methodname, int Communicationid, Logtype logging)
        {

            switch (logging)
            {
                case Logtype.file:
                    {

                        LoginFile(System.Net.Dns.GetHostName(), Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        break;
                    }
                case Logtype.Database:
                    {
                        LoginDatabase(Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        break;
                    }
                case Logtype.Mail:
                    {
                        LogthroughMail(Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        break;
                    }
                case Logtype.SMS:
                    {
                        LogthroughSMS(Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        break;
                    }
                case Logtype.FileandDatabase:
                    {
                        LoginFile(System.Net.Dns.GetHostName(), Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        LoginDatabase(Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        break;
                    }

                case Logtype.All:
                    {
                        LoginFile(System.Net.Dns.GetHostName(), Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        LoginDatabase(Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        LogthroughMail(Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        LogthroughSMS(Errordes, Errorno, Errorsource, Classname, Methodname, Communicationid);
                        break;
                    }
            }
        }

        public void ErrorsEntry(string Errordes, string Errorsource, long Errorno, string Classname, string Methodname, Logtype logging)
        {

            switch (logging)
            {
                case Logtype.file:
                    {

                        LoginFile(System.Net.Dns.GetHostName(), Errordes, Errorno, Errorsource, Classname, Methodname);
                        break;
                    }
                case Logtype.Database:
                    {
                        LoginDatabase(Errordes, Errorno, Errorsource, Classname, Methodname);
                        break;
                    }
                case Logtype.Mail:
                    {
                        LogthroughMail(Errordes, Errorno, Errorsource, Classname, Methodname);
                        break;
                    }
                case Logtype.SMS:
                    {
                        LogthroughSMS(Errordes, Errorno, Errorsource, Classname, Methodname);
                        break;
                    }
                case Logtype.FileandDatabase:
                    {
                        LoginFile(System.Net.Dns.GetHostName(), Errordes, Errorno, Errorsource, Classname, Methodname);
                        LoginDatabase(Errordes, Errorno, Errorsource, Classname, Methodname);
                        break;
                    }

                case Logtype.All:
                    {
                        LoginFile(System.Net.Dns.GetHostName(), Errordes, Errorno, Errorsource, Classname, Methodname);
                        LoginDatabase(Errordes, Errorno, Errorsource, Classname, Methodname);
                        LogthroughMail(Errordes, Errorno, Errorsource, Classname, Methodname);
                        LogthroughSMS(Errordes, Errorno, Errorsource, Classname, Methodname);
                        break;
                    }
            }
        }

        public void LoginFile(string SystemName, string Errordes, long Errorno, string Errorsource, string Classname, string Methodname, int Communicationid)
        {
            string path = ConfigurationSettings.AppSettings["LogLocation"];
            string dir = path.Substring(0, path.LastIndexOf(@"\"));
            string file = path.Substring(0, path.LastIndexOf(".txt")) + "-" + DateTime.Today.ToString("dd-MM-yyyy") + ".txt";
            StreamWriter sw = File.AppendText(file);
            try
            {
                if (!(Directory.Exists(dir)))
                {
                    Directory.CreateDirectory(dir);
                }

                sw.WriteLine("====================" + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
                sw.WriteLine("SystemName : " + SystemName);
                sw.WriteLine("Error Description : " + Errordes.ToString());
                sw.WriteLine("Error Source : " + Errorsource.ToString());
                sw.WriteLine("Errorno : " + Errorno.ToString());
                sw.WriteLine("Class Name : " + Classname);
                sw.WriteLine("Method Name : " + Methodname);
                sw.WriteLine("CommunicationId : " + Communicationid);
                sw.Flush();
                sw.Close();
            }
            catch (UnauthorizedAccessException ex)
            {
                //MessageBox.Show ("Contact Administrator for creating logs, Access denied !");
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                sw.Close();
            }
        }

        public void LoginFile(string SystemName, string Errordes, long Errorno, string Errorsource, string Classname, string Methodname)
        {
            string path = ConfigurationSettings.AppSettings["LogLocation"];
            string dir = path.Substring(0, path.LastIndexOf(@"\"));
            string file = path.Substring(0, path.LastIndexOf(".txt")) + "-" + DateTime.Today.ToString("dd-MM-yyyy") + ".txt";

            try
            {
                if (!(Directory.Exists(dir)))
                {
                    Directory.CreateDirectory(dir);
                }

                StreamWriter sw = File.AppendText(file);
                sw.WriteLine("====================" + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
                sw.WriteLine("SystemName : " + SystemName);
                sw.WriteLine("Error Description : " + Errordes.ToString());
                sw.WriteLine("Error Source : " + Errorsource.ToString());
                sw.WriteLine("Errorno : " + Errorno.ToString());
                sw.WriteLine("Class Name : " + Classname);
                sw.WriteLine("Method Name : " + Methodname);

                sw.Flush();
                sw.Close();
            }
            catch (UnauthorizedAccessException ex)
            {
                //MessageBox.Show ("Contact Administrator for creating logs, Access denied !");
                Console.WriteLine(ex.ToString());
            }
        }

        private void LoginDatabase(string Errordes, long Errorno, string Errorsource, string Classname, string Methodname, int Communicationid)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Parameters.Add(new SqlParameter("@Errordescription", SqlDbType.VarChar, 500));
                cmd.Parameters["@Errordescription"].Value = Errordes;

                cmd.Parameters.Add(new SqlParameter("@Errorno", SqlDbType.Decimal));
                cmd.Parameters["@Errorno"].Value = Errorno;

                cmd.Parameters.Add(new SqlParameter("@SystemName", SqlDbType.VarChar, 50));
                cmd.Parameters["@SystemName"].Value = System.Net.Dns.GetHostName();

                cmd.Parameters.Add(new SqlParameter("@Errorsource", SqlDbType.VarChar, 100));
                cmd.Parameters["@Errorsource"].Value = Errorsource;

                cmd.Parameters.Add(new SqlParameter("@ClassName", SqlDbType.VarChar, 50));
                cmd.Parameters["@ClassName"].Value = Classname;

                cmd.Parameters.Add(new SqlParameter("@MethodName", SqlDbType.VarChar, 100));
                cmd.Parameters["@MethodName"].Value = Methodname;

                cmd.Parameters.Add(new SqlParameter("@LogTime", SqlDbType.DateTime));
                cmd.Parameters["@LogTime"].Value = System.DateTime.Now;

                cmd.Parameters.Add(new SqlParameter("@CommunicationId", SqlDbType.Int));
                cmd.Parameters["@CommunicationId"].Value = Communicationid;


                int res = ACLData.SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "ACL.ins_ErrorLog");
            }
            catch (SqlException ex)
            {
                // res=0;
                ErrorsEntry(ex.GetBaseException().ToString(), "CallTaker", 12345, "test", ex.GetBaseException().Source, 1, clsErrorHandlerALL.Logtype.All);
            }
            catch (Exception ex)
            {
                // res=0;
                Console.Write(ex.GetBaseException().ToString());
            }
        }

        private void LoginDatabase(string Errordes, long Errorno, string Errorsource, string Classname, string Methodname)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Parameters.Add(new SqlParameter("@Errordescription", SqlDbType.VarChar, 500));
                cmd.Parameters["@Errordescription"].Value = Errordes;

                cmd.Parameters.Add(new SqlParameter("@Errorno", SqlDbType.Decimal));
                cmd.Parameters["@Errorno"].Value = Errorno;

                cmd.Parameters.Add(new SqlParameter("@SystemName", SqlDbType.VarChar, 50));
                cmd.Parameters["@SystemName"].Value = System.Net.Dns.GetHostName();

                cmd.Parameters.Add(new SqlParameter("@Errorsource", SqlDbType.VarChar, 100));
                cmd.Parameters["@Errorsource"].Value = Errorsource;

                cmd.Parameters.Add(new SqlParameter("@ClassName", SqlDbType.VarChar, 50));
                cmd.Parameters["@ClassName"].Value = Classname;

                cmd.Parameters.Add(new SqlParameter("@MethodName", SqlDbType.VarChar, 100));
                cmd.Parameters["@MethodName"].Value = Methodname;

                cmd.Parameters.Add(new SqlParameter("@LogTime", SqlDbType.DateTime));
                cmd.Parameters["@LogTime"].Value = System.DateTime.Now;

                //cmd.Parameters.Add(new SqlParameter("@CommunicationId", SqlDbType.Int));
                //cmd.Parameters["@CommunicationId"].Value = Communicationid;


                int res = ACLData.SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "ACL.ins_ErrorLog");
            }
            catch (SqlException ex)
            {
                // res=0;
                ErrorsEntry(ex.GetBaseException().ToString(), "CallTaker", 12345, "test", ex.GetBaseException().Source, 1, clsErrorHandlerALL.Logtype.All);
            }
            catch (Exception ex)
            {
                // res=0;
                Console.Write(ex.GetBaseException().ToString());
            }
        }

        private void LogthroughMail(string Errordes, long Errorno, string Errorsource, string Classname, string Methodname)
        {
        }

        private void LogthroughMail(string Errordes, long Errorno, string Errorsource, string Classname, string Methodname, int Communicationid)
        {
        }

        private void LogthroughSMS(string Errordes, long Errorno, string Errorsource, string Classname, string Methodname, int Communicationid)
        {
        }

        private void LogthroughSMS(string Errordes, long Errorno, string Errorsource, string Classname, string Methodname)
        {
        }

        public static void LogEntry(string Description, TimeSpan Difference, string Logsource, string Classname, string Methodname, int Communicationid)
        {
            string path = ConfigurationSettings.AppSettings["LogEntry"];
            string dir = path.Substring(0, path.LastIndexOf(@"\"));
            string file = path.Substring(0, path.LastIndexOf(".txt")) + "-" + DateTime.Today.ToString("dd-MM-yyyy") + ".txt";
            if (!(Directory.Exists(dir)))
            {
                Directory.CreateDirectory(dir);
            }

            StreamWriter sw = File.AppendText(file);
            sw.WriteLine("====================" + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
            sw.WriteLine("SystemName : " + System.Net.Dns.GetHostName().ToString());
            sw.WriteLine("Description : " + Description.ToString());
            sw.WriteLine("Source : " + Logsource.ToString());
            sw.WriteLine("Duration : " + Difference.ToString());
            sw.WriteLine("Class Name : " + Classname);
            sw.WriteLine("Method Name : " + Methodname);
            sw.WriteLine("CommunicationId : " + Communicationid);
            sw.Flush();
            sw.Close();

        }

        public static void LogEntry(string Description, TimeSpan Difference, string Logsource, string Classname, string Methodname)
        {
            string path = ConfigurationSettings.AppSettings["LogEntry"].ToString();
            string dir = path.Substring(0, path.LastIndexOf(@"\"));
            string file = path.Substring(0, path.LastIndexOf(".txt")) + "-" + DateTime.Today.ToString("dd-MM-yyyy") + ".txt";
            if (!(Directory.Exists(dir)))
            {
                Directory.CreateDirectory(dir);
            }

            StreamWriter sw = File.AppendText(file);
            sw.WriteLine("====================" + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
            sw.WriteLine("SystemName : " + System.Net.Dns.GetHostName().ToString());
            sw.WriteLine("Description : " + Description.ToString());
            sw.WriteLine("Source : " + Logsource.ToString());
            sw.WriteLine("Duration : " + Difference.ToString());
            sw.WriteLine("Class Name : " + Classname);
            sw.WriteLine("Method Name : " + Methodname);
            //sw.WriteLine("CommunicationId : " + Communicationid);
            sw.Flush();
            sw.Close();
        }

      
    }
}