quinta-feira, 30 de julho de 2015

Distributed Logging with log4net e MSMQ

What is Log4net?

Log4net is an open source library that allows .NET applications to log output to a variety of sources (e.g., The console, SMTP or files). Log4net is a port of the popular log4J library used in Java. 




Architecture

The framework is built on the concept of layers and has 4 main components: Logger, Repository, Appender, and Layout.
Logging Levels

1 - OFF - nothing gets logged (cannot be called)
2 - FATAL
3 - ERROR
4 - WARN
5 - INFO
6 - DEBUG
7 - ALL - everything gets logged (cannot be called)

What Appender support?
Console Appender, File Appender, Rolling File Appender, ADO.NET Appender, MSMQ?

What is Microsoft Message Queuing (MSMQ)?

Message Queuing (MSMQ) technology enables applications running at different times to communicate across heterogeneous networks and systems that may be temporarily offline. Applications send messages to queues and read messages from queues. The following illustration shows how a queue can hold messages that are generated by multiple sending applications and read by multiple receiving applications.


Let's encode!!




Implement override AppenderSkeleton ...


Don't forget RenderLayout and two config (QueueName, LabelLayout)


Add a new appender for log4net

Let me know if you would like me to expound on any area listed above or if you have an issue using log4net.Record information on MSMQ allows you to distribute the actions to be taken at every level of log, it's great solution of enterprise application where exist big lots of message log.

Thanks, Happy coding :)

terça-feira, 28 de julho de 2015

WCF ClientBase and Command Dispatcher

What is WCF?

Windows Communication Foundation (WCF) is a unified, simplified and optimized evolution of a number of communication technologies into a single model. Most of the WCF functionalities are included in a single assembly called System.ServiceModel.dll in the System.ServiceModel namespace.


To run WCF service on the client side you have some options:

Option 1: Generate Adding Proxy Service Reference


Problem for enterprise application:

- Updates on service
- Changes in the service configuration


Option 2: Generate Proxy by implementing ClientBase<T> class


It is a good option, but in a great architecture generation can become unproductive and without much need.

Option 3: Generate Dynamic Command Dispatcher

Let's encode!!








Method overloading sending client credencial...



Method overloading sending custom header...



Async method run...



Usage!!



...With this implementation the service call is dynamic and independent enabling updates on unchanged in customer service.

Thanks, Happy coding :)

segunda-feira, 27 de julho de 2015

Using JSON Web Token

( Wikipedia ) JSON Web Token (JWT) is a JSON-based open standard (RFC 7519) for passing claims between parties in web application environment. The tokens are designed to be compact, URL-safe and usable especially in web browser single sign-on (SSO) context. JWT claims can be typically used to pass identity of authenticated users between an identity provider and a service provider, or any other type of claims as required by business processes. The tokens can also be authenticated and encrypted. JWT relies on other JSON-based standards: JWS (JSON Web Signature) RFC 7515 and JWE (JSON Web Encryption)

JWT is a recent open standard that is being driven by the international standards body IETF and has top-level backers from the technology sector (for example, Microsoft, Facebook, and Google).


What is JSON Web Token?
http://jwt.io/
http://tools.ietf.org/html/draft-jones-json-web-token-10
https://en.wikipedia.org/wiki/Internet_Engineering_Task_Force

JWT is simple method send information authentication over a URL or other services transports. Let's not forget JWT does not encrypt the payload, it only signs it so you may want to consider using SSL for all communication between the application requesting authentication and the application granting authentication . You may also want to consider encrypting the JWT token.

The example code below demonstrates a fully working in C#:


Let's encode!!


JWT really does provide a very simple solution to communicating information across untrusted channels.

Don't forget Unit Test...

I hope, this article has given you sufficient information to start implementing. 

Thanks, Happy coding :)

link download:
https://onedrive.live.com/redir?resid=EB97825B1A5209E9%212009