Thursday, June 15, 2006

Hello!

Today my blog has ranked on google for the first time, everything is a result of good SEO (Search Engines Optimization) actions on my web site..

Try to find me :)

Posted by: Eran Nachum (c)
Post Date: 6/15/2006 2:35:13 PM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [3] | Trackback   #
 Wednesday, June 14, 2006

While searching for new features and products from Microsoft's breeding ground, I discussed with my team leader Egozi, about nice advanced graphical editor that will be easy to use (not like professional editors and studios like: Photo Shop or FreeHand etc...) to design simple and well graphically designed web controls, like buttons, tabs, tables, grids and more... I wanted a nice graphical editor to create the above controls to be well designed and interactive for my private 'developing at home' application - Haverut.co.il.

He introduced me the Microsoft Expression tool (or product, call it whatever you like...). This product is still in BETA version but it works fine (for the most features I've tried).
The Product contains 3 tools:

  • Graphic Designer
  • Interactive Designer
  • Web Designer

I will focus on the Web Designer CTP1 (Community Technologhy Tool)!
This tool is very easy to use and supplies you greater flexibility to create sophisticated applications and contents. It contains nice code editor, that enables you to write code easily (with extended and comprehensive intellisense), sophisticaed CSS-based layouts, rich data presentation and more.

I played a little bit with that and created nice designed interactive button, that on hover and on click changes its color and design.

The regular design of the button:
The on mouse over design of the button:
The on mouse click design of the button:

And the coolest thing with this button creation is that you don't need to upload images or to create the javascript methods and CSS layouts, you design the button only with the graphical designer and saves the content - the tool generates the code automaticlly and creates the GIF or JPEG files and CSS code.

So go and download this, just play with it from: http://www.microsoft.com/products/expression/en/default.mspx

Bye for now...

Posted by: Eran Nachum (c)
Post Date: 6/14/2006 8:45:41 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [0] | Trackback   #
 Monday, June 12, 2006

Hi!

Yeasterday, while working on a big web application project, I wanted to copy System.Collections.Generic.Dictionary<TKey, TValue>'s values to a System.Collections.Generic.List<TValue>.

Instead running a loop over the Dictionary<T, K> and copy its values to the List<T>, I used the AddRange(TValues) method.
For example:

Dictionary<int, Job> myDictioanry = new Dictionary<int, Job>();

//Fill the Dictionary...

List<Job> listJobs = new List<Job>();
listJobs.AddRange(myDictioanry.Values);

Hope it will help someone...
see you later

Posted by: Eran Nachum (c)
Post Date: 6/12/2006 8:01:28 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [3] | Trackback   #
 Thursday, June 08, 2006

I am developing from this month a new web application project, and I think this will be one of the best *** sites on the web (*** means that the plan is still secret). The site will be called Haverut and it will be hosted on: www.haverut.co.il or www.haverut.com.

Now, as you know (or not), Microsoft has a nice Custom Membership and Roles Providers that generates very comfortable SQL Server database to work with and very comprehensive API to communicate with that enable you to manage all the membership and roles issue.

In my first thought, I was planing to build the pilot of my application to work with MS Access database, and ofcourse I wanted to use the Custom Membership and Roles Providers that Microsot supplies. After long searches on the web I found a msi file (you can dowload it here) that after you install it on your machine, it opens you a new template possibility in VS 2005 that called 'ASP.NET Access Providers'. This template generates you automaticly the Access database with all its tables and queries.

But, on the second thought I decided to build the database on SQL Server from the begining (much more secure and efficient).  

A very good acticle and tutorials references you can find at Scott Guthrie's blog at: http://weblogs.asp.net/scottgu/archive/2006/02/24/438953.aspx

See you...

(P.S. - If I didn't mentioned, the Custom Membership and Roles Providers is exist in the first place for SQL Server and you can activate with the aspnet_reqsql  command from the Visual Studio 2005 Command Prompt).

Posted by: Eran Nachum (c)
Post Date: 6/8/2006 8:13:15 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [1] | Trackback   #
 Tuesday, June 06, 2006

Yesterday noon, in a middle of our department's technical conversation, I raised the issue of the difference between IHttpHandler and IHttpModule models, because I'm using an IHttpHandler logic model in a part of the application I working on.

Also I want to clarify OrenEllenbogen's (one of our team leaderes) findings. He claims, correctly, that the clothing of an application (Global.asax) is the IHttpModule that "hosts" several IHttpHandlers. Now, by the specific request that goes through the IHttpModule firstly, it knows to navigate it to the specific handler (IHttpHandler) to handle it.

Here, I want to go into details about those two nice and essential models.

HttpHandler - Every typical page (that derives from System.Web.UI.Page) implements the IHttpHandler interface. Writing an IHttpHandler is no different that writing typical page or control. It includes server application objects like: Session, Request and Response. An HttpHandler is created for each request to the server and its lifetime exists on the request ProcessRequest step. (It important to mention that this action happens before the page events are raised (like Page_Init, Page_Load etc...)

Another thing to know about HttpHandler behavior is the IsReusable property that defined in the interface. If this retured as true, the HttpHandler won't be destroyed when a control exits ProcessRequest - it will be released to the pool for future requestor. This means that request specific data must be de-initialized at the end of the request, or re-initialized at the begining of a request.

Nice example of use is Url Rewriting. We used a handler in previous a web application development that handles multi-lingual states (supports English and Hebrew languages). We wrote an HttpHandler that in every request to the server, checks the browser url, and by a specific address symbols "guides" the page what language adn direction to display.

HttpModule - The HttpModule is the filter for all requests. It receives notification at various processing points during the lifespan of the request. We can map HttpModule to all application requets.

The main difference between HttpModule to HttpHandler is that HttpModule provides class intance for all application's requests and HttpHandler provides single instance for each request. Also, HttpModule doesn't store any data about any request because it handles all the application requests, opposite to HttpHandler that can store data about a specific request (IsReuseable property, remember...?)

An important adventage of HttpModule over HttpHandler is by the initializing and maintain an application state option, since there is alive class intance all along the application lifespan. For example, you can load a data structure (like XML string for example) in the Init method and use it safely accross the apllication lifespan.

Hope I answered some questions (if you had some...)

A nice implementation example you can find in MSDN or here.

 

Posted by: Eran Nachum (c)
Post Date: 6/6/2006 9:29:29 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [5] | Trackback   #
 Wednesday, May 31, 2006

Hello all...

After long evening of "Mangaling" and mingling at company party in 'GolfiTech' Tel Aviv yesterday, I came up to work this morning and decided to share you with Master Page working.

In the current project that we are working on, we are using MasterPage (new feature in asp.net 2.0). This is a great control that does the work like 'header' and 'footer' user controls, for an example, (that are customied by the user), it comes to let us better and easier unified design to all (ao some of) the application pages.

Good tutorials and example how to create Master Page you can find: here.

And now to the issue of this post. In some of the application that I am working on, in addition to the super master page, there is a nested one. Now, when I tried to get the control (from the server side ofcrouse) that sits in the nested master page I couldn't find it, and this was a problem ofcourse... :)

The solution is to go up until you reach the super master page and after it to go down to the nested master page where the control is. The syntax is:

Page.Master.Master.FindControl("<Container Name>").FindControl("<Control Name>");

Where the <Container Name> is the placeholder that holds the page.

Hope this will help someday...

Posted by: Eran Nachum (c)
Post Date: 5/31/2006 8:32:55 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [0] | Trackback   #
 Sunday, May 28, 2006

Hi!

In this post, I will examine several different approaches to work properly against web services. I will explain the question (or problem, you can define it however you want) from the real life: You are working on an HR registration application and you want to register a new employee to the system, but the DB that holds all the employees details is located in remoted server. The actions that the application need to do are:

  1. Check if the username is already exist in the repository of contents (first WS).
  2. Register the user and save her details to the system DB (second WS).
  3. Send a registration information to the user that all her details has been feed (third WS).

As we saw, every WS will do a single action, and the last 2 ones are dependent each other.

Now, the question that is being asked is how to handle those actions in exceptions cases, should I want to roll back or to complete the whole bunch of actions.

The approaches are:

  1. Repeated requests handling: This way handles the situation that the request is already has been sent to the remote server (by web service ofcourse), and we will want to know if the request handling is over. The way is to attach transaction indetifier to the request. By that, if the server is still busy (while processing the resuest), it will send an appropriate message to the client (status ID). This solution comes to prevent duplicates mesaages requests to the server. One more thing... when implementing this sulotion, you need to consider and to support large number of transcactions (for further cases). By that, the client needs to know the ID of the transaction before sending the request to the server.
  2. Two-Phase commit: Before I start speaking the solution, I will explain this term: The two-phase-commit protocol is a distributed algorithm which lets all nodes in a distributed system agree to commit a transaction. The protocol results in either all nodes committing the transaction or aborting, even in the case of network failures or node failures. Now, the common approach, claims that algorithm is not "healthy" to use when working over web services, because if the web service is fails (or shuts down) in a middle of a transcation, there is a chance that the remote server won't know to send a message regarding the transaction state. The solution recommended here is to devide BIG transaction(s) to small transactions, when every small transaction will be handled by one web service. One more important thing is to plan properly the transactions flow, to prevent as much as minimum loss of data (if accured). I recommend to execute each action over one web service, and to call to a transaction manager web service that will be responsable to all the web services actions.
  3. Queued Processing: This approach claims that as long as the request is OK (no exception has been received), we will assume that action has been completed properly. To implement this approach you need to create a requests' queue (the requests that we will want to execute). Now, if no exception has been received, the queue will continue executing the further ones. If an exception has been received, the mechanism will roll back the related requests.
  4. Transaction Locking: When calling a web service (which is a part of a transaction), all its related resources will be locked in purpose not to allow other users to execute it. Real life example is withdrawaling cash from an ATM. When the user withdrawals the money from the machine, the transaction and his related data in the database is being locked, to prevent mismatch.

In summary, I spread here 4 different approaches to handle transactions over web services. I will be glad to have some comments if you have some.

Wellness untill next time, see you...

Posted by: Eran Nachum (c)
Post Date: 5/28/2006 8:22:55 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [0] | Trackback   #
 Wednesday, May 24, 2006

Hello all again...

Some monthes ago, while reading professional tutorials, I encountered with a nice implementation (maybe some of you encountered it before, but I think this is a nice syntax to know) and it called Smart Indexer of a specific object.

Look at the example below:

class EranEntity
{
   private Hashtable qualities = new Hashtable();

   // Indexer (i.e. smart array) 
   public object this[string key]
   {
      get { return qualities[key]; }
      set { qualities[key] = value; }
   }
}

Here, I've created new class called, 'EranEntity' and it contains a Hashtable that holds all of my qualities (and I have a lot of it, as you know... :)). By building this property, it will be much easier to get quality or to update one using 'Dictionary' - the interface is much more readable and easier to use.

Now, lets set some qualities:

public static void Main()
{
   // Create EranEntity instance
   EranEntity entity = new EranEntity();

   entity["smart"] = "very good…";
   entity["nice"] = "very nice…";
}

Today in the new world of terms of .NET 2.0, we can also implement this genericly using the new Generics mechanism.

p.s.

Another thing, there is a VS. 2005 quick shortcut to do it by typing the word: indexer (in the editor ofcourse...) and clicking the Tab key until the whole bunch of code is being generated for you to edit.

 

See you for now...


 

Posted by: Eran Nachum (c)
Post Date: 5/24/2006 7:54:13 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [0] | Trackback   #