This blog is subject the DISCLAIMER below.

Thursday, March 27, 2008

Amazon S3 via C#

Amazon Simple Storage Service (Amazon S3) via C#

Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers. It’s provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web.

It uses standards-based REST and SOAP interfaces so it is platform independent and language independent.

It `s commercial but highly scalable, reliable, fast and inexpensive data storage infrastructure.

To know more about its advantage and the cost click here:

http://www.amazon.com/gp/browse.html?node=16427261

I am writing here to give you my experiences and tricks which I faced it when I started in develop the service using Dot Net (C#) and soap.

First trick:

When you work using .Net, you must use WSE 2.0 NOT WSE 3.0 as Amazon support DIME (WSE 2.0) NOT MTOM (WSE 3.0).

Second trick:

You can only using the class System.Web.Services.Protocols.SoapHttpClientProtocol, if you want upload files to AWS (Amazon Web Service) that are less than one Megabytes.

Here is an excellent example that server the required (files less than megabyte) with complete demo code for view and upload files.

http://developer.amazonwebservices.com/connect/entry.jspa?externalID=774&categoryID=55

Third trick:

If your files are bigger than one Megabytes (ten, twenty or may be 50 megabytes), you must to change the class System.Web.Services.Protocols.SoapHttpClientProtocol to Microsoft.Web.Services2.WebServicesClientProtocol . (As mentioned in this link)

http://developer.amazonwebservices.com/connect/entry!default.jspa?categoryID=103&externalID=689&fromSearchPage=true

Then follow the last trick...

Last trick:

You must raise the Timeout property that inherits the Microsoft.Web.Services2.WebServicesClientProtocol (the AmazonS3class if you opened the following example) more time out (this property measures in milliseconds) .

Here it an excellent example that server the required (more than one megabyte) with complete code.

http://developer.amazonwebservices.com/connect/entry!default.jspa?categoryID=47&externalID=690&fromSearchPage=true

The Amazon S3 Developer Guide :

http://docs.amazonwebservices.com/AmazonS3/2006-03-01/

.. more.

EDC registration is open!

Microsoft EDC
EDC 2008 is the biggest Developers Conference of the year in Egypt, and is a critical event for any developer who wants to see the newest as well as the next-generation technology. EDC is full of sessions and activities that help you to learn the current and the future of the Microsoft Platform and get to know people who are as passionate about software as you are.

Benefits of Attending EDC 2008
Egyptian Developer Conference is designed to help those who build, deploy, or operate solutions based on Microsoft technologies. It helps professional developers, designers, analysts and architects to learn the capabilities and the possibilities with the current Microsoft .Net Platform. It also helps technology managers evaluate the range of technologies to consider for the future growth and management of their ongoing IT systems needs and requirements.

Who should attend
Whether you are an amateur developer, a "code-guru" or anything in between, you need to be at the biggest developer conference in the region. Code developers, webmasters, web designers, infrastructure architects, applications & database developers, hobbyists or just plain geeks: If your job title has even a passing resemblance to any of these, be sure to be there. This developer conference is your window into the future of the Microsoft platform and the software industry as a whole. After the event, you'll be more informed, more skilled, and more inspired than ever before.

Hurrrry up registration is limited...
Registration: http://www.edc2008.com/Register.aspx
Agenda: http://www.edc2008.com/Agenda.aspx

.. more.

CNAME

In the name of Allah,

Today I will present a common name or definition between networks administrator and we (as developers) may hear it specially if you are a web developer. It is a CNAME or CNAME record.

CNAME is abbreviated term to canonical name. CNAME is a record in DNS database to domain name aliases.

Any computer sure has a domain name (IP) to be visible throw the internet, but what about you if you want to call by more than one name (domain aliases )!!! What about your site if you want to change the old site’s name to new one and you want your site to be available for the users from the both the two domains (old and new name)!!!

How www.googel.com (as you see el NOT le ... googel NOT Google ) opens the right site www.google.com (*le NOT *el)!!!

The all previous scenarios are done by the same way CNAME (adding DNS record for domain aliases)…

Simple example :

www.abc.com CNAME www.xyz.com

www.12345.com CNAME www.xyz.com

so any requests ordered as www.abc.com or www.12345.com will be serve to open www.xyz.com .

you may browse Wikipedia’s DNS page for more information .

http://en.wikipedia.org/wiki/Domain_Name_System

.. more.

Sunday, March 23, 2008

The Building Information Model (BIM)

The Building Information Model (BIM) is a set of information generated and maintained throughout the life cycle of a building. BIM is the process of generating and managing a building information model.

BIM covers geometry, spatial relationships, geographic information, quantities and properties of building components (for example manufacturers' details). BIM can be used to demonstrate the entire building life cycle including the processes of construction and facility operation. Quantities and shared properties of materials can easily be extracted. Scopes of work can be isolated and defined. Systems, assemblies, and sequences are able to be shown in a relative scale with the entire facility or group of facilities.

BIM is able to achieve such improvements by modeling representations of the actual parts and pieces being used to build a building. This is a substantial shift from the traditional computer aided drafting method of drawing with vector file based lines that combine to represent objects.

Read more about BIM:

http://en.wikipedia.org/wiki/Building_Information_Modeling

http://bim.arch.gatech.edu/?id=402


-> Check Autodesk Green Research
http://usa.autodesk.com/adsk/servlet/item?id=10262483&siteID=123112

Watch the video on youtube.

-> Check also BIM by Professor Charles M. Eastman at Georgia Institute of Technology

http://bim.arch.gatech.edu/


.. more.

Friday, March 14, 2008

The Singularity Research Development Kit

At Tuesday, February 13, 2007 Shereef Saker has posted article on FCI-H about Singularity: A research OS written in C# while going through Microsoft Student Partners forum I found a post sent by Matthieu Suiche an MSP from France informing about Singularity first release...

Microsoft research page: http://research.microsoft.com/os/singularity/
The Singularity Research Development Kit (RDK) 1.1 is now available for academic non-commercial use. You can download it from CodePlex, Microsoft's open source project hosting website, here. http://www.codeplex.com/singularity

Overview:
Singularity is a research project focused on the construction of dependable systems through innovation in the areas of systems, languages, and tools. We are building a research operating system prototype (called Singularity), extending programming languages, and developing new techniques and tools for specifying and verifying program behavior.
Advances in languages, compilers, and tools open the possibility of significantly improving software. For example, Singularity uses type-safe languages and an abstract instruction set to enable what we call Software Isolated Processes (SIPs). SIPs provide the strong isolation guarantees of OS processes (isolated object space, separate GCs, separate runtimes) without the overhead of hardware-enforced protection domains. In the current Singularity prototype SIPs are extremely cheap; they run in ring 0 in the kernel’s address space.
Singularity uses these advances to build more reliable systems and applications. For example, because SIPs are so cheap to create and enforce, Singularity runs each program, device driver, or system extension in its own SIP. SIPs are not allowed to share memory or modify their own code. As a result, we can make strong reliability guarantees about the code running in a SIP. We can verify much broader properties about a SIP at compile or install time than can be done for code running in traditional OS processes. Broader application of static verification is critical to predicting system behavior and providing users with strong guarantees about reliability.

.. more.

Monday, March 10, 2008

OOP Design Concepts - Abstract Classes

hey all, and specially soli who asked about abstract classes.
In this post we discuss abstract classes, however, it would be better if you read the post titled OOP Design Concepts - Interfaces first.

- What is an abstract class?

Abstract classes are partial classes, in other words, they are classes that needs to be inherited by other classes to be used. The word abstract means that methods inside such class are not completely implemented, an abstract class can mark some methods as abstract, so, the child class needs to implement them according to its behavior. An abstract class works as a generalized type that needs specialization for each subtype.



Well, i hate those complex descriptions, so lets get to the example mentioned previously in OOP Design Concepts - Interfaces. The case was that we had different types of cars and we specified their behavior by an interface named "iMovable", now, lets consider an extension to that design. Suppose that all cars starts using the same way using the same method of ignition, so, it is not relevant for every car to implement the method named "Start" with the same implementation. In this case we will introduce the abstract class named "Car", this class implements the "iMovable" interface and introduces a new method named "Start" and implements it. Now, any new car will extend the abstract car instead of directly implementing "iMovable".

- A closer look.
So, we did not forget that the abstract car implements iMovable, but we did not mention any thing about implementing iMovable's methods?. yes, the methods are still treated the same way, as the classes extending the abstract car are still responsible for providing the actual implemenation of such methods, in our case, it is the single move method. Methods in interfaces are abstract by default, and marking a class as abstract indicates that this class is not yet complete, so it has the option to implement what it wants from the interface, and in our case, we need nothing from the interface to be implemented in the abstract car.
Now, any car extending the abstract car can use the start method directly but it still have to implement how the move method will be implemented.
An abstract class may implement methods declared in an interface, thus, making it an option for subclasses to override those methods or not.

-Why?
The previous modification makes classification perfect, as we said before, it is all about logical thinking, reconsidering the first design that rely only on interfaces, you will find it not logic that every movable object is a car!!, so, abstract classes provides an extra level of specialization, as we can introduce an extra specification level to more subtypes. In our case, we defined a common behavior for cars, if we have planes, we will introduce the plane type the same way we did with cars.

-Coding
lets see an java code segment declaring our example class.

public abstract class Car implements iMovable{

public void start()
{
//code for starting engine
}

//Another method marked abstract for implementation by child classes
public abstract void koko();
}


public class NormalCar extends Car{

//The method declared by the iMovable interface.
public void move()
{
//code for moving...
}

public void koko()
{
//Code for the koko method which does anything.....
}

}


Marking a method as abstract, makes it a must for child classes to implement such a method or the code will not compile, thus forcing the same kind of behavioral description provided by interfaces in the older design.

.. more.

Saturday, March 08, 2008

Wikimania 2008, Alex, Egypt, Call for participation Deadline is drawing near

Wikimania 2008
For those who visit my blog probably you know since long but I just realized that I (myself) don't visit my friends blogs, for more than a year, may be (long live Google, Reader.. or is it "Don't"..lol)..

Anyway, I'm just making sure that you know that Wikimania2008 (which will be held on 17-19 July, Alex, Egypt) call for participation deadline is drawing near. It is March 16, 2008.. So if you want to attend as a speaker, hurry up!!

If you rather be a regular attendee -like me ;)- you'll have to just wait & keep tuned to the event page (that's http://wikimania2008.wikimedia.org/wiki/Main_Page )..

I waited.. so much for the organizers to make an FB event but they didn't.. so I'll :P ( as if it's a must.. lol)

.. more.

Thursday, March 06, 2008

Save As PDF using C#

Welcome guys , this day we will display an esay way to convert files from any format that Microsoft Office open to PDF file format using simple C# code.

Frist of all you should to install 2007 Microsoft Office Add-in: Microsoft Save as PDF (very small about 934 KB) .

Click here to download it from Microsoft site

After you have finished your setup , you should to have new save as option like the picture .

saveasPDF


Secondly : add this two reference to your DotNet project as you see in this picture .

refrences

Then insert the required namespaces in the project ..

Like here :

using System;

using System.Data;

using System.Text;

using System.IO;

using Microsoft.Office.Interop.Word;

finally : here is the class called Doc2PDFAtServerClass , this class have only one static function word2PdfFcih which have two paramters .

this is a example :

object SourceFileName = “Fci-H.doc” ;

object newFileName = “Fci-H.pdf” ;

static public class Doc2PDFAtServerClass

{

static public void word2PdfFcih(object SourceFileName, object newFileName)

{

//Pid++;

Microsoft.Office.Interop.Word.ApplicationClass MSdoc = null;

//object Source = "d:\\Document" + Pid.ToString(System.Globalization.CultureInfo.CurrentCulture) + ".doc";

object Source = SourceFileName;

object readOnly = false;

object Unknown = System.Reflection.Missing.Value; //Type.Missing;

object missing = Type.Missing;

try

{

//Creating the instance of Word Application

if (MSdoc == null)

MSdoc = new Microsoft.Office.Interop.Word.ApplicationClass();

MSdoc.Visible = false;

MSdoc.Documents.Open(ref Source, ref Unknown,

ref readOnly, ref Unknown, ref Unknown,

ref Unknown, ref Unknown, ref Unknown,

ref Unknown, ref Unknown, ref Unknown,

ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown);

MSdoc.Application.Visible = false;

MSdoc.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize;

object FileName = newFileName;

object FileFormat = WdSaveFormat.wdFormatPDF;

object LockComments = false;

object AddToRecentFiles = false;

object ReadOnlyRecommended = false;

object EmbedTrueTypeFonts = true;

object SaveNativePictureFormat = false;

object SaveFormsData = false;

object SaveAsAOCELetter = false;

//object Encoding = MsoEncoding.msoEncodingUSASCII;

object InsertLineBreaks = false;

object AllowSubstitutions = false;

object LineEnding = WdLineEndingType.wdCRLF;

object AddBiDiMarks = false;

/*

to get more details about SaveAs(...) function and it's parameter ,read this microsoft's link

http://msdn2.microsoft.com/en-us/library/aa662158(office.10).aspx

*/

MSdoc.ActiveDocument.SaveAs(ref FileName, ref FileFormat, ref LockComments,

ref missing, ref AddToRecentFiles, ref missing,

ref ReadOnlyRecommended, ref EmbedTrueTypeFonts,

ref SaveNativePictureFormat, ref SaveFormsData,

ref SaveAsAOCELetter, ref /*Encoding*/missing, ref InsertLineBreaks,

ref AllowSubstitutions, ref LineEnding, ref AddBiDiMarks);

}

catch (FileLoadException e)

{

Console.WriteLine(e.Message + "Error" );

}

catch (FileNotFoundException e)

{

Console.WriteLine(e.Message + "Error");

}

catch (FormatException e)

{

Console.WriteLine(e.Message + "Error");

}

finally

{

if (MSdoc != null)

{

MSdoc.Documents.Close(ref Unknown, ref Unknown, ref Unknown);

//WordDoc.Application.Quit(ref Unknown, ref Unknown, ref Unknown);

}

// for closing the application

// WordDoc.Quit(ref Unknown, ref Unknown, ref Unknown);

MSdoc.Quit(ref Unknown, ref Unknown, ref Unknown);

MSdoc = null;

}

}

}

Have fun ;) ..

.. more.

Setting Up ANT !!!

One of the most boring tasks is to set up ant to work on your computer, it is really a a very boring task that i usually spend a good amount of time doing and if i need to set it up again for any reason i discover that i do not remember and the spaghetti of environment variables begin :S. So, this post is to remind me rather than any body else what i need to do when setting up ANT :).

After downloading ANT, you need to specify some paths in the environment variables in order to work just by writing "ant" on the command line:

-In case you do not know where to find the environment variables :
right click on my computer -> advanced -> Environment variables.

-Make sure you have a JDK installed, and set the variable JAVA_HOME with the installation path of the JDk. e.g; c:\jdk1.6.0_02

- Make a variable named ANT_HOME with the path to installation directory to ant, e.g; C:\apache-ant-1.7.0

- MAKE SURE to add the path to the bin folders of both the jdk and ant to the "path" variable. The "path" variable must contain these two entries:
C:\jdk1.6.0_02\bin;C:\apache-ant-1.7.0\bin

Hopefully, you will get ANT working by now. If you do not know what ANT is, you can wait to see the coming post :).

.. more.

Wednesday, March 05, 2008

OOP Design Concepts - Interfaces

What is an interface in OOP?
During the process of designing an application using OOP Paradigm, the application will be designed as a set of classes indicating how objects will be created each with specific status and behavior, as well as defining the ways of interaction between those objects. By this way, almost every class indicates a type(an abstracted data type in a more specific manner).
For example, a class named car indicates an object of type car that has a set of status variables and a set of methods that indicates how other objects can interact with it. Consider that we have a car that have the normal four wheels and another type that uses one wheel in the middle of the car to move!!.
The common behavior between the two types of cars is that they can move, either on 4 wheels or 1 wheel it does not make a difference, all what we care about is that they can move, so, simply we can consider the two cars as "Movable". The word movable indicates the ability of the two objects to move which is an indication of the behavior of them without concerning other details like; the model of the car or even the way they can move. These are interfaces.
Interfaces indicate how certain types of objects have to behave. If we want to indicate clearly how a movable object must behave, we will create an interface with a method named " move" and make every movable object provide how this method will be implemented.
In our example; we will create something like what follows:

public interface iMovable
{
public void move();
}

public class normalCar implements iMovable
{
//actual implementation of the move method declared in iMovable
public void move()
{
//the code required to make a normal car move
}
}

public class weirdCar implements iMovable
{
public void move()
{
//the weird code to make a weird car move
}
}


So, why do we need interfaces?
OOP tries to resemble how objects are defined in the real life, and interfaces are a very logical way of grouping objects in terms of behavior. Suppose that we are making a game that has the normal and the weird car,however, a creative team member came with the idea that we need to make the extra super weird car with no wheels and with the ability to turn to a frog to hide from enemies and many many extra features. If we are not using interfaces, the game logic will need to handle the motion of each car as if they are of different type in spite that logically they share the core common behavior.
Interfaces also enhance abstraction which is a core principal of OOP, design patterns like the factory pattern make a perfect use of interfaces through abstracting objects to know which implementation of a certain object type is provided. Interfaces make it very flexible to change implementations of services specially in multilayer applications, for example; in an application, we have a data base layer that have an object named UserDb which is responsible to get the data of the user from the database, and we have another one named UserTxtFile which retrieves the information from a plain text file.
Each of the user objects can be used by a higher layer to retrieve the user data without any modification to the code, inspect the following code:

public interface iUserInfo
{
string getUserName(int userId);
string getUserAge(string username);
}

public class UserDb implements iUserInfo
{
string getUserName(int userId)
{
//code to retrieve user info from the database
}
}

public class UserTxtFile implements iUserInfo
{
string getUserName(int userId)
{
//code to retrieve user info from the plain text file
}
}

public class UserManager()
{
private iUserInfo userInfo;

public string retrieveUserData(string userName)
{
return userInfo.getUserAge(userName);
}
}


Take a close look at the manager class and you will find that it has a reference variable of type iUserInfo, so, if this reference is provided by a factory method or by any other means, the code of the manager class will be the same regardless what implementation is provided. This approach maximizes flexibilty if some implementations need to be altered during the process of software development, as higher level layers will not be affected at all.
Another benefit of interfaces shows up during the development of large projects by large teams, at which the interface acts as a specification for developers with the set of methods they need to implement in classes of a certain type.

What interfaces are NOT?
- Unless the interface specifies a common behavior, do not create one. A common mistake is to use interfaces just to make some constants visible to objects in different layers.
- Interfaces are not a work around to multiple inhertience.

I hope i could make my points clear enough, and about the super car that turns to a frog ; i think it is a good idea. think about it :) .

.. more.

Monday, March 03, 2008

launching SQL 2008 in Egypt

As we mentioned before the global launch for SQL 2008 had been on 27 of Feb , Now, We have the pleasure to announce the launching SQL 2008 in Egypt will be in March 24 (Intercontinental City Stars Hotel) , but unfortunately the attendance is by Invitation Only :( .

You can see the agenda of the day and more information from here :
http://www.microsoft.com/middleeast/egypt/launch2008/register/default.aspx

.. more.