AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 15.03.2011, 09:49   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
If you haven’t already read part 4 (and the prior parts) you should do so here, before continuing to read this post.

In this post, I am going to create a small Windows Phone 7 application, which basically will be a phone version of the sidebar gadgets from this post. When we are done, your Windows Phone 7 will look like:



During the other posts, I have been describing how to make the Proxy and one way of securing this.

For this sample, I have created a new Proxy (Proxy2) and added 3 functions to this proxy:

Customer[] GetMyCustomers(string username, string password)
Vendor[] GetMyVendors(string username, string password)
Item[] GetMyItems(string username, string password)


You can imagine that these functions are implemented in the Proxy simply by authenticating and calling the corresponding function in the MyStuff codeunit from this post, I will not go into further detail about how the Proxy is done.


A small Console Application
Try the following:
  • In Visual Studio 2010, create a Windows Console Application
  • Add a service reference to sb://navdemo.servicebus.windows.net/Proxy2/mex and use the namespace Proxy2 (note that you need the Windows Azure AppFabric SDK to do this and you can download that here).
  • Use the following code in main:
static void Main(string[] args)
{
    Proxy2.ProxyClassClient client = new Proxy2.ProxyClassClient("NetTcpRelayBinding_IProxyClass");
    foreach(Proxy2.Customer customer in client.GetMyCustomers("freddy", "password"))
        Console.WriteLine(string.Format("{0} {1}", customer.Name, customer.Phone));
    Console.ReadLine();
}


  • Run the app, and you should get something like:


This in effect calls my NAV proxy2 (which is placed in Redmond) through the Service bus and returns My Customers. I will try to keep the server running, but please understand that it might be down for various reasons (I might be doing development work on the Proxy).


A Windows Phone 7 application
Now for the real thing.

In order to create solutions for Windows Phone 7, you will need the developer tools and they can be downloaded for free here: http://create.msdn.com/en-us/home/getting_started:

There are three steps to the install process:
  1. Download and install the Windows Phone Developer Tools (Release Notes)
  2. Download and install the Windows Phone Developer Tools January 2011 Update (Release Notes) [Note: Installation may take several minutes and is complete when the install dialog box closes.]
  3. Download and install the Windows Phone Developer Tools Fix


Anyway – when done – you are ready.

I created a Windows Phone Panorama Application from the templates:



After this, I add a service reference to the Proxy (sb://navdemo.servicebus.windows.net/Proxy2/mex) with the namespace Proxy2.

Looking at the ServiceReferences.ClientConfig, you will see that only the http:// and the https:// endpoints are mentioned here as the Windows Phone doesn’t support sb://.

In Windows Phone applications it is common to have a ViewModel, which is the data for the app. The templates comes with a default ViewModel, which we need to modify:

Declaring the collections:

/// <summary>
/// Collections for My stuff objects.
/// </summary>
public ObservableCollection<Proxy2.Customer> MyCustomers { get; private set; }
public ObservableCollection<Proxy2.Vendor> MyVendors { get; private set; }
public ObservableCollection<Proxy2.Item> MyItems { get; private set; }


Initializing the ViewModel:

public MainViewModel()
{
    this.MyCustomers = new ObservableCollection<Proxy2.Customer>();
    this.MyVendors = new ObservableCollection<Proxy2.Vendor>();
    this.MyItems = new ObservableCollection<Proxy2.Item>();
}


Loading the data:

/// <summary>
/// Load data into collections
/// </summary>
public void LoadData()
{
    BasicHttpBinding binding;
    EndpointAddress endpoint;




    // Emulator doesn’t support HTTPS reliably
    binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
    endpoint = new EndpointAddress("
http://schemas.microsoft.com/winfx/2006/xaml/presentation"      
    xmlns:x="
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 08:33.