Protected: Software Architecture -To Study PCMS – Pegasus ERP Cargo Management System-Release-6 from Architecture perspective.

November 6, 2010

This content is password protected. To view it please enter your password below:


Protected: Software Architecture – Assemblies Abstractness vs. Instability for PCMS – Pegasus ERP Cargo Management System Release-6

November 6, 2010

This content is password protected. To view it please enter your password below:


Protected: Software Architecture – Assemblies Dependencies Diagram for PCMS – Pegasus ERP Cargo Management System Release-6

November 6, 2010

This content is password protected. To view it please enter your password below:


Software Architect – New Feature – WFP 4.0 and Silverlight 4.0 – Layout Rounding

September 15, 2010

Layout Rounding is a new concept in WFP 4.0 and Silverlight 4.0
Which means that the layout rendering engine rounds off non integer values during layout pass.

UIElement Class has a UseLayoutRounding property. The default value of this property is true, which means that layout rounding is on by default.

Example:

Lets put some xaml on silverlight page as:

<Grid x:Name="LayoutRoot" Background="White" UseLayoutRounding="False" Width="388">
        <Button Content="Shahzad Sarwar"  Height="150.5" HorizontalAlignment="Left" Margin="12,64,0,0" Name="button1" VerticalAlignment="Top" Width="363.5"  BorderBrush="Black"  BorderThickness="4" Background="White" FontSize="38"/>
    </Grid>

Output of appears as shown in image below:

[Zoom till 600% to view the real details]

Note that Firstly, the border of button [Bottom + Right] has a shade of light grey color. Secondly, 4 corner of border has some shade effect. Thirdly, characters of text have some shade effect.
First shade effect is not required, but second shade effect is required to show the corner shape and third shade effect is required to show the edges of characters.
These effects are called “antialiasing effect”

Before version 4.0, there was no concept of LayoutRounding. So effect was same as false.

Change UseLayoutRounding to True as:

<Grid x:Name="LayoutRoot" Background="White" UseLayoutRounding="True" Width="388">
        <Button Content="Shahzad Sarwar"  Height="150.5" HorizontalAlignment="Left" Margin="12,64,0,0" Name="button1" VerticalAlignment="Top" Width="363.5"  BorderBrush="Black"  BorderThickness="4" Background="White" FontSize="38"/>
    </Grid>

Output will be as:


[Zoom till 600% to view the real details]

Note that First antialiasing effect at the border of button is gone which was causing bad visual effect. Second and Third antialiasing effects are still there which are usefull to have a better visual effect.


Software Architecture – Difference between id, name and clientid – For WPF/Silverlight/Window Forms/ASP .Net?

August 14, 2010

Lets focus on id and name first.

For WPF/Silverlight/Window Forms:
There is no concept of “id” in WPF, Silverlight and Windows Forms. But “name” is used to identify a control uniquely. So if you create a Textbox with “name” as “myTextBox”, then a variable will be created in code behind to access its properties.

For ASP .Net
In ASP .Net, “id” is used to uniquely identify a control in a page.

In ASP .Net, if you create a TextBox control as:

<asp:TextBox  ID="TextBox1" runat="server"></asp:TextBox>

Then in code behind file, a variable will be created as “TextBox1”, so in ASP .Net “ID” is used to uniquely identify a control.

So if you create a ASP .Net page with controls as:

<asp:TextBox  ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox  ID="TextBox1" runat="server"></asp:TextBox>

It will give a compile time error that two controls with same “ID” can’t co-exist in the same ASP .Net form.

If you will put control as below:

<asp:TextBox  name="TextBox1Name" ID="TextBox1" runat="server"></asp:TextBox>

A message will be shown as below:

Validation (ASP.Net): Attribute 'name' is not a valid attribute of element 'TextBox'.	

So in Asp .Net “name” is not allowed in server side control.

In ASP .Net, against following ASP .Net control

<asp:TextBox   ID="TextBox1" runat="server"></asp:TextBox>

Will transform in html as:

<input name="ctl00$MainContent$TextBox1" type="text" id="MainContent_TextBox1" />

Means that a “name” attribute is automatically created by concatenating the control hierarchy with “$” character and ” ID” values modified by concatenating with “_” character.
It is because in HTML ID and Name co-exist side by side.

id attribute was introduced only in DOM .ID supposed to be unique for the given document, while name can be the same for many elements (think of radio buttons group for instance).

According to http://solidlystated.com, best comparison can be done as:

Id Attribute
• Valid on any element
• Each Id should be unique
• Can be used as anchor reference in URL
• Is referenced in CSS or URL with # sign
• Is referenced in JS with getElementById()
• Shares same name space as name attribute
• Must begin with a letter
• Is case sensitive

Name Attribute
• Valid only on a, form, iframe, img, map, input, select, textarea
• Name does not have to be unique
• Can not be referenced in CSS or URL
• Is referenced in JS with getElementsByName()
• Shares same name space as id attribute
• Must begin with a letter
• Is case sensitive
• Used on form elements to submit information

Reference:
http://solidlystated.com/scripting/html-difference-between-id-and-name/

According to w3, following are main usage of ID attribute in HTML:

• As a style sheet selector.
• As a target anchor for hypertext links.
• As a means to reference a particular element from a script.
• As the name of a declared OBJECT element.
• For general purpose processing by user agents (e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.).

What is clientid?
There is no concept of ClientID in Windows forms, Silverlight and WPF. It is only related to ASP .Net.
Clientid is used to give a systemically created id attribute to HTML control generated by running a ASP .Net control.

<script type="text/javascript">
    function DoSomething(){
        alert('<%= TextBox1.ClientID %>');
    }
</script>

The above code will give “MainContent_TextBox1” showing the id of control.


Software Architecture – Problems and Solutions with MVVM Model-View-ViewModel

July 29, 2010

MSDN Flash Newsletter pointed out a very good article dated July 19, 2010 .

Topic: When is the MVVM design pattern applicable to RIA and desktop apps? When is it unnecessary?
By: Robert McCarter
URL: http://msdn.microsoft.com/en-us/magazine/ff798279.aspx

Really a good Reading.


Software Architecture – Tips for Development Model with Microsoft Visual Studio 2010+ .Net Framework 4.0 + Sliverlight 4.0

June 27, 2010

Environment:
Microsoft Visual Studio 2010+ .Net Framework 4.0 + Sliverlight 4.0
WCF + Nhibernate + Sliverlight

Assumption: This document assumes that you have initial understanding of WCF and NHibernate.

Tips:
1. Entities will be shared b/w NHibernate and WCF, so sample entity will look like as:

[DataContract]    
    public class City
    {
        public City() { }

        [DataMember]
        public virtual int CityID { get; set; }

        [DataMember]
        public virtual string CityCode { get; set; }

        [DataMember]
        public virtual string Description { get; set; }
             
    }

Corresponding HBM will look like as:

<class name="SilerverlightTest.Web.City, SilerverlightTest.Web" table="GeneralCityMaster" lazy="false" >
      <id name="CityID" column="CityID">
        <generator class="native" />
      </id>
      <property name="CityCode" column="CityCode" />
      <property name="Description" column="Description" />
       </class>

2. Incase there are circular references between the entities of Data contract, all entities must be marked as IsReference = true. See below:

 [DataContract(IsReference = true)] 
public class CurrencyRate : ParentClass<CurrencyRate>
{
 }

Search goolge with keywords “WCF + NHibernate + circular reference” for more details and see top 5 links for theory related to it.

3. As lazy loading can’t work across the WCF wire, so all entities must be marked as lazy=”false” in HBM file. See Below.

<class name="Pegasus.BusinessObjects.General.Main.Company, PCMS-SL.Web" table="GeneralCompanyMaster" lazy="false" >

4. Incase of ManyToOne relationship in class of HBM files, make sure to add option not-found=”ignore” so that if relation is missing then exception is not thrown.

<many-to-one name="ModifiedBy" column="ModifiedBy" class="Pegasus.BusinessObjects.General.Administration.Employees, PCMS-SL.Web" cascade="none"   lazy="false" not-found="ignore"/>

5. In all *.svc.cs, services must be marked as [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
See Blow:

 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class AccountsManager : IAccountsManager
    {
}

6. For many issues, WCF Service will show following error as:
{System.TimeoutException: The HTTP request to ‘http://localhost/PCMS-SL.Web/businessmanagers/MastersManager.svc&#8217; has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout. —> System.Net.WebException —> System.Net.WebException
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.c__DisplayClass5.b__4(Object sendState)
at System.Net.Browser.AsyncHelper.c__DisplayClass2.b__0(Object sendState)

That is general error, possible error can be anything that is specified above.So try to investigate the root cause of this error.

7. In order to see the exception generated in WCF Service enble error in web.config of ASP Project as:

<behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>

8. Copy ClientAcessPolicy.xml at the root of ASP .net Project, with content as:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from>
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

Otherwise following error will occur:

An error occurred while trying to make a request to URI “http://localhost:1498/SecurityManager.svc&#8221;. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.

Search google with this exception and see top 5 urls for theory related to it.

9. NHibernate will list for IList for collection definition. But WCF Look for List so a trick is to use properties as :

<bag name="InstrumentList" cascade="all" inverse="true" lazy="false">
        <key column="Cityid" />
        <one-to-many class="SilerverlightTest.Web.Instrument, SilerverlightTest.Web"  />
      </bag>

Code for collection will be as:

public virtual IList<Instrument> InstrumentList {get;set;}

        [DataMember(Name = "InstrumentList")]
        public  List<Instrument> InstrumentListPrivate
        {
            get { return  new List<Instrument>(this.InstrumentList) ; }
            set { this.InstrumentList = value; }
        }  

For reference see the link below:
http://stackoverflow.com/questions/1538811/nhibernate-and-wcf-ilist-conflict

10. Exception as:
{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. —> System.Net.WebException: The remote server returned an error: NotFound. —> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.c__DisplayClass5.b__4(Object sendState)
at System.Net.Browser.AsyncHelper.c__DisplayClass2.b__0(Object sendState)
— End of inner exception stack trace —
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)

That is general error, possible error can be anything that is specified above. So try to investigate the root cause of this error.


Software Architecture – From Windows Presentation Foundation To Silverlight

May 21, 2010

Topic:  From Windows Presentation Foundation To Silverlight

Date: 21th May 2010

 A brief introduction of SL for WPF Developers

  This Presentation assume that you have at least 6 months experience with WPF

Feel free to pass comments.

 

 


Software Architecture -Presentation layer technologies Comparasion – Windows Forms VS ASP .Net VS WPF VS Sliverlight

May 2, 2010

 Project: PCMS, Pegasus Cargo Management System

Date: 2nd May 2010

Subject: To study different presentation layers technologies in Microsoft .Net framework

 Problem Definition:

Suppose you are planning to develop a new application, so the most difficult elements are architectural and strategic decisions that are related to technology selection from a large stack of available Group.

Each technology and product has is own pro and corns. So detailed analysis of all aspects of technology, is must.

Microsoft .Net provide a wide set of technologies and tools for presentation Layer creation, so right decision to select a tech is very critical for success of a project.

 

Solution:

List of Presentation layer technologies are as:

  • Windows Forms
  • ASP .Net
  • WPF
  • Sliver light

 

Windows forms are Fat client applications. ASP .Net is thin client application. WPF and Sliverlight are smart client Applications.

Let differentiate b/w definition of Fat , thin and smart client.

Fat Client, according to Wiki:

A fat client is a computer or computer program  in client–server architecture networks which typically provides rich functionality independently of the central server.

So Windows form application don’t have depency to central server a lot. That is application runs on client end and uses most of resources from client machine in a client server Arcchitecture.

 

Fat Client is also called Rich Client or  Thick client.

Thin Client according to Wiki:

A thin client (sometimes also called a lean or slim client) is a computer or a computer program which depends heavily on some other computer (its server) to fulfill its traditional computational roles.

So ASP .Net application heavy depends on central Server. Actually ASP .Net application reside on server (IIS), IIS processes all the application logic and throws only HTML on client end. Communication between client and server is handled by Request (from Browser on client end to IIS at Server end) and Response (from IIS at Server end to Browser on client end).

Smart Client according to Wiki:

Smart Client is a term used to describe an application environment which:

  • delivers applications over a web http connection
  • does not require installation (or provide automated installation and updates)
  • automatically updates without user action
  • has the look and feel of desktop applications

So,The term “Smart Client” is meant to refer to simultaneously capturing the benefits of a “thin client” (zero-install, auto-update) and a “fat client” (high performance, high productivity).

Mainly there are four platforms for building Smart client applications :
Flex : from Adobe.
JavaFX : from SUN.
Windows Presentation Foundation (WPF)/SliverLight : for Microsoft
DataSnap/WebServices : from CodeGear.

WPF and SL both provide look and feel of desktop applications, but still runs on browser.

So they combine the features of Thick client and Thin Client , thus called Smart client.

Smart Client is also called “Rich Internet Application” (RIA) and “rich web application“.

 

 

SilverLight Vs WPF

 

1. Silverlight is simply a subset of WPF.

2. Silverlight is meant to be used online, while WPF is for local use.

3. You can use Silverlight applications regardless of the operating system you use, while WPF applications are restricted to later versions of the Windows operating system.

4. Silverlight lacks access to local resources, while WPF can utilize local resources.

5. Silverlight only has perspective 3D support, while WPF is capable of full 3D images.

Read more:

http://wpfslguidance.codeplex.com/

http://msdn.microsoft.com/en-us/library/cc903925(VS.95).aspx

WPF standalone Vs XBAP Application:

Feature Standalone XBAP
Installed Installed on users computer. Not installed on the client’s computer.
Start Menu Appears in Start Menu. Does not appear in the Start Menu.
Control Panel: Add/Remove Programs Appears in the Add/Remove Programs. Does not appear in the Add/Remove Programs.
Installment methods Installed via XCopy, Windows Installer (MSI) or ClickOnce. Are automatically deployed via ClickOnce.

YourApp.xbap is really a ClickOnce deployment manifest.

Code Access Security Runs in Full Trust unless modified by Administrator. Runs in Internet Zone .
Sandbox restrictions N/A if run as Full Trust. See list below.
Process Runs in its own standard OS window. Runs in PresentationHost.exe
Presentation host is registered as the shell and MIME handler for *.xbap files.
Automatic Updates Standalone apps are not automatically updated. Developer must write auto updating framework or use the Microsoft ClickOnce system. Newer version on server is always used.
Offline access Application works if offline. Cannot run XBAP application unless user can navigate to the XBAP URL.
Requirements .NET 3.0 or later installed on user computer. .NET 3.0 or later installed on user computer.
Internet Explorer(6.0 or later)
Firefox (2.0 or later).
     

 

References:

http://blog.wpfwonderland.com/2007/01/28/comparing-wpf-applications-and-xbap-whats-the-difference/

 

ASP .Net Web Forms vs MVC

OK, Now ASP .Net has been selected, but still there are 2 options to go with ASP .Net  namely, Web forms and MVC.

Advantages of Web Form Model

  1. Powerfull Tooling/designer support
  2. Provides RAD development.
  3. Decarative Syntax
  4. Strong Third party controls support.
  5. Easy development model for heavy data-driven LOB applications.
  6. Event Driven programming Model.
  7. Similar model for windows form developers.
  8. BuildinViewState Support
  9. Buildin PostBack Support.

Advantages of MVC Model

  1. Enable clean separation of concerns (SoC) .
  2. Enable full control over the rendered HTML.
  3. Enable Test Driven Development (TDD) (built with TDD in mind).
  4. SEO and REST friendly URL.
  5. Easy integration with JavaScript frameworks.
  6. Support third-party view engines such as NVelocity, Brail, NHaml.
  7. No ViewState and PostBack events.
  8. Follows the stateless nature of web.
  9. Extensible and Pluggable framework. 

 

Project Future Guidelines:

 

  1. As PCMS, Pegasus Cargo Management System, release 6 is implemented as Smart Client application in Windows Presentation Foundation So there is no need for a version in Sliver Light which is also a smart client technology.
  2. However there is a need for thin client implementation of PCMS as Release 7, which will be implemented in ASP .Net.
  3. As there are two development patterns of ASP .Net, namely Web forms and MVC. So read the feature set for each method in section and lets decide the which pattern to adopt.
  4. As MVC implementation in ASP .Net is new, so a POC is required to explore the complete feature set in terms of programming for MVC.

 

Related Topics:

  1. Differentiate between Thick client, Think client and smart Client with examples?
  2. Differentiate between ASP .Net Web forms and MVC?
  3. Differentiate  between Windows Presentation Foundation and Silver Light of  Microsoft .Net?
  4. Differentiate between WPF standalone and XBAP Application?

 


WPF Windows Presentation Foundation -A Detailed Overview Version 1.2

November 20, 2009

A new version of WPF presentation is uploaded.


WPF Windows Presentation Foundation -A Detailed Overview Version 1.2

Code Sample

[Note: After downloading sample code file. Rename file with rar extension and then extract the rar file to actual sample code.]

Code sample related to following topics.
XMAL,Basic Elements of WPF,Architecture,Property System / Dependency Property,Routed Events,Binding System,Styling / Templating