Microsoft MVP 2016 – Business Solutions – Dynamics CRM

indexI am proud to announce that I just received my 1st Microsoft MVP Award for my focus in Business Solutions – Dynamics CRM.

Congratulations! We are pleased to present you with the 2016 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in Business Solutions technical communities during the past year.

Also in this email:

About your MVP Award Gift
How to claim your award benefits
Your MVP Identification Number
MVP Award Program Code of Conduct

The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say “Thank you for your technical leadership.”

Patrick Malone
Director
Community & Advocacy Programs
Microsoft

The Microsoft MVP award and the included opportunities add a huge benefit like the Microsoft MVP summit where you have the chance to talk to the Microsoft Product Groups, learn and place feedback. But of course the Microsoft MVP award also adds some other great advantages.

Of course there are a lot of people I have to thank, but I want to keep the list as short as possible. I would like to thank my employer which is supporting me in the best possible way year over year, my current and former colleagues, the Microsoft MVP community and of course Microsoft employees in Redmond and all over the world.

CRM2011/2016 – Timeout problem when open Sharepoint documents from CRM

Today I had a big problem with our new customer: When they tried to open a document from CRM, they had an error:

a

After check a little bit, I found a timeout error on sharepoint.  The problem was the Cookie life time configuration:

[..]When using FBA or a trusted provider, SharePoint will set a cookie on the client called FedAuth. I’ll not go into the details of what’s inside the FedAuth cookie. Of course, the FedAuth cookie will have by default a certain lifetime. Session cookies can be configured too making the cookie invalid after the closing the browser and then bypassing the value in this settings.

The default value is 5 days.[..] (Microsoft text)

cp1

To resolve the problem I found this script:

$sts = Get-SPSecurityTokenServiceConfig
$sts.CookieLifetime = New-TimeSpan -Hours 7
$sts.Update()

At the end I restart IIS and all is run in right way.

Unable to activate CRM List Component in Sharepoint

Last week I installed a new CRM and Sharepoint enviroment on my client.  I had a strange problem when I tried to install and activate List Component on Sharepoint: After the installation (I did not have any problem during the process) I tried to activate List Component Plugin: The result was that the plugin was not active but I did not have any error. After some (long) minutes, I found the problem:

Inside zip package setup for CRM List Component there is a powershell file named AllowHtcExtn.ps1

We need to execute this file before activate.

On Technet we can read this :

[…By default, HTML component (.htc) files aren’t enabled on SharePoint 2013. …]

 

After we can activate our plugin.

That’s all 🙂

Sharepoint Error schema database (Version problem)

Last week I migrated Sharepoint database from a server to another one. I did not have any problem with restore database on new server but the problem started when I tried to add the new content database to sharepoint. I had this error:

This content database has a schema version which is not supported in this farm.

img4

After some check and some scounting on Google, I found the reason: The version of Sharepoint where I get the database is different from the version where I tried to install it.  In my case the problem was that on the destination server the Sharepoint Service pack 1 was missing. After installation of Service pack I could add the new content database.

To check the build version, I open the “Manage Patch Status” from Sharepoint Central Administrator:

img5

That’s all… 🙂

MONODROID: Una valida alternativa .NET per sviluppare con Android

Introduzione

In questo articolo cercheremo di introdurre un modo alternativo allo sviluppo di applicazioni Android, utilizzando la potenza della tecnologia .Net come alternativa a JAVA. Ci focalizzeremo sui vantaggi e sugli svantaggi nell’utilizzare uno strumento diverso da JAVA, cercando di capire quali benefici si possono acquisire.  Con lo sviluppo di dispositivi mobili sempre più potenti, le aziende, non solo quelle legate all’intrattenimento, ma anche quelle nel mondo enterprise cercano di trovare un posto di comando nel rispettivo mercato.  In questo mondo concorrenziale, molte volte  ciò che ci distingue è l’applicazione che rendiamo disponibile. Un’azienda cerca sempre di avere le proprie applicazioni sulle principali piattaforme presenti in commercio: ANDROID, IOS, WINDOW PHONE che dispongono di un sistema operativo e di un modello di sviluppo totalmente differente l’uno dall’altro. Con Android sviluppiamo in JAVA, con IOS sviluppiamo in Objective C o XCode mentre in Windows Phone  in C#. Figure professionali distinte, non tutte le realtà aziendali possono permettersele ed è difficile ma soprattutto costoso, avere le competenze necessarie a coprire tutte e tre le piattaforme. Pensiamo ad un’impresa dove il core business è focalizzato su un settore diverso dall’informatica e dove ogni investimento, specialmente in questo momento di crisi e’ sempre fatto col contagocce.  Ma allora come possiamo concorrere con aziende che hanno l’opportunità di investire e quindi avere tutte le applicazioni su tutti i dispositivi? Semplicemente cerchiamo di riciclare il codice ed utilizzare qualcosa che ci possa aiutare in questo. Unsupporto è dato dalla XAMARIN e dalle sue alternative che permettono di sviluppare su tre piattaforme utilizzando .NET, proponendosi quindi a noi sviluppatori che lavoriamo con Visual Studio, programmiamo con C# e sviluppiamo già sulle tecnologie basate su XAML, come Window Phone.
Continua a leggere

SignalR primi passi: Log viewer in Realtime con Log4Net

Per lavoro ho iniziato a muovere i primi passi con SignalR. SignalR è una libreria che crea una persistent connection tra client e server, permettendo al server di inviare al client dati in modalita push. Crea inoltre un’astrazione sulla modalità di trasporto adottata (periodic polling, long polling & websockets), e fornisce un’unica interfaccia di programmazione.
Ma perche’ utilizzarla?  Un’applicazione necessita del real-time perché ci sono situazioni in cui i dati visualizzati devono essere aggiornati costantemente (in modalita push). Un caso emblematico può essere quello delle quotazioni di borsa. 

Il web è basato sul protocollo HTTP, che per sua natura è request/response. Pertanto, ci troviamo ad utilizzare un protocollo unidirezionale senza stato (ovvero che non permette di fare delle chiamate push server-to-client in maniera nativa). Per utilizzare una modalità push, quindi, dobbiamo ricorrere ad alcuni workaround. Ci sono molti siti ufficiali, blog, tutorial, etc. per documentarsi. Questo e’ solo il mio primo esempio.

La parte di configurazione ed installazione la lascio al sito microsoft…  Il progetto che presentero’ e’ una banale  console per visualizzare log in real time da diverse fonti, in questo caso da diverse webApi.

Ci sono 3 livelli di log (lOG4nET): debug, info, error. In SignalR, ogni livello di log è che sia proprio gruppo.  L’interfaccia utente consente all’utente di passare ogni livello. Ogni livello di log e’ associato ad un’attivita’ di SignalR. L’implementazione finale e’ semplice:  Quando il logger ricerve un messaggio, lo trasmette al gruppo associato. Ogni metodo di log chiama Log(string level, string message):

public void Log(string loglevel, string message)
{

     Log(new LogItem() { Level = loglevel, Message = message });
}
private void Log(LogItem item)
{
     IConnectionManager connectionManager = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
     dynamic clients = connectionManager.GetClients<LogEndpoint>();
     clients[item.Level].receiveLogEntry(item);
}

L’hub espone 2 metodi: WatchLevel(string) and UnwatchLevel(string) which add the current connection to the group.

public void WatchLevel(string level)
{
     if (LogLevels.Contains(level))
     {
          AddToGroup(level);
     }
}

public void UnwatchLevel(string level)
{
     if (LogLevels.Contains(level))
     {
          RemoveFromGroup(level);
     }
}

Il frontend ha un metodo principale chiamato receiveLogEntry che accetta un LogItem come parametro.
LogItem è un semplice POCO con Timstamp, livello, e proprietà del messaggio.
I nuovi messaggi vengono anteposti alla tabella o aggiunti alla console a seconda della vista.

Quanto detto e’ il funzionamento di base.
Nel progetto ho aggiunto un paio di cose come la codifica a colori dei messaggi di errore
e una semplice scroll automatica ed un elenco di connessioni correnti e di
registrazione semplici in tutta l’applicazione.

Questo e’ un semplice punto di partenza per avere un log centralizzato. A questo link e’ possibile fare il download del
progetto github qui.

MassTransit and RabbitMQ

Not every application has aspirations to serve millions of requests a day, but to those who aspire to do so, technology has become so easy and friendly that there hasn’t been a better time to go web scale. There are usually two high level solutions to the problem of scaling:

  1. Scale Vertically.
  2. Scale Horizontally

Scaling Vertically

If you’ve worked in technology for any amount of time you’ve probably heard phrases like:

  • Memory is cheap.
  • Throw more money at the problem.
  • Disk space is cheap.
  • SSDs are soooo fast.
  • We need more power Jim!

These phrases are hints that you are about to scale vertically. Your application is most likely hosted on one server, and very little about your application is distributed.

Scaling vertically usually focuses on your host environment gaining more memory, disk space, processing power, or all three at the same time. The problem with scaling vertically, is your are constrained by Moore’s Law. If you continue to grow, you are likely to max out your hardware specifications.

Scaling Horizontally

Scaling horizontally usually starts with introspection, both personally and technologically: Do I really need to do this? Can my processing be distributed. It might also involve a lot of cursing or mentions of Fudge.

Scaling horizontally is a distribution problem. How can you relay your intentions to other machines? I’m here to to tell you that scaling horizontally is a problem of two. If you can distribute your process across two machines, then you can distribute your process across 100 machines. The second machine is the hardest.

This tutorial is to show you how easy it is to distribute your work across many machines using the following technologies: .NET, MassTransit, and RabbitMQ.

Getting Started

The first thing you will need, is to install RabbitMQ on your machine / server. You only need one instance of RabbitMQ for this tutorial, but in production it might be a good idea to load balance your installations.

Download the installer here, you will also need Erlang.

Publisher

First install MassTransit into your solution, with the RabbitMQ add-on.

PM> Install-Package MassTransit.RabbitMQ

So for the purposes of this tutorial, we will be using MassTransit to handle sending messages to our queue, and on MassTransit to consume the messages from the queues. So there are two parts to keep in mind:

  1. Publishers
  2. Consumers

To publish a message to RabbitMQ we first need to setup a Bus. This of the Bus as a service that facilitates communication across your network. Let’s set it up.

Bus.Initialize(cfg => {
    cfg.UseRabbitMq();
    cfg.ReceiveFrom("rabbitmq://localhost/test_queue");
});

Here is the quirky part that might not be intuitive, but each logical process needs its own separate queue. In this case our publisher has a queue of rabbitmq://localhost/test_queue. Let’s see how we can publish the message using the Bus.

Bus.Instance.Publish(new DoWorkItem { Text = string.Format("Message #{0} says: Hello World at {1}!", i, DateTime.Now) })

We’ve published a message! Now the message is out in our queueing system waiting to be picked up. Now to implement the other half.

Consumer

Consumers handle messages (very descriptive name). The process to consume the messages might be a separate application, and in this example it is, so we need to initialize another instance of the Bus.

Bus.Initialize(sbc =>
        {
            sbc.UseRabbitMq();
            sbc.ReceiveFrom("rabbitmq://localhost/test_queue_worker");
            sbc.Subscribe(subs =>
            {
                var del = new Action<IConsumeContext<DoWorkItem>, DoWorkItem>((context, msg) =>
                {
                    Console.WriteLine(msg.Text);
                });
                subs.Handler(del);
            });
        });

Notice a couple things about our implementation of the Bus this time.

  1. We have a different queue
  2. We are not subscribing to the DoWorkItem message.

So you remember how I said each logical process has to have its own queue, well now we can spawn up as many of the consumers as we want. The magic happens in RabbitMQ, which implements a competing consumer model. That means one message per one process at a time. Since all your consumers will be sharing the same queue, they will happily round robin responsibility. This means you can scale to hundreds, if not thousands of processors with no perceived differences in implementation. Let me show you a screenshot of how this all works.

w734

Awesome right? We have three consumers being delegated work from one publisher. You can try this out by cloning my GitHub repository.

https://github.com/algraps/RabbitMQ/tree/master/RabbitMQ.Scaling

Note: You will need NuGet package restore enabled. It helps to start the publisher and consumers at the same time, but that is optional as messages that are published will be persisted in the queue waiting for someone to consume them.

Conclusion

Web Scale is achievable with some OSS goodness and some practice. It really is an amazing time to be a developer. Give my code a try to get started, and let me know if you have any questions.