Sunday, December 1, 2013

From concept to reality in 6 weeks - part 9.5

After an shockingly bad Thanksgiving break, I need to quickly recover and focus on the task at hand of getting the app done as I have exactly five weeks left before the deadline hits. Really I am at day 10 since I have day 8.5 and now today is day 9.5. Of course that is not 25 days like it would seem as I have Christmas and New Year's Day breaks in there to deal with. I do have the weekends if I have to catch up for lost time. So let's just pretend I have 25 days left. Let's quickly recap what is working I have done so far:

  • Day 1 - working Windows 8 laptop
  • Day 2 - development environment Windows 8.1 SDK working on laptop
  • Day 3 - Bing Maps displaying
  • Day 4 - retrieve data from remote server
  • Day 5 - learn Metro UI & 3rd party component libraries
  • Day 6 - use single bottom AppBar
  • Day 6.5 - learn how to submit app to Windows Store
  • Day 7 - custom icons & fonts + deliver 1st iteration to customer
  • Day 8 - component framework lifecycle to learn about dialogs
  • Day 9 - retrieve live data from secure server and process as JSON
So that brings us up to today as I need to finish the JSON parsing, but first I need to make sure I understand how to get the free 3rd party component library I downloaded to work in my app. Last week I downloaded the free license and was not able to get the Perpetuum demos to work. This morning I am going to start that process one more time. There are a couple of reasons why I need to get this working today. I have received daily messages from the developer working on our 3rd party mapping engine and I need to meet him this evening to try to get his stuff working on my machine. I really need to make sure I know how to do this with another 3rd party library first.

I went back to look at the two emails I received from Perpetuum Software which were in response to me not getting their demos to work. It was a free license which means I get no support, but I really thought it was in their best interest to at least help me a bit with their demos since they came with no documentation. The first thing I did was add the original demo project and license files on my SkyDrive from my Mac. Then I deleted the project I had on Windows and started over. I had to retarget the project to Windows 8.1. I then opened the "App.xaml.cs" file and added my free license on the correct line and uncommented out the line. I rebuilt the project and saw the same error but then it went on to build the project.
Error occurred while restoring NuGet packages: System.ArgumentException: The path is not of a legal form
I pretended to not see that error and then ran the project file and it worked. Now I am feeling like I am off to a good start for my half day today!

I then went back into my email to look at the 2nd message on how to get the Perpetuum components to work in my app. I was told to find the DLL folder in the PerpetuumSoft.Controls.Demo project and copy that into my app project, so I followed those directions. I then right clicked on References and clicked on "Add Reference..." and then opened the Browse section on the left and clicked on the "Browse..." button. I then navigated to the PerpetummDll folder I created and added the PerpetuumSoft.Controls.dll and PerpetuumSoft.WinRT.Framework.dll, which resulted in PerpetuumSoft.Controls and PerpetuumSoft.WinRT.Framework showing up on the References section. I then opened my App.xaml.cs file and on the first line in the App constructor, I started typing "perp" and VSE completed PerpetuumSoft and kept completing until I had the following:
PerpetuumSoft.WinRT.Framework.Licensing.LicenseManager.SetKey(@"");
I then added the contents of the email I received with my license key between the double quotes. I rebuilt my app and received no errors. I did not use any of the components but at least it is building. That is good enough for now but eventually I will use their calendar and dual range selectors, so I switch back to finishing off the JSON parsing...

A couple of new lessons to learn at the beginning before I start. First is how to create an abstract method that I implement in subclass? I need to declare the method as "public abstract Process(string text)" in the parent class and then in all subclasses I need to declare it as "public override Process(string text)". That makes sense - I just needed to re-learn how to do it. Next I have to learn how to compare two strings. I first tried string.Equals(string) but that was a failure to compile. I looked up the String class and found a static Compare method so I tried that but it failed in the very same way:
The best overloaded method match for "string.Compare(string, string)" has some invalid arguments
 That is an odd message since this is exactly how the documentation says it should work. Then I look at the second error associated with the same line, which is
Argument 2: cannot convert from 'method group' to 'string'
Then I remember that I forgot to add "()" when calling a method as it was trying to pass a method to the Compare function. That is going to get me every time until I remember it unfortunately. But the good news is that all of my changes compile. Now I need to implement one of the process methods to make sure the JSON I retrieve from the server will be stored correctly in my DAO objects I created on Day 9. That means I need to learn how to process and array of JSON objects as well as how to change the ToString method so I can see the results of my parsing. I also need to know how to work with C# Arrays. If I can going to do all that then I need to know how to concatenate strings to show arrays within my ToString method. That should take care of my learning for the day as I will put all of that into action for my JSON parsing and checking the results.

I definitely fixed one bug where I was calling "await" in the wrong place. I found this article which describes how to determine the state of the app in the main App.xaml.cs file. In that method I called:
MainPage.Current.WaitForDownloads();
Which is very simple and checks for out standings running tasks:
public async void WaitForDownloads() { await DiscoverActionDownloadsAsync(); }
The method being called is very similar to the code I found in the Background Transfer sample code, with the primary different being how to output is logged.

Unfortunately, now two of my remote server calls are returning JSON but when I process the first JSON response I am getting a "System.NullReferenceException", but I have no clue where that occurred since the VSE debugger stops in a place that does not help me at all as it is in an "await" block. I went to the DEBUG menu and look under the Windows sub-menu and selected "Call Stack" to see that helped me but it did not. I went back into the debugger and inspected DownloadOperation variable to see the RequestedUri and now I know which server request is the one that fails. It turns out that is the one I have not written yet but I double checked the code and I don't see what the problem is. I set a break point in the code where I parse the results and it did not get to there yet.

Time for tennis so this will have to wait until tomorrow.


1 comment:

Unknown said...

In the evening I met the lead developer on the mapping package to make some serious progress and to make sure we both understood what was left to do. I got his preliminary code working in my Windows 8 and I gave him the vector tiles we used for the iPad app as that is exactly what we will be using on Windows 8. He asked me if I though it would work the first try and I told him I would give it a 50% chance. Turns out it worked the first time! That was a huge relief. We also worked thru a display problem with the 1080p resolution causing the map to be clipped, but we did not finish that completely but it is definitely better than it was on the first pass. We also went over all of the features that existed in the iPad app as those are the only features we need working right way. He was very confident he could get all of these features working by the end of the year, and so I am confident also.