<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title> &#187; Own design custom Framework</title>
	<atom:link href="http://doddychsaputra.wordpress.com/category/framework-architecture/own-design-custom-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://doddychsaputra.wordpress.com</link>
	<description>System analyst and Application Development blogs</description>
	<lastBuildDate>Sat, 01 Dec 2007 14:24:35 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='doddychsaputra.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/80a30497f3830793216752731a533c8b?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title> &#187; Own design custom Framework</title>
		<link>http://doddychsaputra.wordpress.com</link>
	</image>
			<item>
		<title>Multipurpose of Exception Handling Class Part 3</title>
		<link>http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-3/</link>
		<comments>http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-3/#comments</comments>
		<pubDate>Thu, 05 Jul 2007 11:34:25 +0000</pubDate>
		<dc:creator>Doddy Christiana saputra</dc:creator>
				<category><![CDATA[Design Pattern Code]]></category>
		<category><![CDATA[Development in  C# 2.0]]></category>
		<category><![CDATA[Own design custom Framework]]></category>

		<guid isPermaLink="false">http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-3/</guid>
		<description><![CDATA[Hi..see you again.. this section is the continue part of my trilogy Multipurpose of Exception Handling class, okay let&#8217;s make it this quickly, the last class that we need is EmailGenerator class :

This class using 3 core of .Net library; System IO for accessing the XML email template,System XML and then System.Web.Email.
The main idea for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=23&subd=doddychsaputra&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hi..see you again.. this section is the continue part of my trilogy Multipurpose of Exception Handling class, okay let&#8217;s make it this quickly, the last class that we need is EmailGenerator class :</p>
<ul>
<li>This class using 3 core of .Net library; System IO for accessing the XML email template,System XML and then System.Web.Email.</li>
<li>The main idea for this class is service another class that want to generate the email notification so we need to produce the public method for sending the emai, here are the method</li>
</ul>
<p>public void AutomaticSendEmailLogging(string ErrorMessage)<br />
        {<br />
          <br />
            MailMessage mailMsg = new MailMessage(); // Create instance of EmailMessage Object</p>
<p>            string templateName = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ProgrammerEmailName;<br />
            mailMsg.From = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.EmailSender;<br />
            mailMsg.To = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ProgrammerEmail;<br />
            //mailMsg.Cc = EmailUser;</p>
<p><span id="more-23"></span></p>
<p>            string[] arrParamEmail = new string[2];</p>
<p>            //parametere yang akan dikirim ke email template<br />
            arrParamEmail[0] = System.DateTime.Now.ToString();//tgl<br />
            arrParamEmail[1] = ErrorMessage.ToString(); <br />
          </p>
<p>            this.SendEmail(mailMsg, templateName, arrParamEmail);<br />
        }</p>
<p><!--more--></p>
<ul>
<li>I Guess i will rock&#8217;n roll of all entire code <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .. okay let see below &#8230;</li>
</ul>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Collections.Specialized;<br />
using System.Text;<br />
using System.IO;<br />
using System.Xml;<br />
using System.Web.Mail;<br />
using FrameworkLayer.ConfigurationUtility;<br />
namespace FrameworkLayer.EmailUtility<br />
{<br />
    public class EmailGenerator<br />
    {<br />
        private string xml_file_name;<br />
        //private Logger lg;</p>
<p>        public EmailGenerator()<br />
  {<br />
   //<br />
   // TODO: Add constructor logic here<br />
   //<br />
  }</p>
<p>  public bool IsEmail(string mail)<br />
  {<br />
   System.Text.RegularExpressions.Regex mailPattern = new System.Text.RegularExpressions.Regex(@&#8221;\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*&#8221;);<br />
   return mailPattern.IsMatch(mail);<br />
  }</p>
<p>        //public bool SendEmail (MailMessage mailMessage)<br />
        //{<br />
        //    bool retEmail=false;<br />
        //    string enableEmailTrigger=&#8221;";</p>
<p>        //    enableEmailTrigger = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.IsEmailTrigger;<br />
        //    try<br />
        //    {<br />
        //        if(enableEmailTrigger.ToUpper().Trim()!=&#8221;NO&#8221;)<br />
        //        {<br />
        //            SmtpMail.SmtpServer = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.SmtpServer;<br />
        //            mailMessage.From= FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.EmailSender;<br />
        //            SmtpMail.Send(mailMessage);<br />
        //            retEmail=true;<br />
        //        }<br />
        //    }<br />
        //    catch (Exception exp)<br />
        //    { <br />
        //        //lg=new Logger();<br />
        //        //lg.WriteTextLog(&#8220;Email&#8221;,exp,((string)System.Configuration.ConfigurationSettings.AppSettings.Get(&#8220;ERROR_LOG_PATH&#8221;)));</p>
<p>        //        //string err= exp.Message;<br />
        //        //retEmail=false;   <br />
        //    }<br />
        //    return retEmail;<br />
        //}</p>
<p>        private bool SendEmail(MailMessage mailMessage, string xmlfilename, string[] arrParam)<br />
        {<br />
            bool retEmail = false;<br />
            string m_subject = &#8220;&#8221;;<br />
            string m_title = &#8220;&#8221;;<br />
            string m_body = &#8220;&#8221;;<br />
            string smtpUsr = &#8220;&#8221;;<br />
            string smtpPsw = &#8220;&#8221;;<br />
            string enableEmailTrigger = &#8220;&#8221;;<br />
            string enableEmailAuth = &#8220;&#8221;;</p>
<p>            enableEmailTrigger = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.IsEmailTrigger;<br />
            enableEmailAuth = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.IsEmailEnableAuthorization;<br />
            try<br />
            {<br />
                if (enableEmailTrigger.ToUpper().Trim() != &#8220;NO&#8221;)<br />
                {<br />
                    xml_file_name = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.EmailTemplateLocation + xmlfilename;</p>
<p>                    m_title = readFromXMLEmailTemplate(&#8220;TITLE&#8221;);</p>
<p>                    m_subject = readFromXMLEmailTemplate(&#8220;SUBJECT&#8221;);<br />
                    //m_subject += &#8221; &#8211; &#8221; + m_title;</p>
<p>                    mailMessage.Subject = m_subject;</p>
<p>                    m_body = readFromXMLEmailTemplate(&#8220;BODY&#8221;);<br />
                    m_body = replaceParameter(m_body, arrParam);<br />
                    //m_body.Replace (&#8220;\\N&#8221;,&#8221;\r\n&#8221;);<br />
                    mailMessage.Body = m_body;<br />
                    mailMessage.From = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.EmailSender;</p>
<p>                    if (enableEmailAuth.Trim().ToUpper().Equals(&#8220;YES&#8221;))<br />
                    {</p>
<p>                        smtpUsr = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.SmtpUserName;<br />
                        smtpPsw = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.SmtpPassword;</p>
<p>                        mailMessage.Fields.Add(&#8220;<a href="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate">http://schemas.microsoft.com/cdo/configuration/smtpauthenticate</a>&#8220;, &#8220;1&#8243;); //basic authentication<br />
                        mailMessage.Fields.Add(&#8220;<a href="http://schemas.microsoft.com/cdo/configuration/sendusername">http://schemas.microsoft.com/cdo/configuration/sendusername</a>&#8220;, smtpUsr); //set your username here<br />
                        mailMessage.Fields.Add(&#8220;<a href="http://schemas.microsoft.com/cdo/configuration/sendpassword">http://schemas.microsoft.com/cdo/configuration/sendpassword</a>&#8220;, smtpPsw); //set your password here<br />
                    }<br />
                    SmtpMail.SmtpServer.Insert(0, FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.SmtpServer);<br />
                    //SmtpMail.SmtpServer =MPConfiguration.SMTPServer ;</p>
<p>                    SmtpMail.Send(mailMessage);<br />
                    retEmail = true;<br />
                }<br />
            }<br />
            catch (Exception exp)<br />
            {<br />
                //string err= exp.Message;<br />
                //lg=new Logger();<br />
                //lg.WriteTextLog(&#8220;Email Template: &#8220;+xmlfilename,exp,((string)System.Configuration.ConfigurationSettings.AppSettings.Get(&#8220;ERROR_LOG_PATH&#8221;)));</p>
<p>                //retEmail=false;   <br />
            }<br />
            return retEmail;<br />
        }</p>
<p>        public void AutomaticSendEmailLogging(string ErrorMessage)<br />
        {<br />
          <br />
            MailMessage mailMsg = new MailMessage(); // Create instance of EmailMessage Object</p>
<p>            string templateName = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ProgrammerEmailName;<br />
            mailMsg.From = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.EmailSender;<br />
            mailMsg.To = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ProgrammerEmail;<br />
            //mailMsg.Cc = EmailUser;</p>
<p>            string[] arrParamEmail = new string[2];</p>
<p>            //parametere yang akan dikirim ke email template<br />
            arrParamEmail[0] = System.DateTime.Now.ToString();//tgl<br />
            arrParamEmail[1] = ErrorMessage.ToString(); <br />
          </p>
<p>            this.SendEmail(mailMsg, templateName, arrParamEmail);<br />
        }</p>
<p>  public string replaceParameter(string input,string[] arrParam)<br />
  {<br />
   StringBuilder tmpInput= new  StringBuilder (input);<br />
   int idx=0;<br />
   for(int i=0 ; i &lt; arrParam.Length;i++)<br />
   {<br />
    idx = i+1;<br />
    tmpInput.Replace (&#8220;{&#8221; + i + &#8220;}&#8221;,arrParam[i].Trim());<br />
   }<br />
   tmpInput.Replace (&#8220;\\N&#8221;,&#8221;\r\n&#8221;);tmpInput.Replace (&#8220;\\n&#8221;,&#8221;\r\n&#8221;);<br />
   return tmpInput.ToString ();<br />
  }</p>
<p>  public string readFromXMLEmailTemplate(string tagName)<br />
  {<br />
   bool bStop=false;<br />
   string m_RetVal=&#8221;";<br />
   XmlTextReader reader = new  XmlTextReader (xml_file_name);<br />
   <br />
   while(reader.Read ())<br />
   {<br />
    //    bStop=false;<br />
    //    m_RetVal=&#8221;";<br />
    switch(reader.NodeType )<br />
    {<br />
     case XmlNodeType.Element :<br />
      if(reader.Name.Equals (tagName))<br />
      {<br />
       m_RetVal=&#8221;";<br />
       bStop=true;<br />
      }<br />
      break;<br />
     case XmlNodeType.Text:<br />
      m_RetVal=reader.Value ; <br />
      break;<br />
    }<br />
    if (bStop &amp;&amp; m_RetVal!=&#8221;")<br />
     break;<br />
   <br />
   }<br />
   return m_RetVal;<br />
  }<br />
    }<br />
}</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/doddychsaputra.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/doddychsaputra.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/doddychsaputra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/doddychsaputra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/doddychsaputra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/doddychsaputra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/doddychsaputra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/doddychsaputra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/doddychsaputra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/doddychsaputra.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/doddychsaputra.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/doddychsaputra.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=23&subd=doddychsaputra&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b91382498b0b016e1364e483ec1bf7ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Doddy Christiana saputra</media:title>
		</media:content>
	</item>
		<item>
		<title>Multipurpose of Exception Handling Class Part 2</title>
		<link>http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-2/</link>
		<comments>http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-2/#comments</comments>
		<pubDate>Thu, 05 Jul 2007 11:18:10 +0000</pubDate>
		<dc:creator>Doddy Christiana saputra</dc:creator>
				<category><![CDATA[Design Pattern Code]]></category>
		<category><![CDATA[Development in  C# 2.0]]></category>
		<category><![CDATA[Own design custom Framework]]></category>

		<guid isPermaLink="false">http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-2/</guid>
		<description><![CDATA[Okay in this section part i will talk more detail about those kind of class ,

Logging Class

Prerequisite for this class :

You need provide the xml file for become the email template, the simple form like this :&#60;EMAIL&#62;
&#60;TITLE&#62;Error Notification&#60;/TITLE&#62;
&#60;MESSAGE&#62;
&#60;SUBJECT&#62;Global Coding System Notification
&#60;/SUBJECT&#62;
&#60;BODY&#62;ERROR MESSAGE ALERT {0}
================================================\n\nPlease be advised that somthing error happen in your application :
{1} \N
&#60;/BODY&#62;
&#60;/MESSAGE&#62;
&#60;/EMAIL&#62;



Those [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=22&subd=doddychsaputra&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Okay in this section part i will talk more detail about those kind of class ,</p>
<ol>
<li>Logging Class</li>
</ol>
<p>Prerequisite for this class :</p>
<ul>
<li>You need provide the xml file for become the email template, the simple form like this :&lt;EMAIL&gt;<br />
&lt;TITLE&gt;Error Notification&lt;/TITLE&gt;<br />
&lt;MESSAGE&gt;<br />
&lt;SUBJECT&gt;Global Coding System Notification<br />
&lt;/SUBJECT&gt;<br />
&lt;BODY&gt;ERROR MESSAGE ALERT {0}<br />
================================================\n\nPlease be advised that somthing error happen in your application :<br />
{1} \N<br />
&lt;/BODY&gt;<br />
&lt;/MESSAGE&gt;<br />
&lt;/EMAIL&gt;</li>
</ul>
<p><span id="more-22"></span></p>
<ul>
<li>Those XML email file using two parameters, {0} this parameter will display the date error generate and the second things {1} this parameter will display or capture your exeception handling stack trace.</li>
<li>Those parameter will be taken from the emailGenerator class, wheter triggered from logging class.</li>
<li>In Logging class, there are two important method , first method is Handledexception Method hich has a duty to coordinate to another private method which has a function for logging writing to text file and also the trigerring to email alertGenerator class, and this class will become the second important method in this class.</li>
</ul>
<p>  So Let&#8217;s take a look the concrete code in this sample below :</p>
<p>//***********************************************************************************************************<br />
//  SUBJECT             : LOGGING UTILITY ENGINE<br />
//  CREATED BY          : Doddy Christiana Saputra , MCAD.NET<br />
//  LAST MODIFIED DATE  : JUNE 22,2007<br />
//***********************************************************************************************************</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Data;<br />
using System.Configuration;<br />
using FrameworkLayer.ConfigurationUtility;<br />
using FrameworkLayer.EmailUtility;<br />
using System.IO;</p>
<p>namespace FrameworkLayer.LoggingUtility<br />
{<br />
    public class Logging<br />
    {<br />
        private bool boolHandleErrors;<br />
        private string strLastError;<br />
        private bool boolLogError;<br />
        private string strLogFile;</p>
<p>        EmailGenerator Email = new EmailGenerator(); //Create instance of email generator<br />
  </p>
<p>        public bool HandleErrors<br />
        {<br />
            get<br />
            {<br />
                return boolHandleErrors;<br />
            }<br />
            set<br />
            {<br />
                boolHandleErrors = value;<br />
            }<br />
        }</p>
<p>        public string LastError<br />
        {<br />
            get<br />
            {<br />
                return strLastError;<br />
            }<br />
        }</p>
<p>        public bool LogErrors<br />
        {<br />
            get<br />
            {<br />
                return boolLogError;<br />
            }<br />
            set<br />
            {<br />
                boolLogError = value;<br />
            }<br />
        }</p>
<p>        public string LogFile<br />
        {<br />
            get<br />
            {<br />
                return strLogFile;<br />
            }<br />
            set<br />
            {<br />
                strLogFile = value;<br />
            }<br />
        }<br />
        public void HandleExceptions(Exception ex)<br />
        {<br />
            this.LogErrors = true;<br />
            this.LogFile = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ErrorLogFile;  <br />
                  <br />
            if (LogErrors)<br />
            {<br />
                WriteToLog(ex.Message+ex.StackTrace);<br />
            }<br />
            if (HandleErrors)<br />
            {<br />
                strLastError = ex.Message;<br />
            }<br />
            else<br />
            {<br />
                throw ex;<br />
            }<br />
        }</p>
<p>        private void WriteToLog(string msg)<br />
        {<br />
            StreamWriter writer = File.AppendText(LogFile);<br />
            writer.WriteLine(DateTime.Now.ToString() + &#8221; &#8211; &#8221; + msg);<br />
            writer.Close();</p>
<p>            //This is the part of automatically sending email to programmer<br />
            string[] test = new string[1]; //harus didefine nanti<br />
            Email.AutomaticSendEmailLogging (msg); //hanyautk inisialisasi sementara</p>
<p>           <br />
        }<br />
    }<br />
   <br />
}</p>
<p>okay..after yo see all of those description then you will rather clear enough or getting more itchi <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &#8230;</p>
<p>i will continue the emailgenerator class in the third part. see you..</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/doddychsaputra.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/doddychsaputra.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/doddychsaputra.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/doddychsaputra.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/doddychsaputra.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/doddychsaputra.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/doddychsaputra.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/doddychsaputra.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/doddychsaputra.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/doddychsaputra.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/doddychsaputra.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/doddychsaputra.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=22&subd=doddychsaputra&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://doddychsaputra.wordpress.com/2007/07/05/multipurpose-of-exception-handling-class-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b91382498b0b016e1364e483ec1bf7ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Doddy Christiana saputra</media:title>
		</media:content>
	</item>
		<item>
		<title>Multipurpose of Exception Handling Class Part 1</title>
		<link>http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-of-exception-handling-class/</link>
		<comments>http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-of-exception-handling-class/#comments</comments>
		<pubDate>Mon, 02 Jul 2007 09:47:42 +0000</pubDate>
		<dc:creator>Doddy Christiana saputra</dc:creator>
				<category><![CDATA[Design Pattern Code]]></category>
		<category><![CDATA[Development in  C# 2.0]]></category>
		<category><![CDATA[Own design custom Framework]]></category>

		<guid isPermaLink="false">http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-of-exception-handling-class/</guid>
		<description><![CDATA[In this Part, i will share of my code project which is i have made the multipurpose exception handling class. What is the trully meaning of multipurpose ? in this class i have create the exception handling class which covered the function for throwing the exception message and also giving the email alert notification to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=19&subd=doddychsaputra&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In this Part, i will share of my code project which is i have made the multipurpose exception handling class. What is the trully meaning of multipurpose ? in this class i have create the exception handling class which covered the function for throwing the exception message and also giving the email alert notification to the programmer or event for system administrator.</p>
<p>for instance is like this :</p>
<p>in DAL i am using the exception handling class &#8211;&gt; if there is something error in my DAL class &#8211;&gt; the error handler will capture the Exception stack trace &#8211;&gt; the Exception class will talk to the Logging class and also either the email class.</p>
<p>and then my class like this Logging class and Email class :</p>
<p><a href="http://doddychsaputra.files.wordpress.com/2007/07/emaillogging.jpg" title="log"><img width="323" src="http://doddychsaputra.files.wordpress.com/2007/07/emaillogging.thumbnail.jpg?w=323&#038;h=77" alt="log" height="77" style="width:210px;height:118px;" /></a></p>
<p><span id="more-19"></span></p>
<p>the logging class has a duty to write the log in text file for every single stck error trace and then the email class will send those error stack trace automatically to the proper progammers email and also carbon copy to the system administrator.</p>
<p>let&#8217;s take a look for technically details ( continue to part 2 )</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/doddychsaputra.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/doddychsaputra.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/doddychsaputra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/doddychsaputra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/doddychsaputra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/doddychsaputra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/doddychsaputra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/doddychsaputra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/doddychsaputra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/doddychsaputra.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/doddychsaputra.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/doddychsaputra.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=19&subd=doddychsaputra&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-of-exception-handling-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b91382498b0b016e1364e483ec1bf7ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Doddy Christiana saputra</media:title>
		</media:content>

		<media:content url="http://doddychsaputra.files.wordpress.com/2007/07/emaillogging.thumbnail.jpg" medium="image">
			<media:title type="html">log</media:title>
		</media:content>
	</item>
		<item>
		<title>Multipurpose Data Access Layer part 2</title>
		<link>http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-data-access-layer-part-2/</link>
		<comments>http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-data-access-layer-part-2/#comments</comments>
		<pubDate>Mon, 02 Jul 2007 02:31:01 +0000</pubDate>
		<dc:creator>Doddy Christiana saputra</dc:creator>
				<category><![CDATA[Design Pattern Code]]></category>
		<category><![CDATA[Development in  C# 2.0]]></category>
		<category><![CDATA[Own design custom Framework]]></category>

		<guid isPermaLink="false">http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-data-access-layer-part-2/</guid>
		<description><![CDATA[In this 2nd part i&#8217;ll try to describe more detail in coding which i mentioned it in part 1,
a. ConnectionString Class

First Of all you need to save your connection string variable in your web config, in my case i put all of the setting in particular configuration setting class which being taken from webconfig setting.
I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=18&subd=doddychsaputra&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In this 2nd part i&#8217;ll try to describe more detail in coding which i mentioned it in part 1,</p>
<p>a. ConnectionString Class</p>
<ul>
<li>First Of all you need to save your connection string variable in your web config, in my case i put all of the setting in particular configuration setting class which being taken from webconfig setting.</li>
<li>I must inherit from the WebPageBase class for become the master of base page class, this WebPageBase class inherit the System.web.UI.Page , this class will become the property provider to every page in Web UI such as retrive the current user,current password and of course the applicationID that we need.</li>
<li>And the last thing i made two public static method which return the string of connectionstring and providername, both of those method will filter the appropriate connection string and provider name which inputed from each outside ( define input parameter ).</li>
</ul>
<p>     let see the complete module :</p>
<p>     <span id="more-18"></span>//********************************************************************************************************<br />
// SUBJECT      : MULTIPLE CONNECTION STRING AND PROVIDER CLASS<br />
// CREATED BY   : DODDY CH SAPUTRA , MCAD.NET <br />
// CREATED DATE : JUNE 26,2007<br />
//********************************************************************************************************</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Configuration;<br />
using System.Data.Common;<br />
using FrameworkLayer.WebUtility;<br />
using FrameworkLayer.ConfigurationUtility;<br />
namespace FrameworkLayer.DataUtility<br />
{<br />
    public class ConnectionToDatabase : FrameworkLayer.WebUtility.WebPageBase<br />
    {</p>
<p>   <br />
        //******* Code yang udAH OKAY MONCOR *****************<br />
        //public string Key<br />
        //{<br />
        //    get { return base.IdApplication; }<br />
        //}<br />
        //****************************************************</p>
<p>        //******** Tester Key ********************************<br />
        public string _Key = &#8220;GCS&#8221;;</p>
<p>        public string Key<br />
        {<br />
            get { return _Key; }<br />
            set { _Key = &#8220;GCS&#8221;; }<br />
        }<br />
        //******************************************************<br />
        public static string GetCN()<br />
        {<br />
            string Cn = string.Empty;<br />
            ConnectionToDatabase oKey = new ConnectionToDatabase();<br />
            string Key = oKey.Key.ToString();</p>
<p>            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.GcsAppKey)<br />
            {<br />
                Cn = ConfigurationManager.ConnectionStrings["CN_GCS"].ConnectionString;<br />
            }<br />
            else<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ElearningAppKey)<br />
            {<br />
                Cn = ConfigurationManager.ConnectionStrings["CN_ELN"].ConnectionString;<br />
            }<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.MMwebAppkey)<br />
            {<br />
                Cn = ConfigurationManager.ConnectionStrings["CN_MMW"].ConnectionString;</p>
<p>            }<br />
            else<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.BidAppKey)<br />
            {<br />
                Cn = ConfigurationManager.ConnectionStrings["CN_BID"].ConnectionString;</p>
<p>            }<br />
            else<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.OtherAppKey)<br />
            {<br />
                Cn = ConfigurationManager.ConnectionStrings["CN_OTHERS"].ConnectionString;<br />
            }</p>
<p>            return Cn;<br />
        }</p>
<p>        public static string GetPV()<br />
        {</p>
<p>            string Pv = string.Empty;<br />
            ConnectionToDatabase oKey = new ConnectionToDatabase();<br />
            string Key = oKey.Key.ToString();</p>
<p>            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.GcsAppKey)<br />
            {<br />
                Pv = ConfigurationManager.ConnectionStrings["CN_GCS"].ProviderName ;<br />
            }<br />
            else<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ElearningAppKey)<br />
            {</p>
<p>                Pv = ConfigurationManager.ConnectionStrings["CN_ELN"].ProviderName;<br />
            }<br />
            else<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.MMwebAppkey)<br />
            {<br />
                Pv = ConfigurationManager.ConnectionStrings["CN_MMW"].ProviderName;<br />
            }<br />
            else<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.BidAppKey)<br />
            {<br />
                Pv = ConfigurationManager.ConnectionStrings["CN_BID"].ProviderName;<br />
            }<br />
            else<br />
            if (Key == FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.OtherAppKey)<br />
            {<br />
                Pv = ConfigurationManager.ConnectionStrings["CN_OTHERS"].ProviderName;<br />
            }</p>
<p>            return Pv;<br />
        }<br />
     }<br />
}<br />
  </p>
<p>b. Query Builder Class</p>
<ul>
<li>I made theree public overloading method ( polimorphism method ) which could receive the SQL server provider and the config define. This all method has function the define and select the proper provider name for which consumed from the connectionstring class.</li>
<li>All Of Query syntax was embed either in this class wheter has a function to service all of query type and command type such as text query or stored procedure command type.</li>
</ul>
<p>Let&#8217;s get rock&#8217;n roll of the code :</p>
<p> <!--more--></p>
<p>//***********************************************************************************************************<br />
//  SUBJECT             : DATA ACCESS ENGINE PROVIDER AND QUERY HELPER<br />
//  CREATED BY          : Doddy Christiana Saputra , MCAD.NET<br />
//  LAST MODIFIED DATE  : JUNE 22,2007<br />
//***********************************************************************************************************</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Data.Common;<br />
using System.Data.SqlClient;<br />
using System.Data.OleDb;<br />
using System.Data.Odbc;<br />
using System.Data.OracleClient;<br />
using System.IO;<br />
using FrameworkLayer.LoggingUtility;<br />
using FrameworkLayer.DataUtility;<br />
using FrameworkLayer.ConfigurationUtility;</p>
<p>namespace FrameworkLayer.DataUtility<br />
{<br />
    public class QueryBuilder : IDisposable<br />
    {<br />
        private string strConnectionString;<br />
        private DbConnection objConnection;<br />
        private DbCommand objCommand;<br />
        private DbProviderFactory objFactory = null;<br />
        Logging msg = new Logging();<br />
      </p>
<p>        //private string strCN = FrameworkLayer.DataUtility.ConnectionToDatabase.GetCN();<br />
        //private string strPV  = FrameworkLayer.DataUtility.ConnectionToDatabase.GetPV();<br />
        public string _CN = string.Empty;<br />
        public string strCN<br />
        {<br />
            get { return _CN; }<br />
            set { _CN = FrameworkLayer.DataUtility.ConnectionToDatabase.GetCN(); }<br />
        }</p>
<p>        public string _PV = string.Empty;<br />
        public string strPV<br />
        {<br />
            get { return _PV; }<br />
            set { _PV = FrameworkLayer.DataUtility.ConnectionToDatabase.GetPV(); }<br />
        }<br />
 <br />
        //Overloading Provider<br />
        public QueryBuilder(Providers provider): this(FrameworkLayer.DataUtility.ConnectionToDatabase.GetCN(), provider)<br />
        {</p>
<p>        }</p>
<p>        //Overloading Connection String<br />
        public QueryBuilder(string connectionstring): this(connectionstring, Providers.SqlServer)<br />
        {<br />
        }</p>
<p>        //Overloading get Connection String and Provider<br />
        public QueryBuilder(): this(FrameworkLayer.DataUtility.ConnectionToDatabase.GetCN(), Providers.ConfigDefined)<br />
        {<br />
        }</p>
<p>        public QueryBuilder(string connectionstring,Providers provider)<br />
        {  <br />
            //Pemilihan Provider Database<br />
            strConnectionString = connectionstring;<br />
            switch (provider)<br />
            {<br />
                case Providers.SqlServer:<br />
                    objFactory = SqlClientFactory.Instance;<br />
                    break;<br />
                case Providers.OleDb:<br />
                    objFactory = OleDbFactory.Instance;<br />
                    break;<br />
                case Providers.Oracle:<br />
                    objFactory = OracleClientFactory.Instance;<br />
                    break;<br />
                case Providers.ODBC:<br />
                    objFactory = OdbcFactory.Instance;<br />
                    break;<br />
                case Providers.ConfigDefined:<br />
                    string providername = FrameworkLayer.DataUtility.ConnectionToDatabase.GetPV();<br />
                    switch (providername)<br />
                    {<br />
                        case &#8220;System.Data.SqlClient&#8221;:<br />
                            objFactory = SqlClientFactory.Instance;<br />
                            break;<br />
                        case &#8220;System.Data.OleDb&#8221;:<br />
                            objFactory = OleDbFactory.Instance;<br />
                            break;<br />
                        case &#8220;System.Data.OracleClient&#8221;:<br />
                            objFactory = OracleClientFactory.Instance;<br />
                            break;<br />
                        case &#8220;System.Data.Odbc&#8221;:<br />
                            objFactory = OdbcFactory.Instance;<br />
                            break;<br />
                    }<br />
                    break;</p>
<p>            }<br />
            objConnection = objFactory.CreateConnection();<br />
            objCommand = objFactory.CreateCommand();</p>
<p>            objConnection.ConnectionString = strConnectionString;<br />
            objCommand.Connection = objConnection;<br />
        }</p>
<p>       </p>
<p>      <br />
        public int AddParameter(string name,object value)<br />
        {<br />
            DbParameter p = objFactory.CreateParameter();<br />
            p.ParameterName = name;<br />
            p.Value=value;<br />
            return objCommand.Parameters.Add(p);<br />
        }</p>
<p>        public int AddParameter(DbParameter parameter)<br />
        {<br />
            return objCommand.Parameters.Add(parameter);<br />
        }</p>
<p>        public DbCommand Command<br />
        {<br />
            get<br />
            {<br />
                return objCommand;<br />
            }<br />
        }</p>
<p>        public void BeginTransaction()<br />
        {<br />
            if (objConnection.State == System.Data.ConnectionState.Closed)<br />
            {<br />
                objConnection.Open();<br />
            }<br />
            objCommand.Transaction = objConnection.BeginTransaction();<br />
        }</p>
<p>        public void CommitTransaction()<br />
        {<br />
            objCommand.Transaction.Commit();<br />
            objConnection.Close();<br />
        }</p>
<p>        public void RollbackTransaction()<br />
        {<br />
            objCommand.Transaction.Rollback();<br />
            objConnection.Close();<br />
        }</p>
<p>        public int ExecuteNonQuery(string query)<br />
        {<br />
            return ExecuteNonQuery(query, CommandType.Text, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public int ExecuteNonQuery(string query,CommandType commandtype)<br />
        {<br />
            return ExecuteNonQuery(query, commandtype, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public int ExecuteNonQuery(string query,ConnectionState connectionstate)<br />
        {<br />
            return ExecuteNonQuery(query,CommandType.Text,connectionstate);<br />
        }</p>
<p>        public int ExecuteNonQuery(string query,CommandType commandtype, ConnectionState connectionstate)<br />
        {<br />
            objCommand.CommandText = query;<br />
            objCommand.CommandType = commandtype;<br />
            int i=-1;<br />
            try<br />
            {<br />
                if (objConnection.State == System.Data.ConnectionState.Closed)<br />
                {<br />
                    objConnection.Open();<br />
                }<br />
                i = objCommand.ExecuteNonQuery();<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                msg.HandleExceptions(ex);<br />
            }<br />
            finally<br />
            {<br />
                objCommand.Parameters.Clear();<br />
                if (connectionstate == ConnectionState.CloseOnExit)<br />
                {<br />
                    objConnection.Close();<br />
                }<br />
            }</p>
<p>            return i;<br />
        }</p>
<p>        public object ExecuteScalar(string query)<br />
        {<br />
            return ExecuteScalar(query, CommandType.Text, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public object ExecuteScalar(string query,CommandType commandtype)<br />
        {<br />
            return ExecuteScalar(query, commandtype, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public object ExecuteScalar(string query, ConnectionState connectionstate)<br />
        {<br />
            return ExecuteScalar(query, CommandType.Text, connectionstate);<br />
        }</p>
<p>        public object ExecuteScalar(string query,CommandType commandtype, ConnectionState connectionstate)<br />
        {<br />
            objCommand.CommandText = query;<br />
            objCommand.CommandType = commandtype;<br />
            object o = null;<br />
            try<br />
            {<br />
                if (objConnection.State == System.Data.ConnectionState.Closed)<br />
                {<br />
                    objConnection.Open();<br />
                }<br />
                o = objCommand.ExecuteScalar();<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                msg.HandleExceptions(ex);<br />
            }<br />
            finally<br />
            {<br />
                objCommand.Parameters.Clear();<br />
                if (connectionstate == ConnectionState.CloseOnExit)<br />
                {<br />
                    objConnection.Close();<br />
                }<br />
            }</p>
<p>            return o;<br />
        }</p>
<p>        public DbDataReader ExecuteReader(string query)<br />
        {<br />
            return ExecuteReader(query, CommandType.Text, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public DbDataReader ExecuteReader(string query,CommandType commandtype)<br />
        {<br />
            return ExecuteReader(query, commandtype, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public DbDataReader ExecuteReader(string query, ConnectionState connectionstate)<br />
        {<br />
            return ExecuteReader(query, CommandType.Text, connectionstate);<br />
        }</p>
<p>        public DbDataReader ExecuteReader(string query,CommandType commandtype, ConnectionState connectionstate)<br />
        {<br />
            objCommand.CommandText = query;<br />
            objCommand.CommandType = commandtype;<br />
            DbDataReader reader=null;<br />
            try<br />
            {<br />
                if (objConnection.State == System.Data.ConnectionState.Closed)<br />
                {<br />
                    objConnection.Open();<br />
                }<br />
                if (connectionstate == ConnectionState.CloseOnExit)<br />
                {<br />
                    reader = objCommand.ExecuteReader(CommandBehavior.CloseConnection);<br />
                }<br />
                else<br />
                {<br />
                    reader = objCommand.ExecuteReader();<br />
                }</p>
<p>            }<br />
            catch (Exception ex)<br />
            {<br />
                msg.HandleExceptions(ex);<br />
            }<br />
            finally<br />
            {<br />
                objCommand.Parameters.Clear();<br />
            }</p>
<p>            return reader;<br />
        }</p>
<p>        public DataSet ExecuteDataSet(string query)<br />
        {<br />
            return ExecuteDataSet(query, CommandType.Text, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public DataSet ExecuteDataSet(string query,CommandType commandtype)<br />
        {<br />
            return ExecuteDataSet(query, commandtype, ConnectionState.CloseOnExit);<br />
        }</p>
<p>        public DataSet ExecuteDataSet(string query,ConnectionState connectionstate)<br />
        {<br />
            return ExecuteDataSet(query, CommandType.Text, connectionstate);<br />
        }</p>
<p>        public DataSet ExecuteDataSet(string query,CommandType commandtype, ConnectionState connectionstate)<br />
        {<br />
            DbDataAdapter adapter = objFactory.CreateDataAdapter();<br />
            objCommand.CommandText = query;<br />
            objCommand.CommandType = commandtype;<br />
            adapter.SelectCommand = objCommand;<br />
            DataSet ds = new DataSet();<br />
            try<br />
            {<br />
                adapter.Fill(ds);<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                msg.HandleExceptions(ex);<br />
            }<br />
            finally<br />
            {<br />
                objCommand.Parameters.Clear();<br />
                if (connectionstate == ConnectionState.CloseOnExit)<br />
                {<br />
                    if (objConnection.State == System.Data.ConnectionState.Open)<br />
                    {<br />
                        objConnection.Close();<br />
                    }<br />
                }<br />
            }<br />
            return ds;<br />
        }<br />
       <br />
        public void Dispose()<br />
        {<br />
            objConnection.Close();<br />
            objConnection.Dispose();<br />
            objCommand.Dispose();<br />
        }</p>
<p>    }</p>
<p>    public enum Providers<br />
    {<br />
        SqlServer,OleDb,Oracle,ODBC,ConfigDefined<br />
    }</p>
<p>    public enum ConnectionState<br />
    {<br />
        KeepOpen,CloseOnExit<br />
    }<br />
   <br />
}</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/doddychsaputra.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/doddychsaputra.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/doddychsaputra.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/doddychsaputra.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/doddychsaputra.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/doddychsaputra.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/doddychsaputra.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/doddychsaputra.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/doddychsaputra.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/doddychsaputra.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/doddychsaputra.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/doddychsaputra.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=18&subd=doddychsaputra&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://doddychsaputra.wordpress.com/2007/07/02/multipurpose-data-access-layer-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b91382498b0b016e1364e483ec1bf7ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Doddy Christiana saputra</media:title>
		</media:content>
	</item>
		<item>
		<title>Multipurpose Data Access Layer part 1</title>
		<link>http://doddychsaputra.wordpress.com/2007/06/30/automatic-database-provider-in-data-access-layer/</link>
		<comments>http://doddychsaputra.wordpress.com/2007/06/30/automatic-database-provider-in-data-access-layer/#comments</comments>
		<pubDate>Sat, 30 Jun 2007 03:18:20 +0000</pubDate>
		<dc:creator>Doddy Christiana saputra</dc:creator>
				<category><![CDATA[Design Pattern Code]]></category>
		<category><![CDATA[Development in  C# 2.0]]></category>
		<category><![CDATA[Own design custom Framework]]></category>

		<guid isPermaLink="false">http://doddychsaputra.wordpress.com/2007/06/30/automatic-database-provider-in-data-access-layer/</guid>
		<description><![CDATA[In my current project i have made some DAL ( Data Access Layer ) class in my framework which has some purpose for handling many project needs such as :
1.  Able to provide multiple connection string in my project
2. Able to provide the multiple datastore string with many provider
3. Should be able to handling many application [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=5&subd=doddychsaputra&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://doddychsaputra.files.wordpress.com/2007/06/class-design.jpg" title="class-design.jpg"></a>In my current project i have made some DAL ( Data Access Layer ) class in my framework which has some purpose for handling many project needs such as :</p>
<p>1.  Able to provide multiple connection string in my project</p>
<p>2. Able to provide the multiple datastore string with many provider</p>
<p>3. Should be able to handling many application parameter response redirect</p>
<p>see the picture below of my class design :</p>
<p><a href="http://doddychsaputra.files.wordpress.com/2007/06/class-design.jpg" title="class-design.jpg"></a><a href="http://doddychsaputra.files.wordpress.com/2007/06/class-design.jpg" title="class-design.jpg"><img src="http://doddychsaputra.files.wordpress.com/2007/06/class-design.thumbnail.jpg" alt="class-design.jpg" /></a></p>
<p>I put the all of my engine application in Framework layer project including the Data Access utility, wheter contain :</p>
<p>a. ConnectionString Class :</p>
<ul>
<li>This Class has purpose and duty to serving the connection string and provider name which will be consumed by the Query Builder class. In this class i set the Connection to database namespace and also i made inherit the web base class for accessing the web base class page property and method in the future utilization.</li>
<li>Why i must inherit from the page base class, in this project framework i need to access the ApplicationID property which catered by the page base class wheter all of web page should inherit from this base class.</li>
<li>After the initialially web page loaded in this case the default.aspx, there is an automatically fill the ApplicationID property in base class which consumed from the url parameter. Actually there is still need the decrypt class which serving for securing the parameter from URL but later i will create for this purpose.</li>
<li>This class has 2 methods which will cater the connection string and provider name the mthods are GetCN which return on string and either for GetPV.</li>
</ul>
<p>b. Query Builder Class ( Interface Class )</p>
<ul>
<li>This is sound of interesting part from the whole stories, this class has a duty for catering the automatically object parameter, object connection and the type of the sql command.</li>
<li>Therefore this class has an may important part method that execution in any output parameter method such as execute the dataset return,data reader return,execute scalar return in integer and also add parameter method for processing the parameter input to this class.</li>
<li>This Class has three kind overload method which catering the text string query, the stored procedure type of query which will be implemented in DAL project later. </li>
</ul>
<p><a href="http://doddychsaputra.files.wordpress.com/2007/06/class-design.jpg" title="class-design.jpg"></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/doddychsaputra.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/doddychsaputra.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/doddychsaputra.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/doddychsaputra.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/doddychsaputra.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/doddychsaputra.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/doddychsaputra.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/doddychsaputra.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/doddychsaputra.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/doddychsaputra.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/doddychsaputra.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/doddychsaputra.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=doddychsaputra.wordpress.com&blog=1305638&post=5&subd=doddychsaputra&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://doddychsaputra.wordpress.com/2007/06/30/automatic-database-provider-in-data-access-layer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b91382498b0b016e1364e483ec1bf7ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Doddy Christiana saputra</media:title>
		</media:content>

		<media:content url="http://doddychsaputra.files.wordpress.com/2007/06/class-design.thumbnail.jpg" medium="image">
			<media:title type="html">class-design.jpg</media:title>
		</media:content>
	</item>
	</channel>
</rss>