public List <ApartmentModel> MaidGetListApartment() { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var contracts = _service.GetAllCurrentContractByEmployeeId(maid.employee_id); var apartmentList = contracts.Select(p => new ApartmentModel { Id = p.apartment.apartment_id, Code = p.apartment.code, Building = p.building, NoApartment = p.no_apartment, Project = Equals(p.apartment.project_id, null) ? new ProjectModel() : new ProjectModel { Name = p.apartment.project.project_content.FirstOrDefault(q => q.language == 0).name }, Address = p.address }).ToList(); return(apartmentList); } return(new List <ApartmentModel>()); }
public List <CalendarModel> GetMaidCalendar(int minTime, int maxTime) { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var x = 60 * 60 * 24; var result = new List <CalendarModel>(); var contractEmployees = _service.GetAllCurrentContractEmployeeByEmployeeId(maid.employee_id); while (minTime < maxTime) { var max = minTime + x; var dow = (int)ConvertDatetime.UnixTimeStampToDateTime(minTime).DayOfWeek; var apartmentList = new List <ApartmentModel>(); foreach (var item in contractEmployees) { var days = item.work_date.Split(',').ToList(); if (days.IndexOf(dow.ToString()) != -1) { var apartment = new ApartmentModel { Id = item.contract.apartment.apartment_id, Code = item.contract.apartment.code, NoBedRoom = item.contract.no_bedroom, WorkHour = item.work_hour, Address = item.contract.address, NoApartment = item.contract.no_apartment, Building = item.contract.building, Project = !Equals(item.contract.apartment.project_id, null) ? new ProjectModel { Name = item.contract.apartment.project.project_content.FirstOrDefault(p => p.language == 0).name } : new ProjectModel() }; apartmentList.Add(apartment); } } var calendar = new CalendarModel { ApartmentList = apartmentList, Time = minTime }; result.Add(calendar); minTime = max; } return(result); } return(new List <CalendarModel>()); }
public void MaidCreateProblem(ProblemModel model) { if (Request.Headers.TryGetValues("Token", out var values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var contract = _service.GetCurrentParentContractByApartmentId(model.ApartmentId); if (Equals(contract, null)) { ExceptionContent(HttpStatusCode.InternalServerError, "err_apartment_not_contract"); } var problem = new problem { created_date = ConvertDatetime.GetCurrentUnixTimeStamp(), issue_id = model.IssueId, description = model.Description, problem_id = 0, status = 0, summary = model.Summary, type = (int)ProblemType.Maid, is_calendar = false, apartment_id = model.ApartmentId, employee_id = maid.employee_id, contract_id = contract.contract_id }; _service.SaveProblem(problem); int idx = 0; var listImage = new List <problem_image>(); foreach (var item in model.ListImage) { var img = new problem_image { problem_id = problem.problem_id, img = _service.SaveImage("~/Upload/problem/", "problem_" + ConvertDatetime.GetCurrentUnixTimeStamp() + "_" + idx + ".png", item.Img_Base64) }; listImage.Add(img); idx++; } _service.SaveListProblemImage(listImage); } }
public List <CalendarModel> GetMaidTotalTimeSheet() { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var startTime = ConvertDatetime.GetBeginMonthUnixTimeStampByTimestamp(maid.created_date); var endCurrentTime = ConvertDatetime.GetEndMonthUnixTimeStamp(); var result = new List <CalendarModel>(); while (startTime < endCurrentTime) { var endTime = ConvertDatetime.GetEndMonthUnixTimeStampByTimestamp(startTime); var apartmentEmployees = _service.GetListApartmentEmployeeByEmployeeIdAndTimeStamp(maid.employee_id, startTime, endTime).Select(p => new ApartmentEmployeeModel() { Id = p.apartment_employee_id, CheckInTime = p.check_in_time ?? 0, CheckOutTime = p.check_out_time ?? 0, Type = p.type, Apartment = new ApartmentModel() { Id = p.contract.apartment_id.Value, Code = p.contract.apartment.code, NoBedRoom = p.contract.no_bedroom } }).ToList(); var calendar = new CalendarModel() { Time = startTime, ApartmentEmployeeList = apartmentEmployees }; result.Add(calendar); startTime = endTime + 1; } return(result); } return(new List <CalendarModel>()); }
public List <TimeSheetModel> MaidGetListTimeSheet() { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } } return(new List <TimeSheetModel>()); }
public void MaidTrackingIssue(ApartmentEmployeeModel model) { if (Request.Headers.TryGetValues("Token", out var values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var apartmentEmployee = _service.GetLastApartmentEmployeeByApartmentIdAndEmployeeId(model.ApartmentId, maid.employee_id); apartmentEmployee.check_out_time = ConvertDatetime.GetCurrentUnixTimeStamp(); apartmentEmployee.check_out_geo = JsonConvert.SerializeObject(model.CheckOutGeo); apartmentEmployee.type = model.Type; _service.SaveApartmentEmployee(apartmentEmployee); var apartmentIssues = _service.GetListApartmentEmployeeIssueByApartmentEmployeeId(apartmentEmployee .apartment_employee_id); foreach (var item in apartmentIssues) { _service.DeleteApartmentEmployeeIssue(item); } var listIssue = new List <apartment_employee_issue>(); foreach (var item in model.ListIssue) { var issue = new apartment_employee_issue { apartment_employee_id = apartmentEmployee.apartment_employee_id, issue_id = item.IssueId, apartment_employee_issue_id = 0, is_complete = item.IsComplete }; listIssue.Add(issue); } _service.SaveListApartmentEmployeeIssue(listIssue); } }
public void ChangePassword(EmployeeModel model) { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var oldPass = Encrypt.EncodePassword(model.OldPassword); if (!Equals(oldPass, maid.password)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_old_password_not_valid"); } var newPass = Encrypt.EncodePassword(model.Password); maid.password = newPass; _service.SaveEmployee(maid); } }
public ApartmentModel GetApartmentByCode(ApartmentEmployeeModel model) { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_email_or_pass"); } var apartment = _service.GetApartmentByCode(model.ApartmentCode); if (Equals(apartment, null)) { ExceptionContent(HttpStatusCode.InternalServerError, "err_apartment_not_found"); } var contract = _service.GetCurrentParentContractByApartmentId(apartment.apartment_id); if (Equals(contract, null)) { ExceptionContent(HttpStatusCode.InternalServerError, "err_apartment_not_contract"); } var contractEmployee = _service.GetContractEmployeeByContractIdAndEmployeeId(contract.contract_id, maid.employee_id); if (Equals(contractEmployee, null) || contractEmployee.status != 1 || !Equals(contractEmployee.to_date, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_not_authorize"); } var apartmentEmployee = _service.GetLastApartmentEmployeeNotCheckOutByEmployeeId(maid.employee_id); if (!Equals(apartmentEmployee, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_not_complete_check"); } apartmentEmployee = new apartment_employee { apartment_employee_id = 0, check_in_time = ConvertDatetime.GetCurrentUnixTimeStamp(), check_in_geo = JsonConvert.SerializeObject(model.CheckInGeo), contract_id = contract.contract_id, employee_id = maid.employee_id, status = 1 }; _service.SaveApartmentEmployee(apartmentEmployee); return(new ApartmentModel { Id = apartment.apartment_id, Address = contract.address, Building = contract.building, NoApartment = contract.no_apartment, Project = !Equals(apartment.apartment_id, null) ? new ProjectModel { Name = apartment.project.project_content.FirstOrDefault(p => p.language == 0).name } : new ProjectModel(), Resident = new UserProfileModel { FullName = contract.resident_name, Phone = contract.resident_phone, Id = contract.user_profile1.user_profile_id, NoteList = contract.user_profile1.user_profile_note.Select(p => new UserProfileNoteModel { Id = p.user_profile_note_id, CreatedDate = p.created_date, Note = p.note }).ToList() }, PassWifi = contract.pass_wifi, WifiName = contract.wifi_name, PassDoor = contract.pass_door, WorkHour = contractEmployee.work_hour, WorkDate = contractEmployee.work_date.Split(',').ToList(), Maid = new EmployeeModel { FirstName = maid.first_name, LastName = maid.last_name }, Area = contract.area, NoBedRoom = contract.no_bedroom }); } return(new ApartmentModel()); }
public ApartmentModel MaidGetApartmentDetail(int apartmentId) { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var contract = _service.GetCurrentContractByApartmentAndEmployeeId(apartmentId, maid.employee_id); var contractEmployee = _service.GetContractEmployeeByContractIdAndEmployeeId(contract.contract_id, maid.employee_id); return(new ApartmentModel { Id = contract.apartment.apartment_id, Code = contract.apartment.code, Address = contract.address, Building = contract.building, NoApartment = contract.no_apartment, Project = !Equals(contract.apartment.project_id, null) ? new ProjectModel { Name = contract.apartment.project.project_content.FirstOrDefault(p => p.language == 0).name } : new ProjectModel(), PassDoor = contract.pass_door, PassWifi = contract.pass_wifi, WifiName = contract.wifi_name, WorkHour = contractEmployee.work_hour, WorkDate = contractEmployee.work_date.Split(',').ToList(), Resident = new UserProfileModel { FullName = contract.resident_name, Phone = contract.resident_phone, Id = contract.user_profile1.user_profile_id, NoteList = contract.user_profile1.user_profile_note.Select(p => new UserProfileNoteModel { Id = p.user_profile_note_id, CreatedDate = p.created_date, Note = p.note }).ToList() }, Maid = new EmployeeModel { FirstName = maid.first_name, LastName = maid.last_name }, ProblemList = contract.apartment.problems.Where(p => p.type == (int)ProblemType.Maid).Select(p => new ProblemModel { Id = p.problem_id, CreatedDate = p.created_date, Summary = p.summary, Description = p.summary, Status = p.status, ListImage = p.problem_image.Select(q => new ProblemImageModel { Id = q.problem_image_id, Img = q.img }).ToList() }).ToList() }); } return(new ApartmentModel()); }
public async Task <IActionResult> UploadMedicalRecord([FromBody] UploadMedicalRecordInput input) { Patient patient = await dbContext.Patients.FirstOrDefaultAsync(p => p.Id == input.PatientId); if (patient == null) { return(BadRequest(Json(new { Error = "不存在该患者" }))); } InitialDiagnosis initialDiagnosis = await dbContext.InitialDiagnoses.FirstOrDefaultAsync(i => i.PatientId == patient.Id); if (initialDiagnosis == null) { return(BadRequest(Json(new { Error = "该患者未填写初步诊断" }))); } PastMedicalHistory pastMedicalHistory = await dbContext.PastMedicalHistories.FirstOrDefaultAsync(p => p.PatientId == patient.Id); if (pastMedicalHistory == null) { return(BadRequest(Json(new { Error = "该患者未填写既往史" }))); } Symptom symptom = await dbContext.Symptoms.FirstOrDefaultAsync(s => s.PatientId == patient.Id); if (symptom == null) { return(BadRequest(Json(new { Error = "该患者未填写症状体征信息" }))); } List <FoodInfo> foodInfos = await dbContext.FoodInfos.Where(f => f.PatientId == patient.Id).ToListAsync(); XmlHelper xmlHelper = new XmlHelper(); string requestXml = ""; if (input.OperationType == 3) { requestXml = xmlHelper.ConvertToXml(input.OperationType, apiOptions, patient); } else { requestXml = xmlHelper.ConvertToXml(input.OperationType, apiOptions, patient, initialDiagnosis, pastMedicalHistory, symptom, foodInfos); } ReportServiceClient reportService = new ReportServiceClient(); string responseString = await reportService.WEBRequestAsync(Encrypt.Base64Encode(requestXml)); string responseXmlString = Encrypt.Base64Decode(responseString); XmlReader xmlReader = XmlReader.Create(new StringReader(responseXmlString)); XDocument xdoc = XDocument.Load(xmlReader); UploadMedicalRecordOutput output = new UploadMedicalRecordOutput { Code = Convert.ToInt32(xdoc.Element("接口").Element("操作状态").Value), Msg = xdoc.Element("接口").Element("状态描述").Value }; if (input.OperationType == 1 && output.Code == 1) { patient.Status = "已上传"; } if (input.OperationType == 3 && output.Code == 1) { patient.Status = "正常"; } dbContext.Patients.Update(patient); dbContext.SaveChanges(); return(new ObjectResult(output)); }