public async Task InitiateFileUploading() { // patientList = new List<PatientData>(); StartTime = DateTime.Now.ToString(); PatientData PatientDataObj=null; var storage = new Setting<List<PatientData>>(); IReadOnlyList<StorageFile> files = await GetUploadingFileList(); var currentUploadCount = new Setting<int>(); DeletePartiallyUploadedItems(); int count = 0; //var temp = patientList.Select(p => p.Image1.Name).Except(files.Select(x=>x.Name)); IEnumerable<string> filesTemp; if (patientList.Count > 0) filesTemp = files.Select(p => p.Name).Except(patientList.Select(x => x.Image1.Name)); else filesTemp = files.Select(p => p.Name); int newfilecount = 0; foreach (var file in files) { foreach (var newfiles in filesTemp) { if (newfiles == file.Name) { if (newfiles.Contains(app.Username)) { newfilecount = newfilecount + 1; PatientDataObj = new PatientData(); PatientDataObj.ID = count; PatientDataObj.Image1 = new FileUploadCompleted(); PatientDataObj.Image1.Name = file.Name; PatientDataObj.Image1.Status = 0; PatientDataObj.Image1.Url = app.NormalBucketURL + file.Name; PatientDataObj.Age = count + 20; PatientDataObj.Sex = count % 2 == 0 ? DataModel.Gender.Male : DataModel.Gender.Female; var properties = await file.GetBasicPropertiesAsync(); PatientDataObj.Image1.Size = Convert.ToInt32(properties.Size) / 1000000; patientList.Add(PatientDataObj); await Task.WhenAll(Task.Factory.StartNew(() => UploadFile(file.Name, file, PatientDataObj.Image1))); ////await Task.WhenAll(Task.Run(() => UploadFile(file.Name, file, PatientDataObj.Image1))); //using (var semaphore = new SemaphoreSlim(MAX_PARALLEL_UPLOADS)) //{ //} } } } await storage.SaveAsync("UploadStat", patientList); await currentUploadCount.SaveAsync("CurrentUploadCount", newfilecount); count = count + 1; } AutoDownload downloadObj = new AutoDownload(); downloadObj.InitializeDownload(); }
public bool CreatePatient(PatientData s) { PatientREST obj = new PatientREST(); obj.auth_token = app.AccessToken; obj.acquirer_user_id = s.ID.ToString(); s.Image1.Name = s.Image1.Name.Replace(" ", "+"); obj.image_left_url = app.NormalBucketURL +"/"+ s.Image1.Name; obj.image_right_url = app.NormalBucketURL+"/"+s.Image1.Name; obj.patient_file_id = s.ID.ToString(); obj.patient_name = app.Username; obj.site = app.Site; HttpClient client = new HttpClient(); StringBuilder strb = new StringBuilder(); strb.Append("auth_token=" + obj.auth_token); strb.Append("&acquirer_user_id=" + app.UserId); strb.Append("&image_left_url=" + obj.image_left_url); strb.Append("&image_right_url=" + obj.image_right_url); strb.Append("&patient_file_id=" + obj.patient_file_id); strb.Append("&patient_name=" + obj.patient_name); strb.Append("&site=" + obj.site); strb.Append("&workflow_status=" + ActivityType.ImageUploadCompleted); strb.Append("&age=" + "21"); strb.Append("&sex=" + Gender.Female); strb.Append("&user_name=" + app.Username); // StringContent con = new StringContent(""); HttpResponseMessage response = client.PostAsync(app.DomainName + "/rest/case/new?" + strb.ToString(), new StringContent("")).Result; if (response.IsSuccessStatusCode) { LogREST.LogEvent("MetaData Upload info", "File " + s.Image1.Name + " uploaded.", app.Username); //dynamic users = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result); // app.AccessToken= //foreach (string typeStr in users.Type[0]) //{ //} } return true; }