Wednesday, May 11, 2011
Tip: Proper use of the jQuery "get" function
let say I have a variable named "items" that is a drop down list with several options as represented at the html code below:
This will not work
items.get(1) --> TypeError: items.get is not a function
This will work
$('option', items).get(1) --> return option with value 2
Wednesday, May 4, 2011
Tip: How to make use of WorkflowControlClient to control workflows in a workflow service
If you host your WF service in IIS probably you will need a way to suspend, terminate, abandon, etc. a workflow that is running or persisted, other than using AppFabric Dashboard. In order to use WorkflowControlClient correctly, configuration at the workflow service is important. Given the following client code that terminates a workflow:
WorkflowControlEndpoint endpoint = new WorkflowControlEndpoint()
{
Binding = new BasicHttpBinding(),
Address = new EndpointAddress("http://localhost/WorkflowService/AbsoluteDelayService.xamlx/wce")
};
WorkflowControlClient c = new WorkflowControlClient(endpoint);
if (!String.IsNullOrEmpty(TextBox2.Text))
{
c.Terminate(new Guid(TextBox2.Text));
c.Close();
}based on the code above, the interesting part is the EndPointAddress that ends with the “wce” word. The “wce” word is actually configured in the workflow service web.config as shown below:<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
<behaviors>
<serviceBehaviors>
<behavior name="behaviour2">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<sqlWorkflowInstanceStore connectionString="Data Source=(local)\SQL2008R2;Initial Catalog=PersistenceDatabase;Integrated Security=True;Asynchronous Processing=True;" instanceEncodingOption="GZip" instanceCompletionAction="DeleteAll" instanceLockedExceptionAction="BasicRetry" runnableInstancesDetectionPeriod="00:00:05" hostLockRenewalPeriod="00:00:05" />
<workflowInstanceManagement authorizedWindowsGroup="AS_Administrators" />
<workflowUnhandledException action="Terminate" />
<workflowIdle timeToPersist="00:01:00" timeToUnload="00:00:00" />
<etwTracking profileName="Sample Tracking Profile" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="httpSecurityOff" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MustMatchWithXamlxConfigurationName" behaviorConfiguration="behaviour2">
<endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" />
<endpoint address="wce" contract="System.ServiceModel.Activities.IWorkflowInstanceManagement" binding="basicHttpBinding" bindingConfiguration="httpSecurityOff" kind="workflowControlEndpoint" />
<endpoint address="" contract="IService" binding="basicHttpBinding" bindingConfiguration="httpSecurityOff" />
</service>
</services>
</system.serviceModel>The configuration above shows how the service endpoints should be configured in order for client to access it through the WorkflowControlClient API. Another important thing that one must ensure is that the service name must be the same as the “ConfigurationName” in the Xamlx file.
If the name is not matching, WCF will throw exception stating the following message:
The message with To 'http://(macinename)/WorkflowService/AbsoluteDelayService.xamlx/wce cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
Thursday, April 21, 2011
Tip: How to create a One-Way WCF WF service that persist to a SQL server?
This how one can create a one-way WCF call to the Workflow Service:
1. Create a WCF Service Activity in Visual Studio
2. Remove the ReplyRequest Messaging activity.
3. Click on the ReceiveRequest activity, remove the item from CorrelationIntializers. This is not needed for one-way communication.
4. The end result will look something like this
5. At the client side reference the Workflow Service. Right click on the service reference and click Configure Service. Check the Generate asynchronous operations check box.
6. One can make use of the referenced service as follow:
7. Make sure to call to the GetDataAsync function and close the connection when done. The request will return immediately after the workflow hits the delay activity.
The IIS will resume whatever that is persisted in the database automatically when the time is right.
Friday, March 25, 2011
Tip: JavaScript "unload" event myth for IE8
One thing that i noticed when using the "unload" event is that, once the user clicks on a new link to navigate to a new page, browser will first send the request to web server causing the "pageLoad" function to be triggered then only the Ajax request is process in the web server.
If the next page that the user navigates to relies on the first page state, there will be problem because the new page is loading without getting the data from previous page.
My workaround is not to rely on the "unload" event, but to use user action to save the state. For example, when the user clicks on a link to do popup, after the popup immediately save the state to server. It's costly but working for now.
Wednesday, March 2, 2011
Tip: Asp.Net Request.InputStream is empty?
System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
string json = sr.ReadToEnd();
There's one problem with the above codes, that is the json variable will hold empty string even though I am sure that data is posted to the web server. The resolution of the problem is to always set the stream position to 0. The resulting codes looks like this:
Request.InputStream.Position = 0; System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
string json = sr.ReadToEnd();
Now with the first line of the codes, you will be able to get the stream data.
Wednesday, January 5, 2011
Tip: Choosing MS SQL Server + Reporting Tool
1. SQL Server 2008 R2 Editions Feature Comparison
http://technet.microsoft.com/en-us/library/cc645993(printer).aspx
2. Browser Support for SQL Server 2008 R2 Reporting Server Browser Compatibility Check
http://www.blogger.com/post-create.g?blogID=146115522879877832
3. SQL Server 2008 R2 Express Edition Reporting Service Features Summary
http://technet.microsoft.com/en-us/library/cc281020.aspx
Tuesday, August 24, 2010
Microsoft Internet Explorer 8 Not Meeting Expectation
Summary, the way that IE8 is built really give a big hit to online businesses that provide highly sophitiscated functions and UI, users are just requesting more and more but there is nothing much can be done or rather the limit is caused by how IE perform eventually. I hope IE 9 will give something that the users are expecting (i.e. speed + stability).