Romualdas's profileBlogging on .Net and oth...PhotosBlogLists Tools Help

Blogging on .Net and other things

Romualdas

Occupation
Location
If you don't like to play by the rules, make new!!
View Romualdas Stonkus's profile on LinkedIn
 

Xbox Live GamerCard

romualdas
Xbox Live GamerCard
Rep:
3/5 stars
Score:
4830
Zone:
Recreation
Rainbow Six® Vegas 2Halo 3Army of Two™ (EU)Assassin's CreedHalo Wars
June 12

WCF WSDL in a single file

As always, there is something I need from time to time, but not frequently enough to have it close to me, so I have to search for it from time to time. I mean OK, bing is good, but still it takes some time, so I’m publishing this as a note to myself and maybe the others. One of such problems – to generate single WSDL file for WCF service. Mainly this is required if you have some interoperability issues.

Ok, so to have the single WSDL right way you need following things (assuming you’re hosting WCF in IIS):

So, its fairly easy to achieve in the end. And if you think what is else possible to do with custom behaviors, service hosts, etc. – you will realize how much WCF is rock’n’roll.

How to get files associated to specified work item from TFS

Today I’ve got a question on how to get files that are associated with specific work item. The requirement behind that was to grab configuration, data and similar files that were associated to a specific change request, which was entered as a work item.
After quick binging and browsing of the Team Foundation Server SDK, I’ve got the sample below.

static void Main(string[] args)
{
    using (TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(args[0],
        new UICredentialsProvider()))
    {
        tfs.EnsureAuthenticated();
        WorkItemStore wiStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
        VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

        int workItemId;
        if (int.TryParse(args[1], out workItemId))
        {
            WorkItem workItem = wiStore.GetWorkItem(workItemId);
            Console.WriteLine("Work item: {0}", workItem.Title);
            //We look for links associated with work item
            foreach (Link link in workItem.Links)
            {
                ExternalLink extLink = link as ExternalLink;
                if (extLink != null)
                {
                    ArtifactId artifact = LinkingUtilities.DecodeUri(extLink.LinkedArtifactUri);
                    //For this example I grab Changeset directly
                    //however in the real scenario you could grab other related workitems
                    //and this way parse entire tree up to the changeset
                    if (String.Equals(artifact.ArtifactType, "Changeset", StringComparison.Ordinal))
                    {
                        // Convert the artifact URI to Changeset object.
                        Changeset cs = vcs.ArtifactProvider.GetChangeset(new Uri(extLink.LinkedArtifactUri));
                        foreach (Change change in cs.Changes)
                        {
                            //We want to download files only
                            if (change.Item.ItemType == ItemType.File)
                            {
                                RetrieveFile(change);
                            }
                        }
                    }
                }
            }
            Console.ReadLine();
        }
    }
}

private static void RetrieveFile(Change change)
{
    //Technically we should process the information
    //i.e. you should create separate folders according to the server location
    //to avoid the file overwriting
    //if folders are not present - those should be created
    string fileName = change.Item.ServerItem.Split('/').Last();
    Console.WriteLine("Item name: {0}. Last operation {1}", fileName, change.ChangeType);
    change.Item.DownloadFile(@"C:\MyProjects\VS10Solution\GetWIFiles\ttt\" + fileName);
}

Here go the credits: http://blogs.msdn.com/buckh/archive/2006/08/12/artifact_uri_to_changeset.aspx
A quick reminder to myself (and the others): TFS is VERY extensible. You can extend the processes, work items, reports, functionality, … just need the right tools

May 26

Interpersonal skills

If you are consultant like me, then it is very important to understand "magic" of communication.
I found one nice place to read about interpersonal skills: http://sourcesofinsight.com/2009/05/25/top-10-lessons-learned-in-interpersonal-skills/
What I would like to stress is one topic: LISTEN
For myself I noted that often I think that I understood the problem and start talking (yeap, the next day I understand how I ...) about my understanding, which is sometimes absolutely wrong.
The general idea is - if you listen, then you probably may hear something beyond just facts. You may hear frustration, uncertainty, fear, questions, etc. These things are often related to what is called "Emotional Intelligence" or EQ. Being a good consultant requires you to balance well between IQ (our subject competence) and EQ (our ability to hear, understand and feel).
 
Thinking about the same subject with Aikido in mind - the ability to listen translates to feel and be able to adjust.
Not only patterns of the movements are important, but also the behaviour and stance of the partner you are practicing with.
If you don't "listen" to a partner, who moves slower than you want to perform the technique, then probably you're trying to drag, push, etc.
And even if you would be doing that technically correct from the angles and stance position, the result will be far from what it is supposed to be.
 
April 30

Morihei Ueshiba Quotes

One of my friends sent me a Quote from Morihei Ueshiba. After a little search I found nice collection of them at “Brainy Quote”.

A good stance and posture reflect a proper state of mind.” (M. Ueshiba)

January 23

Starting new series: Living in HD

Ok, I’ve decided to start new category: Living in HD. This is because I’ve recently bought a Canon HF100 camera as a replacement for my old Sony DV camcorder. I did it mainly because those “low” quality movies I’ve done with Sony look quite ugly on LCD TV capable showing 720p. And the tapes, those tapes. I hated copying them to computer at the filming speed.

So, here I am, a person that owns pretty decent consumer camcorder and doesn’t know almost anything about making the HD movies. And of course, I’ll be looking more like an IT guy on how did I understood some issues I’ve faced and finally what software or methods I’ve used to achieve some goals.

Ok, so here it comes – the first quest: Shooting in 30p

If you look here, you’ll find this nice description about shooting in 30p mode. Basically what I found important is the statement: “Excellent for action shots and sports”. I’ve seen many times before how movie maker and windows DVD maker break the video by not-deinterlacing the source video. After that the fast moving objects look almost exactly like it is shown in the simulated picture on Canon site.

So, I took a 30p film of a sports activity and tried to look at it using Windows Media Player. I had necessary CoreAVC and AC3Filter (those most probably came with Corel Video Studio trial), so Medial Player started showing the action I shot pretty straight forward.

Now, guess what. The image looked like interlaced. Hmmm … didn’t I set up the camera to take the shot at 30p?

Of course, I’ve tried to encode the m2ts files into WMV with Pinnacle Studio Plus 12 Trial and Corel’s (Ulead) Video Studio X2 Trial. Corel’s software failed to encode WMV. Pinnacle was ok – it did the job. Strangely, but those encoded movies were ok.

So I continued researching why the WMP shows something I didn’t expect to see – the interlaced view. It took quite a while to figure out. After searching couple of links I’ve found something like these statements:

Well, at that moment I could say only one thing. WTF is this 24/30p recorded in interlaced 60i? Anyway, getting a bit smarter at what to look for I found the place where I got the clear picture: here and here.

After getting things understood – fixing the stuff was fairly easy. I just set the CoreAVC to deinterlace using DirectShow. Everything became perfect.

I use WMV as a basic format at home, because I mostly play those videos by streaming them from Windows Home Server to Xbox 360, which is connected to my TV. Also, I like WMV for its good quality/size ratio (at least for my eyes).

So the next questions on the queue are: what would be the easiest and fastest way to work with AVCHD to produce WMV?

The general requirements and notes are:

  • Tool needs to join multiple files (longer movies are split by the camera into multiple files)
  • Tool needs to be as simple as possible
  • The tool needs to have WMV-HD (VC1) output support (primary output)
  • Command line option is welcome
  • Must have decent speed for my home laptop
  • Usage of all available CPU cores is a plus
  • Must run on Vista (and Windows 7 later)
  • Least amount of money investment required compared to useful available capability set
  • So far I’m not planning to use BlueRay output (I don’t have the device either)
  • I rarely use video editing (however I’ll do that from time-to-time)

Several initial thoughts are:

  • Windows Media Encoder
  • Expression Encoder
  • Windows Movie Maker (this and two above require purchasing CoreAVC, etc.)
  • Pinnacle Studio Plus 12
  • Make your own (based on WME most probably)

Those will come next.

January 06

Freezing query plan with SQL Server

Lets presume that you have a 3rd party application that just runs a query against the SQL Server. You see in the profiler that the query does not performs well and can see the way to optimize the query, however it is the 3rd party application.

Is it a dead-end or still there are chances to do something about it?

Very nice article here (in Russian language)

P.S. It is also quite funny to read as long as you know Russian language well :)

November 18

Now this one is a real offer

Today I did received an e-mail from MSDN and found a real nice thing there.
If you attend the intructor-led course about SQL Server, you'll get SQL Server 2008 with single CAL for free.
 
Nice Hot
June 07

WCF certificate authentication under Windows Vista

Security is always A topic, because you have to maintain multiple gates. IIS and WCF is a good example of that. When you want to configure security settings for WCF - you'll have to change the web.config file appropriately and ... most probably the IIS configuration as well.

This post will serve me as a reminder as well on what I have to do in order to achieve the necessary results. So, let's get to the topic.

The goal: To configure WCF service to allow only HTTPS and clients must be authenticated using client certificate using the basicHttpBinding (sounds simple, doesn't it?).

The configuration:

Ok, the first things first - we need to configure basicHttpBinding to request SSL and request client certificates. For that we need to add binding section like this:

<basicHttpBinding>
 <binding name="SSLBinding">
  <security mode="Transport">
   <transport clientCredentialType="Certificate" />
  </security>
 </binding>
</basicHttpBinding>

Generally it means that we will be securing communications at Transport level and the client credentials will be Certificates.

Second, we want to have access to metadata and map the certificates to Windows accounts. For that we will need to configure behaviors section:

<behavior name="SSLBehavior">
  <serviceMetadata httpsGetEnabled="true" />
  <serviceDebug httpHelpPageEnabled="false" includeExceptionDetailInFaults="true" />
  <serviceCredentials>
    <clientCertificate>
      <authentication certificateValidationMode="PeerOrChainTrust" mapClientCertificateToWindowsAccount="true" />
    </clientCertificate>
    <windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false" />
  </serviceCredentials>
</behavior>

After this one is done - there is the last step to configure the service itself. Nice and easy:

<service behaviorConfiguration="SSLBehavior" name="Namespace.Implementation">
 <endpoint address=https://localhost/Implementation/Implementation.svc binding="basicHttpBinding"
  bindingConfiguration="SSLBinding" name="TheService" contract="Namespace.IContract">
  <identity>
   <dns value="Server" />
   <certificateReference x509FindType="FindBySubjectName" findValue="localhost" />
  </identity>
 </endpoint>
</service>

Setting up SSL with Windows Vista is too easy, just take a look: http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx 

So far so good, but there is one more thing - to configure the SSL and map windows accounts to certificates. In Windows 2003 - there is a UI in the IIS management console, but You won't find one in the Vista. Help comes from here: http://blogs.iis.net/ulad/archive/2007/01/19/vbscript-to-configure-one-to-one-client-certificate-mapping-on-iis7.aspx

It will configure your applicationHost.config file and add similar section:

<security>
  <access sslFlags="SslRequireCert,SslNegotiateCert" />
  <authentication>
    <anonymousAuthentication enabled="true" />
    <windowsAuthentication enabled="true" useKernelMode="true" />
    <iisClientCertificateMappingAuthentication enabled="true" oneToOneCertificateMappingsEnabled="true">
      <oneToOneMappings>
        <add enabled="true" userName="computer\username" password="[enc:AesProvider:Encrypted password:enc]"
            certificate="Certificate content" />
      </oneToOneMappings>
    </iisClientCertificateMappingAuthentication>
  </authentication>
</security>

Now lets get back to the bad parts:

First, you probably already noted that the service configuration is missing the IMetadataExchange endpoint, which is usually added to the service configuration. If you'd leave it, then you would receive errors like: "The SSL settings for the service 'None' does not match those of the IIS 'Ssl, SslNegotiateCert, SslRequireCert, SslMapCer".

Also, you will need to enable anonymous authentication, because otherwise you will receive something like: "Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service."

And finally, couple of references I've used when going through all these issues (big thanks to authors):

June 02

SkyDrive availability

For those who are interested in SkyDrive - it is available in Lithuania as well (you should check though).
So, if you're interested in storing and sharing files on the internet - skydrive is an option.
Please, visit the http://skydrive.live.com to sign-up.
April 12

BizTalk tools and updates

BizTalk best practices analyzer 1.1 was released with couple updates. The link: http://www.microsoft.com/downloads/details.aspx?FamilyId=DDA047E3-408E-48BA-83F9-F397226CD6D4&displaylang=en 

Keep up to date with BizTalk operations guide: http://www.microsoft.com/downloads/details.aspx?FamilyID=5251f103-329d-4f8d-95b5-64f99f2f6dfc&DisplayLang=en

And finally, I found this one today and I am quite happy with the finding: http://www.codeplex.com/bud. It is a BizUnit designer or in other words GUI for setting up BizUnit test scenarios.