using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
//using System.Convert;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data.Sql;
//using localhost_service;
namespace Anadigics_WebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
//[WebService(Namespace = "http://localhost:2396/WebForm1.aspx")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// 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 Service1 : System.Web.Services.WebService
{
[WebMethod]
public string ConnectionToDb()
{
SqlConnection sqlCon =
new SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
"User ID=logon;Password=logon;" +
"Trusted_Connection=False");
sqlCon.Open();
if (sqlCon.State == System.Data.ConnectionState.Open)
return "open";
else
{
return "Closed";
}
}
/*
[WebMethod]
public void ClientAdd(string compName, string description,
string ip, string Network)
{
SqlCommand sqlCmd;
SqlConnection sqlCon = new
SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
"User ID=logon;Password=logon;" +
"Trusted_Connection=False");
sqlCon.Open();
if (sqlCon.State == System.Data.ConnectionState.Open)
{
sqlCmd = new SqlCommand(String.Format("INSERT Into Clients (ClientName," +
"ClientDescription,IP_Address, Network)" +
" values('{0}','{1}','{2}','{3}')",
compName, description, ip, Network), sqlCon);
sqlCmd.ExecuteNonQuery();
}
}
*/
[WebMethod]
public string xmlToDb(string xmlStringIn)
{
SqlCommand sqlCmd;
//SqlDataReader sqlRdr;
SqlConnection sqlCon =
new SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
"User ID=logon;Password=logon;" +
"Trusted_Connection=False");
sqlCon.Open();
sqlCmd =
new SqlCommand
(string.
Format("INSERT INTO xmlString (inXmlString)" +
"values('{0}')",xmlStringIn), sqlCon);
return returnList();
}
[WebMethod]
public string returnList()
{
SqlCommand sqlCmd;
//SqlDataReader sqlRdr;
SqlConnection sqlCon =
new SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
"User ID=logon;Password=logon;" +
"Trusted_Connection=False");
sqlCon.Open();
string name = null;
if (sqlCon.State == System.Data.ConnectionState.Open)
{
sqlCmd =
new SqlCommand
(string.
Format("SELECT DISTINCT FROM xmlString"), sqlCon
);
//sqlRdr = sqlCmd.ExecuteReader();
name = sqlCmd.ExecuteScalar().ToString();
}
return name;
}
}
}
/*
[WebMethod]
public string TESTING()
{
info information = new
info("information","installer","None","john","COMPNAME",630,250,11432);
printStructInfo(information);
return "TESTING";
}
//[WebMethod]
public string printStructInfo(info infoOne)
{
Console.WriteLine(infoOne.type);
Console.WriteLine(infoOne.time);
Console.WriteLine(infoOne.source);
Console.WriteLine(infoOne.category);
Console.WriteLine(infoOne.user);
Console.WriteLine(infoOne.computer);
return infoOne.type;
}
}
//a struct loosely modeled off of event viewer logs.
public struct info
{
public string type, source, category, user, computer;
public int date, time, eventNum;
public info(string typeIn, string sourceIn, string categoryIn, string userIn,
string computerIn, int dateIn, int timeIn, int eventNumIn)
{
type = typeIn;
source = sourceIn;
category = categoryIn;
user = userIn;
computer = computerIn;
date = dateIn;
time = timeIn;
eventNum = eventNumIn;
}
*/
/*
private string Server = "DDMGCFC1\\SQLEXPRESS";
private string Username = "MIDGARD\\Mmich1902";
private string Password = "soccer2190";
private string Database = "WebServDB.dbo";
*/
/* Two sqlConnection strings that I tried...Neither worked.
*
*
* "Data Source=DDMGCFC1\\SQLEXPRESS;Initial Catalog=WebServDB.dbo;UserId=MIDGARD\Mmich1902;Password=soccer2190;"
* "Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB.dbo;UserID=MIDGARD\\Mmich1902;Password=soccer2190;Trusted_Connection=False"
*/
/*SqlConnection sqlCon = new
SqlConnection("Data Source=" + Server + ";" +
"Database=" + Database + ";" +
"User ID=" + Username + ";" +
"Password=" + Password + ";" +
"Trusted_Connection=False");
//"Initial Catalog=" + Database + ";");
*/
using System;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Web;
namespace WindowsFormsApplication1
{
class FormGUI : Form
{
TextBox urlBox =
new TextBox
();
TextBox xmlString =
new TextBox
();
//TextBox description = new TextBox();
//TextBox IP = new TextBox();
//TextBox Network = new TextBox();
Button connect =
new Button
();
Button sendXML =
new Button
();
TextBox returnName =
new TextBox
();
Button returnNameButton =
new Button
();
Anadigics_WebService.
Service1 log =
new Anadigics_WebService.
Service1();
public FormGUI()
{
this.
Size =
new Size
(400,
250);
this.Text = ".:WEBSERVICE TEST HARNESS:.";
string pad = this.Text;
pad = pad.PadLeft(40);
this.Text = pad;
string imageString = "C:\\Documents and Settings\\Mmich1902\\" +
"My Documents\\Visual Studio 2008\\Projects\\" +
"WindowsFormsApplication1\\WindowsFormsApplication1\\bg1.jpg";
Image bgImage =
new Bitmap
(imageString
);
this.BackgroundImage = bgImage;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
urlBox.Text = "Connection Status";
urlBox.
Size =
new Size
(250,
20);
urlBox.MaxLength = 800;
urlBox.
Location =
new Point
(20,
20);
urlBox.ReadOnly = true;
xmlString.Text = "Please enter the comp name";
xmlString.
Size =
new Size
(250,
20);
xmlString.MaxLength = 800;
xmlString.
Location =
new Point
(20,
50);
connect.Text = "Connect";
connect.
Size =
new Size
(80,
20);
connect.
Click +=
new System.
EventHandler(this.
OpenConToWebService);
connect.
Location =
new Point
(280,
20);
sendXML.Text = "Send XML";
sendXML.
Size =
new Size
(80,
20);
sendXML.
Click +=
new System.
EventHandler(this.
SendXMLToWebService);
sendXML.
Location =
new Point
(280,
140);
returnName.Text = "Return box for compName";
returnName.
Size =
new Size
(250,
20);
returnName.MaxLength = 800;
returnName.
Location =
new Point
(20,
200);
returnNameButton.Text = "GET NAME";
returnNameButton.
Size =
new Size
(80,
20);
returnNameButton.
Click +=
new System.
EventHandler(this.
ReturnCompName);
returnNameButton.
Location =
new Point
(280,
200);
Controls.Add(sendXML);
Controls.Add(urlBox);
Controls.Add(xmlString);
//Controls.Add(description);
//Controls.Add(IP);
//Controls.Add(Network);
Controls.Add(connect);
Controls.Add(returnName);
Controls.Add(returnNameButton);
}
public void SendXMLToWebService(object sender, System.EventArgs e)
{
string xmlStingToServ = xmlString.ToString();
/*string descriptionS = description.ToString();
string IPS = IP.ToString();
string networkS = Network.ToString();
*/
log.xmlAdd(xmlStringToServ);
}
public void OpenConToWebService(object sender, System.EventArgs e)
{
if (log.ConnectionToDb().ToString() == "open" || log.ConnectionToDb().ToString() == "Open")
{
urlBox.Text = "OPEN CONNECTION";
}
else
urlBox.Text = "NO Connection";
}
public void ReturnCompName(object sender, System.EventArgs e)
{
if (log.returnList() != null)
{
returnName.Text = log.returnList();
returnName.ReadOnly = true;
}
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FormGUI form1 =
new FormGUI
();
form1.
Size =
new Size
(800,
800);
Application.
Run(new FormGUI
());
//Anadigics_WebService.ConnectoinToDbCompletedEventArgs();
}
}
}
/*static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FormGUI form1 = new FormGUI();
Application.Run(new FormGUI());
//FormGUI form1 = new FormGUI();
}*/
CREATE DATABASE Customers
CREATE TABLE CustomerID (
First_Name varchar(20),
Last_Name varchar(32),
Age smallint,
Social_Security_Number int,
)
INSERT INTO CustomerID
(First_Name,Last_name,age,Social_Security_Number)
values ('Bob','Johnson',33,5555)
CREATE TABLE Shipping_Address (
House_# int,
Street_Name varchar(30),
Zip_code int,
Phone_# int,
Social_Security_Number int,
)
INSERT INTO Shipping_Address
(House_#,Street_Name,Zip_code,phone_#,Social_Security_Number)
Values (5,'King Rd.',78560,908-853-8888,5555)
CREATE TABLE Billing_Info (
Credit_Card_# int,
Expiration_Date int,
Security_Code int,
Social_Security_Number int,
)
INSERT INTO Billing_Info
(Credit_Card_#,Expiration_Date,Security_Code,Social_Security_Number)
Values (111111,3/3/09,234,5555)
SELECT * FROM Billing_Info