Wednesday, May 07, 2008

To leverage the DatePicker control just drag it on the form. Then in the form load function determine the format (e.g., DateTimePicker1.Format = DateTimePickerFormat.Short ). The selected date is then available in the Text property of the control (and should show up on the form). By default today's date should be shown.

The key properties for the calendar are

SelectionStart - This is the first selected date (it is possible to select multiple dates at a time!)

TodayDate - This sets today's date (which otherwise is set automatically by the system clock!)

Enumerations are commonly used for small sets of finite values (i.e., types or status). It is easy to work with Enums in the .NET framework, the .NET compact framework, however, has some limitations. The example below is for an Enum called PersonStatus (with the values Here, There, Somewhere)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' In the .NET framework this would work
        '    Me.ComboBox1.DataSource = [Enum].GetNames(GetType(PersonStatus))
        ' Unfortunately this does not work in the .NET Compact Framework
        ' So some hardcoding needs to be done ...
        Me.ComboBox1.Items.Add("Here")
        Me.ComboBox1.Items.Add("There")
        Me.ComboBox1.Items.Add("Somewhere")
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case Me.ComboBox1.SelectedItem
            Case "Here"
                thisPerson.Status = PersonStatus.Here
            Case "There"
                thisPerson.Status = PersonStatus.There
            Case "Somewhere"
                thisPerson.Status = PersonStatus.Somewhere
            Case Else
                'do nothing
        End Select
    End Sub


Powered by Zoundry

5/7/2008 2:04:45 PM (Central Standard Time, UTC-06:00)
 Monday, May 05, 2008
If your project is leveraging a Web service and you need more data to start out with, here is what you can do:

1) Write code in your device application that calls the addX (X is your thing ... restaurant, task, etc.) of your Web service. Make sure you provide unique IDs!

2) Create a network location (see previous blog) and work directly in the XML. Open your XML file in Visual Studio. Can be a quick way, but also error prone, which may lead to problems in the deserialization of your XML data. Use copy/paste as much as possible.

3) Modify the generateData method in your Web service. Right now it only creates one test item. Simply repeat as much as you like the code that creates the data item, assigns the values, and adds it to the array list. Make sure you provide unique IDs!
        Dim al As New ArrayList()
        Dim da As DataItem()
        Dim di As DataItem

        Try
            'test item (your item may have other attributes!)
            di = New DataItem
            di.ID = "0000" 'provide unique ids
            di.Name = "test"
            di.Value = 1.0
            al.Add(di)

            'another item
            di = New DataItem
            di.ID = "0001"
            di.Name = "test again"
            di.Value = 1.0
            al.Add(di)

            '... and so on

            da = al.ToArray(GetType(DataItem))

            Return DataManagementSystem.saveDataItems(da)
        Catch ex As Exception
            Return ex.Message
        End Try



I would use 3 to get started (and reset if necessary) and then work using 2.

MH

5/5/2008 12:07:06 PM (Central Standard Time, UTC-06:00)
 Saturday, May 03, 2008

I have created - for everyone who has sent me a class and a Web service URL - a web service that can be leveraged by the mobile device application for the project.

Some examples are

John's pricing service

Tom's Restaurant service

All the services provide basic CRUD functionality for each class ... create, read, update, delete ... and are based on my DataManagementService. John, for example, has three classes, thus he has quite a few more functions in his service than Tom. Depending on their business logic not all of the methods may be used.

It is important to note that every class has an ID property with which an object can be identified.

Creating all the "different" Web services, was quite easy. In Tom's case I just had to find "DataItem" in my code and replace it with "Restaurant" ...

If you want to see the code behind this take a look at the DataManagementService project in the code folder on the G-drive.

The data.xml files are stored at ../fpdb/data.xml . That means in the fpdb folder right below your personal folder on the Web server, as this folder has the needed write permissions. In case you do want to view your data.xml you need to setup a "network location" to your fpdb folder (in my case http://www.746.sba.uwm.edu/mhaines/fpdb) (see FAQ for instructions).

MH

Note: The generateDataFile method is used to create a data file if none exist. However, I did create one already for each Web service. If the generateDataFile method is used all existing data will be lost!

Technorati : ,

Powered by Zoundry

5/3/2008 5:04:43 AM (Central Standard Time, UTC-06:00)
 Wednesday, April 30, 2008

For anyone you needs to do some direct XML processing (i.e., RSS feeds) take a look at the following past blog entry and other resources:

Blog post about Google Calendar feed

Slides with XML processing code

... or just use this RSS Feed Web service :-) (Just plug-in the RSS URL, it returns an RssFeed object with its "news" items. The application key is "rss".)

MH


Technorati : , ,

4/30/2008 3:34:07 PM (Central Standard Time, UTC-06:00)

Vista users: In case you are getting stuck again with getting your device emulator to connect to the Internet after cradling it: Don't miss the last step in the Mobile Device Center!

In the Mobile Device Center, you should see the green check mark and "connected". However, that is not enough. Make sure you click on "connect with out setting up your device". Only after this step you can connect to the network (and the Internet). Check it out by running Internet Explorer in the device emulator.

If you can pull up a Web page you are good to go!

MH


Technorati : ,

4/30/2008 3:29:12 PM (Central Standard Time, UTC-06:00)
 Wednesday, April 23, 2008

Just a note about creating your own Web service.

For a description on how to create a Web site project for a Web service see my previous blog entry regarding this issue.

I would like everyone to go ahead and create a Web site for your Web service. Once you have created it let me know by sending me the URL. This will allow me to check whether it has been created correctly.

The other thing that you probably want to send me is the classes that you will use in your project. This serves two purposes; one, I will be able to give you feedback on the class structure itself, second, I will be able to help you setup the functions in your Web service with the classes (i.e., getXList, updateX, ... whatever your X is).

One additional note. If you do want to test your Web service you need to insert this snippet of XML in your Web.config file:

      <webServices>
        <protocols>
          <add name="HttpPost"/>
        </protocols>
      </webServices>

It goes right under the

<system.web>
tag in the Web.config file.

4/23/2008 10:16:01 AM (Central Standard Time, UTC-06:00)
 Thursday, April 17, 2008

As you may have noted, lab #4 and assignment #4 are very similar. In fact, if you have completed the optional part of lab #4, you have essentially solved assignment #4.

Here is where the solution to assignment #4 may differ slightly from the lab. In the lab the patient information is loaded into the listboxes right upon loading the form. In your assignment you should have a load and a save menu option. The data can be loaded from the Web service or from the local file. This means you may provide two load menu options (load local and load remote) ... or you could write code that tries to always load the remote file via the Web service and when this is not possible tries the local file. The quick and dirty solution would be a a try-catch statement. Just let the remote attempt fail and load the local file in the catch part. The smarter solution is to determine with some code whether the device is connected .

In any case you will need to think about where the code that loads the data from the Web service has to go now, as this may be different from lab#4. There could be also some opportunity (not required) for refactoring!

A note regarding using XML. As it became apparent in the demo provided in the last class session, you may need to add the System.Xml reference to your project references. Go to MyProject, the Reference tab, and view the existing references. If it is not listed, click on Add Reference and select System.Xml from the list in the dialog box. Then add a Imports System.Xml.Serialization statement at the top of your code file.

MH

Technorati : , ,

Powered by Zoundry

4/17/2008 6:31:21 PM (Central Standard Time, UTC-06:00)
Search
Navigation
On this page....
Archives
<September 2008>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
Aggregate Me!
RSS 2.0 | Atom 1.0 | CDF
Categories
Blogroll
Contact me
Send mail to the author(s) E-mail
Themes
Administration