Archive for October 2013
Splash Screen for windows phone 8 apps
Create an image with 720*1280 px.
Save it as SplashScreenImage.jpg in the root folder of your project then it will be automatically applied as splash screen for your app.
Generally use it when first page of your app takes some time to load.
This resolution is recommended as it will automatically scale to all other resolutions of windows phones.
Save it as SplashScreenImage.jpg in the root folder of your project then it will be automatically applied as splash screen for your app.
Generally use it when first page of your app takes some time to load.
This resolution is recommended as it will automatically scale to all other resolutions of windows phones.
JavaScript Part-8 Required field validation using js code
Javascript example code to add required field validation for html input textbox
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post">
First name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post">
First name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</html>
JavaScript Part-7 Sending input parameters for js function
In this example when user click on the button two input parameters are sent to the js function to print them in alert box
JS code to send input parameters for function
<!DOCTYPE html>
<html>
<body>
<p>Click the button to call a function with arguments</p>
<button onclick="myFunction('Hello','World')">Try it</button>
<script>
function myFunction(name, job) {
alert("Welcome " + name + ", the " + job);
}
</script>
</body>
</html>
JS code to send input parameters for function
<!DOCTYPE html>
<html>
<body>
<p>Click the button to call a function with arguments</p>
<button onclick="myFunction('Hello','World')">Try it</button>
<script>
function myFunction(name, job) {
alert("Welcome " + name + ", the " + job);
}
</script>
</body>
</html>
Javascript Part-6 changing css class using js code if condition
In this example i wrote two css classes cssclass1 and cssclass2.
when page is loaded cssclass1 styles is applied to the div1 tag and when user click on the button cssclass2 is applied to div tag using javascript.
js code to change css class of div tag
<!DOCTYPE html>
<html>
<head>
<style type="text/css" >
.cssclass1
{
width:200px;
height:200px;
background-color:yellow;
}
.cssclass2
{
width:200px;
height:200px;
background-color:green;
}
</style>
<script language="javascript">
function f1() {
var css = document.getElementById("div1").className;
if (css == "cssclass1") {
document.getElementById("div1").className = "cssclass2";
} else { document.getElementById("div1").className = "cssclass1"; }
}
</script>
</head>
<body>
<div id="div1" class="cssclass2" >Text inside div tag</div>
<input type="button" value="Submit" onclick="f1()">
</body>
</html>
when page is loaded cssclass1 styles is applied to the div1 tag and when user click on the button cssclass2 is applied to div tag using javascript.
js code to change css class of div tag
<!DOCTYPE html>
<html>
<head>
<style type="text/css" >
.cssclass1
{
width:200px;
height:200px;
background-color:yellow;
}
.cssclass2
{
width:200px;
height:200px;
background-color:green;
}
</style>
<script language="javascript">
function f1() {
var css = document.getElementById("div1").className;
if (css == "cssclass1") {
document.getElementById("div1").className = "cssclass2";
} else { document.getElementById("div1").className = "cssclass1"; }
}
</script>
</head>
<body>
<div id="div1" class="cssclass2" >Text inside div tag</div>
<input type="button" value="Submit" onclick="f1()">
</body>
</html>
Javascript Part-5 changing background color style property using js code
Javascript code to change the background color style of div tag based on the color selected from dropdown by the user
<html>
<head>
<script>
function f1()
{
var x= document.getElementById('colorpicker').value;
document.getElementById('colormsg').style.background= x;
}
</script>
</head>
<body>
<div id='colormsg' font-size="100px";width="100";height="180";padding="5px">choose a background color</div>
<select id='colorpicker' onclick='f1()'/>
<option value="transparent">None</option>
<option value="Yellow">yellow</option>
<option value="Cyan">cyan</option>
<option value="pink">Pink</option>
</body>
</html>
<html>
<head>
<script>
function f1()
{
var x= document.getElementById('colorpicker').value;
document.getElementById('colormsg').style.background= x;
}
</script>
</head>
<body>
<div id='colormsg' font-size="100px";width="100";height="180";padding="5px">choose a background color</div>
<select id='colorpicker' onclick='f1()'/>
<option value="transparent">None</option>
<option value="Yellow">yellow</option>
<option value="Cyan">cyan</option>
<option value="pink">Pink</option>
</body>
</html>
Javascript Part-3 inner html property to create html
In the below example onkeyup event is fired after every release of keyboard key.
placeholder property is used to display a watermark message inside textbox.
innerHTML is the property used in js code to add h1 tag inside paragraph tag.
Js code to print text entered in textbox as heading in paragraph
<html>
<head>
<script type="text/javascript">
function showMsg() {
var userInput = document.getElementById('userInput').value;
document.getElementById('userMsg').innerHTML = "<h1>"+userInput+"</h1>";
}
</script>
</head>
<body>
<input type="text" maxlength="40" id="userInput" onkeyup="showMsg()" placeholder="Enter text here..." />
<p id="userMsg"></p>
</body>
</html>
placeholder property is used to display a watermark message inside textbox.
innerHTML is the property used in js code to add h1 tag inside paragraph tag.
Js code to print text entered in textbox as heading in paragraph
<html>
<head>
<script type="text/javascript">
function showMsg() {
var userInput = document.getElementById('userInput').value;
document.getElementById('userMsg').innerHTML = "<h1>"+userInput+"</h1>";
}
</script>
</head>
<body>
<input type="text" maxlength="40" id="userInput" onkeyup="showMsg()" placeholder="Enter text here..." />
<p id="userMsg"></p>
</body>
</html>
Javascript Part-2 using variables , comments
Variables are used to hold the data retrieved from input controls.
In the below example a textbox and a button is displayed on the output screen. The text entered in the textbox is displayed in an alertbox when user clicks on the button.
In the below example txt1 is the id given to a textbox which is used to retreive its value using js code.
document.getElementById is used to find an item with id as txt1 in the html document.
Javascript code to display entered text in an alertbox
<html>
<head>
<script language="javascript">
function f1()
{
var a=document.getElementById("txt1").value;
alert(a);
}
</script>
</head>
<body>
<input type="text" id="txt1"/>
<input type="button" value="click me" onclick="f1()"/>
</body>
</html>
In the below example two textboxes and a button is displayed on the output screen. when user clicks on the button the added value of the two textboxes is displayed in an alert box.
parseInt is the function used to convert a value inside a variable into numeric type to perform arthimetic operations.
javascript code to add two numbers entered in two textboxes
<HTML>
<head>
<script language="javascript">
function f1()
{
var a=document.getElementById("txt1").value;
var b=document.getElementById("txt2").value;
var c=parseInt( a)+parseInt(b);
alert(c);
}
</script>
</head>
<body>
<input type="text" id="txt1"/>
<input type="text" id="txt2"/>
<button id="btn1" onclick="f1()" >
Click me
</button>
</body>
</html>
In the below example a textbox and a button is displayed on the output screen. The text entered in the textbox is displayed in an alertbox when user clicks on the button.
In the below example txt1 is the id given to a textbox which is used to retreive its value using js code.
document.getElementById is used to find an item with id as txt1 in the html document.
Javascript code to display entered text in an alertbox
<html>
<head>
<script language="javascript">
function f1()
{
var a=document.getElementById("txt1").value;
alert(a);
}
</script>
</head>
<body>
<input type="text" id="txt1"/>
<input type="button" value="click me" onclick="f1()"/>
</body>
</html>
In the below example two textboxes and a button is displayed on the output screen. when user clicks on the button the added value of the two textboxes is displayed in an alert box.
parseInt is the function used to convert a value inside a variable into numeric type to perform arthimetic operations.
javascript code to add two numbers entered in two textboxes
<HTML>
<head>
<script language="javascript">
function f1()
{
var a=document.getElementById("txt1").value;
var b=document.getElementById("txt2").value;
var c=parseInt( a)+parseInt(b);
alert(c);
}
</script>
</head>
<body>
<input type="text" id="txt1"/>
<input type="text" id="txt2"/>
<button id="btn1" onclick="f1()" >
Click me
</button>
</body>
</html>
Comments
//single line comments goes here
/* Multi line
comments in javascript
*/
Global variable: Variable that is created ouside the body of the function.
Local variable: Variable that is created inside the body of the function.
In the below example global variable "word" is created outside the function which can be called within and outside the function named "first".
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var word="ABCD ";
function first()
{
document.write("inside: "+word);
}
document.write("outside: "+word);
first();
</script>
</head>
<body>
</body>
</html>
Output:
outside: ABCD inside: ABCD
------------------------
In the below example local variable "alphabet" is created inside the function which can be called within the function named "first" only.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function first()
{
var alphabet="C ";
document.write("inside: "+alphabet);
}
first();
</script>
</head>
<body>
</body>
</html>
Output:
inside: C
Global variable: Variable that is created ouside the body of the function.
Local variable: Variable that is created inside the body of the function.
In the below example global variable "word" is created outside the function which can be called within and outside the function named "first".
Global variable example code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var word="ABCD ";
function first()
{
document.write("inside: "+word);
}
document.write("outside: "+word);
first();
</script>
</head>
<body>
</body>
</html>
Output:
outside: ABCD inside: ABCD
------------------------
In the below example local variable "alphabet" is created inside the function which can be called within the function named "first" only.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function first()
{
var alphabet="C ";
document.write("inside: "+alphabet);
}
first();
</script>
</head>
<body>
</body>
</html>
Output:
inside: C
Javascript Part-1 What is Javascript?
What is Javascript?
It is a light weight client side scripting language.You can write javascript code in html page to convert static web page to dynamic page.
It is a case sensitive language ie., you cannot use lowercase letters incase of uppercase letters.
It is recommended to write javascript in head tag.
Javascript functions should be written inside <script> and </script>.
It is executed line by line by interpreter.
You can write javascript in external javascript file with .js as extension. You can call javascript functions written in external js file by adding the below tag in the html page.
<script src="external.js"> </script>
Using javascript we can change the properties of html elements, create html tags in runtime, change css styles in runtime.
Example javascript code in html file
<html>
<head>
<script language="javascript">
function f1()
{
alert('hi');
}
</script>
</head>
<body>
<input type="button" value="click me" onclick="f1()"/>
</body>
</html>
In the above code a button is created using html input button tag. It Clickme is the text displayed on the button. onclick is the event which calls javascript function f1 when user clicks on the button.
f1 function is written inside the script tag. alert box with hi message is displayed when user click on the button.
Example to call javascript function written in external js file
code in html file
<html>
<head>
<script src="external.js">
</script>
</head>
<body>
<input type="button" value="click me" onclick="f1()"/>
</body>
</html>
code in external.js file
function f1()
{
alert('hi');
}
Windows Phone 8 apps development with Phone gap cardova
Apache cardova is used to create cross platform mobile applications.
latest version of phonegap from 3.0 is called as cardova.
It is an open source platform and used by the applications of ios, windows phone, android, blackberry and so on.
For working with phone gap applications you have to be familiar with html5 js and css.
Install phonegap from http://phonegap.com/
Install visual studio 2012 windows phone 8 express
http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#d-express-for-windows-phone
Install Node.js
http://nodejs.org/
set the path:
Path settings
computer
properties
advanced settings
Environment Variables
path Edit
append below path after npm;
c:\windows\microsoft.net\framework\v4.03.0000(go this path in your system and paste it)
ok
link to download and install phone gap in windows 8
http://phonegap.com/install/
latest version of phonegap from 3.0 is called as cardova.
It is an open source platform and used by the applications of ios, windows phone, android, blackberry and so on.
For working with phone gap applications you have to be familiar with html5 js and css.
Install phonegap from http://phonegap.com/
http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products#d-express-for-windows-phone
Install Node.js
http://nodejs.org/
set the path:
Path settings
computer
properties
advanced settings
Environment Variables
path Edit
append below path after npm;
c:\windows\microsoft.net\framework\v4.03.0000(go this path in your system and paste it)
ok
link to download and install phone gap in windows 8
http://phonegap.com/install/
npm install -g phonegap
commands to create cordova sample project in command prompt to customize in visual studio 2012
cordova create sample bin.debug.x app1
cd sample
cordova platform add wp8
cordova build wp8
http://docs.phonegap.com/en/3.1.0/cordova_compass_compass.md.html#Compass
http://cordova.apache.org/docs/en/3.1.0/cordova_camera_camera.md.html#Camera
phonegap api references link for phonegap js code and commands to install plugins for both phonegap and cordova
http://docs.phonegap.com/en/3.1.0/cordova_compass_compass.md.html#Compass
Use only cordova javascript codes from the examples if you are working with cordova
http://cordova.apache.org/docs/en/3.1.0/cordova_camera_camera.md.html#Camera
Windows phone 8 apps C# navigation code with sending values from one page to other
Windows phone 8 apps C# navigation code with sending values from one page to other
Here is the code to under a button click to navigate from mainpage.xaml to Plans.xamlIn the below code hello is the text present inside a string planCategory.
the value inside planCategory is sent to the plans.xaml page using the below code.
string planCategory="Airtel,SMSPlan";
NavigationService.Navigate(new Uri("/Plans.xaml?msg=planCategory , UriKind.Relative));
Code in second page ie., Plans.xaml to display text which is sent in the before page
int i=0;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string msg = "";
if (NavigationContext.QueryString.TryGetValue("msg", out msg))
i=msg.IndexOf(',');
PageTitle.Text = msg.Substring (0,i);
PlanCategory.Text = msg.Substring(i+1, msg.Length - i);
}
Reading json data from WebAPI in windows store apps xaml C#
In this example i created a Web api controller named as ConnectController contains a method named as get. It retreives data from SQL Server database table using ADO.NET Code.
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("http://localhost:7239/");
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Limit the max buffer size for the response so we don't get overwhelmed
httpClient.MaxResponseContentBufferSize = 256000;
var response = await httpClient.GetAsync("api/Connect");
response.EnsureSuccessStatusCode(); // Throw on error code.
var users = await response.Content.ReadAsStringAsync();
MessageDialog m = new MessageDialog(users);
m.ShowAsync();
}
Code in WebAPI Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Data.SqlClient;
using System.Data;
namespace ConnectWebAPI.Controllers
{
public class ConnectController : ApiController
{
SqlConnection con = new SqlConnection("Data Source=sudhir-pc;Initial Catalog=Connect;Integrated Security=True");
// GET api/<controller>
public DataTable Get()
{
SqlCommand cmd = new SqlCommand("select * from tbl_register",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0];
}
}}
WebAPI Url and Output
Data
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<DataTable xmlns="http://schemas.datacontract.org/2004/07/System.Data">
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:int" minOccurs="0"/>
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="emailid" type="xs:string" minOccurs="0"/>
<xs:element name="pwd" type="xs:string" minOccurs="0"/>
<xs:element name="phoneno" type="xs:string" minOccurs="0"/>
<xs:element name="stat" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<id>1</id>
<name>sudhir</name>
<emailid>sudhir@gmail.com</emailid>
<pwd>sudhir</pwd>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<id>2</id>
<name>raj</name>
<emailid>raj@gmail.com</emailid>
<pwd>raju</pwd>
</Table>
</NewDataSet>
</diffgr:diffgram>
</DataTable>
Code in windows store app
private async void BtRegister_Click(object sender, RoutedEventArgs e)
{HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("http://localhost:7239/");
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Limit the max buffer size for the response so we don't get overwhelmed
httpClient.MaxResponseContentBufferSize = 256000;
var response = await httpClient.GetAsync("api/Connect");
response.EnsureSuccessStatusCode(); // Throw on error code.
var users = await response.Content.ReadAsStringAsync();
MessageDialog m = new MessageDialog(users);
m.ShowAsync();
}
Output data in Message dialog
MVC Web API Example code in controller ADO.NET
ADO.NET C#.NET code in controller to return table data from sql server database
using System;using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Data.SqlClient;
using System.Data;
namespace ConnectWebAPI.Controllers
{
public class ConnectController : ApiController
{
SqlConnection con = new SqlConnection("Data Source=sudhir-pc;Initial Catalog=Connect;Integrated Security=True");
// GET api/<controller>
public DataTable Get()
{
SqlCommand cmd = new SqlCommand("select * from tbl_register",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0];
}
//Circle k macs store
// GET api/<controller>/5
public string[] Get(int id)
{
SqlCommand cmd = new SqlCommand("select * from tbl_register where sno="+id+"", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
string[] s = new string[4];
for (int i = 0; i < 4; i++)
{
s[i] = ds.Tables[0].Rows[0][i + 1].ToString();
}
return s;
}
// POST api/<controller>
public void Post([FromBody]string value)
{
}
// PUT api/<controller>/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/<controller>/5
public void Delete(int id)
{
}
}
}
URL to retreive data
http://localhost:7239/api/connect/Data
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<DataTable xmlns="http://schemas.datacontract.org/2004/07/System.Data">
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="sno" type="xs:int" minOccurs="0"/>
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="pwd" type="xs:string" minOccurs="0"/>
<xs:element name="phoneno" type="xs:string" minOccurs="0"/>
<xs:element name="stat" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<sno>1</sno>
<name>sudhir</name>
<pwd>sudhi</pwd>
<phoneno>9985323114</phoneno>
<stat>welcome to connect</stat>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<sno>2</sno>
<name>ramu</name>
<pwd>ram</pwd>
<phoneno>9989989989</phoneno>
<stat>hello world</stat>
</Table>
</NewDataSet>
</diffgr:diffgram>
</DataTable>
URL
data
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfstring xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<string>sudhir</string>
<string>sudhi</string>
<string>9985323114</string>
<string>welcome to connect</string>
</ArrayOfstring>
Controller code to insert data into data base table
public int Get(string name,string emailid,string pwd)
{
SqlCommand cmd = new SqlCommand("insert into tbl_register(name,emailid,pwd) values('"+name+"','"+emailid+"','"+pwd+"')", con);
con.Open();
int i = cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
return i;
}
code in webapi.config file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace ConnectWebAPI
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{name}/{emailid}/{pwd}",
defaults: new { name = RouteParameter.Optional, emailid = RouteParameter.Optional, pwd = RouteParameter.Optional }
);
// Uncomment the following line of code to enable query support for actions with an IQueryable or IQueryable<T> return type.
// To avoid processing unexpected or malicious queries, use the validation settings on QueryableAttribute to validate incoming queries.
// For more information, visit http://go.microsoft.com/fwlink/?LinkId=279712.
//config.EnableQuerySupport();
// To disable tracing in your application, please comment out or remove the following line of code
// For more information, refer to: http://www.asp.net/web-api
config.EnableSystemDiagnosticsTracing();
}
}
url and output for the url
data
ASP.NET Web API
Web API is a part of the ASP.NET technology that fits in nicely in Web forms, Web pages and MVC.
It is used to create web based services of any kind.
Same Web API can return both xml format and JSON format data based on the request.
If you request for json content type it will return data in json format and if you request for xml content type it will return in xml format.
Living documentation is available in WebAPI ie., when you update the api automatically the documentation available in views page will be
It is used to create web based services of any kind.
Same Web API can return both xml format and JSON format data based on the request.
If you request for json content type it will return data in json format and if you request for xml content type it will return in xml format.
Living documentation is available in WebAPI ie., when you update the api automatically the documentation available in views page will be
What is cloud computing
Cloud computing is a concept of using resources like hardware and software which are physically existing is other locations through network.
It has advantages like elasticity, metering, automatic deprovisioning, billing flexibilities.
Elasticity : Scale up and down based on the requirement of resources.
Metering: Transaction details are monitored.
Automatic deprovisioning: Release of resources which are not required.
Billing flexibilities: Pay for what you use.
Definition by NIST about cloud computing
Cloud computing is a model for enabling ubiquitous, convenient, on-demand network access to a shared pool of configurable computing resources (eg., networks, servers, storage, applications, and services) that can be rapidly provisioned and released with minimal management effort or service provider interaction. This cloud model promotes availablity and is composed of five essential characterstics, three service models, and four deployment models.
Three service models are IaaS, PaaS, SaaS.
IaaS: Infrastructure as a Service
Hardware resources are provided by the cloud on which we can run client/server applications.
In IaaS cloud provider manages the network, servers and storage resources.
Paas: Platform as a Service
In this cloud provider manages everything including operating systems and middleware also.
We has to manage the data and applications only.
SaaS: Software as a Service
In this cloud provider manages everything including data and applications also.
It has advantages like elasticity, metering, automatic deprovisioning, billing flexibilities.
Elasticity : Scale up and down based on the requirement of resources.
Metering: Transaction details are monitored.
Automatic deprovisioning: Release of resources which are not required.
Billing flexibilities: Pay for what you use.
Definition by NIST about cloud computing
Cloud computing is a model for enabling ubiquitous, convenient, on-demand network access to a shared pool of configurable computing resources (eg., networks, servers, storage, applications, and services) that can be rapidly provisioned and released with minimal management effort or service provider interaction. This cloud model promotes availablity and is composed of five essential characterstics, three service models, and four deployment models.
Three service models are IaaS, PaaS, SaaS.
IaaS: Infrastructure as a Service
Hardware resources are provided by the cloud on which we can run client/server applications.
In IaaS cloud provider manages the network, servers and storage resources.
Paas: Platform as a Service
In this cloud provider manages everything including operating systems and middleware also.
We has to manage the data and applications only.
SaaS: Software as a Service
In this cloud provider manages everything including data and applications also.
Displaying data from sql server database in windows store app using webservice ado.net c# code
SQL Server Database Table
WebService code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Collections;
/// <summary>
/// Summary description for myhotelappwebservice
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class myhotelappwebservice : System.Web.Services.WebService {
public myhotelappwebservice () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public List<object> allhotels()
{
SqlConnection con = new SqlConnection("Data Source=2MPYL1S\\SQLSERVER;Initial Catalog=allhotelsinfodatabase;Integrated Security=True");
string selectquery = "select * from allhotelsdetails";
SqlCommand cmd = new SqlCommand(selectquery, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
int count = ds.Tables[0].Rows.Count;
//arraylist used to store whole table data , each item = row
List<object> a=new List<object> ();
for(int i=0;i<ds.Tables[0].Rows.Count ;i++ )
{
string s = ds.Tables[0].Rows[i][0].ToString()+","+ds.Tables[0].Rows[i][1].ToString()+","+ds.Tables[0].Rows[i][2].ToString()+","+ds.Tables[0].Rows[i][3].ToString()+","+ds.Tables[0].Rows[i][4].ToString()+","+ds.Tables[0].Rows[i][5].ToString()+","+ds.Tables[0].Rows[i][6].ToString();
a.Add(s);
}
return a;
}
}
Output from web service on browser
<?xml version="1.0" encoding="UTF-8"?>
-<ArrayOfAnyType xmlns="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><anyType xsi:type="xsd:string">kanishka,india,andhra pradesh,kadapa,newrtcbusstand,oppositetobusstop,7842119930</anyType><anyType xsi:type="xsd:string">tajkrishna,india,andhra pradesh,hyderabad,banjarahills,begumpet,405869956</anyType><anyType xsi:type="xsd:string">harsha mess,india,andhra pradesh,hyderabad,sr nagar,main road,8977336653</anyType><anyType xsi:type="xsd:string">greenland,india,andhra pradesh,hyderabad,begumpet,lalbungalow,9618326260</anyType></ArrayOfAnyType>
xaml code in windows store app
<Page
x:Class="All_hotels.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:All_hotels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="#F2F2F2" >
<Grid.RowDefinitions>
<RowDefinition Height="120"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Text="My Hotels" Foreground="Blue" FontWeight="Bold" Grid.Row="0" FontSize="60" FontFamily="segoui" Margin="437,10,63,10"/>
<TextBlock Text="At Your Place" Foreground="Blue" FontStyle="Italic" FontFamily="segoui" FontSize="25" Margin="675,80,-675,-8" Grid.RowSpan="2" />
</Grid>
<Button x:Name="btn_search" Grid.Row="2" BorderBrush="Black" FontWeight="Bold" Content="Search" Foreground="White" FontFamily="segoui" FontSize="20" Grid.Row="5" Grid.ColumnSpan="2" Margin="250,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Click="btn_search_Click_1"/>
<!--list view for showing hotels addresses-->
<Grid x:Name="listviewofhotels" Grid.Row="1" Background="#1589FF" Visibility="Collapsed" >
<ListView x:Name="listofhotels" Margin="120,5,20,10" Height="auto" Width="auto" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Hotels List At Your Area" FontSize="30" FontWeight="Bold" FontFamily="segoui" Foreground="White" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="200,0,0,0"/>
<TextBlock Text="Hotel Name:" FontSize="20" FontWeight="Bold" Foreground="White" FontFamily="segoui" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="250,20,0,20"/>
<TextBlock x:Name="txtb_hotelname" Text="{Binding hotelname}" Foreground="White" FontSize="20" FontFamily="segoui" Height="auto" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1"/>
<TextBlock Text="Country:" FontSize="20" FontWeight="Bold" Foreground="White" FontFamily="segoui" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="250,20,0,20"/>
<TextBlock x:Name="txtb_country" Text="{Binding country}" Foreground="white" FontSize="20" FontFamily="segoui" Height="auto" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="2" Grid.Column="1"/>
<TextBlock Text="State:" FontWeight="Bold" FontSize="20" Foreground="White" FontFamily="segoui" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="250,20,0,20"/>
<TextBlock x:Name="txtb_state" Text="{Binding state}" Foreground="white" FontSize="20" FontFamily="segoui" Height="auto" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="3" Grid.Column="1"/>
<TextBlock Text="District:" FontWeight="Bold" FontSize="20" Foreground="White" FontFamily="segoui" Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="250,20,0,20"/>
<TextBlock x:Name="txtb_district" Text="{Binding district}" Foreground="white" FontSize="20" FontFamily="segoui" Height="auto" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="4" Grid.Column="1"/>
<TextBlock Text="Area:" FontWeight="Bold" FontSize="20" Foreground="White" FontFamily="segoui" Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="250,20,0,20"/>
<TextBlock x:Name="txtb_Area" Text="{Binding area}" Foreground="white" FontSize="20" FontFamily="segoui" Height="auto" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="5" Grid.Column="1"/>
<TextBlock Text="street:" FontWeight="Bold" FontSize="20" Foreground="White" FontFamily="segoui" Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="250,20,0,20"/>
<TextBlock x:Name="txtb_street" Text="{Binding street}" Foreground="white" FontSize="20" FontFamily="segoui" Height="auto" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="6" Grid.Column="1"/>
<TextBlock Text="Contact No:" FontWeight="Bold" FontSize="20" Foreground="White" FontFamily="segoui" Grid.Row="7" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="250,20,0,20"/>
<TextBlock x:Name="txtb_contactno" Text="{Binding contactno}" Foreground="white" FontSize="20" FontFamily="segoui" Height="auto" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="7" Grid.Column="1"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
<Page.BottomAppBar>
<AppBar x:Name="bottomappbar" Padding="10,10,10,0">
<Grid>
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button x:Name="btn_home" Margin="300,10,0,0" Click="btn_home_Click_1" Style="{StaticResource HomeAppBarButtonStyle }"/>
<Button x:Name="btn_user" Margin="50,10,0,0" Click="btn_user_Click_1" Style="{StaticResource SearchAppBarButtonStyle}"/>
<Button x:Name="btn_hotel" Margin="50,10,0,0" Click="btn_hotel_Click_1" Style="{StaticResource SaveAppBarButtonStyle}" />
</StackPanel>
</Grid>
</AppBar>
</Page.BottomAppBar>
</Page>
c# code in mainpage.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Collections;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Windows;
using All_hotels.myhotelappwebservice;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace All_hotels
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
grid_myhotelinfo.Visibility = Visibility.Visible;
}
//user search information enabled on button click user
private void btn_user_Click_1(object sender, RoutedEventArgs e)
{
if (grid_hotelinfo.Visibility == Visibility.Visible)
{
grid_hotelinfo.Visibility = Visibility.Collapsed;
grid_userinfo.Visibility = Visibility.Visible;
}
else if(grid_myhotelinfo.Visibility==Visibility.Visible)
{
grid_myhotelinfo.Visibility = Visibility.Collapsed;
grid_userinfo.Visibility = Visibility.Visible;
}
else
grid_userinfo.Visibility = Visibility.Visible;
}
//hotel information enabled on button click hotel
private void btn_hotel_Click_1(object sender, RoutedEventArgs e)
{
if (grid_userinfo.Visibility == Visibility.Visible)
{
grid_userinfo.Visibility = Visibility.Collapsed;
grid_hotelinfo.Visibility = Visibility.Visible;
}
else if(grid_myhotelinfo.Visibility==Visibility.Visible)
{
grid_myhotelinfo.Visibility=Visibility.Collapsed;
grid_hotelinfo.Visibility = Visibility.Visible;
}
else
grid_hotelinfo.Visibility = Visibility.Visible;
}
//my hotel app information details will be displayed on clicking home button
private void btn_home_Click_1(object sender, RoutedEventArgs e)
{
if (grid_hotelinfo.Visibility == Visibility.Visible)
{
grid_hotelinfo.Visibility = Visibility.Collapsed;
grid_myhotelinfo.Visibility = Visibility.Visible;
}
else if (grid_userinfo.Visibility == Visibility.Visible)
{
grid_userinfo.Visibility = Visibility.Collapsed;
grid_myhotelinfo.Visibility = Visibility.Visible;
}
else
grid_myhotelinfo.Visibility = Visibility.Visible;
}
//hotel information will be saved in database
private void btn_savehotelinfo_Click_1(object sender, RoutedEventArgs e)
{
string hotelname = txt_hotelname.Text,
country = txt_country.Text,
state = txt_state.Text,
district = txt_district.Text,
Area = txt_Area.Text,
street = txt_street.Text;
long contactno=Convert.ToInt64(txt_contactno.Text);
myhotelappwebserviceSoapClient obj = new myhotelappwebserviceSoapClient();
obj.savehotelinfoAsync(hotelname,country,state,district,Area,street,contactno);
}
//user searched hotels list in that area will be displayed
private async void btn_search_Click_1(object sender, RoutedEventArgs e)
{
object[] a;
if (grid_userinfo.Visibility == Visibility.Visible)
{
grid_userinfo.Visibility = Visibility.Collapsed;
listviewofhotels.Visibility = Visibility.Visible;
}
myhotelappwebserviceSoapClient obj = new myhotelappwebserviceSoapClient();
a = await obj.allhotelsAsync();
string[] rowarr = new string[a.Length];
for (int i = 0; i < a.Length; i++)
{
string s = a[i].ToString();
rowarr = s.Split(',');
//rowarr contains a row data
for (int j = 0; j < rowarr.Length; )
{
Hotels h = new Hotels();
h.hotelname = rowarr[j];
j++;
h.country = rowarr[j];
j++;
h.state = rowarr[j];
j++;
h.district = rowarr[j];
j++;
h.area = rowarr[j];
j++;
h.street = rowarr[j];
j++;
h.contactno = rowarr[j].ToString();
j++;
listofhotels.Items.Add(h);
}
}
}
}
public class Hotels
{
public string hotelname { set; get; }
public string country { set; get; }
public string state { set; get; }
public string district { set; get; }
public string area { set; get; }
public string street { set; get; }
public string contactno { set; get; }
}
}