Author Archive

XNA, Yesterday – Now – Tomorrow

Saturday, April 10th, 2010
Autor: goncalo.chaves


xna11 thumb XNA, Yesterday – Now   Tomorrow

Once again Microsoft has invited a fullsix employee to be speaker on a great gamming event, so I would like share with all of you my presentation slide deck, from the last XNA Pizza night 2010 event.

It’s was great gathering about this growing technology. Although the game applications also it’s a great framework for other applications, such as medical image, 3D simulation and so on.

You can see more at the event page.

Download SlideDeck in pdf.

News: http://creators.xna.com/en-US/spotlight/MicrosoftPortugal

Second Annual Scrum User Group Meeting – The after

Wednesday, February 3rd, 2010
Autor: goncalo.chaves


ScrumUserGroup Portugal sm1 thumb Second Annual Scrum User Group Meeting – The after

Hi all,

Today at Microsoft Portugal took place the 2nd Annual Scrum User Group meeting. With a great morning sessions opened by Dr. Jeff Sutherland, then Mitch Lacey and two Portuguese testimonials with: Prof. Ademar Aguiar and Mário Araújo.

The Microsoft’s auditorium was full with more then 120 people engaged to learn and exchange Scrum best practices and knowledge. You can review the agenda here:

http://www.fullsix.pt/scrum/Annual_Meeting_2010.htm 

And some photos about it at:

http://www.flickr.com/photos/gchaves/sets/72157623217629763/

I really enjoyed the sessions and Tiago Andrade e Silva (our fullsix Portugal CTO) suggested a next meeting with a full user group feedback interaction about individuals experiences with Scrum.

Stay tuned for next meetings and training at: www.fullsix.pt/scrum

Remove Spammers of your Community Server

Tuesday, January 19th, 2010
Autor: goncalo.chaves


Hi all,

I would like start this new year with a full dedicated post of one of hell head pain, that’s your usual community server 200x installation with tons of spammers users and content…

I’ve been working with Community Server from Telligent a while ago, and it’s a nicer community driven web platform, and if we could get the CS with Umbraco in the same web site I could say that solution would be the 90% useful in most websites of this days.

Has we have some CS community web sites, we notice that they have been a nice target for the tons of spam and unwanted content… really? who wants sex terms related ads, in your peacefully community site? So he had our mission to go…

First – Protect, close the gates

Sure, the first step is get something that kept the registration form (ie. /yourTheme/users/createuser.aspx) protected against the spammer robot, so the one that we’ve chosen was a captcha mechanism, in order to require a code that only the user can decipher from the image. Sounds promising… from the paper into the code we found a captcha control named Upupo Captcha … nice! It comes with the dll and a sample that we can apply on our pages.

So we first insert the control into the createuser.aspx registration form in order to avoid new spam registrations icon smile Remove Spammers of your Community Server

<%@ Register Assembly="Upupo.Captcha" Namespace="Upupo.Captcha" TagPrefix="Captcha" %>

In page look like:

image thumb1 Remove Spammers of your Community Server

With a required control inside of it the automatic spammer cannot advance on this…. at least for now.

So now we close the entrance for new registrations… now let’s deal with the spammer content…

Note, if you want to improve protection with this control you can add it into the comment blogs forms, forum post form and media post form. Same way as the sample createuser.aspx sample page.

 

Second – Delete, kill all spam traces

Now that we close doors for unwanted “fake persons”, maybe you notice that your community has increased in 2500 new users in some days… wow… all spammers, all trash… so another head pain was how we can remove this guys and grant the database data integrity. When cs has a new user he create a lot of references inside the ASP.NET Membership tables and in CS_ tables… and to help the field UserID is different from the Memebership UserId … yeah… not great implementation.

Although this little issue, you can remove using the ControlPanel, on Memebership administration section, but you have to search and then remove one by one… NO WAY!

That’s right so how we can automate this process, in order to remove the unwanted users and delete related content?

If you explore the StoredProcedures from your CS database you will find something like this:

image thumb2 Remove Spammers of your Community Server

Hum… <dbo.cs_User_Delete> sounds good, and it sounds! This Sp is used each time that you delete a user using the control panel on the membership admin section. So all we needed to do in order to automate the remove process of this users and contents was a custom SQL to execute this SP with some additional prams and features.

So we used this sp to execute for each registration that we want to find so we did something like this:

SELECT 'EXEC cs_User_Delete '+ CONVERT(int,UserId) + 'Anonymous'
FROM  dbo.cs_Users
WHERE UserName like '%.%.%.%'

So now we’ve only made some adjustments on the LIKE statement in order to catch all spammers, so spaces, keywords that we know like casino or hotel or pharmacy, this query selects all that and draws the execution SQL of the CS delete SP necessary and deletes from all tables the user data and assign their related content with the Anonymous user. Sweet ha?

With this we were capable of remove all spammers from our CS based sites. this is only one tip maybe there are others but the telligent community unfortunately don’t care anymore and I couldn’t find anything related with this.

Stays another journey with CS.

WPF XBAP: Import your Contacts from Outlook (demo)

Friday, November 6th, 2009
Autor: goncalo.chaves


 

[PT] (for a English version, see bellow on this page, please)

Olá a todos,

Recentemente num projecto interno nós estávamos a necessitar de utilizar algum tipo de activeX numa página Web, para que fosse possível a importação dos contactos do Outlook, tal como no linkedIn.

Portanto, para quê um activeX quando temos as aplicações XBAP? Hum… parece-me bem. Então aqui fica um pouco da experiência que tivemos no desenvolvimento desta brincadeira. Em primeiro lugar, não esquecer que se a nossa aplicação vai interagir com um dos membros do Microsoft Office, as Visual Tools for Office têm as bibliotecas certas para isto!

Eis os nossos passos:

1) Importação da biblioteca do Outlook para a nossa aplicação:

using Microsoft.Office.Interop.Outlook;

2) Criação dos tipos necessários para a transmissão com o Outlook e leitura dos dados:

private MAPIFolder oContactsFolder = null;
//load outlookcontacts
           var oApp = new Microsoft.Office.Interop.Outlook.Application();
           NameSpace oNS = oApp.GetNamespace("MAPI");
           oContactsFolder = oNS.PickFolder();
      
           string filter = "[MessageClass] = \"IPM.Contact\"";
           Items oContactItems = oContactsFolder.Items.Restrict(filter);
 
           foreach (ContactItem oContact in oContactItems)
           {
               var item = new EmailContact();
              if (oContact != null)
               {
                   item.ContactEmail = oContact.Email1Address;
                   item.ContactName = oContact.FullName;
                   //before add the email let's see that's is valid
                   if (ValidateEmailAdd(item.ContactEmail) && !String.IsNullOrEmpty(item.ContactEmail))
                   {
                       contactList.Add(item);
                   }
               }

3) Definição da interface e da lógica da aplicação

Para tal escolhemos a XBAP para que nos seja possível aplicar todas as funcionalidades que o WFP nos oferece, mas para tal existem algumas notas importantes a ter em consideração:

- A XBAP deverá correr em modo de “full trust”, e para tal é necessário um certificado digital que assine o código da aplicação, e obviamente o nosso browser deverá confiar no mesmo.

image thumb WPF XBAP: Import your Contacts from Outlook (demo)

Para tal, criámos um certificado fullsix CA, algo que fomos seguindo aqui:

http://msdn.microsoft.com/en-us/library/aa194055%28office.11%29.aspx

Outro post com informações muito importantes sobre esta parte:

http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/05/wpf-xbap-as-full-trust-application.aspx

Para a extracção do certificado seguimos:

http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/31/how-to-run-wpf-xbap-application-in-full-trust-mode-post-2-certificate-extraction.aspx

Para automatizar este processo, desenvolvemos uma pequena aplicação de consola que permite o download e a instalação silenciosa do mesmo. Assim o certificado fullsix CA fica instalado no computador, que assina o certificado que usamos para assinar o código da nossa XBAP application.

image thumb1 WPF XBAP: Import your Contacts from Outlook (demo)

Aqui fica o código que usámos:

try
           {
 
               var myStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("InstallXBAPOutlookCert.Console.f6signing.cer");
 
               byte[] b = new byte[myStream.Length];
 
               myStream.Read(b, 0, b.Length);
 
               X509Certificate2 cert = new X509Certificate2(b);
 
               X509Store store = new X509Store(StoreName.AuthRoot, StoreLocation.LocalMachine);
 
               store.Open(OpenFlags.ReadWrite);
 
               store.Add(cert);
 
               store.Close();
 
               store = new X509Store(StoreName.TrustedPublisher, StoreLocation.LocalMachine);
 
               store.Open(OpenFlags.ReadWrite);
 
               store.Add(cert);
 
               store.Close();
 
               System.Console.WriteLine("Certificate Successfully Installed...!");
 
               System.Console.Read();
           }
           catch (Exception ex)
           {
               
               System.Console.WriteLine("Error " + ex.ToString());

}

Não esquecer de embeber o ficheiro de manifesto da aplicação dentro do ficheiro exe da aplicação, isto é necessário para utilizar os direitos de Administrador da máquina, para que seja possível fazer a instalação do certificado. É necessário alterar este manifesto como se segue:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

E para embeber o manifesto no exe:

image thumb2 WPF XBAP: Import your Contacts from Outlook (demo)

O utilizador vê o ficheiro .exe no browser e se no seu caso a empresa possuir um certificado assinado por uma das bem conhecidas CA’s não deverá existir qualquer problema, no nosso caso, os utilizadores deverão confiar no nosso certificado, para que seja possível visualizar a demo correctamente icon smile WPF XBAP: Import your Contacts from Outlook (demo)

image thumb3 WPF XBAP: Import your Contacts from Outlook (demo)

Depois o certificado fullsix CA fica instalado no computador tal como se pode ver abaixo:

image thumb4 WPF XBAP: Import your Contacts from Outlook (demo)

Agora a aplicação XBAP está devidamente assinada e é confiada pelo browser e tudo corre em modo full trust.

Nota:

- WPF threading module. É um pouco doloroso entender para quem está mais familiriarizado com o modo de threading do silverlight como é o nosso caso. Em WPF existem algumas diferenças, o que significia que é necessário pensar sobre esta questão para que não se bloqueie a thread da Interface. Imaginando por exemplo uma animação de loading enquando a comunicação com o Outlook é feita. Um bom artigo para ajudar nesta questão:

http://msdn.microsoft.com/en-us/library/ms741870.aspx

Para evitar o bloqueio da thread principal da interface, lançamos o método de interacção com o Outlook noutra thread da seguinte forma:

var myDispatcher = new Thread(new ParameterizedThreadStart(s => { StartRetriveContacts(); }));

Depois no regresso á thread original:

private void StartRetriveContacts()
       { …
UIDispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { ProcessContacts(contactList); },
                                    contactList);

Usando este tipo de “roteamento” entre as threads permite-nos fazer um update constante na interface de modo a dar feedback constante ao utilizador sobre as operações que decorrem em background.

E pronto icon smile WPF XBAP: Import your Contacts from Outlook (demo) é isto, podem testar. http://labs.fullsix.pt/projects/xbapoutlookdemo/demo.htm e já agora dar uma vista de olhos nos outros projectos que estão no fullsix Labs.

Queria deixar também uma nota de agradecimento aos meus colegas Antoine e Fiel pela ajuda no desenvolvimento.

Merci.

 

[EN]

Hi all,

In order for a internal project we need some kind of an activeX in a web page from Outlook contact email addresses importation, such has like linkedIn has.

So why use a activeX when we have XBAP apps? Sweet hum? Here is how we’ve done the little app. First of all keep in mind this is something to interop with an Microsoft Office application, right? The Visual Tools for Office have the right libraries for it!

Steps:

1) Import the Microsoft Interop Namespace:

using Microsoft.Office.Interop.Outlook;

easy as butter

2) Create the right types to exchange with outlook and load content

private MAPIFolder oContactsFolder = null;
//load outlookcontacts
           var oApp = new Microsoft.Office.Interop.Outlook.Application();
           NameSpace oNS = oApp.GetNamespace("MAPI");
           oContactsFolder = oNS.PickFolder();

           string filter = "[MessageClass] = \"IPM.Contact\"";
           Items oContactItems = oContactsFolder.Items.Restrict(filter);

           foreach (ContactItem oContact in oContactItems)
           {

               var item = new EmailContact();

               if (oContact != null)
               {
                   item.ContactEmail = oContact.Email1Address;
                   item.ContactName = oContact.FullName;

                   //before add the email let's see that's is valid

                   if (ValidateEmailAdd(item.ContactEmail) && !String.IsNullOrEmpty(item.ContactEmail))
                   {
                       contactList.Add(item);
                   }
               }

3) Define your UI and the rest of the behaviors

We choose a XBAP application in order to have the WPF capabilities in a regular web page but you must be aware of some important settings:

- XBAP app needs to run in a full trust mode, so that requires a DigitalCertificate to sign your code and the browser needs to trust on that.

image thumb WPF XBAP: Import your Contacts from Outlook (demo)

So we created a fullsix CA certificate. Something that follows here:

http://msdn.microsoft.com/en-us/library/aa194055%28office.11%29.aspx 

You can see a quite nice post’s about this at:

http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/05/wpf-xbap-as-full-trust-application.aspx 

and for the certificate extraction

http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/31/how-to-run-wpf-xbap-application-in-full-trust-mode-post-2-certificate-extraction.aspx

to automate this process we develop a simple console application that you download first and installs on your computer our fullsix CA certificate, that signs the code sign certificate that we use previously to sign the xbap code.

image thumb1 WPF XBAP: Import your Contacts from Outlook (demo)

Here is the code for that:

try
           {

               var myStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("InstallXBAPOutlookCert.Console.f6signing.cer");

               byte[] b = new byte[myStream.Length];

               myStream.Read(b, 0, b.Length);

               X509Certificate2 cert = new X509Certificate2(b);

               X509Store store = new X509Store(StoreName.AuthRoot, StoreLocation.LocalMachine);

               store.Open(OpenFlags.ReadWrite);

               store.Add(cert);

               store.Close();

               store = new X509Store(StoreName.TrustedPublisher, StoreLocation.LocalMachine);

               store.Open(OpenFlags.ReadWrite);

               store.Add(cert);

               store.Close();

               System.Console.WriteLine("Certificate Successfully Installed...!");

               System.Console.Read();
           }
           catch (Exception ex)
           {

               System.Console.WriteLine("Error " + ex.ToString());
           }

Don’t forget to embed the application manifest in the exe file, you need that for auto Admin rights permissions to install icon smile WPF XBAP: Import your Contacts from Outlook (demo) like this in your manifest file:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

and to embed it on the exe:

image thumb2 WPF XBAP: Import your Contacts from Outlook (demo)

The user see’s the .exe on the browser and if your company has a certificate that’s signed by one of very well known CA you should haven’t any trouble. In this case our users must have trust on us icon smile WPF XBAP: Import your Contacts from Outlook (demo)  

image thumb3 WPF XBAP: Import your Contacts from Outlook (demo)

 

then you have the fullsix CA in your machine as you can see here:

image thumb4 WPF XBAP: Import your Contacts from Outlook (demo)

So now XBAP application is signed and User grant a full trust environment for it.

Note:

- WPF threading module. It’s some kind of “pain”, for those who are more familiar with Silverlight like me, in WPF there are some differences, which means that you have to think about threading block handling, in order to avoid frozen the main UI thread, that can being display, for example, a loading animation of the contact import progress. for that there are also a nice article:

 http://msdn.microsoft.com/en-us/library/ms741870.aspx 

To avoid the main UI thread block we launched the Outlook interop method in another thread, here’s the way:

var myDispatcher = new Thread(new ParameterizedThreadStart(s => { StartRetriveContacts(); }));

then to get back on the main UI:

private void StartRetriveContacts()
       { …
UIDispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { ProcessContacts(contactList); },
                                    contactList);

Using this kind of “routed threading model” we were able to provide an UI update with some animation and application update state.

And that’s it..! you can try for your self 

http://labs.fullsix.pt/projects/xbapoutlookdemo/demo.htm , and take a look into our others fullsix labs projects.

Also a thanks to Antoine and Fiel for their help on this development.

Silverlight: Colors in Hexadecimal values

Monday, November 2nd, 2009
Autor: goncalo.chaves


 

[PT]

Gostaria de deixar um pequeno truque para se trabalhar com cores nos controlos de Siverlight. Imaginem que instanciam um controlo como por exemplo uma textbox:

var newTextBox = new TextBox();

Agora, gostaria de mudar a color de fundo para preto, vermelho, verde, etc…

Então será necessário escrever algo como: myTextBox.Background = new Brush(Opacity bla blabla, etc); etc, e mais bla… Mas eu só queria algo como .Background = Colors.Red;

Ok, eis algo que pode ajudar e muito. Criem um método para extraír de um valor Hexadecimal a vossa cor como por ex:

private SolidColorBrush GetColorFromHex(string myColor)
{
    return new SolidColorBrush(
        Color.FromArgb(
            Convert.ToByte(myColor.Substring(1, 2), 16),
            Convert.ToByte(myColor.Substring(3, 2), 16),
            Convert.ToByte(myColor.Substring(5, 2), 16),
            Convert.ToByte(myColor.Substring(7, 2), 16)
        )
    );
}

Agora, é mais simples atribuir ao nosso controlo:

newTextBox.Background = GetColorFromHex("#00FFFFFF");

Cool! não?

[EN]

Just a tip, if you want in your code work with an color in Hexadecimal format maybe a little complicate.

Imagine that you create a new control such as:

var newTextBox = new TextBox();

Now you want give a color to it, right? So to do something like myTextBox.Background = new Brush(Opacity … etc, etc, etc). :s I just want a simple red, white… or something similar…

Here’s a tip, create a method to extract a color from an Hexadecimal value:

private SolidColorBrush GetColorFromHex(string myColor)
      {
          return new SolidColorBrush(
              Color.FromArgb(
                  Convert.ToByte(myColor.Substring(1, 2), 16),
                  Convert.ToByte(myColor.Substring(3, 2), 16),
                  Convert.ToByte(myColor.Substring(5, 2), 16),
                  Convert.ToByte(myColor.Substring(7, 2), 16)
              )
          );
      }

now it’s more simple to use on your control:

newTextBox.Background = GetColorFromHex("#00FFFFFF");

Cool! Isn’t it?


Better Tag Cloud