private void AddNewRecord(string data)
        {
            //UploadFile(fileName);
            WebService.ECGServiceClient WS = new WebService.ECGServiceClient();
            string recordID = WS.generateRecordID(Patient.ID);

            Record newRecord = new Record(Patient.DoctorName, Patient.DoctorID, DateTime.Now, recordID, this.Flag, data);
            Patient.AddRecord(newRecord);

            this.Updated = true;
        }
        private void UploadFile(string filename)
        {
            try
            {
                // get the exact file name from the path
                String strFile = System.IO.Path.GetFileName(filename);

                // get the file information form the selected file
                FileInfo fInfo = new FileInfo(filename);

                //Uploader.FileUploaderSoapClient srv = new Uploader.FileUploaderSoapClient();
                //TestUploader.FileServiceLocal.FileServiceClient fsl = new FileServiceLocal.FileServiceClient();

                // get the length of the file to see if it is possible
                // to upload it (with the standard 4 MB limit)
                long numBytes = fInfo.Length;
                double dLen = Convert.ToDouble(fInfo.Length / 1000000);

                // Default limit of 4 MB on web server
                // have to change the web.config to if
                // you want to allow larger uploads
                if (dLen < 4)
                {
                    // set up a file stream and binary reader for the
                    // selected file
                    FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    BinaryReader br = new BinaryReader(fStream);

                    // convert the file to a byte array
                    byte[] data = br.ReadBytes((int)numBytes);
                    br.Close();

                    // get new record id
                    WebService.ECGServiceClient WS = new WebService.ECGServiceClient();
                    string recordID = WS.generateRecordID(Patient.ID);

                    // pass the byte array (file) and file name to the web service
                    //string sTmp = srv.UploadFile(data, strFile);
                    //string sTmp = srv.UploadECGRecord(data, strFile, recordID, Patient.ID, DateTime.Now);

                    fStream.Close();
                    fStream.Dispose();

                    // this will always say OK unless an error occurs,
                    // if an error occurs, the service returns the error message
                    //MessageBox.Show("File Upload Status: " + status.ToString(), "File Upload");
              //      MessageBox.Show("File Upload Status: " + sTmp.ToString(), "File Upload");
                }
                else
                {
                    // Display message if the file was too large to upload
                    MessageBox.Show("The file selected exceeds the size limit for uploads.", "File Size");
                }
            }
            catch (Exception ex)
            {
                // display an error message to the user
                MessageBox.Show(ex.Message.ToString(), "Upload Error");
            }
        }
Ejemplo n.º 3
0
        private void Record(object sender, EventArgs e)
        {
            if (state == state.Realtime)
            {
                StartRecordPoint = Data[0].Count;
                state = state.Record;

                RecordTime = new DateTime(2012, 1, 1, 0, 0, 0);
                RecordTimer.Enabled = true;

                this.StartRecordButton.Image = global::ECGWorkStation.Properties.Resources.square_black;
            }
            else if (state == state.Record)
            {
                // changer state
                RecordTimer.Stop();
                RecordTimer.Enabled = false;

                this.StartRecordButton.Image = global::ECGWorkStation.Properties.Resources._1346394869_Media_WMP;
                state = state.Realtime;

                // create record data

                StringBuilder temp = new StringBuilder();
                temp.Append("1\t1\t1\t1\t1\t1\t1\t1\t1\t1\t1\t1\t");

                int StopRecordPoint = Data[0].Count;
                int Cycle = (int)(Data[0].Time[1] - Data[0].Time[0]);
                int hh = 0;
                int mm = 0;
                int ss = 0;
                int ff = 0;

                for (int i = StartRecordPoint; i < StopRecordPoint; i++)
                {
                    temp.Append(
                        "   " +
                        (hh == 0 ? "   " : hh.ToString("00:")) +
                        (mm > 9 ? mm.ToString("00") : " " + mm.ToString("0"))  + ":" +
                        ss.ToString("00")  + "." +
                        ff.ToString("000") + "\t");

                    ff += Cycle;
                    if (ff >= 1000)
                    {
                        ff = 0;
                        ss += 1;
                        if (ss >= 60)
                        {
                            ss = 0;
                            mm += 1;
                            if (mm >= 60)
                            {
                                mm = 0;
                                hh += 1;
                            }
                        }
                    }

                    foreach (ECGData _data in Data)
                    {
                        if (_data.Sign[i] >= 0) temp.Append(" ");
                        if (Math.Abs(_data.Sign[i]) < 10) temp.Append(" ");
                        temp.Append(_data.Sign[i].ToString("0.000\t"));
                    }
                }

                // Add new Record

                WebService.ECGServiceClient WS = new WebService.ECGServiceClient();
                string recordID = WS.generateRecordID(Patient.ID);

                StreamWriter file = new StreamWriter(recordID + ".txt");
                file.Write(temp.ToString());
                file.Flush();
                file.Close();

                Record newRecord = new Record(Patient, DateTime.Now, recordID, this.Flag, temp.ToString());
                Patient.AddRecord(newRecord);

                this.Updated = true;

                // uploadfile to server

                UploadFile(recordID + ".txt", newRecord);
            }
        }