/// <summary> /// Data items rage request /// </summary> /// <param name="startIndex">Start range index</param> /// <param name="pageCount">Items count</param> public void FetchRangeCommand(int startIndex, int pageCount) { Task.Run(() => { RequestedData <HttpResponce> result; using (var db = new HttpResponcesContext()) { int realPageCount; var httpResponcesCount = db.HttpResponces.Count(); if (httpResponcesCount < startIndex + pageCount) { realPageCount = pageCount; } else { realPageCount = httpResponcesCount - startIndex; } var selectedResponces = db.HttpResponces.OrderBy(k => k.Id).Skip(startIndex).Take(pageCount); var requestedList = new List <HttpResponce>(selectedResponces); result = new RequestedData <HttpResponce>(startIndex, realPageCount, requestedList, httpResponcesCount); } if (ListUpdates != null) { ListUpdates(new List <ServerListChanging <HttpResponce> > { result }); } }); }
public static async void HandleException(HttpContext context) { var feature = context.Features.Get <IExceptionHandlerPathFeature>(); var exception = feature.Error; Logger.Log(exception.Message + "\n" + exception.InnerException); Alert alert = new Alert { Type = AlertTypeEnum.Error, Message = exception.Message, Title = "حذث خطأ" }; if (exception.InnerException is SqlException sqlEx && (sqlEx.Number == 547)) { alert.Message = "يجب حذف البيانات المربوطة اولا"; } RequestedData <object> requestedData = new RequestedData <object> { Alerts = new List <Alert>() { alert } }; var result = JsonConvert.SerializeObject(requestedData, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); context.Response.ContentType = "application/json"; context.Response.Headers.Add("access-control-allow-origin", "*"); context.Response.StatusCode = 500; await context.Response.WriteAsync(result); }
protected void FetchRangeCommand(int startIndex, int pageCount, bool isPriority) { Task.Run(() => { var sortedAndFilteredList = SortAndFilterHttpResponcesList(); int realPageCount; if (sortedAndFilteredList.Count > 0 && sortedAndFilteredList.Count > startIndex + pageCount) { realPageCount = pageCount; } else { realPageCount = sortedAndFilteredList.Count - startIndex; } var array = new KeyValuePair <long, HttpResponce> [realPageCount]; sortedAndFilteredList.CopyTo(startIndex, array, 0, realPageCount); var requestedList = array.Select(l => l.Value).ToList(); var result = new RequestedData <HttpResponce>(startIndex, realPageCount, requestedList, sortedAndFilteredList.Count, isPriority); if (ListUpdates != null) { ListUpdates(new List <ServerListChanging <HttpResponce> > { result }); } }); }
public async Task Invoke(HttpContext httpContext) { try { if (httpContext.Request.Method == HttpMethods.Post && !httpContext.Request.ContentType.Contains("multipart/form-data") && httpContext.User.HasClaim(c => c.Type == ClaimTypes.NameIdentifier)) { int userId = Convert.ToInt32(httpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); httpContext.Request.EnableBuffering(); using (var reader = new StreamReader(httpContext.Request.Body)) { string requestBodyAsString = await reader.ReadToEndAsync(); RequestedData <object> objRequestBody = JsonConvert.DeserializeObject <RequestedData <object> >(requestBodyAsString); objRequestBody.UserId = userId; var bodyAsJson = JsonConvert.SerializeObject(objRequestBody); var requestContent = new StringContent(bodyAsJson, Encoding.UTF8, "application/json"); httpContext.Request.Body = await requestContent.ReadAsStreamAsync(); } } } catch (Exception e) { throw e; } await _next(httpContext); }
public IActionResult DeleteClinic([FromBody] RequestedData <ClinicDTO> requestedData) { requestedData.EntityList = clinicDSL.Delete(requestedData.Entity, requestedData.GridSettings); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم حذف العيادة بنجاح" }); return(Ok(requestedData)); }
public IActionResult DeleteAppointment([FromBody] RequestedData <AppointmentDTO> requestedData) { requestedData.EntityList = appointmentDSL.Delete(requestedData.Entity, requestedData.GridSettings); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم حذف الكشف بنجاح" }); return(Ok(requestedData)); }
public IActionResult SaveState([FromBody] RequestedData <AppointmentDTO> requestedData) { appointmentDSL.SaveState(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم حفظ الكشف بنجاح" }); return(Ok(requestedData)); }
public IActionResult AddPatient([FromBody] RequestedData <PatientDTO> requestedData) { patientDSL.Add(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم اضافة المريض بنجاح" }); return(Ok(requestedData)); }
public IActionResult DeleteMedicalHistory([FromBody] RequestedData <MedicalHistoryDTO> requestedData) { requestedData.EntityList = medicalHistoryDSL.Delete(requestedData.Entity, requestedData.GridSettings); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم حذف التاريخ الطبي بنجاح" }); return(Ok(requestedData)); }
public IActionResult EditMedicalHistory([FromBody] RequestedData <MedicalHistoryDTO> requestedData) { medicalHistoryDSL.Update(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم تعديل التاريخ الطبي بنجاح" }); return(Ok(requestedData)); }
public IActionResult EditUser([FromBody] RequestedData <UserDTO> requestedData) { userDSL.Update(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم تعديل المستخدم بنجاح" }); return(Ok(requestedData)); }
public IActionResult DeleteUser([FromBody] RequestedData <UserDTO> requestedData) { requestedData.EntityList = userDSL.Delete(requestedData.Entity, requestedData.GridSettings); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم حذف المستخدم بنجاح" }); return(Ok(requestedData)); }
public IActionResult AddAppointmentCategory([FromBody] RequestedData <AppointmentCategoryDTO> requestedData) { appointmentCategoryDSL.Add(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم الاضافة بنجاح" }); return(Ok(requestedData)); }
public IActionResult EditExpense([FromBody] RequestedData <ExpenseDTO> requestedData) { expenseDSL.Update(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم تعديل المصاريف بنجاح" }); return(Ok(requestedData)); }
public IActionResult EditAppointmentAddition([FromBody] RequestedData <AppointmentAdditionDTO> requestedData) { appointmentAdditionDSL.Update(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم التعديل بنجاح" }); return(Ok(requestedData)); }
public IActionResult EditClinic([FromBody] RequestedData <ClinicDTO> requestedData) { clinicDSL.Update(requestedData.Entity, requestedData.UserId); requestedData.Alerts.Add(new Alert { Title = "تم بنجاح", Type = AlertTypeEnum.Success, Message = "تم تعديل العيادة بنجاح" }); return(Ok(requestedData)); }
public IActionResult Login([FromBody] RequestedData <UserDTO> requestedData) { requestedData.Entity = userDSL.Login(requestedData.Entity.Username, requestedData.Entity.Password); if (requestedData.Entity != null) { var securityKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("DentalClinicKey#12*")); var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); var claims = new[] { new Claim(JwtRegisteredClaimNames.NameId, requestedData.Entity.Id.ToString()) }; var token = new JwtSecurityToken(null, null, claims, expires: DateTime.Now.AddDays(1), signingCredentials: credentials); requestedData.Entity.Token = new JwtSecurityTokenHandler().WriteToken(token); } return(Ok(requestedData)); }
public IActionResult GetMedicalHistorys([FromBody] RequestedData <MedicalHistoryDTO> requestedData) { requestedData.EntityList = medicalHistoryDSL.GetAll(requestedData.GridSettings); return(Ok(requestedData)); }
public IActionResult GetAllAppointmentAdditionLite([FromBody] RequestedData <AppointmentAdditionDTO> requestedData) { requestedData.EntityList = appointmentAdditionDSL.GetAllLite(); return(Ok(requestedData)); }
public IActionResult GetUser([FromBody] RequestedData <UserDTO> requestedData) { requestedData.Entity = userDSL.GetById(requestedData.Entity.Id); return(Ok(requestedData)); }
public IActionResult GetAllMedicalHistoryLite([FromBody] RequestedData <MedicalHistoryDTO> requestedData) { requestedData.EntityList = medicalHistoryDSL.GetAllLite(); return(Ok(requestedData)); }
public IActionResult GetUsers([FromBody] RequestedData <UserDTO> requestedData) { requestedData.EntityList = userDSL.GetAll(requestedData.GridSettings); return(Ok(requestedData)); }
public IActionResult GetAllUserLite([FromBody] RequestedData <UserDTO> requestedData) { requestedData.EntityList = userDSL.GetAllLite(); return(Ok(requestedData)); }
public IActionResult GetAppointmentDetailsLists([FromBody] RequestedData <AppointmentDTO> requestedData) { requestedData.DetailsList = appointmentDSL.GetDetailsLists(); return(Ok(requestedData)); }
public IActionResult GetMedicalHistory([FromBody] RequestedData <MedicalHistoryDTO> requestedData) { requestedData.Entity = medicalHistoryDSL.GetById(requestedData.Entity.Id); return(Ok(requestedData)); }
public IActionResult GetPatientDetailsLists([FromBody] RequestedData <PatientDTO> requestedData) { requestedData.DetailsList = patientDSL.GetDetailsLists(); return(Ok(requestedData)); }
protected void FetchRangeCommand(int startIndex, int pageCount, bool isPriority) { Task.Run(() => { if (_httpResponces == null) { return; } //Filter items List <HttpResponce> filteredList; if (LastFilterParams != null && LastFilterParams.Conditions.Root != null) { var filterExpression = FilterConditionConverter.GetLinqFilteringConditions(LastFilterParams.Conditions.Root, _httpResponceType, _httpResponcesKnownTypes); //Dynamic LINQ has constraints at filter by property only into inheritance objects //If use filter via SQL you have more capabilities filteredList = _httpResponces.AsQueryable().Where(filterExpression).ToList(); } else { filteredList = _httpResponces; } //Sort items //Default sort by time var sortString = "DetectTime"; var isAsc = false; if (LastSortParams != null) { bool isFindProperty; var sortProperty = ReflectionHelper.GetPropertyPathFromClass(LastSortParams.PropertyDescr.FieldName, _httpResponceType, _httpResponcesKnownTypes, String.Empty, out isFindProperty); isAsc = LastSortParams.IsAsc; if (isFindProperty) { sortString = sortProperty; } } List <HttpResponce> sortedList; if (isAsc) { sortedList = filteredList.AsQueryable().OrderBy(x => ReflectionHelper.GetPropertyValue(x, sortString)).ToList(); } else { sortedList = filteredList.AsQueryable().OrderByDescending(x => ReflectionHelper.GetPropertyValue(x, sortString)).ToList(); } int realPageCount; if (sortedList.Count > 0 && sortedList.Count > startIndex + pageCount) { realPageCount = pageCount; } else { realPageCount = sortedList.Count - startIndex; } var array = new HttpResponce[realPageCount]; sortedList.CopyTo(startIndex, array, 0, realPageCount); var requestedList = new List <HttpResponce>(array); var result = new RequestedData <HttpResponce>(startIndex, realPageCount, requestedList, sortedList.Count, isPriority); if (ListUpdates != null) { ListUpdates(new List <ServerListChanging <HttpResponce> > { result }); } }); }
public IActionResult GetAllAppointmentsDashboard([FromBody] RequestedData <AppointmentDTO> requestedData) { requestedData.EntityList = appointmentDSL.GetAllDashboard(requestedData.Entity); requestedData.DetailsList = appointmentDSL.GetDashboardDetailsLists(); return(Ok(requestedData)); }
public IActionResult GetAppointments([FromBody] RequestedData <AppointmentDTO> requestedData) { requestedData.EntityList = appointmentDSL.GetAll(requestedData.GridSettings); return(Ok(requestedData)); }
public IActionResult GetAppointmentAddition([FromBody] RequestedData <AppointmentAdditionDTO> requestedData) { requestedData.Entity = appointmentAdditionDSL.GetById(requestedData.Entity.Id); return(Ok(requestedData)); }