Jade_1 0 Newbie Poster

Hi,

Sorry to be a pain but I've become a little stuck. I've created a Windows Form program that intakes data from a text file, adds a timestamp to each line of data and then allows for it to be sampled or looked at given a particular timestamp. I now want to change it from a windows form to a web service. Can anyone suggest the best way to do this? I've worked with web services before but not much and I'm not entirely sure what i'm doing with the code so any help or suggestions would be cool. The code of my form is below;

using System;  
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace Patient_Simulator
{
    public partial class frm_patient_simulator : Form
    {
        private string filePath = AppDomain.CurrentDomain.BaseDirectory + "data.txt";
        private static List<vitalSigns> vitalSignData = new List<vitalSigns>();

        /// <summary>
        /// Keeps the count of samples taken, starts from 0;
        /// </summary>
        private static int lastReadCount = 0;


        public class vitalSigns
        {
            public int HR { get; set; }
            public int BP { get; set; }
            public decimal Temp { get; set; }
            public int RR { get; set; }
            public int SPo2 { get; set; }
        }

        private void ChangeStatus(string message)
        {
            statusStrip_lbl_status.Text = message;
        }


        public frm_patient_simulator()
        {
            InitializeComponent();
        }

        private void frm_patient_simulator_Load(object sender, EventArgs e)
        {
            LoadDataIntoMemory(filePath);
        }

        private void LoadDataIntoMemory(string filePath)
        {
            var allData = File.ReadAllLines(filePath).Where(s => s.Trim() != string.Empty).Skip(1).Select(x=>x.Split('\t')).ToList();

            //var kjhl = allData.Select(x => x.Split('\t')).ToList();
            vitalSignData = allData
                .Select(x => 
                    new vitalSigns
            {
                HR = Convert.ToInt32(x[0]),
                BP = Convert.ToInt32(x[1]),
                Temp = Convert.ToDecimal(x[2]),
                RR = Convert.ToInt32(x[3]),
                SPo2 = Convert.ToInt32(x[4])
            }).ToList();  // LINQ to Objects used here.

        }

        private void btn_play_pause_Click(object sender, EventArgs e)
        {
            tmr_SI.Enabled = !tmr_SI.Enabled;
        }


        private void tmr_SI_Tick(object sender, EventArgs e)
        {
            var listViewItem = new ListViewItem();
            listViewItem.Text = DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss");
            listViewItem.SubItems.Add(vitalSignData[lastReadCount].HR.ToString(CultureInfo.InvariantCulture));
            listViewItem.SubItems.Add(vitalSignData[lastReadCount].BP.ToString(CultureInfo.InvariantCulture));
            listViewItem.SubItems.Add(vitalSignData[lastReadCount].Temp.ToString(CultureInfo.InvariantCulture));
            listViewItem.SubItems.Add(vitalSignData[lastReadCount].RR.ToString(CultureInfo.InvariantCulture));
            listViewItem.SubItems.Add(vitalSignData[lastReadCount].SPo2.ToString(CultureInfo.InvariantCulture));
            lastReadCount++;
            listView_vital_data.Items.Add(listViewItem);
            listView_vital_data.Items[listView_vital_data.Items.Count - 1].EnsureVisible();
        }

        private void btn_reset_restart_Click(object sender, EventArgs e)
        {
            lastReadCount = 0;
            ChangeStatus("Counter Reset!");

        }

        private void btn_set_SI_Click(object sender, EventArgs e)
        {
            var SI = 0;
            if (!int.TryParse(txt_SI.Text, out SI))
            {
                MessageBox.Show("Please enter a numberic value for Sampling Interval, in Seconds!", "Invalid Value!",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_SI.Text = "5";
                txt_SI.Focus();
                return;
            }
            if (SI == 0)
            {
                MessageBox.Show("Sampling Interval can not be zero, enter a numberic value, in Seconds!", "Invalid Value!",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_SI.Text = "5";
                txt_SI.Focus();
            }
            else
            {
                ChangeStatus(string.Format("SI changed from {0} to {1} seconds.",tmr_SI.Interval/1000,txt_SI.Text));
                tmr_SI.Interval = SI*1000;
            }


        }



    }
}

Can anyone suggest the best way to turn this into a web service? I want it to still be able to read the data, add a timestamp to the data in the file and be able to sample it given a particular time range. I'll need the service to accept either stringified raw data, or serialised vital sign data objects from the client but I'm unsure how to do it with the web service. Any help would be amazing. Thanks in advance! ;)