Thursday, October 25, 2012

A Very good article regarding deferred execution and lazy loading

http://www.rizalalmashoor.com/blog/linq-to-entities-deferred-execution-and-lazy-loading/

Wednesday, August 1, 2012

must receive before sending a fault message on an implemented port

As a .net developer , just moved to BizTalk field,  I came across a lot issues in the last couple month when our project start to use BizTalk intensively.

As the title, when I was trying to implement a very simple sample ,  I got this error .

I setup a port which have request/response/fault, refer to the above snapshot.  in my orchestration, I implement very simple logic.
1.receive a message from the request port.
2.read the information from request, and then based on the message type specified in the request, dynamically transform the request to a response message.
3.send the response back to client.
4.if there are any error/exception happens, send a fault back to client.
refer to the following snapshot.
it is quite simple logic , but when I compile it, I get the following two errors.
1.must receive before sending a fault message on an implemented port
2.incomplete requestresponse operation; missing 'send'

By just simply look at the orchestration, I didn't aware anything is wrong, I do have a receive shape at the beginning , also I do have a send shape at the end of the orchestration,thus I refer to my good friend google for answers.  

It is quite hard to find a solution for this easily , I think this might be too easy, too basic, thus no one bother to talk about it.  but I do find some clues, When Visual Studio compile the solution , it will try to make sure every logic path is correct.  Then I go back to visit my orchestration, assume we get an exception in the scope , during the dynamic mapping.  here is the flow. 
1.receive a message from the port. 
2.construct the response message.
3.do the dynamic mapping. here we get an exception.
4.it jump to exception handling.
5.construct fault message
6.send the fault message back to client. 
7 then the flow continue to send a response back. 

You see the issue, after you send a fault message back to client, the whole channel had been faulted, how could we send  a response back client again?

In order to resolve this issue, I simple put a terminate shape after send the fault message back , then it compiles and works smoothly.  The orchestration looks like this.

It puzzled me a while as new BizTalk developer. when you get it , it is so easy.


Monday, March 12, 2012

AQGridView, load AQGridCell from xib file

Recently I am working on an app , which will need to use AQGridView, which will allow me to present my content in a grid format.
Like the UITableView, we need to implement a class to draw the cell content, and this class should inherit from AQGridCell.  the downside of this method is , we need to draw the whole cell UI use code, if it is simple cell , that should be fine. but I don't want to write too much code which can be done with a xib file. so I was thinking how to load a xib file on the fly. it does take me sometime to figure it out, thus I write it down, hope someone else still want to do the same thing can benefit from this, also for myself , if later on I need to implement similar features, I can come back to read it, my long term memory is bad.

So here it is.
First of all, I create a class and inherit it from UIView,


#import <UIKit/UIKit.h>

@interface TVViewCellWithUI : UIView
{
    
}

Then I create a xib file call it , TVViewCellWithUI.xib, pretty simple , put one UIImagView and a couple labels on it, 
On the view, I set the view is "TVViewCellWithUI" 

Then I can create outlet, actions stuff with drag and drop in TVViewCellWithUI class. 


then , the tricky part is , how I create the AQGridCell ,  refer to the following snapshot. 


so what I did is , first of all I create an instance of TVViewCellWithUI and then use NSBundle to load the TVViewCellWithUI xib file dynamically.  after that , assign the first element of the array to TVViewCellWithUI instance.
TVViewCellWithUI *vClass = [[TVViewCellWithUI alloc] init];
        NSArray* array = [[NSBundle mainBundle] loadNibNamed:@"TVViewCellWithUI" owner:vClass options:nil];
        
        vClass = [array objectAtIndex:0];

Note, NSArray* array = [[NSBundle mainBundleloadNibNamed:@"TVViewCellWithUI" owner:vClass options:nil]; the type of owner parameter should match with the type of the root view which we specified in the xib file, in my cause it is TVViewCellWithUI. 

if a different type of instance has been passed in as the owner, you will get unexpected result, for me , the function will stuck there without return control to you. 

after all these , create an instance of AQGridViewCell , and also add the TVViewCellWithUI into 
filledCell = [[AQGridViewCell alloc] initWithFrame:vClass.frame reuseIdentifier:FilledCellIdentifier];
        [filledCell.contentView addSubview:vClass];

In this way, we can take advantage of the xib file which we can easily change the UI without writing extra code.



Friday, February 3, 2012

In BizTalk map, use funtoid to skip the output element for some values.

We are using BizTalk 2010 in our project,   In the source schema from our origination system, they use string type to represent datetime, and when the source system can't provide it, for example, when the source system is experiencing some technical difficulties,it use dash instead, thus we need to handle this special character. 

In the destination schema of map , we already set the field to be nullable, so what we need to implement in the map is, when the datetime is not dash, we convert the datetime, and set to the destination element, when it is dash, we need to keep skip it , and leave the destination element untouched.
Here is how I make it happen.

  1. Use a Logical functoid, to make sure the value is not dash.

2.Use a value map functoid.

3.Then send the value to the script functoid to convert the value , and finally map it to the destination element. 
In this way, if the source value is dash, then the destination element will not be assigned any values.

Monday, January 30, 2012

BizTalk tricks

I was making a very simple BizTalk map changes last Friday.

we have a bunch of maps in our solution, which just convert one schema to another.  In one of the map, a couple of the values had been hard coded using string concatenate functoid.  but unfortunately , our vendor required us to change the values before it go live. So I just open the map and change the value, then checked in.

But after I deploy it to the server, it turns out the map doesn't pick up the value I had changed in the map. thus it still using the old values.  I was called up to fix it, obviously, VS don't think I made changes to the map , thus it doesn't compile it correctly, so I end up make some link changes in the map to make sure VS2010 pick up the changes. and then it is fixed.

Also , in order to avoid similar changes in the future, I create a functoid to read the values from the configuration file.  another strange thing happened, I put the function in a separate project, I deployed to GAC, but unfortunately , when I try to pick up the functoid from the map, it can't find the functoid which I added just now.

After I close the VS2010 and open it again, it found the new function correctly....

So in a conclusion
1. if you only make some value changes in the functoid of your map , please make sure VS2010 really had picked up the changes, make some link change should do it.
2. if you add new functoid  and VS2010 failed to pick it up , please restart your VS2010 , this might save you.

BizTalk is powerful , but the development is not that user friendly.

Friday, January 27, 2012

UITableView grouped

When I am trying to implement a window under IOS, it is quite simple Table View, but I want it to have round corner, the grouped style UITableView, but some how I can't make that happen even after I set the TableView's style to "Group", but it still display as a plain style.
After some investigation , I found out it is to do with the way I create the view object. 

I was using something like the following to create the table view. 
TableView *view = [TableView alloc] init];
In this way, the UITableView's style will always be set to UITableViewStylePlain, the correct way to do it is 
TableView *view = [TableView alloc] initWithStyle:UITableViewStyleGrouped];

or TableView *view = [TableView alloc] initWithNibName:@"MyTableView" bundle:nil];

It is a simple issue, but just write down in case somebody else is still wandering... The final result should looks like the following.