[HttpPost] // This is from System.Web.Http, and not from System.Web.Mvc public async Task <IHttpActionResult> UploadRecord() { var currentUser = await GetCurrentUser(); RecordBLL rBll = new RecordBLL(_unit); if (!Request.Content.IsMimeMultipartContent()) { this.Request.CreateResponse(HttpStatusCode.UnsupportedMediaType); } var provider = GetMultipartProvider(); var result = await Request.Content.ReadAsMultipartAsync(provider); // On upload, files are given a generic name like "BodyPart_26d6abe1-3ae1-416a-9429-b35f15e6e5d5" // so this is how you can get the original file name var originalFileName = GetDeserializedFileName(result.FileData.First()); // uploadedFileInfo object will give you some additional stuff like file length, // creation time, directory name, a few filesystem methods etc.. var uploadedFileInfo = new FileInfo(result.FileData.First().LocalFileName); var inRec = GetFormData(result); inRec.Owner = currentUser.Id; inRec.CreateDT = DateTime.Now; inRec.OriginalFileName = originalFileName; // Through the request response you can return an object to the Angular controller // You will be able to access this in the .success callback through its data attribute // If you want to send something to the .error callback, use the HttpStatusCode.BadRequest instead var returnData = rBll.UploadRecord(inRec, uploadedFileInfo); return(Ok(new { returnData })); }
public ActionResult GetAllRec(User user) { try { //byte[] arr = new byte[HttpContext.Request.Body.Length]; //HttpContext.Request.Body.Read(arr, 0, arr.Length); //Dictionary<string, string> keyValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(System.Text.Encoding.UTF8.GetString(arr)); string system = user.System; // keyValues["system"]; string maincode = user.MainCode; //keyValues["maincode"].ToString(); string mainid = user.MainID; //keyValues["mainid"].ToString(); if (!string.IsNullOrWhiteSpace(system) && !string.IsNullOrWhiteSpace(maincode) && !string.IsNullOrWhiteSpace(mainid)) { RecordBLL recordbll = new RecordBLL(); IList <Record> records = recordbll.GetAll(system, maincode, mainid); if (records != null && records.Count > 0) { return(new JsonResult(records)); } } return(null); } catch (Exception ex) { throw; } }
public async Task <IHttpActionResult> Delete(int id) { try { var currentUser = await GetCurrentUser(); RecordBLL bll = new RecordBLL(_unit); bool isAdmin = await AppUserManager.IsInRoleAsync(currentUser.Id, "Admin"); if (isAdmin) { bll.DeleteRecord(id); } else { var w = bll.GetByID(id); if (w.Owner == currentUser.Id) { bll.DeleteRecord(id); } else { BadRequest("You don't have permission to delete this record."); } } } catch (Exception ex) { LogHelper.Error(_log, ex.ToString()); return(InternalServerError(ex)); } return(Ok()); }
public void ProcessRequest(HttpContext context) { HttpResponse response = HttpContext.Current.Response; response.ClearContent(); response.ClearHeaders(); response.Clear(); if (HttpContext.Current.Request.QueryString.GetValues(null)?.Contains("record") ?? false) { response.StatusCode = 404; return; } long recordID = Convert.ToInt64(HttpContext.Current.Request.QueryString["record"]); Record record = new RecordBLL().GetRecord(recordID); if (record == null || !record.IsFileSafe()) { response.StatusCode = 404; } else { if (record.fileExtension.Equals(".jpeg")) { response.ContentType = "image/jpeg"; } else if (record.fileExtension.Equals(".jpg")) { response.ContentType = "image/jpg"; } else if (record.fileExtension.Equals(".png")) { response.ContentType = "image/png"; } else if (record.fileExtension.Equals(".txt")) { response.ContentType = "text/plain"; } else if (record.fileExtension.Equals(".csv")) { response.ContentType = "text/csv"; } else if (record.fileExtension.Equals(".mp4")) { response.ContentType = "video/mp4"; } response.AddHeader("Content-Disposition", "attachment; filename=\"" + record.fileName + record.fileExtension + "\""); response.WriteFile(record.fullpath); } response.Flush(); response.Close(); }
static void Main(string[] args) { var biz = new RecordBLL(); var ls = biz.GetData(); var q = from r in ls.AsQueryable() orderby r.Times select r.SeventhNum; var lSeven = q.ToList(); var lFind = new List <int>(); lFind.Add(12); lFind.Add(13); lFind.Add(14); var dict = Get(lSeven, lFind, 4); Console.ReadKey(); }
public void TestCreate() { RecordBLL bll = new RecordBLL(_unit); Record r = new Record { Title = "name 1", Type = "Buy", ZoneId = 2, Owner = "a3b06d61-8fea-456c-ab1e-9207f3bfb875", CreateDT = DateTime.Now }; bll.Create(r); }
public async Task <IHttpActionResult> Get(int?zoneId, int size = 50) { List <Record> slist = null; try { //var currentUser = await GetCurrentUser(); RecordBLL bll = new RecordBLL(_unit); slist = bll.GetByZoneID(zoneId, size).ToList(); } catch (Exception ex) { LogHelper.Error(_log, ex.ToString()); return(InternalServerError(ex)); } return(Ok(slist)); }
public HttpResponseMessage Download(int id) { RecordBLL rbll = new RecordBLL(_unit); Record rec = rbll.GetByID(id); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); string filePath = rbll.GetRecordFilePath(rec); var stream = new FileStream(filePath, FileMode.Open); result.Content = new StreamContent(stream); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); result.Content.Headers.ContentDisposition.FileName = Path.GetFileName(rec.Path); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.Add("x-filename", Path.GetFileName(rec.Path)); result.Content.Headers.ContentLength = stream.Length; return(result); }
protected void Bind_GridViewPatientAndRecord() { string nric = string.Empty; if (ViewState["GridViewPatientSelectedPatientNRIC"] != null) { nric = Convert.ToString(ViewState["GridViewPatientSelectedPatientNRIC"]); } List <Record> records = new RecordBLL().GetRecords(nric); ViewState["GridViewRecords"] = records; GridViewRecords.DataSource = records; GridViewRecords.DataBind(); string term = TextboxSearch.Text.Trim().ToLower(); List <Classes.Entity.Patient> patients = therapistBLL.GetCurrentPatients(term); ViewState["GridViewPatient"] = patients; GridViewPatient.DataSource = patients; GridViewPatient.DataBind(); UpdatePanelNewMedicalNote.Update(); }
private void CheckIn(HttpContext context) { string realName = context.Request.Params["realname"]; string phoneIMEI = context.Request.Params["phoneimei"]; string catmacaddress = context.Request.Params["catmac"]; string result = string.Empty; if (catmacaddress != catMac) { result = "errmac"; } else { UserBLL bll = new UserBLL(); int userid = bll.getUserID(phoneIMEI); Record record = new Record() { UserID = userid, time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") }; RecordBLL rbll = new RecordBLL(); try { if (rbll.insertCheckInRecord(record) > 0) { result = "ok"; } } catch (Exception) { result = "err"; } } context.Response.Write(result); }
protected void GridViewMedicalNote_RowCommand(object sender, GridViewCommandEventArgs e) { long id = Convert.ToInt64(e.CommandArgument.ToString()); ViewState["GridViewGridViewMedicalNoteSelectedID"] = id; if (e.CommandName.Equals("ViewNote")) { try { Note note = therapistBLL.GetNote(id); // Note Details inputTitle.Value = note.title; TextBoxContent.Text = note.content; inputCreateBy.Value = note.creator.lastName + " " + note.creator.firstName; inputCreateTime.Value = note.createTime.ToString(); inputPatientNRIC.Value = note.patient.nric; if (note.patient.approvedTime == null) { inputPatientName.Value = "Redacted"; PanelNoteUnauthorized.Visible = true; PanelPatientPersonalInformation.Visible = false; PanelPatientDiagnosis.Visible = false; PanelNoteRecords.Visible = false; } else { inputPatientName.Value = note.patient.lastName + " " + note.patient.firstName; // Personal Details inputNRIC.Value = note.patient.nric; DateofBirth.Value = note.patient.dateOfBirth.ToString("MM/dd/yyyy"); FirstName.Value = note.patient.firstName; LastName.Value = note.patient.lastName; CountryofBirth.Value = note.patient.countryOfBirth; Nationality.Value = note.patient.nationality; Sex.Value = note.patient.sex; Gender.Value = note.patient.gender; MaritalStatus.Value = note.patient.maritalStatus; // Contact Details Address.Value = note.patient.address; PostalCode.Value = note.patient.addressPostalCode; EmailAddress.Value = note.patient.email; ContactNumber.Value = note.patient.contactNumber; // Patient NOK Details NOKName.Value = note.patient.nokName; NOKContact.Value = note.patient.nokContact; // Patient Diagnoses List <PatientDiagnosis> patientDiagnoses = therapistBLL.GetPatientDiagnoses(note.patient.nric, id); ViewState["GridViewPatientDiagnoses"] = patientDiagnoses; GridViewPatientDiagnoses.DataSource = patientDiagnoses; GridViewPatientDiagnoses.DataBind(); // Records List <Record> records = new RecordBLL().GetRecords(note.patient.nric, note.id); ViewState["GridViewRecords"] = records; GridViewRecords.DataSource = records; GridViewRecords.DataBind(); } ViewState["GridViewPatientSelectedNRIC"] = note.patient.nric; UpdatePanelNote.Update(); ScriptManager.RegisterStartupScript(this, GetType(), "Open Select Note Modal", "$('#modalNote').modal('show'); $('#NoteInformation').collapse('show');", true); } catch { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error Opening Note View.');", true); } } else if (e.CommandName.Equals("ViewSendNoteModal")) { try { Bind_GridViewTherapistSendNote(); ScriptManager.RegisterStartupScript(this, GetType(), "Open Select Note Modal", "$('#modalSendNote').modal('show');", true); } catch { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error Opening Send Note View.');", true); } } Bind_GridViewMedicalNote(); }
protected void GridViewPatient_RowCommand(object sender, GridViewCommandEventArgs e) { string nric = e.CommandArgument.ToString(); ViewState["GridViewPatientSelectedNRIC"] = nric; if (e.CommandName.Equals("ViewPermission")) { try { Update_UpdatePanelPermissions(nric); ScriptManager.RegisterStartupScript(this, GetType(), "Open Select Permission Modal", "$('#modalPermissions').modal('show');", true); } catch { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error Opening Permission View.');", true); } } else if (e.CommandName.Equals("ViewInformation")) { try { Classes.Entity.Patient patient = therapistBLL.GetPatientInformation(nric); // Personal Details LabelInformationNRIC.Text = patient.nric; inputNRIC.Value = patient.nric; DateofBirth.Value = patient.dateOfBirth.ToString("MM/dd/yyyy"); FirstName.Value = patient.firstName; LastName.Value = patient.lastName; CountryofBirth.Value = patient.countryOfBirth; Nationality.Value = patient.nationality; Sex.Value = patient.sex; Gender.Value = patient.gender; MaritalStatus.Value = patient.maritalStatus; // Contact Details Address.Value = patient.address; PostalCode.Value = patient.addressPostalCode; EmailAddress.Value = patient.email; ContactNumber.Value = patient.contactNumber; // Patient NOK Details NOKName.Value = patient.nokName; NOKContact.Value = patient.nokContact; UpdatePanelInformation.Update(); ScriptManager.RegisterStartupScript(this, GetType(), "Open Select Information Modal", "$('#modalInformation').modal('show');", true); } catch { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error Opening Information View.');", true); } } else if (e.CommandName.Equals("ViewRecords")) { try { List <Record> records = new RecordBLL().GetRecords(nric); LabelRecordsNRIC.Text = nric; modalRecordsHyperlinkNewRecord.NavigateUrl = "~/Therapist/My-Patients/New-Record?Patient-NRIC=" + nric; ViewState["GridViewRecords"] = records; GridViewRecords.DataSource = records; GridViewRecords.DataBind(); UpdatePanelRecords.Update(); ScriptManager.RegisterStartupScript(this, GetType(), "Open Select Records Modal", "$('#modalRecords').modal('show');", true); } catch { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error Opening Records Modal.');", true); } } else if (e.CommandName.Equals("ViewDiagnosis")) { try { TextboxSearchDiagnosis.Text = string.Empty; Bind_GridViewPatientDiagnoses(nric); ScriptManager.RegisterStartupScript(this, GetType(), "Open Diagnosis Modal", "$('#modalDiagnosisView').modal('show');", true); } catch { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "toastr['error']('Error Opening Diagnosis Modal.');", true); } } Bind_GridViewPatient(); }
// validate input private void ButtonRegister_Click(object sender, EventArgs e) { reset(); if (!ctr.nameValidator(textBoxFirstName.Text)) { firstNameErrorLabel.Visible = true; } if (!ctr.nameValidator(textBoxLastName.Text)) { lastNameErrorLabel.Visible = true; } if (!ctr.phoneValidator(textBoxPhoneNum.Text)) { phoneErrorLabel.Visible = true; } if (!ctr.passwordValidator(textBoxPassword.Text)) { passwordErrorLabel.Visible = true; } if (!ctr.confirmPasswordValidator(textBoxPassword.Text, textBoxConfirmPassword.Text)) { confirmErrorLabel.Visible = true; } if (!ctr.addressValidator(textBoxAddress.Text)) { addressErrorLabel.Visible = true; } if (!ctr.dobValidator(textBoxDOB.Text)) { dobErrorLabel.Visible = true; } if (!ctr.emailValidator(textBoxEmail.Text)) { emailErrorLabel.Visible = true; } if (!ctr.confirmUserTypeValidator(comboBoxRoleType.Text)) { userTypeErrorLabel.Visible = true; } if (!ctr.confirmWorkTypeValidator(comboBoxWorkType.Text)) { workTypeErrorLabel.Visible = true; } if (!(firstNameErrorLabel.Visible || lastNameErrorLabel.Visible || phoneErrorLabel.Visible || passwordErrorLabel.Visible || confirmErrorLabel.Visible || userTypeErrorLabel.Visible || addressErrorLabel.Visible || dobErrorLabel.Visible || emailErrorLabel.Visible || workTypeErrorLabel.Visible)) { string fname = textBoxFirstName.Text; string lname = textBoxLastName.Text; string phone = textBoxPhoneNum.Text; string password = textBoxPassword.Text; string role = comboBoxRoleType.Text.Trim(); string addr = textBoxAddress.Text; string email = textBoxEmail.Text; string wt = comboBoxWorkType.Text.Trim(); DateTime tempDate = DateTime.Parse(textBoxDOB.Text); RecordBLL rd = new RecordBLL(); Employee s = new Employee(); s.Name = fname + lname; s.Address = addr; s.DoB = tempDate; s.Email = email; s.Phone = phone; s.WorkType = wt; s.Password = password; s.RoleType = role; int id = rd.addStaff(s); MessageBox.Show("Register success!\n Your user ID is " + id.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); LoginForm lf = new LoginForm(id); lf.ShowDialog(); this.Close(); } }