1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. //using System.Convert;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Services;
  10. using System.Web.Services.Protocols;
  11. using System.Xml.Linq;
  12. using System.Data.SqlClient;
  13. using System.Data.Sql;
  14. //using localhost_service;
  15.  
  16.  
  17. namespace Anadigics_WebService
  18. {
  19. /// <summary>
  20. /// Summary description for Service1
  21. /// </summary>
  22. [WebService(Namespace = "http://tempuri.org/")]
  23. //[WebService(Namespace = "http://localhost:2396/WebForm1.aspx")]
  24. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  25. [ToolboxItem(false)]
  26. // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
  27. // [System.Web.Script.Services.ScriptService]
  28. public class Service1 : System.Web.Services.WebService
  29. {
  30.  
  31.  
  32. [WebMethod]
  33. public string ConnectionToDb()
  34. {
  35. SqlConnection sqlCon = new
  36. SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
  37. "User ID=logon;Password=logon;" +
  38. "Trusted_Connection=False");
  39.  
  40. sqlCon.Open();
  41.  
  42. if (sqlCon.State == System.Data.ConnectionState.Open)
  43. return "open";
  44. else
  45. {
  46. return "Closed";
  47. }
  48. }
  49.  
  50.  
  51. /*
  52.   [WebMethod]
  53.   public void ClientAdd(string compName, string description,
  54.   string ip, string Network)
  55.   {
  56.  
  57.   SqlCommand sqlCmd;
  58.  
  59.   SqlConnection sqlCon = new
  60.   SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
  61.   "User ID=logon;Password=logon;" +
  62.   "Trusted_Connection=False");
  63.  
  64.   sqlCon.Open();
  65.  
  66.   if (sqlCon.State == System.Data.ConnectionState.Open)
  67.   {
  68.   sqlCmd = new SqlCommand(String.Format("INSERT Into Clients (ClientName," +
  69.   "ClientDescription,IP_Address, Network)" +
  70.   " values('{0}','{1}','{2}','{3}')",
  71.   compName, description, ip, Network), sqlCon);
  72.   sqlCmd.ExecuteNonQuery();
  73.   }
  74.  
  75.   }
  76.   */
  77.  
  78.  
  79. [WebMethod]
  80. public string xmlToDb(string xmlStringIn)
  81. {
  82. SqlCommand sqlCmd;
  83. //SqlDataReader sqlRdr;
  84. SqlConnection sqlCon = new
  85. SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
  86. "User ID=logon;Password=logon;" +
  87. "Trusted_Connection=False");
  88.  
  89. sqlCon.Open();
  90.  
  91. sqlCmd = new SqlCommand(string.Format("INSERT INTO xmlString (inXmlString)" +
  92. "values('{0}')",xmlStringIn), sqlCon);
  93.  
  94. return returnList();
  95. }
  96.  
  97. [WebMethod]
  98. public string returnList()
  99. {
  100. SqlCommand sqlCmd;
  101. //SqlDataReader sqlRdr;
  102. SqlConnection sqlCon = new
  103. SqlConnection("Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB;" +
  104. "User ID=logon;Password=logon;" +
  105. "Trusted_Connection=False");
  106.  
  107. sqlCon.Open();
  108.  
  109. string name = null;
  110.  
  111. if (sqlCon.State == System.Data.ConnectionState.Open)
  112. {
  113.  
  114. sqlCmd = new SqlCommand(string.Format("SELECT DISTINCT FROM xmlString"), sqlCon);
  115. //sqlRdr = sqlCmd.ExecuteReader();
  116.  
  117. name = sqlCmd.ExecuteScalar().ToString();
  118. }
  119.  
  120. return name;
  121.  
  122. }
  123.  
  124.  
  125.  
  126.  
  127. }
  128.  
  129. }
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. /*
  153.  
  154.   [WebMethod]
  155.   public string TESTING()
  156.   {
  157.   info information = new
  158.   info("information","installer","None","john","COMPNAME",630,250,11432);
  159.   printStructInfo(information);
  160.  
  161.   return "TESTING";
  162.   }
  163.  
  164.  
  165.  
  166.   //[WebMethod]
  167.   public string printStructInfo(info infoOne)
  168.   {
  169.  
  170.   Console.WriteLine(infoOne.type);
  171.   Console.WriteLine(infoOne.time);
  172.   Console.WriteLine(infoOne.source);
  173.   Console.WriteLine(infoOne.category);
  174.   Console.WriteLine(infoOne.user);
  175.   Console.WriteLine(infoOne.computer);
  176.  
  177.   return infoOne.type;
  178.  
  179.   }
  180.  
  181.   }
  182.  
  183.   //a struct loosely modeled off of event viewer logs.
  184.   public struct info
  185.   {
  186.   public string type, source, category, user, computer;
  187.   public int date, time, eventNum;
  188.  
  189.  
  190.   public info(string typeIn, string sourceIn, string categoryIn, string userIn,
  191.   string computerIn, int dateIn, int timeIn, int eventNumIn)
  192.   {
  193.   type = typeIn;
  194.   source = sourceIn;
  195.   category = categoryIn;
  196.   user = userIn;
  197.   computer = computerIn;
  198.   date = dateIn;
  199.   time = timeIn;
  200.   eventNum = eventNumIn;
  201.   }
  202.  
  203. */
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211. /*
  212.  
  213.   private string Server = "DDMGCFC1\\SQLEXPRESS";
  214.   private string Username = "MIDGARD\\Mmich1902";
  215.   private string Password = "soccer2190";
  216.   private string Database = "WebServDB.dbo";
  217.  
  218. */
  219.  
  220. /* Two sqlConnection strings that I tried...Neither worked.
  221.   *
  222.   *
  223.   * "Data Source=DDMGCFC1\\SQLEXPRESS;Initial Catalog=WebServDB.dbo;UserId=MIDGARD\Mmich1902;Password=soccer2190;"
  224.   * "Server=DDMGCFC1\\SQLEXPRESS;Database=WebServDB.dbo;UserID=MIDGARD\\Mmich1902;Password=soccer2190;Trusted_Connection=False"
  225.   */
  226.  
  227.  
  228.  
  229.  
  230.  
  231. /*SqlConnection sqlCon = new
  232.   SqlConnection("Data Source=" + Server + ";" +
  233.   "Database=" + Database + ";" +
  234.   "User ID=" + Username + ";" +
  235.   "Password=" + Password + ";" +
  236.   "Trusted_Connection=False");
  237.   //"Initial Catalog=" + Database + ";");
  238. */
  239.  
  240.  
  241.  
  242.  
  243. using System;
  244. using System.Drawing;
  245. using System.Collections.Generic;
  246. using System.Linq;
  247. using System.Windows.Forms;
  248. using System.Web;
  249.  
  250. namespace WindowsFormsApplication1
  251. {
  252.  
  253. class FormGUI : Form
  254. {
  255. TextBox urlBox = new TextBox();
  256. TextBox xmlString = new TextBox();
  257. //TextBox description = new TextBox();
  258. //TextBox IP = new TextBox();
  259. //TextBox Network = new TextBox();
  260. Button connect = new Button();
  261. Button sendXML = new Button();
  262. TextBox returnName = new TextBox();
  263. Button returnNameButton = new Button();
  264.  
  265.  
  266. Anadigics_WebService.Service1 log = new Anadigics_WebService.Service1();
  267. public FormGUI()
  268. {
  269.  
  270.  
  271.  
  272. this.Size = new Size(400, 250);
  273. this.Text = ".:WEBSERVICE TEST HARNESS:.";
  274. string pad = this.Text;
  275. pad = pad.PadLeft(40);
  276. this.Text = pad;
  277. string imageString = "C:\\Documents and Settings\\Mmich1902\\" +
  278. "My Documents\\Visual Studio 2008\\Projects\\" +
  279. "WindowsFormsApplication1\\WindowsFormsApplication1\\bg1.jpg";
  280. Image bgImage = new Bitmap(imageString);
  281. this.BackgroundImage = bgImage;
  282.  
  283. this.FormBorderStyle = FormBorderStyle.FixedDialog;
  284. this.MaximizeBox = false;
  285.  
  286. urlBox.Text = "Connection Status";
  287. urlBox.Size = new Size(250, 20);
  288. urlBox.MaxLength = 800;
  289. urlBox.Location = new Point(20, 20);
  290. urlBox.ReadOnly = true;
  291.  
  292.  
  293.  
  294. xmlString.Text = "Please enter the comp name";
  295. xmlString.Size = new Size(250, 20);
  296. xmlString.MaxLength = 800;
  297. xmlString.Location = new Point(20, 50);
  298.  
  299.  
  300. connect.Text = "Connect";
  301. connect.Size = new Size(80, 20);
  302. connect.Click += new System.EventHandler(this.OpenConToWebService);
  303. connect.Location = new Point(280, 20);
  304.  
  305. sendXML.Text = "Send XML";
  306. sendXML.Size = new Size(80, 20);
  307. sendXML.Click += new System.EventHandler(this.SendXMLToWebService);
  308. sendXML.Location = new Point(280, 140);
  309.  
  310.  
  311. returnName.Text = "Return box for compName";
  312. returnName.Size = new Size(250, 20);
  313. returnName.MaxLength = 800;
  314. returnName.Location = new Point(20, 200);
  315.  
  316. returnNameButton.Text = "GET NAME";
  317. returnNameButton.Size = new Size(80, 20);
  318. returnNameButton.Click += new System.EventHandler(this.ReturnCompName);
  319. returnNameButton.Location = new Point(280, 200);
  320.  
  321.  
  322. Controls.Add(sendXML);
  323. Controls.Add(urlBox);
  324. Controls.Add(xmlString);
  325. //Controls.Add(description);
  326. //Controls.Add(IP);
  327. //Controls.Add(Network);
  328. Controls.Add(connect);
  329. Controls.Add(returnName);
  330. Controls.Add(returnNameButton);
  331.  
  332. }
  333.  
  334. public void SendXMLToWebService(object sender, System.EventArgs e)
  335. {
  336. string xmlStingToServ = xmlString.ToString();
  337. /*string descriptionS = description.ToString();
  338.   string IPS = IP.ToString();
  339.   string networkS = Network.ToString();
  340.   */
  341. log.xmlAdd(xmlStringToServ);
  342.  
  343. }
  344.  
  345.  
  346. public void OpenConToWebService(object sender, System.EventArgs e)
  347. {
  348.  
  349. if (log.ConnectionToDb().ToString() == "open" || log.ConnectionToDb().ToString() == "Open")
  350. {
  351. urlBox.Text = "OPEN CONNECTION";
  352. }
  353. else
  354. urlBox.Text = "NO Connection";
  355.  
  356. }
  357.  
  358. public void ReturnCompName(object sender, System.EventArgs e)
  359. {
  360. if (log.returnList() != null)
  361. {
  362. returnName.Text = log.returnList();
  363. returnName.ReadOnly = true;
  364. }
  365.  
  366.  
  367.  
  368. }
  369.  
  370. [STAThread]
  371. static void Main()
  372. {
  373.  
  374. Application.EnableVisualStyles();
  375. Application.SetCompatibleTextRenderingDefault(false);
  376. FormGUI form1 = new FormGUI();
  377. form1.Size = new Size(800, 800);
  378.  
  379. Application.Run(new FormGUI());
  380.  
  381.  
  382. //Anadigics_WebService.ConnectoinToDbCompletedEventArgs();
  383.  
  384.  
  385. }
  386.  
  387. }
  388.  
  389.  
  390. }
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405. /*static class Program
  406. {
  407.   /// <summary>
  408.   /// The main entry point for the application.
  409.   /// </summary>
  410.   ///
  411.  
  412.  
  413.   [STAThread]
  414.   static void Main()
  415.   {
  416.  
  417.  
  418.   Application.EnableVisualStyles();
  419.   Application.SetCompatibleTextRenderingDefault(false);
  420.   FormGUI form1 = new FormGUI();
  421.  
  422.   Application.Run(new FormGUI());
  423.  
  424.   //FormGUI form1 = new FormGUI();
  425.  
  426.   }*/
  427.  
  428.  
  429.  
  430. CREATE DATABASE Customers
  431.  
  432.  
  433.  
  434. CREATE TABLE CustomerID (
  435.  
  436. First_Name varchar(20),
  437. Last_Name varchar(32),
  438. Age smallint,
  439. Social_Security_Number int,
  440.  
  441. )
  442. INSERT INTO CustomerID
  443.  
  444. (First_Name,Last_name,age,Social_Security_Number)
  445. values ('Bob','Johnson',33,5555)
  446.  
  447.  
  448.  
  449.  
  450. CREATE TABLE Shipping_Address (
  451.  
  452. House_# int,
  453. Street_Name varchar(30),
  454. Zip_code int,
  455. Phone_# int,
  456. Social_Security_Number int,
  457.  
  458. )
  459.  
  460. INSERT INTO Shipping_Address
  461.  
  462. (House_#,Street_Name,Zip_code,phone_#,Social_Security_Number)
  463. Values (5,'King Rd.',78560,908-853-8888,5555)
  464.  
  465.  
  466.  
  467. CREATE TABLE Billing_Info (
  468.  
  469. Credit_Card_# int,
  470. Expiration_Date int,
  471. Security_Code int,
  472. Social_Security_Number int,
  473. )
  474.  
  475.  
  476. INSERT INTO Billing_Info
  477.  
  478. (Credit_Card_#,Expiration_Date,Security_Code,Social_Security_Number)
  479. Values (111111,3/3/09,234,5555)
  480.  
  481.  
  482. SELECT * FROM Billing_Info