Thursday, August 26, 2010

I’m joining the team at Epinova!

A lot of things are happening at the moment, and with those things comes great news: I’m joining the team at Epinova!

I’ve worked as a consultant at Itera Consulting (Objectware) for approximately 18 months now. I started fresh out of university, which means I’ve had a pretty steep learning curve.

In university, I had Java programming for my first two semesters and then moved on to C and scripting for the rest of my degree. For those of you who don’t know much about the University in Oslo, it’s all about Linux; Microsoft is considered the ‘dark side’. As a result of this I hadn’t touched an object-oriented language in two years when I started working for Itera Consulting. In addition, I’d never before touched .NET, C# or even Visual Studio (oh yes, I spent my entire time at university playing with Emacs). And worst of all, I had never heard of EPiServer.

So in the last 18 months or so, I’ve bent over backwards in order to learn everything I could about .NET, C# and EPiServer. And Itera Consulting has helped me learn in the best way possible, by throwing me head first into various EPiServer projects while at the same time holding my hand. My colleagues have always been eager to help me, teach me and at times laugh with me when I realize some of the strange things I’ve done.

As always, the hard work has paid off! I’ve simply fallen in love with EPiServer, its community and all that comes along with it. And I want more more more! So Epinova, you’re up next :) I look forward to joining your team and working alongside some of the best EPiServer developers in Norway!

Thursday, August 12, 2010

Technical thoughts on the open source Microsoft Dynamics CRM Framework for EPiServer – Part 2

In part 1 I gave an overview of how MS CRM entities and attributes, creating entity classes and creating CrmEntityControllers. This blog post will focus on the methods available through the CrmEntityController<T> class.

In the examples below we will assume that the CrmContact class from part 1 exists, so the only thing we need is a CrmControllerFactory and CrmEntityController<T> object:

CrmControllerFactory factory = CrmControllerFactory.Instance();

CrmEntityController<CrmContact> crmContactController = factory.GetEntityController<CrmContact>();

Creating a CRM entity

CrmEntityController<T>.Create(T entity) : Guid

Example:

CrmContact contact = new CrmContact();

contact.FirstName = "John";

contact.LastName = "Smith";

Guid contactGuid = crmContactController.Create(contact);

Reading a CRM entity

Get:

CrmEntityController<T>.Get(Guid entityId) : T

Example:

CrmContact contact = crmContactController.Get(guid);

FindAll:

CrmEntityController<T>.FindAll() : List<T>

CrmEntityController<T>.FindAll(CrmSortingCriteria sorting) : List<T>

Example:

List<CrmContact> contactList = crmContactController.FindAll();

 

List<CrmContact> sortedContactList = crmContactController.FindAll(new CrmSortingCriteria("firstname", CrmSortOrder.Ascending));

Find:

CrmEntityController<T>.Find(CrmQuery query) : List<T>

CrmEntityController<T>.Find(CrmQuery query, CrmSortingCriteria sorting) : List<T>

CrmEntityController<T>.Find(CrmQuery query, int page, int pageSize, out int totalCount, CrmSortingCriteria sorting) : List<T>

Example:

CrmQuery query = new CrmQuery();

query.AddCondition(new CrmAttributeCriterion("firstname", "John", CrmConditionOperator.Equal));

query.LogicalOperator = CrmLogicalOperator.Or;

query.AddCondition(new CrmAttributeCriterion("firstname", "Sarah", CrmConditionOperator.Equal));

 

List<CrmContact> contactList = crmContactController.Find(query);

 

List<CrmContact> sortedContactList = crmContactController.Find(query, new CrmSortingCriteria("firstname", CrmSortOrder.Ascending));

 

int totalCount;

List<CrmContact> pagedContactList = crmContactController.Find(query, 1, 10, out totalCount, null);

Updating a CRM entity

CrmEntityController<T>.Update(T entity)

Example:

CrmContact contact = crmContactController.Get(guid);

contact.FirstName = "Paul";

crmContactController.Update(contact);

Deleting a CRM entity

CrmEntityController<T>.Delete(Guid guid)

Example:

crmContactController.Delete(guid);

 

So these are the methods created so far, keep in mind that they might change! One of the things that definitely will change is the CrmQuery class. I’m not quite happy with that yet. So if you have any tips on how to create a good query system, please let me know :)

Wednesday, August 11, 2010

Someone just reminded me of “Push Your Limits”

A year ago I wrote a text for “97 things programmers should know” by O’Reilly. I decided not to write a technical piece, but rather a personal piece focusing on pushing your limits. The text did not make it into the book, but that doesn’t matter. What matters is that I hadn’t seen this text in a year until today when someone sent me the link. So just for fun I thought I’d post it here :)

Push your Limits

For many areas in life you need to know your limits in order to survive. Where it concerns personal safety, your limits define a boundary that should not be crossed. Where it concerns personal limitations, skills, and knowledge, however, knowing your limits serves an entirely different purpose. In programming, you want to know your limits so that you can pass them in order to become a better programmer.

Fortunately, not many programmers view their code as a ticket to their next paycheck. Those of us who are truly programmers at heart thrive on immersing ourselves in new code and new concepts, and will never cease to take an interest in and learn new technology. Whichever technology or programming language these programmers favor, they have one important thing in common: They know their limits, and they thrive on pushing them little by little every day.

We have all experienced that, if not armed with the knowledge we need or wished we had, attacking a bug or a problem head on takes a lot of time and effort. It can be too easy to pass the beast on to a colleague you know has the solution or can find one quickly. But how will that help you become a better problem solver? A programmer unaware of their own limits — or, worse, aware of them but not challenging them — is more likely to end up working in a never-ending loop of the same tasks every day. To insert a break into this loop, you need to acknowledge your limits by defining your programmatic weaknesses: Is your code readable by others? Are your tests sufficient? Focus on your weaknesses and you'll find that at the end of the struggle, you will have pushed that boundary an inch forward.

Needless to say, what others know should not be forgotten. Fellow programmers and colleagues offer a nearby source of knowledge and information which should be shared and taught to others. They are, however, ignorant of your limits. It is your responsibility to acknowledge exactly where your boundaries are hiding so that you can make better use of the knowledge they offer. One of the most challenging and, many would say, most effective ways to extend your own limits is to explain code and concepts to fellow programmers, for example by blogging or hosting a presentation. You will then force yourself to focus on one of your weaknesses, while at the same time deepening your own and others' knowledge by discussing and getting feedback from others.

At the end of the day, it is not about surviving. It is about surviving in the best way possible, by actively challenging yourself to excel as a programmer.

Monday, August 9, 2010

Technical thoughts on the open source Microsoft Dynamics CRM Framework for EPiServer – Part 1

Last week I announced that I’ve made up my mind about creating an open source MS CRM framework for EPiServer. The development has been going on since then, and in this blog post I’ll give some insight to what the framework will be like. Please keep in mind that the framework is in its alpha phase, and based on feedback, future code reviews and further development, the code might change! So consider this a draft :)

MS CRM entities and attributes

Before starting, it’s important to know the difference between entities and attributes. An entity such as Contact contains attributes such as Firstname and Lastname. Entities can be related to each other through one-to-many and many-to-many relationships. 

You can view all entities and attributes in ‘Settings’ –> ‘Customization’ –> ‘Customize Entities’ in CRM:

crm entities

You can view an entities attributes from ‘Customize Entities’ –> Entity –> ‘Attributes’:

crm attributes

Web.config

Integration with EPiServer is of course the main focus of this framework, so I’ve put all connection specific details in a separate configSection in the web.config file.

In <configSections>:

<sectionGroup name="crmFramework">

   <section name="crmConnector" type="Custom.CrmConnector.Configuration.CrmConnectorSection" />

</sectionGroup>

The configuration section itself:

<crmFramework>

   <crmConnector crmUrl="http://customer.crm.com:5555" username="UserName" password="Password" domain="Domain" organization="CrmOrg" />

</crmFramework>

Creating an Entity class in EPiServer

If you want to get an entity from CRM with all its attributes, this results in a lot of data being transferred and hence the operation can get time consuming. So in order for you to chose exactly what attributes you need, you need to create a class for each entity specifying its attributes. You can do CRUD operations on all CRM entities, standard or custom, and the framework supports all CRM attribute types.

The class needs a CrmEntity attribute speficying the CRM entity name. Each CRM attribute is defined as a public property with a CrmAttribute attribute specifying the attributes CRM name.

Here’s an example of a class created for the CRM Contact entity:

[CrmEntity("contact")]

public class CrmContact

{

// Has to be included for update operations

   [CrmAttribute("contactid")]

   public Guid ContactId

   {

      get;

      set;

   }

 

   [CrmAttribute("firstname")]

   public string FirstName

   {

      get;

      set;

   }

 

   [CrmAttribute("lastname")]

   public string LastName

   {

      get;

      set;

   }

}

Creating a CrmControllerFactory and CrmEntityControllers

In order to use the entity class we just created, we’ll need to get an instance of the CrmControllerFactory class. This is a singleton class handling authentication towards CRM and the CrmEntityControllers.

A CrmEntityController is a generic controller for doing operations on CRM entities. Through the controller you can access methods like Create, Delete, Find, Get, Update etc.

So let’s create a CrmControllerFactory and a CrmEntityController for the CrmContact class created above:

CrmControllerFactory factory = CrmControllerFactory.Instance();

CrmEntityController<CrmContact> crmContactController = factory.GetEntityController<CrmContact>();

As mentioned before, we can now use the crmContactController to do operations on CRM Contact entities. An example is getting a contact by Guid:

CrmContact contact = crmContactController.Get(new Guid("309B8DB0-C5DF-DC11-B07C-0003FF360638"));

string firstName = contact.FirstName;

All the methods available through the CrmEntityController<T> class will be covered in Part 2 of this blog series (in a couple of days). In the future, after a code review, I will also post some code showing the framework itself.

And remember, things might change! If you see anything you already disagree with, please let me know, I’m up for a discussion :)

Wednesday, August 4, 2010

Are you ready for an open source Microsoft Dynamics CRM Framework for EPiServer?


Since May I’ve been contemplating developing an open source Microsoft Dynamics CRM Framework for EPiServer. Then, a couple of weeks ago, I made up my mind. I’m going to do it!

Doesn’t that already exist though? Well, yes. EPiServer has its own EPiServer Connect for CRM which is useful in simple projects, but it has quite a lot of limitations when it comes to more complex cases. For instance, it only supports retrieving attributes of some CRM types and it’s limited to working with the Contact and Account entities. It is possible to extend the CRM Connector, but you will not be able to come clear of all the limitations. But EPiServer are not the only ones developing CRM frameworks, there are tons of them out there. The only problem is that most of them are too complex and not made for EPiServer. So my goal is to create a framework that can be used in complex projects where EPiServer Connect for CRM won’t do the trick, but the framework will be easy to use and most importantly: open source and free.

The development has already started and is coming along great if I may say so myself :) In phase 1 of the development I’m focusing on the following:

- CRUD operations on all types of entities (custom and standard)
- Read and update all types of entity attributes (custom and standard).
- Conditional search for entities
- And of course: Integration with EPiServer

I will keep on blogging while developing the framework, so you can expect the first technical blog post this weekend. That will give some insight to how you can use the framework and it will give you the opportunity to influence the development. I’m not quite sure when the framework itself will be available, but I’m hoping the Beta version is out in a couple of months (after all, I do have a job).

All opinions, wishes or slaps on the hand is highly appreciated!