Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.Services;
- [WebService(Namespace = "http://LaundryBookingWebService.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- [System.Web.Script.Services.ScriptService]
- public class LaundryBookingWebService : System.Web.Services.WebService
- {
- public LaundryBookingWebService()
- {
- }
- private SqlConnection connection = new SqlConnection("Data Source=LAPTOP-5EDFEDTV\\WACKU;Initial Catalog=LaundryBookingApp;Integrated Security=True");
- //--------GET Residents FROM SQL-DATABASE------------
- [WebMethod(Description = "Returns Residents", EnableSession = true)]
- public DataSet GetResidents()
- {
- try
- {
- connection.Open();
- SqlDataAdapter adapter = new SqlDataAdapter("select * from Residents", connection);
- DataSet ResidentDS = new DataSet();
- adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- adapter.Fill(ResidentDS, "Residents");
- connection.Close();
- return ResidentDS;
- }
- catch (Exception e)
- {
- return null;
- }
- }
- //--------GET Bookings FROM SQL-DATABASE------------
- [WebMethod(Description = "Returns Bookings", EnableSession = true)]
- public DataSet GetBookings()
- {
- try
- {
- connection.Open();
- SqlDataAdapter adapter = new SqlDataAdapter("select * from Bookings", connection);
- DataSet BookingDS = new DataSet();
- adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- adapter.Fill(BookingDS, "Residents");
- connection.Close();
- return BookingDS;
- }
- catch (Exception e)
- {
- return null;
- }
- }
- //--------GET LaundryRooms FROM SQL-DATABASE------------
- [WebMethod(Description = "Returns LaundryRooms", EnableSession = true)]
- public DataSet GetLaundryRooms()
- {
- try
- {
- connection.Open();
- SqlDataAdapter adapter = new SqlDataAdapter("select * from LaundryRooms", connection);
- DataSet LaundryRoomDS = new DataSet();
- adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- adapter.Fill(LaundryRoomDS, "LaundryRooms");
- connection.Close();
- return LaundryRoomDS;
- }
- catch (Exception e)
- {
- return null;
- }
- }
- [WebMethod(Description = "Get file content", EnableSession = true)]
- public string ReadFile(string FileName)
- {
- try
- {
- string strdocPath;
- strdocPath = @"C:\Users\Jacob\Desktop\" + FileName;
- strdocPath += ".txt";
- string content = File.ReadAllText(strdocPath);
- return content;
- }
- catch (Exception e)
- {
- return e.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement