Thursday, October 1, 2015

Bitbucket Clone All Repos

I needed to backup all the repositories for a Bitbucket account/team. Almost 100 of them. The other fun part is that they are a mixture of bit and mecurial repos.

 Thankfully, Bitbucket has a rest api that makes it easy to get a list of repositories for a team. It also tells you what kind of repo it is. I created a powershell script to get the list of repositories, determine the type, and then clone the repo.  Maybe it would have been more purposeful to do this with bash, but I've never used bash and know a bit of powershell.

 The script is not polished and doesn't handle branch/fork cases. But it's a start. I put it up on github if it can help anyone.

 https://github.com/mlbrown7/scripts/blob/master/BitBucketTeamCloneAll.ps1

Wednesday, August 12, 2015

It's Alive!

It's alive. Resurrected the blog and wow, the old posts are still there. Not really relevant anymore, but at least there is some content! I will attempt to put something useful out here. I've spent a lot of time lately building public facing API's using ASP.Net MVC, working with Android Apps, and exploring ASP.Net 5 and MVC 6.

Monday, February 8, 2010

Visual Studio 2010 Release Candidate

The Visual Studio 2010 RC dropped today!!!

http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx

Thursday, November 26, 2009

Windows Server 2008 IIS7 SSL Host Header

I’ll start off with the bad.  You cannot set this up using the IIS Manager.  Also, once you have it setup, you can view the settings from the IIS Manager, but if you make any changes, the ssl host header settings will be removed.  Very convenient.

The good news is, once you figure out the command line to set it up, it works great.  I have been using it on a couple of test servers for quite a while now to host different test urls on a single ip address.

Assuming you have IIS setup and a cert ready to use, here are the steps I followed.

1. Go ahead and add an SSL binding with your certificate to the website.  The reason for this is to get the certificate hash and Application ID.  You can also get the certificate hash by viewing the details of the cert.  As for the Application ID, this is the only way I could find to get it.  It is probably also the the IIS metabase xml file as well.

2.  In a command prompt run the following command and save the certhash and appid.

  • netsh http show sslcert

showsslcert 

3.  Change directories in the command window to c:\Windows\System32\inetsrv and run

  • appcmd.exe set config -section:system.applicationHost/sites /+"[name='test.mydomain.com'].bindings.[protocol='https',bindingInformation='127.0.0.1
    443:test.mydomain.com']"
    /commit:apphost

appcmd

  • Note: The name= parameter is the name of the site in IIS manager.

4.  The last step is to bind the ssl certificate to the site.

  • netsh http add sslcert ipport=127.0.0.1:443 certhash=1f5596aa6ed348243056eec325fe1fbc326c2d3a appid="{4dc3e181-e14b-4a21-b022-59fc669b0914}"

addsslcert

  • Note: Make sure you put in the values for certhash and appid that you copied earlier.

Finally, the end result….

iis

Labels:

Friday, November 13, 2009

TFS 2008 Remove Alerts

Today I had the need to remove alerts for a user no longer on the project.  It is easy to edit build alerts/notifications using Team Explorer or the TFS Power Tools.  But, I could not find a way to remove Work Item alerts for a user.  Maybe I was missing something simple, but I like to think I wasn’t.  Plus, with the user being a contractor, the email address that was used was not in exchange or tied to the domain account.  After some digging around, I found where TFS stores alert subscriptions in the database and simply deleted the rows.  I found them at

TfsIntegration.dbo.tbl_subscription

So far, this appears to work.  I anyone has a better/cleaner way, I would love to hear about it.

Thursday, August 7, 2008

WCF Client Proxy IDisposable - Generic WCF Service Proxy

I have run into this issue on several clients now.  The basic issue is when using WCF on the client, using ClientBase<>, and you do not close the channel, you can tie up the server until the channel times out.  So, once the max instances, sessions, or concurrent calls is reached and the clients are not closing their channels, the server will block and queue up subsequent calls.  The un-closed client channels will eventually timeout, which causes a fault on the client, and the next set of calls will then make it through.

When I first hit this issue, my thought was to wrap my client base code in a using () statement so Dispose() would then be called.  But, ClientBase<> does not implement IDisposable.  Here is some info on the issue...

Guidance on factory close and message faults

Why does ClientBase Dispose need to throw on faulted state

So, after lots of testing to understand all the WCF knobs to tweak, I came up with a generic class I called ServiceProxy for clients to use when creating/using client channels.  This has been through several revisions and here is what I have ended up with.  The idea to add support for the delegate came from this blog entry

iServiceOriented.com

Here is the code for my generic service proxy wrapper...

public class ServiceProxy<TInterface> : ClientBase<TInterface>, IDisposable where TInterface : class

    {

        public delegate void ServiceProxyDelegate<T>(TInterface proxy);

 

        public ServiceProxy()

            : base(typeof(TInterface).ToString())

        {

        }

        public ServiceProxy(string endpointConfigurationName)

            : base(endpointConfigurationName)

        {

        }

 

        protected override TInterface CreateChannel()

        {

            return base.CreateChannel();

        }

 

        public TInterface Proxy

        {

            get

            {

                return this.Channel;

            }

        }

 

        public static void Call(ServiceProxyDelegate<TInterface> proxyDelegate)

        {

            Call(proxyDelegate, typeof(TInterface).ToString());

        }

 

        public static void Call(ServiceProxyDelegate<TInterface> proxyDelegate, string endpointConfigurationName)

        {

            ChannelFactory<TInterface> channel = new ChannelFactory<TInterface>(endpointConfigurationName);

 

            try

            {

                proxyDelegate(channel.CreateChannel());

            }

            finally

            {

                if (channel.State == CommunicationState.Faulted)

                {

                    channel.Abort();

                }

                else

                {

                    try

                    {

                        channel.Close();

                    }

                    catch

                    {

                        channel.Abort();

                    }

                }

            }

        }

 

        public void Dispose()

        {

            if (this.State == CommunicationState.Faulted)

            {

                base.Abort();

            }

            else

            {

                try

                {

                    base.Close();

                }

                catch

                {

                    base.Abort();

                }

            }

        }

    }

 

And, here are some usages samples...

//delegate example1

            string response = null;

            ServiceModel.ServiceProxy<IUnitTestService>.Call(p =>

            {

                response = p.DoStuff("ServiceProxyUsingTest");

            }

            );

 

            //delegate example2

            string response = null;

            ServiceProxy<IUnitTestService>.Call(p => response = p.DoStuff("ServiceProxyUsingTest"));

 

            //using example

            string response = null;

            using (ServiceProxy<IUnitTestService> service = new ServiceProxy<IUnitTestService>())

            {

                response = service.Proxy.DoStuff("ServiceProxyUsingTest");

            }

Tuesday, June 3, 2008

WCF Presentation at South Colorado .Net User Groupo

Here is the content from my WCF presentation today at the South Colorado .Net User Group. The zip file includes the powerpoint, code, and a sql backup file of the demo database. Feel free to email me with any questions.


WCFDemo.zip