Wednesday, 25 May 2011

App Metrics System (Notes)

Some brief notes on the flow of information in the app metrics system I'm working on so that I remember how it works when I come back to it...

(1) An app is selected in the gui from the list of apps/projects that the user has access to.

(2) A request is sent to the server to get the xml config page which contains the css styles and the markup/layout for each of the pages (including the list of widgets contained).

(3) The xml config page is rendered on the gui and for the default ('dashboard') page a request is sent to the server to get the values for each of the widgets.

(4) A subsequent request is sent for widget values is sent to the server for each of the other pages the first time they are selected and also when refreshed.

Tuesday, 17 May 2011

Sql server column and stored procedure data types

Given a table with a column 'postcode' (for example) taking data type 'varchar(20)' and a stored procedure taking parameter '@postcode' of type 'varchar(max)'. Passing a string of length larger than 20 will throw up an exception.

On the other hand, given a table with a column 'postcode' taking data type 'varchar(20)' and a stored procedure taking parameter '@postcode' of type 'varchar(20)'. Passing a string of length larger than 20 will truncate and insert the string no problem.

Tuesday, 26 April 2011

WPF Binding Controls

Tried binding some checkboxes to a "check all" checkbox as below and it worked fine except that when a bound checkbox is clicked the binding gets lost. Not what I was intending but apparently this is how 'OneWay' binding behaves. There were some workarounds but I thought it easier in the end to do what I wanted without binding and instead to add good old-fashioned "Checked" and "Unchecked" event handlers to the "check all" checkbox.

Code I was using before...
Binding binding_isChecked = new Binding("IsChecked");
binding_isChecked.ElementName = "cbCheckAll";
binding_isChecked.Mode = BindingMode.OneWay;
DependencyProperty property_isChecked = CheckBox.IsCheckedProperty;

Binding binding_isNotChecked = new Binding("IsChecked");
binding_isNotChecked.ElementName = "cbCheckAll";
binding_isNotChecked.Mode = BindingMode.OneWay;
BoolToOppositeBoolConverter boolConverter = new BoolToOppositeBoolConverter();
binding_isNotChecked.Converter = boolConverter;
DependencyProperty property_isEnabled = CheckBox.IsEnabledProperty;

cb.SetBinding(property_isChecked, binding_isChecked);
cb.SetBinding(property_isEnabled, binding_isNotChecked);
Code I'm using now...
cb.Checked += delegate
{
foreach (CheckBox checkBoxInStackPanel in sp.Children)
{
if (!checkBoxInStackPanel.Content.Equals(cbCheckAllContent))
{
checkBoxInStackPanel.IsChecked = true;
checkBoxInStackPanel.IsEnabled = false;
}
}
};

cb.Unchecked += delegate
{
foreach (CheckBox checkBoxInStackPanel in sp.Children)
{
if (!checkBoxInStackPanel.Content.Equals(cbCheckAllContent))
{
checkBoxInStackPanel.IsChecked = false;
checkBoxInStackPanel.IsEnabled = true;
}
}
};

Monday, 14 March 2011

WeightTracker Localisation Checklist

Checklist of things to do when creating language assets for a new locale upon receiving string and image files:

(1) Android strings: Need to copy in...
(a) '..._helpText_...'
(b) '..._facebookpost_...'
... strings from the gwt strings file, and need to put in...
(c) 'mobile_2_newentry_1_b_2_UK_ONLY_RadioButton' (if missing)
(d) 'url_...'
(e) 'fbpost_...'
(f) 'marketHelpline' (null value if 'mobile_6_options_1_a_5_disclaimer' doesn't have a 'marketHelpline' string placeholder)
(g) 'stones'
(h) 'pounds'
(i) 'kilograms'
... key-value pairs, and need to manually tinker with...
(j) 'mobile_5_goal_2_update_1_a_3_Paragraph' (change placeholder to "{n}")
(k) 'web_6_help_1_a_2_helpText_1' (put in [] placeholder)
strings. See the equivalent English strings for examples.

(2) Android images: Create folders (hdpi, ldpi, mdpi) in language assets for the locale specific images for the language in question.

(3) GWT strings: Need to put in and fix up
(a) 'url_...'
(b) 'region_...'
(c) 'fbpost_...'
(d) 'mobile_2_newentry_1_a_8_feeling'
strings, and remember to combine
(e) 'web_dashboardscreen_e_1_Paragraph_0'
with
(f) 'web_dashboardscreen_e_1_Paragraph_1'
and remove extra sentence (if extra sentence there) from
(g) 'web_homescreen_c_2_Paragraph_0'
string, and remember to add [] text placeholders in
(h) 'web_dashboardscreen_c_1_Paragraph_0'
(i) 'web_6_help_1_a_2_helpText_1'
(j) 'web_3_editgoal_1_a_8_Paragraph' (change placeholder to "{n}")
(k) 'web_3_editgoal_1_b_7_Paragraph' (change placeholder to "{n}")
(l) 'web_homescreen_b_2_Paragraph'
strings. See the equivalent English strings for examples.

(4) GWT Windows: Create folder in language assets to contain
(a) Locale-specific 'docked_bg.png' image.
(b) 'war/WeightTracker_WINDOWS_flyout.html' and 'war/WeightTracker_WINDOWS.html' files. Remember to change 'alli_locale' meta-variable as appropriate.
(c) 'war/gadget.xml' file. Remember to change 'name', 'info url' and 'description' properties as appropriate.

(5) GWT Mac: Create folder in language assets to contain
(a) 'war/WeightTracker_MAC.html' file. Remember to change 'alli_locale' meta-variable as appropriate.
(b) 'war/Info.plist' file. Remember to change 'CFBundleDisplayName' key value as appropriate.

(6) Server facebook resources: Add 'btnFBLogin_xx.png' and 'fbcrossdomain_xx.aspx' for the region (xx) being added, as well as any other images and files required.

When deploying the Android, Mac and/or Windows app/gadget for a particular locale, copy in the required "language assets" to the 'war' folder for the GWT Mac and Windows gadgets and to the 'res' folder for the Android app. Additionally, for the Android app:
(1) Change 'ALLI_LOCALE' variable in 'AlliCore/User.java'.
(2) Change 'CURRENT_REGION' variable in 'AlliCore/User.java'.

Notes for future:
(i) Create string with value "Saving. Please wait..." (and remember to include in translations).
(ii) Create string with value "Account Error" (and remember to include in translations).

Friday, 4 March 2011

WeightTracker app different Web.config files

Web.config - local test
Web.config2 - our online one for our servers/api/db
Web.config3 - our servers; their api
Web.config4 - their servers; their api

Thursday, 24 February 2011

How to debug a facebook app using eclipse (gwt)

Steps to get a facebook app (written using google web toolkit) to run on the Visual Studio server and be picked up by the Eclipse debugger:

(1) Go to app developer page (e.g. http://www.facebook.com/developers/apps.php?app_id=168754973148732).

(2) Check and edit app settings as necessary. Look out for Facebook Integration settings (and Canvas URL setting) in particular. (Example Canvas URL value: http://127.0.0.1:21024/fb/)

(3) Navigate to app (Canvas Page) and append "index.html" or similar page to url. (Example Canvas Page value: http://apps.facebook.com/gskallitest/) Reload page.

(4) Use Google Chrome or Mozilla Firefox 'Inspect Element' tool to select the app in the page (it might not be visible but will be present in the html markup).

(5) Find the app iframe in the page html markup and pull out the src url. Bung in between "...index.html?" and "signed_request=..." the text "gwt.codesvr=127.0.0.1:9997&".

(6) Stick this modified url into your browser and assuming you have your gwt project running/debugging on Eclipse you're good to debug :)>

Note: When running the facebook project on eclipse (as a web application), uncheck the 'run built-in server' option from the Debug Configurations dialog ('Server' tab) and specify instead the server url to run from ('GWT' tab), i.e. the Canvas URL as specified in step 2.

ps. Remember to change the facebook app settings (step 2) back after testing/debugging. In particular: the Canvas URL setting which should be http://alli2.gsk.kickstartdigital.co.uk/fb/ or similar.