Archive

Archive for January, 2012

CodeFluent Entities: Using your application in SharePoint 2010

January 25, 2012 1 comment

SharePoint 2010 provides a great feature named the Microsoft Business Connectivity Services (BCS) (formerly known as the Business Data Catalog in SharePoint 2007).  SharePoint’s BCS enables users to read and write data from external systems from within SharePoint 2010 and to do so you need to create an External Content Type to bring external data in SharePoint. Once you have an external content type, you can use it with any of the various presentation features of Business Connectivity Services such as external lists, external data columns, and external content controls for Office applications.

External Content Types can be created from databases, WCF services or a .NET assembly, and it just so happens CodeFluent Entities can generate any of the three, therefore using SharePoint’s BCS feature you can, without a single line of code, consume your application in SharePoint 2010!

Form a bird’s-eye view here’s how to do it:

Create Your Application

Nothing specific there: use CodeFluent Entities to design your application and generate the code!

For this post, we used:

  • the SQL Server Producer to generate the database,
  • the Business Object Model Producer to generate our .NET classes,
  • the WCF Service Producer to generate our WCF services and contracts,
  • the Template Producer to generate our WCF configuration file, as well as SVC files to host our services in IIS.

image

 

Create an External Content Type

As a data source to our external content type we used our WCF services so that manipulating data in SharePoint still uses our business logic and we don’t have to deploy our dll in SharePoint.

Here’s how how to do it: How to create an External Content Type based on a Web Service.

image

 

Create an External List in SharePoint

Once you have your External Content Type, still using SharePoint Designer, you can create a SharePoint list from it as well as Forms to create, list, update and delete data in SharePoint by clicking on “Create List & Forms”. Here’s how to do it: http://msdn.microsoft.com/en-us/library/ee558778.aspx.

Note: you can also do it from SharePoint, but don’t forget to create the InfoPath forms or else you’ll only be able to list and delete data as you won’t have any forms to create and update it.

image

 

Set Permissions so users can use the BCS

At this point, everything is ready however if you try to access your list you’ll get this error:

Access denied by Business Data Connectivity

That’s actually normal: by default no user (even the one who created it) can access external data, you need to grant this permission explicitly.

To do this, go to: Central Administration -> Application Management -> Manage Service Applications ->Business Data Connectivity Service* -> [Your Entity] -> Set Permissions, and grant them to the desired accounts or groups. (Here’s a nice blog post with screenshots illustrating how to do it: Access denied by Business Data Connectivity solution).

 

Result

And taadaa!! Here’s your data in SharePoint:

image image

Furthermore, now that your data is in SharePoint you can do way more that just listing them or editing them, you can for instance:

 

Cheers,

Carl Anderson

2011 in review

January 23, 2012 Leave a comment

The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 16,000 times in 2011. If it were a concert at Sydney Opera House, it would take about 6 sold-out performances for that many people to see it.

Click here to see the complete report.

Categories: News

January 23rd 2012 Links: Software Development, Azure, WPF, ASP.NET, Tips

January 23, 2012 2 comments

Here’s our second post in our link-listing series:

Software Development

How I learned to stop worrying and write my own ORM

This post was written by one of the Stack Overflow guys (pretty good resume isn’t it?). It illustrates certain issues due to a core principle of ORMs: “the 100% dynamic” also known as “I hate databases, can’t I do everything in C#?”.

 

HTML5 and the Rise of Hybrid Apps

More and more apps are built in cross-platform HTML5 which is then wrapped into a native container.

 

Windows Azure

Scott Guthrie’s latest public presentation

New to Windows Azure, or looking for an update on where the platform is at? Check this one out, it’s the best place to start!

 

WPF

Announcing the Bing Maps WPF Control v1

Yay, maps in our WPF apps!

 

ASP.NET

Truly Understanding ViewState

An old, yet very helpful, article on the ASP.NET ViewState.

 

Coding Tips

How can I detect the language a run of text is written in?

Ever needed to figure in what language a unicode string is? Here’s a great post providing valuable information on the topic.

 

Want Source Server to Work with Managed Minidumps in Visual Studio? Here’s How!

I guess the title says it all Smile

 

PerfView: New CLR and .NET Performance tool

Vance Morrison, CLR performance architect at Microsoft, has released a new tool (free) for conducting performance investigations on .NET applications.

 

Hope this helps,

Carl Anderson

CodeFluent Entities: Generating a CHM documentation from your Business Object Model

January 19, 2012 2 comments

CodeFluent Entities provides a Documentation producer capable of generating all files and scripts required by Sandcastle to generate a Microsoft Compiled HTML Help (CHM) documentation out of your CodeFluent Entities generated .NET Business Object Model (BOM).

Step 1: Downloading Sandcastle

First, you need to download and install Sandcastle on your machine (http://sandcastle.codeplex.com/).

 

Step 2: Generate using CodeFluent Entities

Then in your model, add the Documentation sub-producer to your Business Object Model Producer:

image

As the Sandcastle Target Directory, set the directory in which you want the sub-producer to generate all the Sandcastle scripts.

If you generate over again, you’ll notice that all members of your BOM (classes, fields, properties, methods) now have remarks:

/// <summary>
///     Loads this instance.
/// </summary><param name=”id”>The id.</param>
public static SoftFluent.Advertising.Customer Load(int id)

 

Step 3: Get the XML documentation file & assembly

To build the CHM documentation Sandcastle needs as an input:

  • The XML documentation file,
  • The actual .NET assembly.

The XML documentation file isn’t created by default, to do so, in your project properties, in the Build tab, you need to check it:

image

Build your project so you’ll get both the XML documentation file made out of the generated remarks, as well as the compiled assembly (.dll).

 

Step 4: Check everything is in order

Those files, the XML documentation and dll, are passed to Sandcastle production tools by the BuildDocumentation.cmd script.

So, before running the script, make sure the paths used in it are correct!

Secondly, the MrefBuilder.exe tool uses reflection to extract information, therefore you need to specify all dependencies used by your BOM so it can load your assembly.

Once the MrefBuilder line of the script runs fine, you’re ready to run the script!

 

Step 5: Generate your documentation!

Run the script, and as a result you’ll have a Microsoft Compiled HTML Help documentation in the Chm directory:

image

 

Carl Anderson

New CodeFluent Entities Release Available

January 17, 2012 3 comments

A new version of CodeFluent Entities is publicly available (1.0.60110.644) which contains a set of new features which we’ll overview in this post.

NewBuild

Feature #1: The Resource Grid

This new release provides a new culture-oriented grid form which allows batch resources edition (project-wide or node-specific).

image

 

Feature #2: The Instance Grid

Same as the the resource grid but for instances:

image

We can now edit multiple instances at once Smile

 

Feature #3: “Go To Xml”

Doing a right-click on a concept on the surface (entities, properties, views, methods, forms, etc.) you now have a “Go To Xml” option in the contextual menu which will take you to the XML node corresponding to the selected shape.

image

 

Feature #4: Support for non-latin characters

I’m sure all non-latin users will be glad to know that using the latest build, you can design your application using non latin-characters:

image

 

Feature #5: Minimize the Ribbon

Probably the sexiest feature in this release: you can now hide/show the ribbon using the upper-right corner arrow:

image

image

 

Interested in getting more details on what is shipped with each release? Subscribe to the CodeFluent Entities RSS Feed and you’ll automatically get all bug fixes and new features comprised in each build as soon as they are online!

 

Carl Anderson

CodeFluent Entities: Member Format Expressions (Final Part)

January 13, 2012 Leave a comment

Last post exploring this feature of the Modeler, detailing what you can do in conditions and the MessagesBrowser class.

Conditions

In the previous post, we’ve seen that we could specify a condition attribute in the <if> and <font> tags. A few notes on the condition attribute:

  • Property paths in condition attributes should not be surrounded by curly brackets (i.e. use IsKey instead of {IsKey}),
  • Shortcuts available on the right side of the statement to ease condition declaration,
  • Therefore prefer placing evaluated values on the left side of the statement rather than on the right.

The following operators are supported:

  • “==” or “=” for a case insensitive equals,
  • “[=CS]” for a case sensitive equals,
  • “!=”, “<>” for a case insensitive not equals,
  • “[!=CS]” for a case sensitive not equals,
  • “>=” for greater than equals,
  • “<=” for lower than equals,
  • “>” for greater than,
  • “<” for lower than,
  • “[StartsWith]” for a case insensitve starts with,
  • “[StartsWithCS]” for a case sensitive starts with,
  • “[EndsWith]” for a case insensitive ends with,
  • “[EndsWithCS]” for a case sensitive ends with,
  • “[Contains]” for a case insensitive contains,
  • “[ContainsCS]” for a case sensitive contains.

Here’s how to highlight all properties ending with “Id”:

<font condition=”Name [EndsWith] ‘Id'” color=’red’>{#Name}<else/>{#Name}</font>

Note: don’t forget to surround the right side statement with quotes so the evaluator knows it’s a string.

Please note that there are also shortcuts such as you don’t have to specify ‘> 0’ for numbers for instance:

{#Name}<font condition=’AllRules.Count’ color=’#007F0E’> (Rules={AllRules.Count})</font>

Will suffix properties with “(Rules=X)” in green:

image

 

The MessagesBrowser Class

The MessagesBrowser class is a class you can use as a property path and which allows you to access messages (a.k.a. resources) defined for the current concept (entity or property). For instance, if you defined English resources for each of your address properties in the documentation class:

image

Using the following expression you can display them:

{#Name} ({MessagesBrowser._doc.en-US})

Here’s the result:

image

Note: As of today, for performance results the MessagesBrowser class is cached and built on first access, so that defining a new resource or editing one will not be reflected on the surface.

Carl Anderson

CodeFluent Entities: Member Format Expressions (Part 2)

January 13, 2012 1 comment

In the previous post, we’ve seen that we could define expressions such as “{Name}” to display the property name, “{#Name}” to display the decamelized property name, and mix values and literals in expressions to do stuff such as “{#Name} (IsKey={IsKey})”.

In this post we’re going to go a little further by introducing “tags”. Three tags are supported in expressions:

  • Font: use it to define styles in your expression,
  • If: use it to define conditions,
  • Else: same as if.

For instance specify the following expression:

<font color=”blue”>{#Name}</font>

Will display all properties in blue:

image

We could also combine the tags to display key properties in red and the other ones in blue:

<if condition=IsKey><font color=”red”>{#Name}</font><else/><font color=”blue”>{#Name}</font></if>

Note: the value in the condition attribute is automatically evaluated, no need to wrap the property path between curly brackets.

And here’s the result:

image

So expressions don’t get too long the <font> tag also has a condition attribute so you don’t necessarily have to wrap it in a <if> tag. Therefore, you could get the same result using this expression:

<font condition=IsKey color=”red”>{#Name}<else/><font color=”blue”>{#Name}</font></font>

The <font> tag supports the following attributes:

Here’s another expression displaying the property type name in a light purple (Alpha=DD, Red=6E, Green=14, Blue=FF):

{#Name} : <font color=”#DD6E14FF”>{#DisplayTypeName}</font>

And here’s the result:

image

Once again use member format expressions with caution as they’ll be evaluated for all property names, so the lighter they are, the better performances will be and vice versa.

Carl Anderson

CodeFluent Entities: Member Format Expressions (Part 1)

January 12, 2012 1 comment

Using CodeFluent Entities, you can use “Member Format Expressions” to customize the way names of entities and properties are formatted:

image

Several expressions are provided by default but you can also define your own expressions by selecting “Choose” (you do this from the “Modeler Tab” of the ribbon or from the contextual menu):

image

Clicking “Add New” will allow you to define your own:

image

Creating this one will display “Test!” for all my properties:

image

It’s not that useful in practice, but still, it illustrates that you can set whatever you want in it and most importantly that it supports literals Smile

As you can see, the default expressions use property paths surrounded by curly brackets such as {Name} and {DisplayTypeName} to displays values from the model. You can access a list of available property paths by clicking on the “Insert Property Path” button which will display the following dialog:

image

For instance, here’s an expression displaying the property name and indicating if the property is a key between parenthesis:

image

Here’s the result on my Address entity:

image

If you prefix your property path with a ‘#’, the value will be decamelized. For instance the expression “{#Name} (IsKey={IsKey})” will display (the difference is visible on the Line1 and Line2 properties):

image

Sweet isn’t it?! Smile

It for sure is a nice feature too change as you can change how the model is presented with a single expression, however use format expressions with caution though, because as they’re evaluated to display each of your properties in your model, big expressions doing a lot of stuff and displaying a lot of text can become a performance killer on big models.

Carl Anderson

CodeFluent Entities Customers

January 10, 2012 Leave a comment

We recently added a world-wide customer map on our web site showing all CodeFluent Entities customers:

image

The map is built in real-time, once a day, and circles are drawn using data from our activation database. There is one circle per country, and its size and color depends on the number of activations per country. This means that what we show as a customer on this map is an actual developer who used CodeFluent Entities at least once and not just a random person who visited our web site.

In the end, the map shows that, as of today, CodeFluent Entities is used in more than 80 countries!

Happy new year,

Carl Anderson

PS: This is our 200th post Smile

Categories: News Tags: , ,

Exploring the CodeFluent Runtime: JsonUtilities – Part 2

January 6, 2012 1 comment

This post follows the “Exploring the CodeFluent Runtime: JsonUtilities” post, in which we introduced the JsonUtilities class as well as its Serialize method.

In addition to serializing objects, you can also use the class to deserialize JSON such as this:

string s = JsonUtilities.Serialize(new string[] { "1", "2" });
List<int> list = JsonUtilities.Deserialize<List<int>>(s);

Running the code above, you’ll get a list of integers out of the JSON string as expected.

Another cool feature is that the serializer, on top of serializing all types such as byte[], guid, long, etc., can serialize anonymous types, you don’t have to use strongly typed objects:

s = JsonUtilities.Serialize(new
{
    MyDateAtt1 = DateTime.Now,
    MyEnumAtt2 = UriKind.RelativeOrAbsolute,
    MyBytes = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF },
    MyGuidAtt = Guid.NewGuid()
});

And then, when deserializing, we can use a strong type such as the MyType class, declared as follows:

public class MyType
{
    public DateTime MyDateAtt1; // field support
    public Guid MyGuidAtt { get; set; } // guid support
}

And here’s the code deserializing our anonymous type into a MyType type:

MyType mt = new MyType();
JsonUtilities.Deserialize(s, mt, JsonSerializationOptions.Default | JsonSerializationOptions.UseReflection); // sets props & fields

Properties which don’t exists (e.g. MyEnumAtt2 and MyBytes) will be skipped without raising an error.
Carl Anderson

Follow

Get every new post delivered to your Inbox.

Join 49 other followers