Archive for March, 2006

15MarGenerics are great

Today I explored generics properly and I must admit that I’m very sorry i did not take the time earlier

Bottom line : GENERICS ARE GREAT

01MarMulti-Threading in asp.net

I got a question asked just recently about multi threading and async execution of a page.

About async execution I am a little bit biased because for asp.net I don’t really see a huge benefit most of the time and I really believe it should be used very wisely.

Spawning threads on the other hand is more convient for lengthy operations that are not essential to the execution of the page.  I will just copy paste the mail I’ve sent to the other guy. It came with a question on what about cleaning of the objects afterwards

If you use it async asp.net should take care of the cleaning.
I haven’t used the async scenario yet because I jump to separate threads more quickly that way my page isn’t blocked ever and I can update the interface through a timed ajax call to a webservice.
I use the multi threading to send mass emails with progress bar etc.
Once you’ve done it you will see that it is pretty easy to implement and has IMHO more advantages than simply executing a page async because you don’t have to wait for the execution to end.
 
You start by making a worker class with a parameterised constructor that implements at least the following interface
 

    4     interface IAggregatorWorker

    5     {

    6         void ExecuteTask();

    7         bool KeepRunning { get; set; }

    8     }

 
The execute task method is the method where you do your work as long as KeepRunning is set to true.  I believe that sessionstate is unavailable in a spawned thread so you will have to find a way to persist your session objects differently if you are needing them at all.
If you want to add properties for the worker thread to work with you that is no problem it behaves as a normal class as far as i can tell
 
In your page you start a thread by instantiating your workerclass and setting the properties
 

   45         BLL.MailThreadWorker mtc = new BLL.MailThreadWorker();

   46         mtc.Body = tbBody.Text;

   47         mtc.Subject = tbSubject.Text;

   48         Guid id = Guid.NewGuid();

   49         mtc.BaseUrl = Request.Url.DnsSafeHost;

   50         mtc.SessionId = id;

   51         System.Threading.Thread thread = new System.Threading.Thread( new System.Threading.ThreadStart(mtc.MailingStart));

   52         thread.Name = “MailingThread” ;

   53         thread.Start();

 
You can stop or suspend the thread at any time and then you can dispose of your objects that are still hanging around. By setting the property of KeepRunning property of the worker instance to false.
and there you should do your clean-up.  The code from the mailingthread is taken from the code beside (i believe is the new word for the file) of my aspx page.
 
This is a link to an article on msdn that explains it probably a lot cleaner than I ever can. Other good examples to look at what you can do with threading is to look after articles about windows services there are a few that explain the concept really clearly
 

01MarFTP Server with sql acces

I have the need to run an ftp server for one of my applications. It is to complement a web application where there is a pretty big datatransfer.  Users need to be able to register and upon activation they need to be able to upload movies (20-70MB) to a folder online. These movies need to be made available online and proposed for review to somebody in the company.

So far so good. Were it not that we are running IIS Ftp server for the moment who stores it’s users in the AD of the server. That is not the place where I want to store credentials for my users. Also I wanted to make only one folder available for a user and to accomplish this IIS is just too difficult to manage.  Thus again time for an internet hunt and yessss there is is Blackmoon FTP server who allows to do the entire configuration in a sql database or an access database. 

Fits like a glove in my opinion :)
I downloaded it, installed it end yes it just works. I can now do the full configuration through the generated DAL from ORM.NET. All it took to integrate an FTP server in my application was one afternoon and that’s it.

You can download blackmoon from their site. They offer a free version for personal use. But even from the enterprise edition with domain license you won’t become  poor man :)
http://www.blackmoonftpserver.com

01MarA poor man’s code generation

There has been a lot of talk about code generation and ORM software around where I was.

I got curious and embarked on a free codegeneration exploration. Being new to the concept of codegeneration my requirements were the following :

  • It needs to be faster then the dataset generator of visual studio 2005
  • It needs to support relations
  • It needs to support stored procedures or at the very least use dynamic query language that uses parameters to set up queries to the database.
  • It needs to be with a very very fast learning curve.
  • It needs to be free (although I also looked at the wilson O/R mapper which is practically free and LLBL codegen which is definetely not free)

These are my findings :

The one that is most easily found is mygeneration with the dOOdads architecture out of the box. Of course you can create your own templates to customize the generated code to you your specific needs and architecture.
my generation can be found at : http://www.mygenerationsoftware.com/portal/default.aspx
It does work fine but the dOOdads architecture does not support relations and these you have to make yourself again.  I found it all a bit too much fiddling about and it didn’t meet my 2 of my requirements, thus the search went on.

Next I found ORM.NET, which is the one I am using for the moment. Total setup time of a DAL that is easily queried 1,5 min flat. I was impressed, and best of all it is completely free. Apparently it is written by a consulting firm that used it for their internal needs. They no longer support it and it turned open source.
ORM.NET gets my stars. And I will be using it a lot in simpler scenario’s like websites etc.
ORM.NET can be found at : http://www.olero.com/OrmWeb/index.aspx?p=ORM.ascx

While looking for some documentation on ORM.NET I came across a link to ntiergen.net which can handle about any job. It generates stored procedures for you, along the DAL and the needed classes. You get to configure all your stored procedures beforehand and get the opportunity to create views and complicated queries through their interface.  Normally it is priced at $449 but the link I found offers a fully functional licensed version open for the public. I downloaded it and just gave it a brief look as I am very pressed for time at the moment.
nTierGen.NET can be found at http://weblogs.asp.net/gavinjoyce/archive/2004/08/28/222017.aspx

Happy code generating !!!

 


Recent Flickrs

    Blogroll

    Recent Listening

    Scrobbler