jump to navigation

User front end for mlists November 9, 2006

Posted by _netoLopez in .net, c#, mlists, programming, projects, web2.0.
add a comment

Ok, now to implement our MailingList class on an application…

I’ll start by showing a screenshot of my outcome,

MailingList GUI

notice I divided it by coloring some sections as follows:
Orange, active mlists
Yellow, selected mlist detail
Blue, create a new mlist
Green, subscribe/unsubscribe to an mlist
Gray, distribute some “html” content to a list

The Orange section

Here, we interact with the MailingList class by means of the GetActiveLists() static method, to get a string array of active mlists on the database. With the string array, I iterate thru it and output some more ways to interact with a MailingList object to accomplish other stuff (refer to the links).  Since I already have the active mlist codes, I also use the same iteration to populate some dropdowns on the Green and Gray sections, which we’ll see later.

mlists_orange_load

Other things that can be covered for the Orange section are the view link and the expire link.

View link: this will show us the active (not expired) email addresses that are subscribed to the mlist. On my implementation, this will popup a new window.

mlists_orange_view

This popup contains the mlist Name in bold, followed by the mlist Description, and then the list of subscribers.

This is my implementation of the View view :P

mlists_orange_view_code

the mlist object is instantiated relying on a QueryString parameter provided by the document opener (as I used a popup). This is the url I used to load the window:
http://server/MailingLists/mlist_entries.aspx?c=Presentation. This will render the Presentation mlist detail to screen!

Expire link: clicking here, will remove the mlist from the list. I accomplished this by going to another page, doing the thing, and then coming back to the initiating page. Here’s the code:

mlists_orange_expire

Again, the mlist is instantiated relying on a QueryString parameter coming from the referer link (?c=mlist.Code).

When the flow goes back to the referer page, it will execute the Page_Load() method, which will ask the MailingList class for the active lists, the recently expired mlist will no longer be included…

The Yellow section

There’s also another user event that goes on on the Orange section, this is when the user clicks on the mlist code. Clicking on the mlist code from the Orange section, will make the Yellow section display the selected mlist detail.

I will not go into detail on my implementation, I’ll just state an overview of what I did.

Used Ajax to tell the server to make an html table with the Name and Description of a specific mlist. Put the resulting html table into the Yellow section (I may expand on the topic on a later blog entry).

The Blue section

This section will use the MailingList class to create more mlists. This is done by means of the Create() static method. The method argument values are provided on the textboxes.

mlists_blue_create

I used the Response.Redirect() to deal with the repainting of the mlist list on the Orange section.

The Green section

The subscription and removal of email addresses from certain mlist will be handled with the Green section. The user would type an email address and select the desired mlist he/she wishes to affect.

mlists_green_code

The Gray section

The last section we’ll cover is the Gray one, where you get to send the same email to all the entries in an mlist. You select the target mlist from the dropdown, and type in a subject and some content, then hit the Publish button :mrgreen:

mlists_gray_publish

… I think this wraps up the Mailing List application series (mlists), please post your comments and thoughts about the series and any suggestions for future ones…

The Logical Layer (mlists) November 6, 2006

Posted by _netoLopez in .net, c#, database, mlists, mssql, programming, projects, web2.0.
add a comment

…or business logic tier, or middle tier/layer…, what I mean to say is that the code on the MailingList class that I’ll present is not tied to any GUI/display functions, meaning it may be used in a web environment, or a desktop application just fine.

Namespaces
Let’s start by viewing and explaining the required .net namespaces:

MailingList namespaces

The System namespace is always used.
The System.Data will supply us with generic data objects like DataTable and DataRow.
System.Configuration we use because we rely on a configuration file (same for web or desktop) to store certain values like connectionStrings.
System.Data.SqlClient is used to connect to an SqlServer2oo5 database instance (or file in our case because of express edition).
And last but not least, the System.Net.Mail namespace we use to send email messages thru SMTP (this is new in .net 2.0 as previously we had to use System.Web.Mail).

Properties
This is how I implemented the properties, all of them are read-only…

MailingList properties

Constructors
I have specified a public constructor that accepts a code parameter to initialize the object properties based on it, and hidden the default constructor from public use; making it private thou, I can still use it on my static methods shown later.

MailingList Constructors

Basically, the public constructor will use the supplied code to get the rest of the property values (name and description). Recall the table definitions on previous post. Notice the use of the helper database method GetDataTable().

Static methods (no instantiation needed)
I implemented two static methods that do not require MailingList to be instantiated to be used.  These are Create() and GetActiveLists().

Create() is used to “add” a new list to the application.  GetActiveLists() will return an array of list codes.

MailingList static methods

Create() method: there are some validations pending, but left them as TODOs to keep the code sample short.  I did do validation to check if the code already exists, and threw an ApplicationException if it in fact exists… Else if the provided code is valid, a new list is created!

GetActiveLists() method: This will query the database and get the list codes that have not been expired.

Object Methods

MailingList expire

When called, Expire() will remove the list from active lists, setting a datetime value on the [expires] field.

MailingList subscribe

The Subscribe() method, will add an email address to the currently instantiated mailingList. Notice it is first activating the email address by “unexpiring” it (putting null on [expires]);  and if this doesn’t work (variable i will be zero), it’ll insert a new row.  I did this because on the mlists_entries table, I placed a uniqueness constraint on the [list_id]+[inbox] columns.

MailingList unsubscribe

This one will do the opposite, it’ll remove an email address from the active list of addresses in the current list.

MailingList update

the Update() method is our way to edit the name and description properties of our mailingList instance.

MailingList getEntries

GetEntries() will retrieve an array of active email addresses from the current mailingList object.

MailingList publish

And the Publish() method, will send an email message to each of the emails retrieved by the GetEntries() method.  This method got a little messy… First, I’m getting some values from the web.config file, being senderInboxDomain and smtpServer.  The senderInbox variable, used to set the From property of the MailMessage instance, is composed of the code ([list_id]) of the mailingList plus the senderInboxDomain.  Second, I am appending stuff to the htmlContent (used as the main body of the MailMessage instance), I recommend appending the following two things to a mailingList message: a disclaimer & a way for the recipient to remove themselves from the list.  Third, the method is relying on the GetEntries() method to get the list of email addresses, and then looping thru them sending the message to each one :D .

Wrapping up the MailingList class
This is all the code I placed on the MailingList class. It covers all the requirements listed in the first post of this series (mlists).  My next entry will touch some activities I did when implementing the user interface portion of the project.

Getting our hands dirty (utility methods) November 6, 2006

Posted by _netoLopez in .net, c#, database, mlists, mssql, programming, projects, web2.0.
add a comment

Hello everybody!, to continue with this “blog-project”, I decided to go with .net 2005 [framework 2.0] (c#) and msSql Server 2005 express edition.

I’ll start by showing two methods I like using to access databases when I’m not relying on stored procedures or any other fancy rdbms stuff…

The first one is GetDataTable() and the second one is Execute()…  These methods are SQLServer2005 specific, but can be made more generic using System.Data.OleDb. They are very handy for quick-and-dirty projects :mrgreen:

{pardon the code display, but wordpress has been stripping all my html and I didn’t like how this template shows code :D }

GetDataTable() returns a System.Data.DataTable; this method will take a SELECT statement to run against your database and will return a DataTable which you can use as you please. Personally, you’ll never see me using a DataGridView object on my projects :wink: . Click here for code.

Execute() returns an integer stating how many rows were affected by the sql statement. It requires you to supply one of the following types of statement: INSERT or UPDATE or DELETE. Click here for code.

Only thing to note on these two methods is they use a web.config appSetting key to get their connectionString. We’ll see the web.config file later.

Mailinglist app, round two November 2, 2006

Posted by _netoLopez in database, mlists, programming, projects, web2.0.
4 comments

 Class(es) design

Now that we have 2 tables to support our application, I’ll mock up a class or two… I’ll keep it simple and not bother with layers…

OK, the MailingList class:

I’ll start with the properties:

  • Code
  • Name
  • Description

Now for some methods:

  • Initialize(string code)
    • this would be the constructor
  • Create(string code, string name, string description)
    • this will be used to create a new mailing list!; I would like this to be a static method
  • Expire()
    • this one will “remove” an active mailing list and mark it inactive
  • Subscribe(string inbox)
    • this will add a new email to a list
  • Unsubscribe(string inbox)
    • this one will “remove” an email from a list
  • Publish(string htmlContent)
    • this one will send an email with the specified content to each entry in the list!
  • Update(string name, string description)
    • here, we can edit the name and the description for the list, the code will remain the same forever…. :twisted: {thx pako!}

Well, looks like this class has it all !! :D

… so I guess the next step would be to start coding… the next item in the toc (table of contents :!: ) is “choosing the technology”…

Don’t know if I can make a poll in wordpress {I’m thinking that could be the topic for the next series of posts} so I’ll rely on the comments to let readers (you!) suggest, or better phrased, pick the technology set to develop this project.

Here’re the choices…

Database choices

  • MSAccess
  • MS SQLServer (express edition)
  • Oracle 10g (express edition)
  • MySQL

Programming Language choices

  • .Net vb
  • .Net c#
  • php
  • java (j2ee)
  • vb6 (what the hey…)

Keep in mind that the produced class will be used in a web environment, so for User Interface (GUI) I’ll choose that part based on the programming language. Meaning if .Net is selected, we’ll use ASP.NET; if php is selected, we’ll use php; if java is selected, we’ll use JSP; as for vb6, we’ll use ASP.NET.

As for application container, that is also linked to the programming language.  On my mind choices are IIS and tomcat. Right now I do not see Apache in the picture as I’ve never configured it :S.

Another thing, this blog has no readers so the final decision may end up being my preferences :P !

Another consideration I would take follows: I have places (at least I think I do) to host on internet (yey!) solutions on .net and php and this could lead to a post for implementation…

Feel free to comment in either english or spanish !

Creating mailing list application, the beginning November 1, 2006

Posted by _netoLopez in design, mlists, programming, projects, web2.0.
1 comment so far

Hello, for my first real post here, I’ll attempt to step thru the design, development, and possibly the implementation of a simple, extendable application to manage mailing/distribution lists (this accomplished by a series of posts =D).

(this is my first post and getting familiarized with linking and inserting images :P)

A mailing list, as I grasp the concept, would be a list of emails that grows as interested people subscribe to the list because they want to receive periodic updates on a certain topic.  They can also unsuscribe when they choose to of course.

The series of posts relating the mailingList component, will try to adhere to the following toc:

  • requirements
  • backend design
  • class(es) design
  • choosing the technology set
  • showing some code
  • maybe implementing somewhere, or choices

Requirements – Starting from the beginning

I’ll list some basic requirements that should be present in the solution:

  • manage lists
    • add
    • delete
    • edit
  • subscribe
  • unsubscribe
  • distribute

That looks like a simple, yet functional set of requirements for our project…  This one other comes to my mind, but I’ll exclude it to keep simplicity [html or plain text format as preference].

The Backend design (as in where to store the data)

{this rich text control on wordpress is really cool! easy to use!!}

This is how I envision the dataStore entities, I may change my mind as we go ahead :P

  • mlists
    • list_id : string [PK]
    • list_name : string
    • list_desc : string
    • expires : date
  •  mlists_entries
    • entry_id : number [PK]
    • list_id : string
    • inbox : string
    • expires : date

description of mlists: in this table, we would manage the list set.  Here’s where we would add new lists, edit them if necessary, and “remove” them.  There are some scenarios where deleting does not necessarily means DELETE, but hide… that’s what the [expires] field will do, if the date stored here is smaller than “current_date”, that means it is inactive. 

description of mlists_entries: here, we will keep track of the emails that are subscribed to a certain list from [mlists].  [expires] serves the same function as in [mlists].

my time’s up, but I’ll continue in a bit :D

Claiming my blog @ Technorati November 1, 2006

Posted by _netoLopez in unique.
comments closed

Technorati Profile

Follow

Get every new post delivered to your Inbox.