Wednesday, August 29, 2012

asp.net MVC4 - $.getJSON with controller and knockout

In this scenario, I am trying to call a backend controller to load the data from backend.
Then the data will be returned as a JSON data to web and mapping back to a knockout view model for binding. And the knockout binding section should be shown by jquery ui dialog and update back to controller for saving.

Here are the listed issues that I got,

- In controller, return Json(data, JsonRequestBehavior.AllowGet), or else $.getJSON call back function won't be triggered if you use get.

- In controller, use new JavaScriptSerializer().Seralize(Model) to return a JSON string representation of data. The string will be used for knockout to load to viewModel

- knockout mapping is a plug-in for automatically mapping the data from JSON to view model. it can be downloaded here.

- Use the following code to create the viewmodel and applybinding
var koModel = ko.mapping.fromJSON(data);
ko.applyBindings(koModel);


Tuesday, August 28, 2012

asp.net mvc 4 - webgrid add it as reference and use javascript in it

1. To use @Html.WebGrid in the razor view page by default it won't be loaded.
The webgrid is in System.Web.Helper, and it needs to be added in web.config like below in system.web section,

< compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>


2. By default, you can use format: (item) => item.GetSelectLink()) to add a select link for each row.

However, I want to add a javascript function to pass an itemId, then open a jquery ui dialog to load the values and save it by Json format.

You can use HtmlString to override it, format: (item) => new HtmlString("<a href=# onclick=...")

A cleaner way will be create a htmlHelperExtension to return the html string, such as,

    public static class HtmlExtension
    {
        public static IHtmlString Link(this HtmlHelper htmlHelper, Post item)
        {
            var anchor = new TagBuilder("a");
            anchor.AddCssClass("sel");
            anchor.Attributes["src"] = "#";
            anchor.Attributes["onclick"] = string.Format("select({0});", item.Id);
            anchor.SetInnerText("select");
            return new HtmlString(anchor.ToString());
        }
    }

Then in the razor view page, it will become format:(item) => Html.Link((Post)item.Value)
The namespace for the HtmlExtension should be declared, and remember to pass item.Value.

Wednesday, August 22, 2012

SharePoint branding 2010 - reference links

http://bniaulin.wordpress.com/2012/06/27/my-sharepoint-branding-series-on-nothingbutsharepoint/

https://www.nothingbutsharepoint.com/sites/eusp/Pages/Brand-SharePoint-SharePoint-Home-Page-CSS-Reference.aspx

https://www.nothingbutsharepoint.com/sites/eusp/Pages/SharePoint-Farmer-Joes-Team-Site-Put-that-in-your-Content-Editor.aspx

http://sharepointexperience.com/csschart/csschart.html

SharePoint 2013 Social - Community members are not as expected

So after installed SharePoint 2013 preview, I can not wait to create a community site right away to check it out.

The Community Members on the menu is a bit confusing though. I think that should be used to manage the members for the site by category. However, it is not what I thought.

From Microsoft, it is only a list which keeps a record of ongoing activity by members and reputation they accrue. It still should use site permission functions to add users as site members.

User Profile Service in SharePoint 2010

Just tried the user profile service in SharePoint 2010, this is the basic to build the my site as community site. Here is the complete guide to setup all the farm account and permissions. In my dev environment, everything is installed in the same virtual machine, basically the first and the most important step is to start the User Profile Synchronization Service, which is in stopped state by default installation.

Go to Central Admin -> system settings -> Managed Service on Server,

The User Profile synchronizaiton service should be disabled, click on start to start the service. And it will provision FIM services and after a long time wait (5-10mins),  you will be able to use configure synchronization connections to configure AD connection and start importing user profiles.

Hopefully later on we can continue to see how the UPS and the new community site in SharePoint 2013.
In 2013, there is another ADImport mode which only imports from active directory. You can switch between Adimport mode and UPS synchronization mode. Also you don't need the User profile synchronization service to manage the synchronization. It is moved to user profile service.

Sunday, August 19, 2012

A very clean article to discuss when to use RenderAction or RenderPartial in MVC3

This post is the best one so far to explain when to use RenderAction and when to use RenderPartial.

RenderAction basically can be a good place holder for some static contents that can be defined in _layout page. However, if the content is driven by main view content, it will be better define it in section area. There is a good tutorial by ScottGu.
Also in the view if you want to get the current action and controller, you can get it from ViewContext.RouteData.Values["controller" or "action"]

Thursday, August 16, 2012

Download large file through routing proxy and stream

In this sceario, we have a WCF service to communicate to SharePoint document library to download files, potentially quite big file, which why are using wcf stream mode. Also the service is in internal data zone and it has to go through wcf routing service for the security reason.

Here is some findings when dealing with it and the afternoon about,
1. have to use basicHttpBinding for stream.
WsHttpBinding doesn't support streaming due to the reliable messaging protocol (WS-RM), which requires that messages are buffered on either end.
2. need to modify the MaxMessageSize property in the routing service config as well, not just the client and service.






Wednesday, August 15, 2012

Difference between Azure Queues and ServiceBus Queues

MSDN just published a good article comparing the Windows Azure queues and ServiceBus queues, from performance, capacity and security perspective.

Windows Azure QueuesServiceBus Queues
Performance10 miliseconds latency, support 2000 message per second100 miliseconds latency, support 2000 message per second
Capacity64KB message, 1TB data storage, 7 days TTL256KB message, 5GB data storage, no limit TTL
SecuritySecurity TokenACS

Thursday, August 9, 2012

My two cents with some finding in BizTalk and ServiceBus

1. BizTalk 2010 R2 is released a CTP, check the details from Mick.
    It is no surprsie for it to be aligned with the latest framework and tools.
    The interesting things for me is the adapters with the REST capability finally, and all the ServiceBus enabled adapters.  So here the support for ServiceBus is very interesting and need more details to see how BizTalk relationship with even the ServiceBus for Windows.

2. Just found this document about implementation with Windows Azure Servicebus, since really there is not many articles about it apart from the msdn.

3. An interesting topic about how to integration Dynamics CRM 2011 with azure service bus on MSDN,
Azure extensions for Microsoft Dynamics CRM

4. The ServiceBus EDI/EAI looks even much more promising especailly with the new mapper. However, I think we still need a BusinessRule engine support for decistion and runtime configuraion.

Tuesday, August 7, 2012

SharePoint 2013 Public Beta adventure notes - Part 2

This is a good link to understand what the new features for SharePoint developers on MSDN.

1. There is new column type called geolocation, if you registered the BingMap key with SharePoint by code or powershell (a new web/app property ["BING_MAPS_KEY"]). The then bing map with the location will be shown in your list.

2. BCS added some good features.
    - Notification and event receivers.
    - Use client model library to access external content type data and REST support

3. When creating Web Application, one of the big changes is that Claims-based Authentication is the default authentication option. The classic Mode Authentication can only be managed by PowerShell cmdlet Convert-SPWebApplication.

SharePoint 2013 preview memory optimize

The resource hunger SharePoint 2013 running on my VM with 3GB only, so many times I have a site not responsive mostly because of the out-of-memory issue.

If you right click on windows task manager -> processes tab, there are 4 noderunner.exe process actually occuping so many memory. They are actually the SharePoint search component, the service SharePoint Search Host Controller is controlling it, you can either restart the service to release some memory or temporarily stop the service to release quite a lot memory if you don't really need the search function for the research purpose, which will give you 1GB back


Monday, August 6, 2012

Disable Loop back if getting the "access denied, verify either the default content access" error

Disable Loopback

Issue: File share Crawl on file:\\localhost\document has ab error with "access is denied, verify either the default content access ...."

Solution: Set DisableLoopbackCheck to "1" in Registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

Update: Disable loopback is also needed for creating apps in sharepoint hosted, when tried to register its own domain.

When the sharepoint web service is called, you may get the access is denied error.

Also after this is done, need to restart the server for it to be effective.

BizTalk Business Rules Deployment in Command Line

Business rules is a good way to config the decision points, however, it will need to be included in your build script for automation.

BizTalk does not provide this out-of-the-box, you have to include them in the MSI.
However, there is a sample program to be build for it.
http://go.microsoft.com/fwlink/?LinkId=102220

This program needs to reference for Microsoft.BusinessRules and Microsoft.BizTalk.BusinessRulesExtension assmeblies, which are in c:\program files\common files\bizTalk folder.

When you run the program to undeploy a policy, if your policy name is in format as XXX.YYY.ZZZ, it will fail with an error "input string was not in correct format".

This because the program will split the policy name by '.' to understand there version number. A work around is to update the helper class included in the source code for the function ExtractPolicyNameMajorMinor. Update the line
from string[] arr = polNameWithVersion.Split('.');
to string[] arr = polNameWithVersion.Split('$');

In this way, the program will ignore the version number and undeploy them.
To use the program for deploy and undeploy from the powershell, it will be like the following.
invoke-expression("D:\Deploy\DeployRules.exe /I '{0}' /P /D" -f $filePath)
invoke-expression("D:\Deploy\DeployRules.exe /U /R /P:'{0}'" -f $ruleName)

Also you can easily use powershell to process the policy xml file to understand the policy name. Such as,
 $xml = [xml](Get-Content $filePath)
 $ruleName = $xml.brl.ruleset.Name