Wednesday, January 30, 2013

Example for BizTalk 2013 to use the SB-Messaging and WCF-NetTcpRelay adapter

The BizTalk 2013 provides some new adapters for service bus to be able to use relay service and send/receive message to service bus queue and topics.

Recently Paolo Salvatori has upload an example demonstrate all of those features in here

I have set it up and tried it with one issue when calling netTcpRelay service in the demo client.

The demo client is using an app.config to call the netTcpRelayService. However, I have the error said, "The element 'bindings' has invalid child element 'netTcpRelayBinding'.

This because an extensions section needs to be added for the client to be able to recognize those element.

The client finally worked after the following config added.

<extensions>
    <behaviorExtensions>

<add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

</behaviorExtensions>

<bindingExtensions>

<add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

</bindingExtensions>

</extensions>

This article here has a complete list for all the extensions that can be added. Just be aware that it is using 1.7.0.0, whereas the latest is 1.8.0.0 now.

Monday, January 21, 2013

SharePoint 2013 Search - Build Query for the specified List only

Just tried with the SharePoint search and their refinement.

1. A custom movie list with the necessary columns has been created.
    The new column will be created as crawl property as ows_columnname
    To used them in the search refinement, the managed property needs to be created and mapped back to the crawl property, also make sure the refinable attribute is set true.

2. A custom search page is created in the pages library.

3. Go to the Site Search Settings (not site collection search settings) to add the new created page in search navigation

4. Go to the created page and edit the web part. On the left, the refiner can be modified as required.

5. The query in search result webpart needs to be updated to query the list only.
Here is the issue I have to get the query correct. It seems to be natural to use the Path contains the ListName. However, that would not work. Path has to include the complete list path.


 
 



The below is what the final search page look like.
 

Saturday, January 19, 2013

SharePoint View BCD List get the error "Login failed for user "NT AUTHORITY\ANONYMOUS LOGON"

The reason is the BDC is created from SharePoint designer and the authentication mode is set to "Connect with user's identity"

If enable the BDC with RevertToSelf to true, then the authentication mode can be set to "BDC identity"

Run the following PS command to set the BDC RevertToSelfAllowed to true.

$bdc = Get-SPServiceApplication | where { $_ -match "Business Data Connectivity Service" }
$bdc.RevertToSelfAllowed =$true
$bdc.Update()



Install SharePoint 2013 workflow Issue - Unable to load one or more of the requested types, Retrieve the LoaderExceptions property for more information.

To be able to use SharePoint workflow 2013, I have configured workflow manager 1.0 successfully.
as http://www.aboutworkflows.com/2012/07/sharepoint-2013-install-sharepoint-2013.html

Then run this command in SharePoint PowerShell,
Register-SPWorkflowService -SPSite http://SERVERNAME -WorkflowHostUri http://SERVERNAME:12291 -AllowOAuthHttp

I got the following error,
Unable to load one or more of the requested types.
 Retrieve the LoaderExceptions property for more information.
At line:1 char:1
+ Register-SPWorkflowService –SPSite "http://mysharepointserver" –WorkflowHostUri "h
ttp:/ ...


The reason is because of the SharePoint Developer Tools for visual studio 2012 preview is also installed.

- Uninstall the sharepoint developer tools for visual studio 2012 preview
- Restart Server
- Run the powershell command again then it worked.
- Also a new office developer tools for visual studio 2012 preview 2 has been released, so I just installed that from web platform installer.

Friday, January 4, 2013

Are there three or four?

This picture really represents the issues we have in the work every day.

Update: I have been thinking what we can do if the thing has been like this. I don't really have a solution as it can be easily said that it is 3.5.
 - At lease, the people can swap their position to understand how the other people look at it
 - Maybe based on how to make the benefits maximum to just decide which can bring the best result.

I am welcome to know any solution you think.

Thursday, January 3, 2013

How to start to use Twitter bootstrap

Recenlty I start to use twitter bootstrap for styling of a small web site. It is very important to go through the web site tutorials and understand each class and what they are. This will make your life much easier and do it right.

Also be careful not to put too much class in the HTML directly. There is an article talking about how to use less mixins to structure your own style better.

Wednesday, January 2, 2013

Example to use ajax post in MVC 4

Since MVC4, it is recommended using jquery and unobtrusive javascript to post form. Here is a quick example to do it in a view to use $.ajax and $.post

   1:   
   2:  <h3>Form 1:</h3>
   3:  @using (Html.BeginForm("Login", "Account", FormMethod.Post, new { Id="form1"}))
   4:  {
   5:      <input type="text" id="text1" name="text1" /><br />
   6:      <input type="text" id="text2" name="text2" /><br />
   7:      <input type="submit" value="submit" id="form1submit" />
   8:  }
   9:   
  10:  <h3>Form 2:</h3>
  11:  @using (Html.BeginForm("About", "Home", FormMethod.Post, new { Id = "form2" }))
  12:  {
  13:      <input type="text" id="txtName" name="txtName" value="abc" /><br />
  14:      <input type="submit" value="submit" id="form2submit" />
  15:  }
  16:   
  17:  @section scripts{
  18:      <script type="text/javascript">
  19:          $(function () {
  20:              $('#form1submit').click(function () {
  21:                  $.ajax({
  22:                      url: '/Home/About',
  23:                      type: 'POST',
  24:                      data: $('#form1').serialize(),
  25:                      success: function (data) {
  26:                          alert(data);
  27:                      }
  28:                  });
  29:   
  30:                  return false;
  31:              });
  32:   
  33:              $('#form2submit').click(function () {
  34:                  var action = $('#form2').attr('action');                
  35:                  $.post(action, $('#form2').serialize(), function (data) { alert(data); });
  36:                  return false;
  37:              });
  38:   
  39:          });
  40:          
  41:      </script>
  42:  }

Tuesday, January 1, 2013

Cool features with CSS3

In this post, it will keep updated to have all the features in CSS3 that I think very useful.

1. Multiple Background Pictures,
#div {
    background-image: url(bg1.gif), url(bg2.gif)
}

Entity Framework One-to-One Relationship Association

In this scenario, Author has many books (1 to m). And the Author has the latest Book (1:1) as well.

Using the link as a reference, here is how I come up with the model and association.

Model:

public class Author
    {
        public int AuthorId { get; set; }
        public string Name { get; set; }
        public int LatestBookId { get; set; }
        public Book LatestBook { get; set; }
        public List<Book> Books { get; set; }
    }
    public class Book
    {
        public int BookId { get; set; }
        public string BookName { get; set; }
        public int AuthorId { get; set; }
        public Author Author { get; set; }
    }

DbContext to set up the relationship using Fluent API

    public class EntityMappingContext : DbContext
    {
        public DbSet<Author> Authors { get; set; }
        public DbSet<Book> Books { get; set; }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<Author>()
                        .HasRequired(a => a.LatestBook)
                        .WithMany()
                        .HasForeignKey(u => u.LatestBookId);
            modelBuilder.Entity<Book>()
                        .HasRequired(a => a.Author)
                        .WithMany()
                        .HasForeignKey(u => u.AuthorId).WillCascadeOnDelete(false);
        }
    }