Thursday, 8 August 2013

Phonegap install in Windows 64bit (for Android app)

I followed the installation process in Phonegap.

There were a few folders I used:
  • C:\AndroidSDK (x) - zip download
  • C:\Development - program files, phonegap source code
  • C:\Android (x) - android source code
  • C:\Node

1, 1.5. I had to reinstall Android adt (it contains android sdk + eclipse) in C:\Development



2. After installing Node.js, I tested and saved the source code in C:\Node

3, 3.1. I don't use C:\Android any more. It just contains the test code I did for Android study.



3.5 C:\AndroidSDK Download - I just saved zip file here. adt zip file seems to have date stamp everyday?!



4. I had to change Path variable many times after installing different softwares. (Path contains %JAVA_HOME%\bin;)

5. The current Path (system variable) looks like this.

5.5 Note that I added JAVA_HOME, ANT_HOME to system variable as well.
The details are at the end of this posting.


6. I failed in adding android platform. I found later this is because my ADT was not set up properly for 64 bit.

7, 7.5. Make sure when you type 'android' in dos command, you can see some android SDK manager starting.


7.6, 7.7. You have to select android version as well. I mainly installed Adnroid 4.2.2.


8. Make sure you are in the right directory when you check installed platform. Otherwise you cannot see anything. In this case, you should have done the 'cordova platform ls' command in C:\Node\hello.


9. I had also problem in installing javac.exe. When I run eclipse.exe I had error.

10.1, 10.2, 10.3 So I had to install java again, but not jre, the jdk.



11. If java is not installed properly, you cannot add android platform.

12. Every time, you change system variable or install java, you have to restart PC to reflect the new path. Log off is not enough.

14, 14.1 I also had to install ANT after installing java.


15, 15.1. After doing all this installation, i could add android platform.


16. You need to emulate in android

17. You can import sample code into sdk if you don't want to see the default html file.

18, 18.1. You need to assign target device to emulate. (or AVD, Android Virtual Device)


19. Finally you can see emulate screen. And wait a bit more, you will see the index.html.

20. FYI, cordova 3.0 doesn't work 'create' function. You have to use 'emulate'.

21. Change index.html whatever you want.

22. You can see it in emulator.

How to deploy into your phone? That's our next task.

-------------

Path (system variable)
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files\Intel\DMIX;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\nodejs\;C:\Development\adt-bundle-windows-x86_64-20130729\sdk\platform-tools;C:\Development\adt-bundle-windows-x86_64-20130729\sdk\tools;%JAVA_HOME%\bin;%ANT_HOME%\bin;

Path (user variable)
C:\Users\Matthew.Oh\AppData\Roaming\npm;C:\Development\adt-bundle-windows-x86_64-20130729\sdk\tools

JAVA_HOME
C:\Program Files\Java\jdk1.7.0_25

ANT_HOME
C:\Development\apache-ant-1.9.2-bin\apache-ant-1.9.2

Wednesday, 20 March 2013

MVC

MVC - Model View Controller

Controller - main function place that controls everything
Model - Connected to database tables, objects
View - reads data from user, play with Model, and displays

Name conventions:
HomeController.cs controls Views/Home.
Function f1() { return View(); } in HomeController.cs returns view, Views/Home/f1.cshtml

Instead of mapping incoming URLs to files, they instead map URLs to methods on classes.

The url ~/first/second/third means {controller}/{action}/{parameters}. It means, FirstController.cs has a function second() with a parameter third, and if the function returns View(), it will show Views\First\Second.cshtml.

visual studio 2010 View folder has the following structure:

\Views\[ControllerName]\[ActionName]


Wednesday, 11 July 2012

FormView

FormView

<NameSpace>
System.Web.UI.WebControls

<Properties>
BackColor:
BackImageUrl:
ClientID:
Context: Gets the HttpContext
DataItem: Gets the data item bound to the FormView control
DataKey:
DataSource: gets or sets the object from which the formview retrieves its list of data items
Page: gets a reference to the Page instance
PagerStyle:

<Methods>
BuildProfileTree:
CreateTable: creates the containing table for the FormView control
DeleteItem: deletes the current record in the FormView
FindControl(String): searches the current naming container for a server control

<Events>
Init
ItemCreated()
ItemDeleted()

Friday, 15 June 2012

DetailsView Class

<Description>
Displays the values of a single record from a data source in a table, where each data row represents a field of the record. The DetailsView control allows you to edit, delete, and insert record

<Properties>
AllowPaging: gets or sets a value indicating whether the paging feature is enabled
AutoGenerateRows : gets or sets a value indicating whether row fields for each field in the data source are automatically generated and displayed in a DetailsView control.
Caption: gets or sets the text to render in an HTML caption element in a DetailsView control.
DataSource: gets or sets the object from which the data-bound control retrieves its list of data items
HeaderRow: gets a DetailsViewRow object that represents the header row in a DetailsView control
Page:
PageCount:

<Method>
CreateFieldSet
CreateRow
CreateTable:
DataBind:
OnPreRender:
OnUnload:
Render:
SaveControlState:
SaveViewState:
UpdateItem: updates the current record in the data source

<Events>
DataBinding:
Init:
ItemCommand:
ItemUpdated:
ItemInserted:
ItemDeleted:

<Example>
The following code example demonstrates how to use a DetailsView control in combination with a GridView control for a simple master-detail scenario.



<table>
        <tr>
        <td>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" 
                DataSourceID="Customers"
                DataKeyNames="CustomerID">
                <Columns>
                    <asp:CommandField ShowSelectButton="true" />
                    <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
                    <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
                </Columns>
            </asp:GridView>
        </td>


        <td valign="top">
            <asp:DetailsView ID="DetailsView1" runat="server"
                AutoGenerateRows="true" DataKeyNames="CustomerID"
                DataSourceID="Details" Height="50px" Width="301px">
                </asp:DetailsView>
        </td>
        
        </tr>
        </table>



<asp:SqlDataSource ID="Details" runat="server"
            ConnectionString="<%$ ConnectionStrings:MOConnectionString %>"
            SelectCommand ="select * from tblMOTest where CustomerID = @CustomerID">
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="CustomerID"
                    PropertyName="SelectedValue"
                    type="String" />
            </SelectParameters>
        </asp:SqlDataSource>



<asp:SqlDataSource ID="Customers" runat="server"
            ConnectionString="<%$ ConnectionStrings:MOConnectionString %>"
            SelectCommand ="select CompanyName, ContactName, CustomerID from tblMOTest ">
        </asp:SqlDataSource>




select CompanyName, ContactName, CustomerID from Customers
select * from Customers where CustomerID = @CustomerID

<Example2>





Sunday, 27 May 2012

ClientFormsIdentity

<Namespace>
System.web.ClientServices

<Constructors>
<Properties>
AuthenicationCookies: Gets a collection of the cookies retrieved from the authenication service
IsAuthencated: Gets a value indicating whether the user has been authenticated

<Methods>
RevalidateUser: Silently authenticates the user by using cached credentials.

<the namespace System.Web.ClientServices>
The System.Web.ClientServices namespace provides classes that support acess in Windowes-based application to the ASP.NET Ajax authentication, roles, and profiles services.

The ConnectivitySatus class enables you to store the status of the user's network connection in the lcoal data cache. The connectivity status indicates whether the client service providers will use the offline cache or attempt to acess the application services.


A code project ariticle talks about 'Client Application Services' in visual studio 2008.



Sunday, 6 May 2012

Cache

Namespace: System.Web.Caching

<Properties>
Count: Gets the number of items stored in the cache
EffectivePercentagePhysicalMemoryLimit:
Item: Gets or sets the cache item at the specified key

<Methods>
Add: adds the specified item to the Cache object with dependencies, expiration and priority policies
Get: retrieves the specified item from the Cache object
GetHashCode: Serves as a hash function for a particular type.
Insert(String, Object): inserts an item into the Cache object with a cache key




To use the CacheItemRemovedCallback delegate, you must add an item to the cache with this method, so that ASP.NET can automatically make the proper method calls when the item is removed. (look at red under line in above picture).

<Cache vs Session Variables>


Cache is application specific and Session is user specific.
eg. If you have a cache object say Cache["abc"], then this value is available to all the user logged in to the site.
Cache["abc"]= "website cache";
User A reads its value as "website cache"
User B reads its value as "website cache"
But if you have session variable, then each user has its own copy of Session.
eg. User A --> Session["UserName"]= "Mr. XYZ";
User B --> Session["UserName"]="Mr. ABC"; 

AuthenticationService Class

Enables access to ASP.NET forms authentication as a web service.

The AuthenticationService type exposes the following members
<Methods>
IsLoggedIn: Determines whether the current user is authenticated.
Login: Checks user credentials and creates an authentication ticket (cookie) if he credentials are valid
ValidateUser: Autheiticate user credentials without issuing an authentication ticket.

<Events>
Authenticating: occurs when user credentials are being validated
CreatingCookie: occurs when the authentication cookie is being set