José Roberto's profileJosé Roberto SiqueiraPhotosBlogListsMore Tools Help

Blog


    June 12

    Estratégia móvel precisa passar por SOA

    Fonte: http://www.itweb.com.br/noticias/index.asp?cod=58204

    Business Services são chave para o sucesso da estratégia móvel

    Como vocês já devem saber, a Apple lançará o iPhone 3.0 em 19 de junho. A Palm introduziu recentemente o Palm Pre como viável competidor que oferece não apenas uma grande tela touchscreen, mas também um teclado completo para aqueles que precisam disso. Enquanto isso, a BlackBerry continua na liderança entre os smartphones business-class.

    Os dispositivos equipados com Windows Móbile oferecem familiaridade com as aplicações utilizadas na rotina, como Word, Excell e PowerPoint.

    Com tantas opções de aparelhos disponíveis e clientes/empregados ávidos por informações em tempo real, muitas companhias estão tentando definir rapidamente uma estratégia móvel.

    Infelizmente, um dos principais requisitos para essa estratégia é como o aparelho móvel trabalha como end point - e todos que eu conheço estão em lua de mel com seus iPhones por conta da aparência e não pelo seu poder computacional. Antes da versão 3.0 do sistema operacional do gadget da Apple, a função copiar e colar não estava disponível. E onde roda a lógica do negócio exatamente? Nos business services!

    Nunca ouviu nada a respeito? Então você deve saber ainda menos sobre Arquitetura Orientada ao Serviço (SOA). Espero que você não seja uma daquelas pessoas que já iniciaram processos de SOA. O ideal, é que tenha iniciado sua implementação de SOA há dois anos e já possua business services rodando dentro da companhia. Se você é um deste, está com sorte, a lógica do negócio já está separada dos dados e você pode facilmente construir sua frente mobile. SE você não chegou neste nível, faça de sua jornada SOA uma boa iniciativa.

    Vá de iPhone a Android com uma app só

    Fonte: http://info.abril.uol.com.br/professional/desenvolvimento/programe-para-iphone-e-android-em-uma-tacada-so.shtml?2 – by Daniela Moreira, de INFO Online

    Com tantas linguagens de programação, plataformas e dispositivos diferentes no mercado, escolher uma só para se concentrar pode ser um desafio e tanto.
    Só na arena móvel, dois fortes concorrentes disputam a atenção dos programadores: de um lado o iPhone, de outro o Android.

    Enquanto o iPhone já contabiliza mais de 40 milhões de usuários à disposição dos desenvolvedores criativos – que por outro lado terão que achar seu espaço em universo de mais de 50 mil aplicativos já disponíveis –, de outro o Android, que vinha avançando mais lentamente, promete decolar este ano, avançando além do terreno dos smartphones e estreando em netbooks de fabricantes de peso.

    Mas a especialista em desenvolvimento em código aberto Appcelerator promete facilitar a vida dos desenvolvedores com uma ferramenta que permitirá aplicativos para o iPhone e para o Android em uma tacada só.

    Plataforma permite criar aplicativos para os smartphones do momento sem dominar linguagens específicas

    Trata-se do novo módulo voltado a aplicativos móveis da plataforma Titanium, que permite criar aplicativos ricos não só para dispositivos móveis, mas também para desktop e para a internet.

    Com a tecnologia, desenvolvedores que não tenham conhecimentos em Objective-C ou Java – linguagens usadas para o desenvolvimento em Android e iPhone – podem criar aplicativos lançando mão das suas habilidades em JavaScript, HTML ou CSS. A plataforma garante que os aplicativos funcionarão nativamente no ambiente desejado.

    O componente móvel da solução estreia em versão beta nesta terça-feira (09/06), durante a WWDC. Por enquanto, os testes serão limitados – é preciso se inscrever para participar.

    Já a versão para desktop da plataforma é distribuída gratuitamente sob licença Apache Public License v2 e pode ser baixada no site da Appcelerator.
    Embora a Titanium seja gratuita, a companhia planeja faturar oferecendo serviços de teste e análise dos aplicativos criados na plataforma.

    November 22

    On Mobile Web Development — Develop mobile widgets with Yahoo! Blueprint

    Fonte: http://feedproxy.google.com/~r/CEnriqueOrtizWeblog/~3/v-OGyeyKIHI/

    I’ve written an article/tutorial on mobile web/widget development using Yahoo! Blueprint; see Develop mobile widgets with Yahoo! Blueprint (IBM developerWorks). The article shows how to develop a Weather widget using the Blueprint XML markup and infrastructure, PHP for server integration, and the consumption of Yahoo! services on the web.

    Developing mobile applications can be a daunting task. With hundreds of handsets to develop against and support, mobile application development can be time consuming and costly.

    With Blueprint, you can author a mobile application one time that can be targeted at mobile devices with a browser (or devices that support the Blueprint platform), allowing you to potentially reach thousands of users. In this tutorial you will see how to develop a weather mobile widget using the Yahoo! Blueprint platform.

    This tutorial is for developers interested in learning how to develop mobile widget-based applications using the Yahoo! Blueprint platform. While this tutorial is for entry-level developers, general knowledge about Web applications, mobile applications, XML, and PHP is desirable, but not essential.

    The article is dedicated to the memory of Heidi Carson:

    This tutorial is dedicated to the memory of Heidi Carson. She was the editor of IBM developerWorks (dW) Wireless and Web development zones. I used to write about mobile and wireless for her; many years ago Heidi gave me the opportunity to write for dW. And she was friendly, kind, and always willing to help through the process. As I learned that she has left us, I’m saddened. But a part of her can be found in each of my previous articles at dW.

    ceo

    October 28

    Resco releases MobileForms Toolkit 2008

    Fonte: http://blogs.msdn.com/lokeuei/archive/2008/10/03/resco-releases-mobileforms-toolkit-2008.aspx

    This is really handy for developers. Resco has released a ton of controls for .NET Compact Framework developers to help speed up application development time. PRESS RELEASE.

    ImageButton_02 AdvancedTree_02 scr_audio

    This toolkit contains the following controls:

    • Resco SmartGrid for .NET - powerful grid control with built-in auto edit capabilities
    • Resco AdvancedList for .NET - professional list control suitable for small displays of mobile devices
    • Resco AdvancedTree for .NET - featured tree control excellent for displaying tree-organized data
    • Resco DetailView for .NET - elegant and quick way of creating user input forms
    • Resco CompactChart for .NET - charting control supporting 5 chart types
    • Resco OutlookShortcutBar for .NET - popular shortcut control, common to all modern applications
    • Resco OutlookWeekCalendar for .NET - Day/Week appointment scheduling control
    • Resco OutlookMonthCalendar for .NET - Month/Year scheduling control
    • Resco OutlookDateTimePicker for .NET - modern version of common control providing advanced styles
    • Resco InkBox for .NET - ink control suitable for quick notes or signatures
    • Resco ImageBox for .NET CF - versatile image control supporting various graphic formats
    • Resco ImageButton for .NET CF - adjustable, modifiable and skinnable button
    • Resco Audio for .NET CF - powerful library for playing and recording audio
    • Resco Zip for .NET - industry standard compression library

    you can checkout screenshots and find out more info here : http://www.resco.net/developer/mobileformstoolkit/overview.aspx

    These controls integrate with Visual Studio 2005 & 2008 editions.

    October 25

    Managed Stored Procedures

    Fonte: http://www.satter.org/2008/03/managed-stored.html

    One of the new features in the Mobile Line of Business Accelerator 2008 is something the team called “Managed Stored Procedures”. Now the team did not really write and add to SQL Server CE 3.5 the ability to create stored procedures. Instead we looked at what developers were really looking for that they wanted stored procedures.

    The basic notion is that you want to separate out your SQL from the code. It turns out that this technique can be done with relative ease using existing feature in Visual Studio. In fact you can do this with Compact Framework 2.0 or 3.5 and VS2005 or VS2008. The trick is in the resource support for CF applications.

    The resource designer supports several types of resources including strings, images, icons, audio, files and other. We played around with the resource designer. First we used “Strings” view. While this gave us the ability to embed the SQL as resource strings the approach was not optimal. While you could access the string by code using “StoredProcs.GetInventory” for example. The actual editing of the string was painful since the SQL is entered in the cell of a grid This meant there was no syntax highlighting or testing support i.e. running the SQL against a test database from within the IDE.

    Msps_image1

    Next the team tried just creating files holding the SQL and setting the files as embedded resources. This had the advantage of getting some syntax highlighting along with the ability to test the SQL on some IDE SKUs. Although the testing has to be against SQL Server and not SQL Server CE it still makes creating and debugging the SQL easier. The problem with this approach was how to signal the data layer to retrieve the right SQL file since we no longer could say” StoredProcs. GetInventory”.

    Msps_image2

    The last approach was to use the “File” designer of the resource manager. By dragging and dropping the files we had created into the “File” design view, the team got the best of both worlds - the ability to use “StoredProcs.GetCustomers” and when editing the SQL seeing it in a full screen editor with syntax highlighting and ability to test the SQL.

    Msps_image3

    So now when using ADO.Net, the new data layer in Mobile LOB Accelerator or your own data layer you can replace the string embedded SQL with the contents of a SQL file.

    cmd.CommandText = StoredProcs.GetInventory;

    I hope you find this way of separating out your SQL from the code useful. Let me know what you think. You can also download the new Mobile Line of Business Accelerator 2008 from Microsoft download site.

    October 24

    Mobile MVC framework (part 3) - communicating with events

    Fonte:

     

    Mobile MVC framework (part 3) - communicating with events

    Just for people who are not comfortable with passing strings when notifiying the view or the controller, I've added the functionality to use events instead. You would not need to hook into the events explicitly because the controller will take care of this behind the scenes.

    In order to demonstrate how to use this functionality I am going to modify the exising code for the SearchForm and the SearchController I created last time.

    Let's start from adding the OnSearchEvent to the SearchForm class:

    [PublishEvent("OnSearch")]

    public event EventHandler<DataEventArgs<string>> OnSearchEvent;

    As you can see the event declaration has a few peculiar things: I've applied the PublishEvent attribute which specifies the name of the event handler in the Controller. As a parameter I've used the DataEventArgs<T> class which is a part of the System.Mobile.Mvc assembly.

    Since we are going to use the OnSearchEvent to notify the SearchController that the Search button has been clicked on the form, let’s modify the code on the button’s event handler to:

    private void cmdSearch_Click(object sender, EventArgs e)

    {

    if (OnSearchEvent != null)

    {

    // Raise the event and notify the controller

    OnSearchEvent(this, new DataEventArgs<string>(txtSearch.Text));

    }

    }

    Now, we can move to the SearchController and add the event handler for the OnSearchEvent:

    private void OnSearch(object sender, DataEventArgs<string> e)

    {

    this.view.ViewData.Model.FilterData(e.Value);

    // Notify the view

    this.NotifyView();

    }

    The obvious positive outcome of this change is the ability to pass a strongly typed parameter between the view and the controller.

    In order to communicate back to the view from the controller we can use exactly the same technique - declare the event with the PublishEvent attribute in the controller:

    [PublishEvent("OnProductsUpdated")]

    public event EventHandler ProductsUpdated;

    private void NotifyView()

    {

    // Raise the event for view

    if (this.ProductsUpdated != null)

    {

    this.ProductsUpdated(this, EventArgs.Empty);

    }

    }

    Here are the final versions of the SearchView and SearchController after modifications:

    public partial class SearchForm : ViewForm, IView<Products>

    {

    [PublishEvent("OnSearch")]

    public event EventHandler<DataEventArgs<string>> OnSearchEvent;

    public SearchForm()

    {

    InitializeComponent();

    }

    private void OnProductsUpdated(object sender, EventArgs e)

    {

    this.lstProducts.DataSource = this.ViewData.Model.ProductList;

    }

    #region IView<Products> Members

    public new ViewDataDictionary<Products> ViewData

    {

    get;

    set;

    }

    #endregion

    private void cmdSearch_Click(object sender, EventArgs e)

    {

    if (OnSearchEvent != null)

    {

    // Raise the event and notify the controller

    OnSearchEvent(this, new

    DataEventArgs<string>(txtSearch.Text));

    }

    }

    private void menuItemBack_Click(object sender, EventArgs e)

    {

    NavigationService.GoBack();

    }

    }

    And the controller:

    public class SearchController : Controller<Products>

    {

    [PublishEvent("OnProductsUpdated")]

    public event EventHandler ProductsUpdated;

    public SearchController(IView<Products> view) : base(view)

    {

    // Create an intance of the Products

    Products products = new Products();

    // Populate the list

    products.PopulateList();

    // Assign the Model

    this.view.ViewData.Model = products;

    // Notify the view of the changes

    this.NotifyView();

    }

    private void OnSearch(object sender, DataEventArgs<string> e)

    {

    this.view.ViewData.Model.FilterData(e.Value);

    // Notify the view

    this.NotifyView();

    }

    private void NotifyView()

    {

    // Raise the event for view

    if (this.ProductsUpdated != null)

    {

    this.ProductsUpdated(this, EventArgs.Empty);

    }

    }

    }

    You should probably notice the usage of the new class - NavigationService - the class I've just added to the framework and which takes care of caching of the controllers as well as showing them and navigating back and forth in the view stack. It implements a few helpful methods:

    public static void Navigate(Controller controller)

    public static void GoBack()

    public static void GoForward()

    Download the project from here.

    Mobile MVC framework (part 1)

    Fonte: http://blogs.msdn.com/priozersk/archive/2008/10/10/mobile-mvc-framework-part-1.aspx

    In order to show you the Mobile MVC framework I came up with, let me walk you through the same excersise we did when I showed you the MVC pattern. Let's create a simple application with the same login form. Let's create a Smart Devices project and rename the Form1.cs to LoginForm.cs and add a few controls to the form:

    We will add the reference to the System.Mobile.Mvc assembly and start with the Controller.

    Login Controller

    Let's add the LoginController class and derive it from the Controller which is defined in the System.Mobile.Mvc. We will also define the constructor that excepts IView as a parameter and overrige OnViewStateChange method:

    public class LoginController : Controller

    {

    public LoginController(IView view)

    : base(view)

    {

    }

    /// <summary>

    /// This method indicates that something has been changed in the view.

    /// </summary>

    /// <param name="key">The string key to identify what has been changed.</param>

    protected override void OnViewStateChanged(string key)

    {

    base.OnViewStateChanged(key);

    }

    }

    Next, let's modify the OnViewStateChanged to handle the Login event from the view:

    protected override void OnViewStateChanged(string key)

    {

    // Check what's changed

    if (key == "Login")

    {

    // The values are in the ViewData. Let's validate them and return the status to the view

    if (view.ViewData["UserId"].ToString() == "Alex" && view.ViewData["Password"].ToString() == "password")

    {

    // Pass the status to the view

    this.view.ViewData["Status"] = "Login succedded.";

    }

    else

    {

    // Pass the status to the view

    this.view.ViewData["Status"] = "Login failed.";

    }

    // Notify the view of the changes to the status

    this.view.UpdateView("Status");

    }

    if (key == "Exit")

    {

    Application.Exit();

    }

    }

    LoginView

    Switch to the code view of your LoginView form and change it to derive from ViewForm. Let's also implement some logic for the menuLogin_Click and menuExit_Click event handlers:

    public partial class LoginForm : ViewForm

    {

    public LoginForm()

    {

    InitializeComponent();

    }

    private void menuLogin_Click(object sender, EventArgs e)

    {

    // Assign the values

    this.ViewData["UserId"] = txtUser.Text;

    this.ViewData["Password"] = txtPassword.Text;

    // Notify the Controller

    this.OnViewStateChanged("Login");

    }

    private void menuExit_Click(object sender, EventArgs e)

    {

    // Notify the Controller

    this.OnViewStateChanged("Exit");

    }

    }

    In the code for menuLogin_Click method we assign the values from the text boxes to the ViewData and make a call to the OnViewStateChanged to notify the controller of the event. Don't forget to pass the key which is used to recoginize what kind of event has happenned in the view.

    All what is left here is to add an override for the OnUpdateView method to the LoginView which will be called when controller wants us to update the view:

    protected override void OnUpdateView(string key)

    {

    // Controller requested to update the view

    if (key == "Status")

    {

    // Update status label

    this.lblStatus.Text = this.ViewData["Status"].ToString();

    }

    }

    The last step is to wire up the controller and view together. You can do it by modifying the Main in the Program.cs:

    [MTAThread]

    static void Main()

    {

    LoginForm form = new LoginForm();

    LoginController controller = new LoginController(form);

    Application.Run(form);

    }

    That is all to the code sample for now. I think the adavantages over the previous implementation are obvious - a lot less of the code to write. Plus we get a certain structure in the way the data is being passed between the view and controller. You can download the demo project from here. I am looking forward to any feedback on the approach I've taken.

    In the next posts I am going to show you how to pass strongly typed data between the layers (although, you should be able to guess it by looking at the MVC for ASP.NET).

    DataGrid with a custom header and selection

    Fonte: http://blogs.msdn.com/priozersk/archive/2007/11/11/datagrid-with-a-custom-header-and-selection.aspx

    One of the questions that has recently come up on the .Net CF MSDN forums was on how to create a custom (owner drawn) header in the DataGrid. This person wanted to implement the look similar to the grid that is used in the Mobile CRM application that has a non standard header and row selection.

    crm_mobile

    Both are using a gradient filled colors. So I decided to take this up for a challenge to create a similar look by using the standard DataGrid control that comes with .NET CF v2 SP2. Ilya Tumanov from the .NET CF team had create a great sample that shows how to create a custom column types and to override the Paint event in the DataGridTextBoxColumn. In my sample I've reused some code from his sample.

    As a first step I have created the CustomSelectionColumn class that inherits from the DataGridTextBoxColumn. Here's how the Paint method looks:

     protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, 
                       int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
     {
         RectangleF textBounds;      // Bounds of text 
         object cellData;     // Object to show in the cell 
    
         // Check if the row is selected
         if (gridControl.IsSelected(rowNum))
         {               
             DrawBackground(g, bounds, rowNum, backBrush, true); 
         }
         else
         {
             DrawBackground(g, bounds, rowNum, backBrush, false);
         }
                
          // Draw cell background
          bounds.Inflate(-2, -2);    // Shrink cell by couple pixels for text.
    
          textBounds = new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height);
          // Set text bounds.
          cellData = this.PropertyDescriptor.GetValue(source.List[rowNum]); // Get data for this cell from data source.
    
          g.DrawString(FormatText(cellData), this.gridControl.Font, foreBrush, textBounds, this.StringFormat);                       
      }

    In order to draw a gradient filled selector in the grid, I went to the MSDN library samples for .NET CF and copied the code from the How to: Display a Gradient Fill article into my project. So the DrawBackround method utilizes the code from this article:

    protected virtual void DrawBackground(Graphics g, Rectangle bounds, int rowNum, Brush backBrush, bool selected)
    {
        // Create rectangle for drawing       
        Rectangle rc = new Rectangle(bounds.Left - 2, bounds.Top, bounds.Width + 4, bounds.Height);
        // Check if the row is selected
        if (selected)
        {
            // Draw gradient cell selection
            GradientFill.Fill(g, rc, Color.LightBlue, Color.RoyalBlue, GradientFill.FillDirection.TopToBottom);
        }
        else
        {
            g.FillRectangle(backBrush, rc);
        }            
    }

    So this should take care of a custom row selection. Now up to the custom header. A few years ago I had created an owner-drawn header control for a ListView. I have modified the CustomHeader control to use with the DataGrid and added the gradient drawing code to it. Here is the how the result looks:

    custom_grid

    You can download the full demo code from here.

    October 04

    How to open a mail in Inbox using Pocket Outlook

    Fonte: http://www.cjcraft.com/blog/2008/10/02/HowToOpenAMailInInboxUsingPocketOutlook.aspx

    I need to open a new email message in Pocket Outlook today. Keep in mind that’s different from just programmatically sending an email from my application.

    Here’s how to programmatically send an email from your application:

       1: Microsoft.WindowsMobile.PocketOutlook.EmailMessage email = new EmailMessage();
       2: email.From = "From";
       3: email.BodyText = "BodyText";
       4: email.To = "To";
       5: email.Subject = "Subject";
       6: email.Send("AccountName");

    Here’s how to programmatically create a new mail message in Pocket Outlook and more:

    [Source: Open a Specific Email Account in Pocket Outlook? - WM Experts]

    • To open inbox for MyMail:
      • tmail.exe -service MyMail
    • To additionally launch a new message with no recipient for sending:
      • tmail.exe -service MyMail -to ""
    • To have the new message pre-addressed:
    • To add a cc (copy to):
    • To add a bcc (blind copy):
    • To have the new message pre-addressed to multiple addresses:
    • To additionally add the subject line "Call Me Tonight":
      • tmail.exe -service MyMail -to nobody@nowhere.com -subject "Call Me Tonight"
    • To additionally add a message in the body:
      • tmail.exe -service MyMail -to nobody@nowhere.com -subject "Call Me Tonight" -body "at 555-1212"
    • To attach the file "Recipe.xls" in the "My Documents" folder:
      • tmail.exe -service MyMail -to nobody@nowhere.com -subject "Call Me Tonight" -body "at 555-1212" -attach "\My Documents\Recipe.xls"

    Resco releases MobileForms Toolkit 2008

    Fonte: http://blogs.msdn.com/lokeuei/archive/2008/10/03/resco-releases-mobileforms-toolkit-2008.aspx

    This is really handy for developers. Resco has released a ton of controls for .NET Compact Framework developers to help speed up application development time. PRESS RELEASE.

    ImageButton_02 AdvancedTree_02 scr_audio

    This toolkit contains the following controls:

    • Resco SmartGrid for .NET - powerful grid control with built-in auto edit capabilities
    • Resco AdvancedList for .NET - professional list control suitable for small displays of mobile devices
    • Resco AdvancedTree for .NET - featured tree control excellent for displaying tree-organized data
    • Resco DetailView for .NET - elegant and quick way of creating user input forms
    • Resco CompactChart for .NET - charting control supporting 5 chart types
    • Resco OutlookShortcutBar for .NET - popular shortcut control, common to all modern applications
    • Resco OutlookWeekCalendar for .NET - Day/Week appointment scheduling control
    • Resco OutlookMonthCalendar for .NET - Month/Year scheduling control
    • Resco OutlookDateTimePicker for .NET - modern version of common control providing advanced styles
    • Resco InkBox for .NET - ink control suitable for quick notes or signatures
    • Resco ImageBox for .NET CF - versatile image control supporting various graphic formats
    • Resco ImageButton for .NET CF - adjustable, modifiable and skinnable button
    • Resco Audio for .NET CF - powerful library for playing and recording audio
    • Resco Zip for .NET - industry standard compression library

    you can checkout screenshots and find out more info here : http://www.resco.net/developer/mobileformstoolkit/overview.aspx

    These controls integrate with Visual Studio 2005 & 2008 editions.

    http://www.easycoded.com/resco-releases-mobileforms-toolkit-2008/

    GZip encoder for Compact WCF

    Fonte: http://blogs.msdn.com/andrewarnottms/archive/2008/10/01/gzip-encoder-for-compact-wcf.aspx

    The GZip encoder is not included in NetCF as it is on the desktop WCF, but it isn't hard to build yourself and in fact we have released a sample of exactly how to add your own GZip encoder to NetCF:

    http://go.microsoft.com/fwlink/?LinkId=108652

    So many people have asked me for it lately I thought I'd better just post the link.  Have fun!

    September 26

    Problem creating data-bound DataGrid in Device Project

    Fonte: http://www.pluralsight.com/community/blogs/jimw/archive/2008/04/08/50683.aspx

    The other day while working in Visual Studio 2008, I encountered an unexpected error while attempting to create a DataGrid by dragging a table from the Data Sources pane onto a form (something we've all done many times).

    At first Visual Studio appeared to be creating the DataGrid and associated components (BindingSource, TableAdapter, etc.) correctly but then Visual Studio threw an error:

    An error occurred while performing the drop:
    Length cannot be less than zero.
    Parameter name: length

    The error message might have been useful if I had access to the Visual Studio source code – but I was just using Visual Studio, not building it. Needless to say, the error message was of little help. J So I did what we all do in such situations, used trial-and-error.

    The project calls a WCF service through a proxy generated by NetCfSvcUtil.exe; as an experiment, I decided to remove the WCF proxy from the project (and any calls to the proxy) to see what happened.

    … VOILA …

    Visual Studio was then able to create the DataGrid with no problem.

    To verify what I had observed, I added the WCF proxy (and any associated calls) back into the project and deleted the DataGrid. Just as before, when I tried to create the DataGrid, Visual Studio threw the same error – so now I know where to start looking for the problem.

    When I checked out the source file for the WCF proxy I realized that there was no namespace declaration. As you may know, if you run the NetCFSvcUtil without specifying the "/namespace" option then the types are not placed within a namespace….

    So as an attempt at a solution, I created the WCF proxy so that the contained types were in a namespace (and added the appropriate using statement to the form class) – I then deleted the DataGrid from the form. Now when I dragged the table from the DataSource pane to the form, the DataGrid was created without any trouble - putting the types in a namespace completely resolved the problem. The program also compiles and runs as expected.

    Now things are working – My assumption at this point was that there must have been a type name conflict (or something similar) between the WCF proxy types and the DataGrid-related types; seemed a reasonable assumption.

    … BUT… here's the thing …

    To confirm my assumption about the name conflict, I created the WCF proxy so that the contained types were not in a namespace (and of course removed the associated using statements) but left the generated DataGrid place. If there were a type name conflict between the DataGrid-related types and the WCF proxy the compiler should report the error

    … BUT … get this …

    The code compiles and runs perfectly --- the namespace was required for Visual Studio to create the DataGrid (and/or associated components) but the namespace is not required for the code to compile and run -- what?!?!

    So what does this all mean? … At this point my guess is that Visual Studio and the DataGrid creation process have a type name sensitivity that may not be consistent with the .NET CF language requirements. If that is the case it would appear to indicate a possible bug but can't be 100% certain until the problem is narrowed down specifically.

    I haven't had a chance to narrow down things further quite yet but I hopefully will shortly. As soon as I have the answer I'll post it here.

    One thing to keep in mind, if you do run into the error I describe above, look for any possible name conflicts or classes outside of a namespace. It seems that there's a good chance that that's the source of the problem.

    I hope to have more to report soon.

    Using LINQ to Access SQL Server Compact Directly – A follow up

    Fonte: http://www.pluralsight.com/community/blogs/jimw/archive/2008/04/18/50753.aspx

    You may recall my webcast from about 6/7 weeks ago where I talked about how to use custom extension methods to allow your mobile device applications to efficiently query a SQL Server Compact (SSC) databases directly.

    I received a question today regarding the webcast. The question relates to the verbosity of returning anonymous types when using the technique discussed in the webcast. For example…

    var records = from order in resultSet
    where (string)order["Ship Country"] == "UK"
    select new
    {
    ShipName = (string)order["Ship Name"],
    ShipAddress = (string)order["Ship Address"],
    ShipCity = (string)order["Ship City"],
    ShipPostalCode = (string)order["Ship Postal Code"],
    ShipCountry = (string)order["Ship Country"],
    ShipVia = (int)order["Ship Via"]
    };

    The verbosity is necessary because "order" in the above LINQ statement is of type SqlCeUpdatableRecord. Although Visual Studio supports generating typed-wrappers for SqlCeResultSet, it doesn't generate wrappers for the SqlCeUpdatableRecord corresponding to the SqlCeResultSet. With that being the case, specifying the individual column values within the anonymous type declaration requires you to use either the indexer (or Getxxx functions).

    Ultimately there's nothing we can do about the way the column values are accessed (unless you write your own typed-wrapper generator for SqlCeUpdatableRecord). What we can do is move the code that creates the anonymous type into a separate function.

    private object ShippingColumns(SqlCeUpdatableRecord order)
    {
    return new
    {
    ShipName = (string)order["Ship Name"],
    ShipAddress = (string)order["Ship Address"],
    ShipCity = (string)order["Ship City"],
    ShipPostalCode = (string)order["Ship Postal Code"],
    ShipCountry = (string)order["Ship Country"],
    ShipVia = (int)order["Ship Via"]
    };
    }

    With that, the LINQ statement becomes very simple.

    var records = from order in resultSet
    where (string)order["Ship Country"] == "UK"
    select ShippingColumns(order);

    Once we move the anonymous type declaration to a separate function we can take things one step further and optimize the column access by caching the column ordinals and then retrieving the column values using the Getxxx functions.

    private object ShippingColumns(SqlCeUpdatableRecord order)
    {
    if (_nameIndex == -1)
    InitializeIndexes(order);
    return new
    {
    ShipName = order.GetString(_nameIndex),
    ShipAddress = order.GetString(_addressIndex),
    ShipCity = order.GetString(_cityIndex),
    ShipPostalCode = order.GetString(_postalCodeIndex),
    ShipCountry = order.GetString(_countryIndex),
    ShipVia = order.GetInt32(_viaIndex)
    };
    }
    private void InitializeIndexes(SqlCeUpdatableRecord record)
    {
    _nameIndex = record.GetOrdinal("Ship Name");
    _addressIndex = record.GetOrdinal("Ship Address");
    _cityIndex = record.GetOrdinal("Ship City");
    _postalCodeIndex = record.GetOrdinal("Ship Postal Code");
    _countryIndex = record.GetOrdinal("Ship Country");
    _viaIndex = record.GetOrdinal("Ship Via");
    }
    private int _nameIndex = -1;
    private int _addressIndex = -1;
    private int _cityIndex = -1;
    private int _postalCodeIndex = -1;
    private int _countryIndex = -1;
    private int _viaIndex = -1;

    Although not a huge performance increase, storing the column indices does eliminate the overhead of the indexer looking up the column name each time. More importantly, using the strongly-typed Getxxx functions eliminates the overhead of boxing any column values that are value-types. As you know, excessive boxing creates a lot of scrap objects which leads to increased memory and garbage collection overhead.

    Using regular class methods like those above work just fine; however, if you find that you use a common anonymous type throughout different parts of your application, you may want to use an extension method – extension methods are also nice just because of their class-member-like syntax.

    public static class ResultSetExtension
    {
    public static IEnumerable<SqlCeUpdatableRecord> Where(
    this SqlCeResultSet resultSet, Func<SqlCeUpdatableRecord, bool> theFunc)
    {
    return new PrepAwareEnumerableWrapper(resultSet, theFunc);
    }
    public static object ShippingColumns(this SqlCeUpdatableRecord order)
    {
    if (_nameIndex == -1)
    InitializeIndexes(order);
    return new
    {
    ShipName = order.GetString(_nameIndex),
    ShipAddress = order.GetString(_addressIndex),
    ShipCity = order.GetString(_cityIndex),
    ShipPostalCode = order.GetString(_postalCodeIndex),
    ShipCountry = order.GetString(_countryIndex),
    ShipVia = order.GetInt32(_viaIndex)
    };
    }
    private void InitializeIndexes(SqlCeUpdatableRecord record) { ... }

    With the extension method, the LINQ statement becomes…

    var records = from order in resultSet
    where (string)order["Ship Country"] == "UK"
    select order.ShippingColumns();

    A couple of notes before I finish up…

    One thing to keep in mind is that all of these functions that create the anonymous type have a return type of object. This means that the IEnumerable<T> collection that is created by the LINQ statement will be of type IEnumerable<object> rather than IEnumerable<compiler_generated_type>. In most cases this difference does not matter but it is something to be aware of.

    And for a final note, if you do find yourself returning the same anonymous type construct from a number of LINQ statements, you might want to consider defining an explicit type and then constructing instances of that type within the LINQ statement. In my experience, anytime I find myself using an anonymous type/function/etc. more than once or twice that I ultimately end up needing access to it in my code in a non-anonymous fashion.

    To return a specific type from a LINQ statement, simply define a type that has a constructor that accepts a SqlCeUpdatableRecord and assigns the desired columns to the corresponding type members – basically the constructor will look like the ShippingColumns methods shown above. Assuming that you've defined a class named ShipInfo with the appropriate constructor, your LINQ statement would look like the following…

    var records = from order in resultSet
    where (string)order["Ship Country"] == "UK"
    select new ShipInfo(order);

    I've updated one of the samples from the original webcast to include examples of what we've talked about in this post. If you'd like the updated sample, you can download it from here. The methods you'll want to look at in the download are menuRedefineType_Click, menuDynamicType_Click, menuDynamicTypeExtMethod_Click all of which are in the Form1.cs source file.

    Debugging device cellular connection code without ActiveSync interference

    Fonte: http://www.pluralsight.com/community/blogs/jimw/archive/2008/07/16/debugging-device-cellular-connection-code-without-activesync-interference.aspx

    I had a situation today where I needed to debug some code that used Connection Manager to establish a cellular connection. The challenge was that the connectivity problem was only observed on certain devices therefore I couldn't use the Device Emulator & Cellular Emulator to debug … I needed to debug on a real device.

    This all sounds simple enough until you start to try and do it… In order to debug application code using Visual Studio, I have to connect the device to my desktop using ActiveSync or WMDC.

    Now here's the problem…

    I want my application to establish a cellular connection but ActiveSync/WMDC provide the device with network connectivity … as a result any call to ConnMgrEstablishConnection or ConnMgrEstablishConnectionSync to establish the network connection returns with a successful connection but not a cellular connection because Connection Manager is recognizing that the current ActiveSync/WMDC connection meets the application's network connectivity requirements.

    I could modify my code to explicitly establish a cellular connection but I want to debug the application code as it will run in real life. In real life, I want Connection Manager to choose the appropriate connection … I just need to debug the cellular scenario right now.

    I have to say that I did stare at my screen for a minute or so wondering what kind of kludge I could come up with to get the device to not use ActiveSync/WMDC and then I realized … the answer is quite simple.

    Windows Mobile manages connections as connecting to Work Network or connecting to The Internet. Since I'm trying to create a cellular connection, I want an Internet connection. All I need to do is tell the device that ActiveSync/WMDC doesn't provide Internet connections.

    On the ActiveSync Connection Settings dialog there's a selection that reads "This computer is connected to:" with a default value of Automatic. Simply changing that setting from Automatic to Work Network solves all my problems.

    Now when I call connection manager requesting a connection that reaches a location on the Internet, Connection Manager looks at the ActiveSync/WMDC setting and determines that ActiveSync/WMDC connection cannot meet that requirement; therefore, Connection Manager looks for other choices which then initiates a new Cellular Connection just as it would in the field when not connected to ActiveSync.

    Viola … I can debug my cellular connectivity code J

    Like many of us, I've often found the whole Windows Mobile Work Network vs. The Internet connectivity handling to be a bit of a pain but in this case it did make my life easier. Of course what would be even better is to have a way to explicitly do what I really wanted to do… setup an application debugging scenario that let's one choose whether ActiveSync should be considered a viable connection route during application debugging.

    September 20

    System Center Mobile Device Manager 2008 Downloads

    Fonte: http://technet.microsoft.com/en-us/scmdm/bb986593.aspx

    Download updates, tools, and documentation to help you configure, deploy, and manage System Center Mobile Device Manager (MDM) 2008 and its components.

    Featured Downloads

    Download New Versions of MDM Resource Kit Tools
    Download New Versions of MDM Resource Kit Tools

    A variety of tools are available to help you configure, deploy, operate and maintain MDM and its components. Learn more about the latest release of these tools and where to download them.

    Evaluate System Center Mobile Device Manager 2008
    Evaluate System Center Mobile Device Manager 2008

    When combined with Windows Server platform services such as Group Policy and Windows Software Update Services, System Center Mobile Device Manager 2008 is a powerful solution for managing Windows Mobile powered devices in a scalable manner for your enterprise.

    Download Windows Mobile Line of Business Solution Accelerator 2008
    Download Windows Mobile Line of Business Solution Accelerator 2008

    The Windows Mobile Line of Business Solution Accelerator is a sample line-of-business application that showcases the latest design principles and technologies in the mobile space.

    Resource Kit Tools and Documentation Downloads
    • Resource Kit Tools

      Find tools designed to make deploying and administering MDM easier.

    • Documentation

      Download guides compiled from Technical Library content.

    Using WM 6.1 Images on the Device Emulator with MDM

    Fonte: http://technet.microsoft.com/en-us/library/cc461417.aspx

    The Microsoft Device Emulator uses the following two emulator images to simulate the use of a Windows Mobile 6.1 device:

    • The WM 6.1 Professional image simulates a Windows Mobile PDA.
    • The WM 6.1 Standard image simulates a Windows Mobile smartphone.

    Use the appropriate Device Emulator to simulate the use of a Windows Mobile 6.1 device on your System Center Mobile Device Manager (MDM) system. You will get both emulators in the Windows Mobile 6.1 Emulator Images download which is available on the Downloads page of the following Microsoft Web site: http://go.microsoft.com/fwlink/?LinkId=115896.

    Requirements

    Before you install and configure the Device Emulator, make sure that the computer hosting the Device Emulator meets the following requirements:

    • Is running a 32-bit version of the Microsoft Windows® operating system
    • Has Microsoft Virtual PC installed
    • Has a connection to the MDM Gateway Server.
    Host Computer

    Do not install the emulator software on a computer running a 64-bit version of Windows. Install the software on an x86-based computer that is running a 32-bit version of Windows.

    Microsoft Virtual PC

    To establish communications, the Device Emulator requires a virtual machine (VM) network driver that enables you to configure the emulator to use the physical network card. This VM network driver is available with Microsoft Virtual PC, which is a free download at this Microsoft Web site: http://go.microsoft.com/fwlink/?LinkId=46859

    Direct Internet Connection

    For MDM features to function, the Device Emulator must be running in an environment that has a direct connection to the Internet. If you are working in a lab environment and can connect directly to the MDM Gateway Server, you do not need an Internet connection.

    Process Overview

    To simulate devices running Windows Mobile 6.1 on your MDM system, you will perform these steps:

    1. Install the Device Emulator Software.
    2. Establish Network Connectivity on the Emulator.
    3. Validate Device Emulator Connectivity.
    4. Enroll the Simulated Device with MDM.
    5. Enable Logging on the Simulated Device.

    GUI CAB Signing Utility

    Fonte: http://tools.enterprisemobile.com/cabsign/

    CAB files are used for installing applications on Windows Mobile devices. When the installation and execution security policy is enabled on Windows Mobile devices, all CAB files must be signed prior to deployment onto a device. Microsoft provides a command line tool, cabsigntool.exe, to sign CAB files which requires the administrator to understand and configure a number of parameters making the process both time-consuming and cumbersome.

    Download CAB Signing Utility

    Features and Benefits

    • A GUI interface for signing CAB files minimizes the chance of errors while expediting the process.
    • Replace existing CAB file signatures with your own signature.
    • Sign multiple CAB files at once.

    System Requirements

    • Requires Microsoft Vista or Windows XP
    September 19

    Profile your windows mobile application

    Fonte: http://jajahdevblog.com/tzah/?p=12

    This post is aimed to windows mobile developers looking for a profiler for their mobile application. I came across EQATEC profile. This tool is great! You can run it on all .NET apps including .NET CF 2.0 and 3.5.  The usage is quite simple:

    1. Compile your application as usual. If you wish, you can later add profiler-attribute later for fine tuning the profiler.
    2. Use the profiler to build a profiled version of your application. The profiled assemblies are typically 30% larger than the original and runs 30% slower. I believe that for most apps that is acceptable.


    profiler

    1. Deploy the profiled version and run it on your device. Your device doesn’t have to be connected via the ActiveSync for this step. After the application finished, find the report file. Usually, it will be be on ‘Temp’ folder or on SD card if you have one.
    2. Drag the report file to your desktop, and from there, to the profiler viewer.
    3. After a few minutes, people around you would probably find you mumbling “OMG, what the…?, I didn’t believe it takes so much time! And why the hell this method is called so many times”.

    I found the viewer useful for the following points:

    1. Find out your bottle-necks methods. This could be methods that takes long time to execute, or relativity fast methods that are called numerous times.
    2. Find out what happens inside your code. You might realize that you overlooked some calls to method that consumes most of the application time.
    3. Prioritize your work. The 80-20 rule will work here. You’ll find out that most of the delays are trackable and easy to resolve.

    For more information and understanding on how to use the profiler, go to the guide.

    BTW, EQATEC also have a tracer tool. However, it is an on-line tool that drastically reduces the performance of your application. For example, the bubbles example application rate was reduced from 54 frames/seconds to 3!

    profviewer

    Windows Mobile: How to take screenshots of your device or emulator

    Fonte: http://jajahdevblog.com/jasmine/?p=181

    In order to take a screen shot of your handset or of the emulator you should do the following:

    1- Open the “Remote Zoom In” application from the “Visual studio Remote Tools”

    WM screenshot

    2- Select to what device or emulator you want to connect. In case your connecting to a device make sure its connected to the PC with the USB cable.

    windows mobile screenshot

    3- the application will connect to the device/emulator  and you will see the screenshot. if you would like to take another screenshot, just click the “Refresh” button

    4 - To save the screenshot, select “Save as”.

    June 08

    Finding Cellcore examples for use in CE6.0

    Fonte: http://ce4all.blogspot.com/2008/02/finding-cellcore-examples-for-use-in.html

    If you are trying out the Cellcore component in CE6.0 to dial voice numbers, receive calls, send and receive text messages and are looking for code examples then try the Smartphone SDK, there are examples under here most of which will compile as they are:


    \Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Smartphone SDK\Samples\CPP\Win32\Cellcore\..


    For example the SMS\HelloSMS code can be used for sending and receiving SMS messages, this uses the SmsOpen and SmsSendMessage functions which are identical between CE6.0 and Windows Mobile.


    There are many code examples in here which certainly helped me out with the TAPI system for setting up voice calls for outgoing and incoming calls.