Saturday, July 30, 2011

Are you sure you want to move to gulf? Think again!

Yep, if you are moving to gulf(Dubai) from Pakistan (Karachi), it(the process) sounds like you are placing an order for a double cheese burger with diet coke!

image

 What is the process?

S. No.

Steps

Duration (Days)

Fee (PKR)

Comment

1

Get passport

7

4200

 

2

Get attested degrees

5

6700

HEC + UAE Consulate (PKR1200 + ~USD45)

3

Send to employer for visa

1

0

 

4

Receive passport/visa

20

0

~Keep 3/4 weeks of time; better resign only when you receive your visa

5

Get NICOP

7

1500

USD 25? @PKR86 (PKR 3000 for urgent); besides NIC

6

Obtain ticket with OK-TO-BOARD

2

21000

Get the ticket agent that is close to your place; they usually charge 6% of the ticket charges

7

Get protector stamp

1

6700

Very cumbersome process if you DIY

8

Shop

3

25000

If you must, must you should

9

Prepare to fly

1

0

Checkout the checklist that, if you may need

TOTAL

47

65100

 

 

STEP 1: How to prepare/renew Pakistani passport?

image

Process:

  1. Day 1: Get bank Challan from the National Bank that is inside Passport office, Saddar (PKR4100 Fee + PKR25 Service Charges = 4125 (as of today) – FastTrack ~5 days)
    • Requires:
      1. Old passport
      2. NIC
      3. NIC of one of your parent

Note that, if you are going for a brand new passport, they will ask you for the educational transcripts; so, inquire before you leave your place for passport office

  1. Day 2: Submit application (if you have time, and patience, you can continue this on the Day1 – but trust me, you wouldn’t want to afford that if you are with you family)
  2. Day 7: Collect passport (~next week sometime)
    • Requires:
      1. NIC

Location:

Passport office, Saddar, Karachi

References:

 

STEP 2: How to get the educational documents (degree/transcripts) attested?

image

Process:

  1. Day 1: Attestation from HEC (Use OCS Courier Service, PKR1200/-) ~5 days. Any OCS close to your place.
    • Requires:
      1. HEC requires Matriculation/Intermediate marksheets, and certificates to be attached as well, besides your University degrees
  2. Day 6: Attestation from Foreign Ministry (Submit PKR25/-) ~2 Day process. This is right beside the FTC (Finance and Trade Center), Sharah-e-Faisal road.
    • Requires:
      1. Degree attested by HEC
  3. Day 8: Attestation from UAE Embassy (Use Bokhari Travels, USD40/- per document) ~1 day if you are willing to pay USD60/- for urgent service, otherwise USD40/- ~4 working days.
    • Requires:
      1. Degrees attested by HEC + Foreign Ministry

Location:

  • For HEC, use nearest OCS
  • Foreign Ministry, right beside FTC, Shahrah-e-Faisal
  • For UAE Consulate, go to Bokhari Travels that is on main Punjab Chowrangi

References:

 

STEP 3: How to get NICOP (National Identity Card for Overseas Pakistanis)?

Please don’t ask why, it is necessary, because I don’t have the answer to that; I wonder about the reason of having multiple identifications, NIC, NICOP, Passport, and what not – for a single reason!

image

Process:

Somewhat similar to when filing for an NIC

  1. Issuance of Token
    • Requires:
      1. Birth Certificate —OR—
      2. Old NIC —OR—
      3. Matriculation Certificate —OR—
      4. CNICs of immediate relatives —OR—
      5. Passport (mandatory in case of new)
  2. Photo capturing
  3. Thumb and Signatures
  4. Data Acquisition by DEO
  5. Form Printing
  6. Attestation & Form Submission

Location:

Any NADRA office close to your place

References:

 

STEP 4: How to get OK-TO-BOARD stamped on my visa copy?

Process:

  1. Get ticket
  2. Send your ticket/itinerary details to your employer, and ask them to apply for the OK-TO-BOARD message — OR—
    • Requires:
      1. Ticket/itinerary details
  3. Give you visa/entry permit copy to your ticket agent, and tell her to provide you with an OK-TO-BOARD stamp.
    • Requires:
      1. Visa/entry permit copy

Note: Get ticket from Emirates. OK-TO-BOARD more streamlined; suggested by a friend. It would look something like following(see hand written OK-TO-BOARD in the highlighted red):

OK TO BOARD

References:

 

STEP 5: How can I get protectorate stamp on my passport?

Who and why in the world would ever want it? This process/explanation might soothe your veins.

image

Process:

  1. Provide documents on the protectorate counter; s/he will give you a bank challan copy to sign it
    • · Requires:
      1. Passport with visa stamped
      2. NICOP or its receipt
      3. Offer letter
      4. Ticket with OK to board —OR—
      5. Attested offer letter by Ministry of foreign affairs in DUBAI

Note: You will need OK-TO-BOARD in any case, but you can’t get it stamped prior to departure.

  1. Submit challan in National Bank, UBL Bank, and Habib Bank
  2. Get photocopy of those challan on single page – not sure why its important, but it was asked with everyone
  3. Attach the challan recepts with other documents, and arrange if you can, otherwise give it to the photocopy guy; he will do that for you.
  4. Hand it over to the counter
  5. If you are lucky, they will tell you collect after 2 hours; meanwhile you roam around the Shahrah-e-Faisal sidewalks, you can enjoy a newly open Biryani shop there. ~PKR60/serving;0)

Catch99: There is a tiny Photostat shop inside the protectorate office; give all of the documents to him, and he will do the job for you, just for PKR100/- no hassle.

I did it on my own, with the help of the people around, and I did all of it. Except for the arrangements of the documents in specific order. I did not know that – and that shop guy was not willing to disclose that to me; under pressure with small amount of time left in that “sarkari (read: government)” office, I decided to let him arrange that for a cost of PKR90/- Money wasn’t the issue, it was just that I wanted to do it myself, because documents were original and I wanted to avoid any last minutes shocks – or – apologies – so to say, that he has lost the documents/etc. Anyway, throw in the money, relax, and enjoy!

Notes

  • NICOP and protector can be done through the same office
  • Takes ~1 week to receive the NICOP for urgent service
  • You can apply for Protectorate based on the receipt of the NICOP

Location:

image

Protectorate Office Karachi

  • If you live somewhere near North Nazimabad, there is one more office, which I have not verified, which is near Nagan Chorangi behind Salim Center, PTCL Office; a service lane is going inside, after ~200 meters, you will find the office on the left. A friend pointed out.

References:

Wednesday, July 6, 2011

How to think a unified design for multi device architecture?

Couple of weeks ago, I responded to question of similar sort, and then I thought I must elaborate on this using actual code snips, that may help anyone looking for similar solution.

Problem statement:
Build an internet based application that should be able to:
  • Process the incoming requests
  • Get records available in the data store
  • Perform actions on that data
Most importantly, a non functional requirement is that, the request may come from multiple devices, for instance PC, Handheld device, iPhone, Windows Phone, Android, etc. This means, solution should have one core functional module (Unified Functionality); that would serve multiple device ends.

Simple? It is.

There could be several ways of achieving that; lets discuss couple ways, and then elaborate the implementation.


SOLUTION 1: Use WCF based RESTful service with App_Browser feature

Why? Because it is easy, tidy, and quick.

What is required to achieve that?

Mark the web service methods with WebGet attribute, and set the ResponseFormat parameter to WebMessageFormat.Json.

For instance:
[OperationContract]
[WebGet(UriTemplate = "/DoSomething?intSomeType={intSomeType}", ResponseFormat = WebMessageFormat.Json)]
Response DoSomething (Int32 intSomeType); 


When the service is accessed RESTfully, it will return the data using the DataContractJsonSerializer. So you should JSONize(JSON Serialize) your POCO’s by marking it with the [DataContract] attribute and mark each serializable member as [DataMember].
Note that, this assumes that requests will only come from browser based user agent.

Also, the type hinting in WCF can add a lot of unnecessary overhead in the JSON response for large collections. Therefore, if you believe that you might want multiple types of end-points (SOAP, etc.) at some point in the time, then WCF is the way to go.


Easy? See! Let’s go through a demo app code right out of my pilot project.


Step 1: Write an interface that defines the basic operations that a mobile service will provide; and then provide an implementation of the interface:

[ServiceContract(Namespace = "izlooite.blogspot.services")]
public interface IMobileService
{
[OperationContract]
[WebGet(UriTemplate = "/ListBusinesses?intBusinessType={intBusinessType}", ResponseFormat = WebMessageFormat.Json)]
Response ListBusinesses(Int32 intBusinessType);
}


Step 2: Create WCF web service that implements IMobileService interface


[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class MobileService : IMobileService
    {
        private NameValueCollection _params = null;

        public MobileService()
        {
            _params = null;
            if (HttpContext.Current.Request.HttpMethod == "POST")
            {
                _params = HttpContext.Current.Request.Params;
            }
        }

        public Response ListBusinesses(Int32 intBusinessType)
        {
            return new Response(AcknowledgmentStateSuccess, ConvertToString(Business.List(intBusinessType)));
        }



Step 3: Create a 

DataContract for a generic response:
[DataContract]
    public class Response
    {
        private AcknowledgmentState _ack;//custom types
        private List _errors;
        private Object _result;

        private void Initialize(AcknowledgmentState ack, List errors, object res)
        {
            _ack = ack;
            _errors = (errors == null) ? new List() : errors;
            _result = (res == null) ? "" : res;
        }

        public Response()
        {
            Initialize(AcknowledgmentStateCustom, null, null);
        }

        public Response(object res)
        {
            Initialize(AcknowledgmentStateSuccess, null, res);
        }

        public Response(AcknowledgmentState ack, object res)
        {
            Initialize(ack, null, res);
        }

        public Response(AcknowledgmentState ack, Error error, object res)
        {
            List errors = new List(1);
            errors.Add(error);
            Initialize(ack, errors, res);
        }

        public Response(AcknowledgmentState ack, List errors, object res)
        {
            Initialize(ack, errors, res);
        }

        [DataMember(EmitDefaultValue = true, IsRequired = true)]
        public AcknowledgmentState Ack { get { return _ack; } set { _ack = value; } }

        [DataMember(EmitDefaultValue = false, IsRequired = false)]
        public List Errors { get { return _errors; } set { _errors = value; } }

        [DataMember(EmitDefaultValue = false, IsRequired = true)]
        public Object Result { get { return _result; } set { _result = value; } }
    }
Step 4: Create a business class that takes in the type of business, and respond with a list.


Step 5: Configure and then use the App_Browser, MOBILE.BROWSER class file
private static List List(int? businessType, int count)
        {
            List businessList = new List();

            if (count > 100)
                count = 100;

            EnumBusinessType enumBizType = EnumBusinessType.UNKNOWN;
            try
            {
                if(businessType != null)
                    if(businessType > 0)
                        enumBizType = (EnumBusinessType)Enum.ToObject(typeof(EnumBusinessType), businessType);
            }
            catch { }

            using (NorthwindDataContext dc = new NorthwindDataContext())
            {
                var records = dc.Businesses.Select(b=> b);
                
                if(enumBizType != EnumBusinessType.UNKNOWN)
                    records = records.Where(b=> b.TypeID == businessType);

                if (!string.IsNullOrEmpty(prefix))
                    records = records.Where(b => b.Name.StartsWith(prefix.Trim()));

                records = records
                            .OrderBy(b => b.Name)
                            .Take(count);

                foreach (var rec in records)
                {
                    businessList.Add(new MyBusinessContract(rec.ID, rec.Name));
                }
            }
            return businessList;
        }


Note that App_Browser is a feature that lets you *tweak* the way user interface is rendered based upon different devices. Its an xml based file, that uses xml to format the user interface presentation.

From MSDN:
Browser definition files contain definitions for individual browsers. At run time, ASP.NET uses the information in the request header to determine what type of browser has made the request. Then ASP.NET uses .browser files to determine the capabilities of the browser. ASP.NET control adapters can use this information to adapt the behavior of an ASP.NET Web server control depending on the type of device. For example, a server control might generate different HTML for a graphical browser such as Internet Explorer than it would for a mobile device.
I will add this .SLN on codeplex soon, ping me if I don’t. (0:

SOLUTION 2: WCF RESTful service with customized client applications


This means, separate client apps for separate devices, for instance Objective-C based app for iPhone, Silverlight based app for Windows Mobile. In this case, let’s get inside the core, and come up with a set of core functionality.

Lets decide, what the "Core" is? Or what the Core should be - what will be the functionality that Core will perform. Ideally, when we say Core, it essentially means, a layer that performs basic or atomic operations.

Over that Core you can wrap the device wrapper (IPhone, PC, etc) that builds a query to be sent to core, for instance, coming in from different device channels.
 
We can use WCF Data Service to constitute a data layer. And your core can perform business operations/etc, and communicate with the Data Service.

For instance:
1. Our core will performs core operations - for instance talking to Datalayer ; the Core will be a "library" that will perform basic operations:
  • Authentication
  • Authorization
  • Select records
  • Perform Action 1
  • Perform Action 2
2. A DeviceWrapper(DeviceAndriod, DeviceIPhone, DeviceWeb, etc), that wraps different devices.
The first thing that comes to mind, in this case, is a mixture of Factory and Builder pattern. Think about factory of Devices, and Builder pattern for types of views to be rendered on different devices.

3. TextRenderer, based upon the device settings, renders the text. Therefore, following will be the steps to implement:
  • Step 1: Write a core that will provide authenticate/authorization; for instance, call the Core.Authenticate(), and .Authorize();
  • Step 2: Based upon the user agent call ICore.RenderView(agentType, url), this may return you the view/html to be rendered.
User may perform an action, your request may call Core.PerformAction(); which in turn may return the link to the page to be redirected, for instance.

Up till now, we were talking about Server side, which primarily is concerned with:
  • How the requests from different user agents will be processed by the server.
  • How the text will be rendered with respect to different devices.
Client ends could be:
  1. A web browser, in this case you don't need any client app to be developed –OR–
  2. A, let’s say, Silverlight app for Windows Phone –OR–
  3. An android app for Android phone –OR–
  4. So on so forth…
Decide what this "client app" will do. For instance:
  • User shall login
  • User shall be able to perform certain operations
Note that, these client apps will call the server side smartly (using web services, rather than asp.net web pages) in order to perform operations.

Related Posts

Popular Posts