WindowsPhone

First spin of ECO on WindowsPhone. First read this

Open up the sample that comes with ECO:

image_thumb[3]

Open up the sln and ignore/ok this:

image_thumb[7]

You will see this:

image_thumb[11]

The ReadMe explains the missing projects but since you are a developer you will probably not read it.

Delete the missing projects.

image_thumb[13]

Choose browse and find the assemblies you downloaded in the PhoneBuilds.zip

image_thumb[15]

Define what to start:

image_thumb[17]

image_thumb[19]

Hit F5 – three windows pop up (the phone emulator starts slowly):

This is a simple WPF UI that shows the information in our “database”

image_thumb[20]

This is the Root directory of our PersistenceServer

image_thumb[21]

This is the Phone App

image_thumb[22]

Press the first of the X buttons in the bottom of the PhoneApp

image_thumb[23]

The code on the phone:

private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            EcoServiceHelper.GetPersistenceService(_ecospace).Refresh(true);
            EcoServiceHelper.GetAsyncSupportService(_ecospace).PerformTaskAsync(new Action(() => { 
                IObjectList list = EcoServiceHelper.GetOclPsService(_ecospace).Execute("Class1.allinstances->select(a|a.Class2->notempty)");
                int noOfC1ThatHasC2s = list.Count;
                string extra = "";
                if (list.Count > 0)
                    extra = list[0].GetValue<Class1>().Attribute1;

                int noOfC1 = EcoServiceHelper.GetExtentService(_ecospace).AllInstances<Class1>().Count;

                EcoServiceHelper.GetAsyncSupportService(_ecospace).DispatchTaskToMainThread(new Action(() => { 
                    // UI Stuff - everyone is happy to see that we do this in the main thread
                        ContentStack.Children.Add(new TextBlock() { Text = "db updated, Now C1 Total: " + noOfC1.ToString() + ",\r\n Total of C1 that has C2's " + noOfC1ThatHasC2s.ToString() + " " + extra });

                }));
            }));
        }

The code makes use of some ECO services.

The other button:

image_thumb[24]

Code:

private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
{

    Class1 c1 = new Class1(_ecospace);
    c1.Attribute1 = "Created on WindowsPhone " + DateTime.Now.ToLongTimeString();
    ContentStack.Children.Add(new TextBlock() { Text = "c1 created" });

    _ecospace.UpdateDatabase();

     
}

We switch back to the WCF app – hit Refresh:

image_thumb[25]

You can play around with the WPF app and the Phone app to ensure yourself that objects created in one client can be seen in the other client after a Refresh.

If things does not work consult the WCF trouble-shoot

That is all I am going to show you about the WindowsPhone right now. Disappointed? Don’t be – we did a lot – strongly typed model driven business objects on the phone with a WCF connection to the server – that persists everything – and lets you find what is on the server.

This entry was posted in WCF, WindowsPhone. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*