Archive for the Development in C# 2.0 Category

Hi guys,

If we know better about the design pattern, it will be usefull a lot for us to build the reusable software component like we want to achieve it, one of the famous pattern is singeleton and much of developer especially in web development until this time still confuse to implemented. Now i wanna to discuss the common usage of singeleton pattern in aspnet which always shown in development project. Lets rock and roll …

There may be numerous programming scenarios when we may need to restrict an
object to a single instance. Some of them are:

  • A single instance of a mail server might be required to process all incoming
    mail requests.
  • The Session object in ASP.NET is implemented using singleton pattern. That
    is why each user will have only one session instance accessible at any point
    of time.
  • The Application object in ASP.NET is also singleton based. There is only
    one instance of the Application object for an entire application.
    We may need a single instance of a logging utility to process all logging
    requests in our application.

(more…)

Hi..see you again.. this section is the continue part of my trilogy Multipurpose of Exception Handling class, okay let’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 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

public void AutomaticSendEmailLogging(string ErrorMessage)
        {
          
            MailMessage mailMsg = new MailMessage(); // Create instance of EmailMessage Object

            string templateName = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ProgrammerEmailName;
            mailMsg.From = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.EmailSender;
            mailMsg.To = FrameworkLayer.ConfigurationUtility.WebApplicationConfiguration.ProgrammerEmail;
            //mailMsg.Cc = EmailUser;

(more…)

Okay in this section part i will talk more detail about those kind of class ,

  1. Logging Class

Prerequisite for this class :

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

(more…)

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.

for instance is like this :

in DAL i am using the exception handling class –> if there is something error in my DAL class –> the error handler will capture the Exception stack trace –> the Exception class will talk to the Logging class and also either the email class.

and then my class like this Logging class and Email class :

log

(more…)

In this 2nd part i’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 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.
  • 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 ).

     let see the complete module :

     (more…)

I would like to share about how to handling the upload file or creating something in your project which is need for file uploading, in this part there are some purpose that we want to achieve :

1. Browsing the file in local client into the list of file uploading

2. Move the all file list into the table which already to sent to web server  

  • The UI design                          * User Control for Editing and viewing Files

           UI Design                   grid-view-file.jpg

  • From the UI design I made the MediaFileUpload.Aspx , and then in the code behind of this control you need to made a declaration for web file repository like this : 

(more…)

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 parameter response redirect

see the picture below of my class design :

class-design.jpg

I put the all of my engine application in Framework layer project including the Data Access utility, wheter contain :

a. ConnectionString Class :

  • 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.
  • 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.
  • 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.
  • 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.

b. Query Builder Class ( Interface Class )

  • 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.
  • 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.
  • 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.