Esempio n. 1
0
 public void Dispose()
 {
     AudioUpload upload = new AudioUpload();
     upload.Abort();
     upload.Dispose();
     upload = null;
 }
Esempio n. 2
0
 public bool IsFindingPresent(int findingId,int userId)
 {
     bool result = false;
     AudioUpload upload = new AudioUpload();
     try
     {
         result = upload.IsFindingPresent(findingId, userId);
     }
     catch (TargetInvocationException tie)
     {
         throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
     }
     catch (System.Net.WebException we)
     {
         throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
     }
     finally
     {
         upload.Dispose();
     }
     return result;
 }
Esempio n. 3
0
 public void GetCompleteFile(int findingId,int userId)
 {
     AudioUpload upload = new AudioUpload();
     try
     {
         upload.GetCompleteFileCompleted += new GetCompleteFileCompletedEventHandler(OnCompleteDownloadCompleted);
         upload.GetCompleteFileAsync(findingId, userId);
         Logging.Instance.WriteLine("Getting Asnc Complet File");
     }
     catch (TargetInvocationException tie)
     {
         throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
     }
     catch (System.Net.WebException we)
     {
         throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
     }
     finally
     {
         upload.Dispose();
     }
 }
Esempio n. 4
0
 public void UploadFile(string filePath,string fileName,int studyId,int userId, int findingId)
 {
     AudioUpload upload = new AudioUpload();
     try
     {
         currentUploadData = new UploadData();
         Logging.Instance.WriteLine("Current Uplaod Initialized");
         currentUploadData.chunkSize = upload.GetChunkSize();
         currentUploadData.uploadedFileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Read);
         currentUploadData.studyId = studyId;
         currentUploadData.userId = userId;
         currentUploadData.findingId = findingId;
         Logging.Instance.WriteLine("currentUploadDate = " + currentUploadData.ToString());
         Logging.Instance.WriteLine("File Size: " + currentUploadData.uploadedFileStream.Length);
         UploadFile(true);
     }
     catch (TargetInvocationException tie)
     {
         throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
     }
     catch (System.Net.WebException we)
     {
         throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
     }
     finally
     {
         upload.Dispose();
     }
 }
Esempio n. 5
0
        private void UploadFile(bool isStart)
        {
            if (currentUploadData == null) return;
            AudioUpload upload = new AudioUpload();
            try
            {
                if (currentUploadData.uploadedFileStream.Position > 1)
                    voiceControl.SetUploadPercentage(Convert.ToInt32((currentUploadData.uploadedFileStream.Position * 100) / currentUploadData.uploadedFileStream.Length));
                int toRead = Convert.ToInt32(Math.Min(currentUploadData.chunkSize, currentUploadData.uploadedFileStream.Length - currentUploadData.uploadedFileStream.Position));
                Logging.Instance.WriteLine("Bytes to read:" + toRead);
                Byte[] data = new Byte[toRead];
                currentUploadData.uploadedFileStream.Read(data, 0, Convert.ToInt32(toRead));
                bool isEnd = (currentUploadData.uploadedFileStream.Position >= currentUploadData.uploadedFileStream.Length) ? true : false;
                Logging.Instance.WriteLine("Is File End:" + isEnd);

                upload.UploadFileCompleted += new UploadFileCompletedEventHandler(OnUploadFileCompleted);
                upload.UploadFileAsync(data, currentUploadData.fileName, currentUploadData.studyId, currentUploadData.userId, currentUploadData.findingId, isEnd, isStart);
                Logging.Instance.WriteLine("Called Async upload file");
            }
            catch (TargetInvocationException tie)
            {
                throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
            }
            catch (System.Net.WebException we)
            {
                throw new VoiceControlExcpetion(Constants.Messages.Error.ServerNotAvailable);
            }
            finally
            {
                upload.Dispose();
            }
        }