XXXII Encontro da Comunidade SQLPort

Data Evento:

2 Mar 2013 – 10:00

Local do Evento:

Edifício D. Henrique, Rua do Bolhão, 221 B-1º, 4000-112 PORTO

Realiza-se no dia 2 de Março de 2013 (Sábado), o XXXII Encontro da comunidade SQLPort, que tem como objectivo a partilha de experiências e conhecimento entre os profissionais e entusiastas de SQL Server em Portugal. O evento vai ser realizado noPORTO, no auditório da Rumos Portugal, pelas 10:00, sendo a entrada livre para todos os inscritos.

Vamos ter diversos prémios para este evento, entre os quais serão:
– Entrada no workshop do Matthew Roche – ‘Getting the most from SQL Server 2012 Integration Services’
– Um Voucher de um curso de SQL Server (Core/BI) na Rumos 

Este evento tem o apoio da RUMOS, a empresa que oferece os mais diversos cursos de treino em SQL Server.
Agenda:

10:00 – 10:30 Abertura e recepção.
10:30 – 10:45 Apresentação de Comunidade
10:45 – 11:45 “”Data Driven” Business Intelligence” – Rui Quintino (Senior Architect – Devscope)
11:45 – 12:00 Coffee-break
12:00 – 13:00 “SQL Server Internal Storage” – Bruno Basto (Consultor Senior – Rumos)
13:00 – 13:10 Sorteio de Prémios e Fecho

Rui Quintino – Senior Architect & Business Intelligence enthusiastic at DevScope. Data addict since…ever! from tuning & troubleshooting to typical business intelligence! Been working with the Microsoft BI platform since 2005. Always looking for ways to build great MS BI solutions, extending SharePoint, Performance Point, Excel and many others.

“Data Driven” Business Intelligence – but isn’t all Business Intelligence “data driven” ? Beyond “business” data, are you getting all the value you can from your Business Intelligence solution data resources? Some questions we’ll try to answer in this session were we’ll explore how we can use data assets, even automation & powershell to better design, build, test, support & scale Business Intelligence solutions on MS BI platform.

Bruno Basto

Bruno Basto, senior consultant  and senior trainer  at Rumos. SQL certified since 6.5 version (1998). Work with MSFT tools and infrastructure since 1992 in the financial, banking and insurance areas. Responsible for several training projects for software solutions with MSFT infrastructure. Speaker at several MSFT and SQLPass events.

SQL Server Internal Storage – this session describes how SQL Server internally stores table data. Although you can use SQL without understanding the internals of data storage, a deep knowledge of how data is stored will improve the development of efficient applications. This session explores the basic of metadata that keeps track of data and index storage information.

Programming in C# Jump Start

Microsoft Virtual Academy is publishing an course called Programming in C# Jump Start, with @jerrynixon and  @darenmay.

COURSE OUTLINE

01 | Object Oriented Programming, Managed Languages and C#

02 | Features of C#, Part 1
• Constructing Complex Types
• Object Interfaces and Inheritance

03 | Features of C#, Part 2
• Code Reflection and Information
• Working with Garbage Collection

04 | Features of C#, Part 3
• Controlling Programmatic Flow
• Manipulating Types and Strings

**MEAL BREAK**

05 | Advanced C#, Part 1
• Type and Value Validation
• Encryption Techniques

06 | Advanced C#, Part 2
• Splitting Assemblies and WinMD
• Diagnostics and Instrumentation

07 | Advanced C#, Part 3
• Interacting with the File System
• Leveraging Web Services

08 | Advanced C#, Part 4
• Using Linq to Objects and XML
• Fundamentals of Serialization

—-

For register click here.

Portable Class Library – Articles and Sample References

For who is looking for articles/samples/presentations about portable class libraries, the following references is that i recommend to see!

(but can be more, add a comment with good references!)

Articles

Samples

PortableNotepad – This sample shows how to access non-portable functionality from portable code by creating a portable abstraction with platform-specific implementations.

Goals: Abstraction for Load / Save data in files

Projects: Windows Phone, Windows Store App, WPF App

ContosoHelpdesk– This demo show advanced concepts.

Goals: Navigation, inversion of control, and synchronizing data across multiple clients with Windows Azure Service Bus.

Projects: Windows Phone, Windows Store App

Note: Use Autofac portable library (IoC Container)

TwitterSearch – This sample shows how to create a twitter search client.

Goals: Twitter Search API, Azure Mobile Services,

Projects: Windows Phone, Windows Store App, Console App

Note: Use MVVMCross portable library

Disentanglement – This is a solver for Thinkfun’s Gordian’s Knot puzzle which runs on Windows and Windows Phone. It uses a Portable Class Library to share the solver code between the different platforms

Goals: Share the solver code.

Projects: Windows Phone App, Desktop App, Xbox App

PixPresenter – is a photo sharing app that enables you to connect to another device using Proximity (NFC) and a tap gesture, and then send pictures back and forth between the connected devices. It demonstrates code sharing techniques that you can use when developing an app for bot

Goals: Windows Runtime API common code

Projects: Windows Phone, Windows Store App (C# and C++)

Cross-Platform Mvvm Samples:

Presentations

[En] Building Android Apps with MVVM and Data Binding

[PT] Como deixar de fazer copy and paste entre windows store e windows phone apps
[En] Do not do more copy and paste between windows store and windows phone apps

[En] Developing for Windows Phone 8 and Windows 8

Sharing Code between Windows Store and Windows Phone App (PCL + MVVM + OData)

Introduction

This sample has the goal to show how to share code between Windows Store and Windows Phone App.

The initial code sample can be find here:

Creating portable code in Windows Store Apps (PCL + MVVM + OData Services)

Before you start, take a look in this presentation:

Do not do more copy and paste between windows store and windows phone apps

Get the code for this sample, here.

Building the Sample

You only need Visual Studio 2012 and Windows 8, both the RTM version.

Description

Like you can see in Creating portable code in Windows Store Apps (PCL + MVVM + OData Services), you have a Portable Class Library that has model and view model defined! Which has the following targts:

 

with this i conclude that code is portable and can be used in Windows Phone 7.5 or higher.

We can create the Windows Phone 8 App and Windows Phone 7.5 (with update for 7.8) App and use this code, let’s see how.

1. Start creating the Windows Phone ClientApp Project:

 

 

2. After this update the namespace and startup object to:

 

 

You can create the same for Windows Phone 7.5!

3. Install the MVVM Light (PCL) for each Windows Phone ClientApp project:

 

4. Install the Bcl.Async package

See more about it here Async for .NET Framework 4, Silverlight 4 and 5, and Windows Phone 7.5 and 8

 

5. Add OData Services

OData Services is not portable,  we need to add the Service metadata for each client app or create a separate project for it ( this is a sample, is not necessary and will add in client app).

The metadata used is :http://odata.netflix.com/v2/Catalog/. For understand that i did see Consuming Odata Service in Windows Store Apps (Include MVVM Pattern) is similar for Windows Phone.

 

6. Create these folders

  • Extensions
  • Services
  • Styles
  • View
  • ViewModel

in each Windows Phone ClientApp project, like this:

 

 

We created the same sctruture from Windows Store App!

Why?

Because make sense and is more simple to undestand all code and more important is because we will reuse code files from Windows Store Apps.

 

7. Use “Add as Link” for link all files that are inside the following folders:

  • Extensions
  • Services
  • ViewModel

 

the result will be

I linked three files that are physically contained inside the Windows Store Client App.

NOTE: Each linked file is unique, is not a copy from the original, each change will represent a change in all projects!

 

8 . Add the ViewModelLocator to the App.xaml

<viewModel:ViewModelLocator x:Key=”Locator”/>

If you compile the code, maybe you will find some old dependencies, because in “last refactoring” uses some using that weren´t delete. And because i created Netflix.ClientApp and NetFlix.ClientApp namespace, the F or f  made the name to different! Is not important, but is more easy if we keep the same names for that can be shared or similar.

These problems are common and I could create a sample and documentation without them, but i think is important to share it, because always happens to all devs! :)

After this we only need to create the view for show data, let’s do it:

9. Create the View, adding content to the page:

Before define the page, prepare the information you will need.

9.1. “Add as Link” the BooleanNegationConverter and BooleanToVisibilityConverter from Windows Store Apps:

 

9.2. Create the ResourceDictionary.xaml with datatemplates:

<!-- DataTemplates for MyTitleItemView  --> 
    <DataTemplate x:Key="MyTopDVDMoviesItemTemplate"> 
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Height="120"> 
            <Image  CacheMode="BitmapCache" Source="{Binding Item.Image}"   Width="82" Stretch="Uniform"  Margin="10,10,5,10"/> 
            <StackPanel  Margin="10,10,5,10"> 
                <TextBlock Text="{Binding Item.Name}" Foreground="{StaticResource ForegroundBrush}" TextWrapping="Wrap"  Margin="0,0,5,0"/> 
               <StackPanel Orientation="Vertical" Margin="0,0,10,0" > 
                    <TextBlock TextWrapping="Wrap"  Foreground="{StaticResource ForegroundBrush}"  Margin="0,0,0,5">Available: <Run  Text="{Binding Item.AvailableFrom,  StringFormat='\{0:d MMMM yyyy\}'}" /></TextBlock> 
                </StackPanel> 
            </StackPanel> 
        </StackPanel> 
    </DataTemplate> 

    <DataTemplate x:Key="MyNewDVDMoviesItemTemplate"> 
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"  Height="120"> 
            <Image  CacheMode="BitmapCache" Source="{Binding Item.Image}"   Width="82" Stretch="Uniform"  Margin="10,10,5,10"/> 
            <StackPanel  Margin="10,10,5,10"> 
                <TextBlock Text="{Binding Item.Name}" Foreground="{StaticResource ForegroundBrush}" TextWrapping="Wrap"  Margin="0,0,5,0"/> 
                <StackPanel Orientation="Horizontal" Margin="0,10,10,0"> 
                    <TextBlock  Margin="0,0,5,5" Text="Rating:" Foreground="{StaticResource ForegroundBrush}" /> 
                    <TextBlock  Margin="0,0,0,5" Text="{Binding Item.Rating}" Foreground="{StaticResource ForegroundBrush}"/> 
                </StackPanel> 
                <StackPanel Orientation="Vertical" Margin="0,0,10,0" > 
                    <TextBlock TextWrapping="Wrap"  Foreground="{StaticResource ForegroundBrush}"  Margin="0,0,0,5">Available: <Run  Text="{Binding Item.AvailableFrom,  StringFormat='\{0:d MMMM yyyy\}'}" /></TextBlock> 
                </StackPanel> 
            </StackPanel> 
        </StackPanel> 
    </DataTemplate>

9. Create inside the View folder the TitlePage.xaml:

<phone:PhoneApplicationPage 
    x:Class="Netflix.ClientApp.View.TitlesPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    DataContext="{Binding TitlesViewModel, Source={StaticResource Locator}}" 
    mc:Ignorable="d" 
    shell:SystemTray.IsVisible="True"> 

    <!--LayoutRoot is the root grid where all page content is placed--> 
    <Grid x:Name="LayoutRoot" Background="#B9090B"> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="Auto"/> 
            <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 

        <!--TitlePanel contains the name of the application and page title--> 
        <StackPanel Grid.Row="0" Margin="12,20,0,0"> 
            <TextBlock Text="MY NetFlix Catalog" Foreground="{StaticResource ForegroundBrush}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}"/> 
        </StackPanel> 

        <!--ContentPanel - place additional content here--> 
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,17,12,0"> 
            <ProgressBar IsIndeterminate="True" Height="20"  
                          Visibility="{Binding IsToShowProgress, Converter={StaticResource BooleanToVisibilityConverter}}" 
                         Foreground="{StaticResource ForegroundBrush}" IsEnabled="{Binding IsToShowProgress}" Margin=" 0,5,0,0"/> 

            <phone:Pivot> 
                <!--Pivot item one--> 
                <phone:PivotItem Header="TOP"> 
                    <ListBox Name="lbxTopTitles" ItemsSource="{Binding Groups[0].Items}" SelectionMode="Single"  ItemTemplate="{StaticResource MyTopDVDMoviesItemTemplate}" /> 
                </phone:PivotItem> 

                <!--Pivot item two--> 
                <phone:PivotItem Header="New"> 
                    <ListBox Name="lbxNewTitles"  ItemsSource="{Binding Groups[1].Items}" SelectionMode="Single" ItemTemplate="{StaticResource MyNewDVDMoviesItemTemplate}" /> 
                </phone:PivotItem> 
            </phone:Pivot> 
        </Grid> 
    </Grid> 

</phone:PhoneApplicationPage>

and

 public partial class TitlesPage 
    { 
        /// <summary> 
        /// Initializes a new instance of the <see cref="TitlesPage" /> class. 
        /// </summary> 
        public TitlesPage() 
        { 
            InitializeComponent(); 
        } 

        /// <summary> 
        /// Called when a page becomes the active page in a frame. 
        /// </summary> 
        /// <param name="e">An object that contains the event data.</param> 
        protected override async void OnNavigatedTo(NavigationEventArgs e) 
        { 
            var titlesViewModel = DataContext as TitlesViewModel; 
            if (titlesViewModel != null 
                && (e.NavigationMode == NavigationMode.New || e.NavigationMode == NavigationMode.Refresh)) 
            { 
                await titlesViewModel.LoadDataAsync(); 
            } 
        } 
     }

There is one point that is diferente from WP8 and WP7.5, is the namespace for pivot control.

XAML cannot be shared, better should´t!

9.4. Define the TitlesPage.xaml as a start page:

 

10. The output

 

 

 

Notes:

1. In inital sample, that was initial source, i did not change the namespace from Netflix.ClientApp to Netflix.PortableClassLibrar, but was because i forgot. You should be aware too. And i did not changed because i am creating a git repository for how wants to see the commit and changes i did.

2. If you want to see the commit and changes i did when i create this sample, visit the codeproject oficial reference, here:

 

Will be published soon!

 

Source Code Files

The solution has the following structure:

 

Details:

  • IServiceManager.cs has the IServiceManager interface and define the interface for the ServiceManager.
  • ServiceManager.cs has the ServiceManager class and it encapsulate the NetFlixService and exposes only the methods that is need in ViewModel.
  • FakeServiceManager.cs is the implementation of the IServiceManager, but is a fake data.
  • TitlesViewModel.cs has TitlesViewModel class and it is used for binding with the DataContext from TitlesPage.
  • ViewModelLocator.cs has the ViewModelLocator class that help to binding the view model with the view.
  • ViewModelHelper.cs has the ViewModelHelper class the helps to create grouped data.
  • TitlesPage.xaml and TitlesPage.xaml.cs that is the main page.
  • Templates.xaml is a resource dictionary that has the DataTemplate for the view.
  • NetFlixItemTemplateSelector.cs has the NetFlixItemTemplateSelector that is used for get the ItemTemplate for each item in gridView.

Others References

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without   debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

 

More Information

Ask me on twitter @saramgsilva

Creating portable code in Windows Store Apps (PCL + MVVM + OData Services)

Introduction

This sample has the goal to show how to create portable code from a existing Windows Store App. The focus is to move all portable code to Portable Class Library (PCL) project.

 

The initial code sample can be find here:

Consuming Odata Service in Windows Store Apps (Include MVVM Pattern)

Before you start, take a look in this presentation:

Do not do more copy and paste between windows store and windows phone apps

Get the code for this sample, here.

Building the Sample

You only need Visual Studio 2012 and Windows 8, both the RTM version.

Description

 

After you got the code sample from Consuming Odata Service in Windows Store Apps (Include MVVM Pattern) you are available to start a refactoring with the goal to create portable code, that can be used in other plaftorms.

 

Let’s start!

 

Start creating the Portable Class Library

 

and then select the following targets:

 

that are the default in PCL project template.

 

Now we can focus in creating portable code, in theory we can say:

Views (Platform-specific)

How to display information

Written in XAML

View Models (Portable)

What information to display

Flow of interaction

Models (Portable)

Data objects

Business logic

Etc.

 

This is simple, but in pratices can be very complicate. That i recomend is: move a small parts of code, for create portable code the Abstraction pattern is the key  and resolve each problem that you have ! Don´t try move all things and don´t forgot that some namespaces are not available in PCL. Another note, dependency injection and ioc can be useful!

See this:

Returning to the sample, the first thing we can try to do is move all about Model,View Model and Helpers to inside the PCL project.

 

But wait, like i said before, move only small parts of code!

 

Let’s move only the Model and Helpers:

Move Helper and Model folder to PCL project and delete it from ClientApp project.

Resolve dependencies related with

  • BitmapImage
  • NotifyPropertyChangedInvocator
  • CallerMemberName

Each will resolver this way

  • BitmapImage – will be replaced with url string and is necessary to fix all related issues ( it is right because i will binding image’s source with the url path and it loads the image this way);
  • NotifyPropertyChangedInvocator – will be removed because is related with Resharper (see this http://bit.ly/11CGebN);
  • CallerMemberName – will be resolved with Microsoft.Bcl.Async ( See Notes 1.)

 

Move all view model and classes related with dependency injection/ioc to inside the PCL

This means, move ViewModel and Service folder to PCL project.

Resolve dependencies related with

  • Old using (“using Windows.UI.Xaml.Media.Imaging;”) inside FakeServiceManager
  • ViewModelBase from MVVM Light Toolkit
  • Task.Run
  • Task.WhenAll

Each will resolver this way:

  • Remove “using Windows.UI.Xaml.Media.Imaging;” because is not necessary, i change bitmap to string from last commit. (See Notes 3)
  • ViewModelBase from MVVM Light Toolkit – install the MVVM Light (PCL) package (See Notes 4.)
  • Replace Task.Run with Task.Factory.StartNew (see more about it here: http://bit.ly/11wTB1Y)
  • Replace Task.WhenAll with TaskEx.WhenAll

Notes:

1. In my first attemps i thought, it could not be possible to be solve. But after some search i found to important package in Nuget: Async for .NET Framework 4, Silverlight 4 and 5, and Windows Phone 7.5 and 8

2. TitleItemview is deleted because it depends from my DataServices and i prefere use only MyTitleItemView and the other things is the fact the OData services is not supported in PCL projects, because is not portable, for now. See this: http://bit.ly/VpE4wD.
3. The path for url image in FakeServiceManager must be defined in especific projec in the same moment that i regist the dependency in my container. This is important too, because in other platforms the path is not the same.

4. Before i install the MVVM Light (PCL) package in PCL project, I removed the MVVM Light packages from ClientApp because it can cause some issues related with differentes packages from same toolkit (that contains same namespace… be aware!). And when you do this, the App.xaml will change and it can be broken, but don´t worry, you need to replace this file with the version from last commit because the unique diference is the references.

4.1 The PCL project was created with defatul targets and when you install the MVVM Light (PCL) you will see this error:

 

Like you can see, if you want to use it you should set Windows Phone 7.5 and higher

 

I could remove Silverlight, but no matter because you will have this:

 

5. ServiceManager and ViewModelLocator cannot be in PCL project, because it dependes from references that aren´t portable and don´t make sense change it.

6. Attention with namespace i am using, i like to keep congruent namespace and StyleCop + Resharper help me to keep rules (but is not necessary, you can change all without it!)

7. This packages contains one git repository that can be used for see all step i said before. Each commit has the respective comment and file changes.

Example:

 

 

 

Source Code Files

The solution has the following structure:

 

Details:

  • IServiceManager.cs has the IServiceManager interface and define the interface for the ServiceManager.
  • ServiceManager.cs has the ServiceManager class and it encapsulate the NetFlixService and exposes only the methods that is need in ViewModel.
  • FakeServiceManager.cs is the implementation of the IServiceManager, but is a fake data.
  • TitlesViewModel.cs has TitlesViewModel class and it is used for binding with the DataContext from TitlesPage.
  • ViewModelLocator.cs has the ViewModelLocator class that help to binding the view model with the view.
  • ViewModelHelper.cs has the ViewModelHelper class the helps to create grouped data.
  • TitlesPage.xaml and TitlesPage.xaml.cs that is the main page.
  • Templates.xaml is a resource dictionary that has the DataTemplate for the view.
  • NetFlixItemTemplateSelector.cs has the NetFlixItemTemplateSelector that is used for get the ItemTemplate for each item in gridView.

Others References

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without   debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

 

More Information

Ask me on twitter @saramgsilva

[PT] Revista PROGRAMAR Edição 39 – Fevereiro de 2013

Já foi lançada a edição de Fevereiro 2013, da Revista Programar.

E não podia estar mais contente, nesta edição a capa da revista apresenta o meu artigo sobre Windows 8 Store Apps. Saliento também o artigo sobre Certificação Microsoft que contém ofertas interessantes!

Imagem Colocada
(clica para download)

.
Nesta edição continuaremos também a premiar os autores dos três melhores artigos, dado o sucesso nas edições anteriores. E os leitores devem dar a sua opinião para que possamos premiar correctamente. Para isso vote em http://tiny.cc/ProgramarED39_V

Assim nesta edição trazemos até si, como artigo de capa, um artigo de Windows 8 Store Apps – Do sonho à realidade de Sara Silva. Nesta 39ª edição pode ainda encontrar os seguintes artigos:

  • Threads, Semáforos e Deadlocks – O Jantar dos Filósofos (Rita Peres)
  • Programação em OpenCL (Patricio Domingues)
  • Accionamento de Servos Usando Arduino  (Nuno Santos)
  • A web em tempo real na plataforma ASP.NET (Ricardo Rodrigues)
  • Bubble Sort – A Técnica da Bolha (Telmo Vaz)
  • C# GeoCoordinateWatcher como um Serviço Reativo (Paulo Morgado)
  • Review do livro Visual Basic 2012: Curso Completo (Sérgio Ribeiro)
  • Review do livro Multimédia e Tecnologias Interactivas (Sérgio Laranjeira)
  • Certificação Microsoft (Sara Silva)
  • Programar – Como começar?   (António Pedro Cunha)
  • Novidades de Sharepoint 2013 (André Vala)
  • SEO Parte 4 (Miguel Lobato)
  • Entrevista a Miguel Gonçalves
  • Projecto em Destaque na Comunidade Portugal-a-Programar: PROGRAMAR