18/9/10

Sample C#, .NET Framework 3.5 project

I always want to provide possible employers with a sample of my work. I decided to implement a Web Application in C# along with .NET Framework 3.5 in order for employers to get a grasp on whether I am suitable for the job. The project is called NewCertification and it is all about data retrieval and manipulation on the MS SQL Database, by communicating with it using an asmx Web Service

Visit this for some code implemented for the NewCertification project
Find the whole project, along with the Database and its log file in mdf format here
You will probably have to change the connection string in the WebService Web Config file to make a successful connection to the Database
Technologies/Techniques used
·         MasterPages
·         WebServices
·         ADO.NET
·         AJAX
·         User roles
·         Localization
·         Exception Handling/Logging
·         Authorization/Authentication
·         C# object oriented programming
·         Stored Procedures
·         Cryptography
·         Configuration Files
·         CSS Files
·         Encrypted Passwords in Database



Logging in the Web Application

1.       LoginUser.aspx
a.       The user enters a username and password
b.      Online Certification makes a Web Service call to validate the credentials and returns a Dataset
c.       If the Dataset contains no rows, the System alerts that there is no such user
d.      If the Dataset contains more than one row, this means that the user is joined to more than one role. Note that due to the implementation on newUser.aspx, the usernames are unique. The system redirects the user to userRoles.aspx to choose the desired role and continue to the specific homepage.
e.      If the Dataset contains a single row, redirect the user to his/hers homepage according to his/hers role

Authorization/Authentication
All WebContentForms use pageBase as their MasterPage. In the page load event of pageBase, the system checks if the Session userPk, username etc are set which can only be done with proper logging in. If these are not set Online Certification redirects the user to loginAgain.aspx, prompting for logging in. Thus if someone tries to bypass the log in page, by changing the text of the address bar to newUser.aspx for example, he/she will not be able to.

Exception Logging
Just like every system, Online Certification, will face exceptions. In order to provide better and faster support for the users, every exception will be logged in the Database. In the case of an exception, the user will be redirected to the exception page where he/she will receive the exception pk. After that he/she will be able to contact the system developers and provide them the pk, which will help them better understand what went wrong by querying the Database for the StackTrace and Message that corresponds to the specific pk.

1/9/10

Sample C#, Silverlight 4, WCF RIA Service Project

This project is based on the idea presented by Ian Griffiths on MSDN's Channel 9 videos series Hand On Lab Silverlight 4. Ian presented a Business Application, where users can log in and attend events. Unfortunately the project he ended up presenting is not so "Business" like. Ian spends a lot of time on out of browser techniques, Web Cams and Drag & Drop and only 7 minutes on user Authentication.

Another bad thing about his presentation, is that he only presented selecting and updating single entities in the database and not pivot tables, such as users_roles for example, which would be the case of a normalized, business database.

The project I ended up building, is not a business application, but a navigation application. I aim to incorporate user log in, user roles and authentication when Pro Business Application with Silverlight 4 gets shipped from Amazon.

In this project I explore the capabilities of the Entity Framework, Domain Service classes and WCF RIA Services.

Find the project here

I used customization of the Domain Service class produced by VS 2010:
        [Query(IsComposable = false)]
        public Attendee GetAttendee(string name, string surname, string email)
        {
            return this.ObjectContext.Attendees.SingleOrDefault(a => (a.name == name) &&     (a.surname == surname) && (a.email == email));
        }
         [Query(IsComposable = false)]
        public Event_Centers GetEventCenter(int centerPk)
        {
            return this.ObjectContext.Event_Centers.SingleOrDefault(c => c.pk == centerPk);
        }
 and also the DomainDataSource provided by RIA Services
                    <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:MyEventsCourses, CreateList=true}" Height="0" LoadedData="myEventsCoursesDomainDataSource_LoadedData" Name="myEventsCoursesDomainDataSource" QueryName="GetMyEventsCoursesQuery" Width="0">
            <riaControls:DomainDataSource.DomainContext>
                <my1:EventPlannerDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>
             int selectedEvent = Convert.ToInt32(NavigationContext.QueryString["eventId"]);
            myEventsCoursesDomainDataSource.FilterDescriptors.Add(new FilterDescriptor { Operator = FilterOperator.IsEqualTo, PropertyPath = "pk", Value = selectedEvent });
 in order to represent the database entities on the UI, either in DataGrids or in Details view, as provided by VS 2010.

To overcome the problem of feeding my DataGrids with pivot tables, I used SQL Views to represent the data

The overall experience was good, although I had problems which included my Entities losing their last characters when trying to generate the ADO.NET Entity Data Model. My entity Users became User and clashed with the built in class User. I also lost Intellisence in the XAML editor when I dragged and dropped a Wrap Panel, not to mention somehow the breakpoints stopped getting hit!!!

I really hope Pro Business Application with Silverlight 4 book meets my expectations, since I haven't found anything yet talking about real Business Apps.