/// <summary> /// Unloading empty collections. /// To avoid an inconsistent state. /// /// TODO This is to be reviewed. /// </summary> internal void UnloadEmptyEntityCollection() { foreach (var entityObject in entities.Select(tracking => tracking.EntityObject)) { PocoHelper.SetEmptyEntityCollectionAsNull(entityObject); } }
/// <summary> /// 查询一行记录 /// </summary> /// <param name="id">主键</param> /// <returns></returns> public T FindById(object id) { //return _repository.FindById(id); var key = MetaData.TableInfo.TableName + ".FindById"; ExecuteContext <TImpl> ctx; //缓存执行语句 if (PocoExecuteContainer.TryGetValue(key, out object value)) { ctx = new ExecuteContext <TImpl>(); Sql s = value as Sql; s.Arguments[0] = id; ctx.ExecuteContainer = s; } else { QueryDescriptor <T> q = QueryDescriptorBuilder.Build <T>(); q.QueryText = PocoHelper.FormatColumn(this.MetaData, this.MetaData.TableInfo.PrimaryKey) + "=@0"; q.Parameters.Add(new QueryParameter("@0", id)); ctx = PocoHelper.ParseContext <T, TImpl>(MetaData, q); PocoExecuteContainer[key] = ctx.ExecuteContainer; } var result = _repository.Single(ctx); return(result); }
/// <summary> /// 查询记录数 /// </summary> /// <param name="q">上下文</param> /// <returns></returns> public long Count(QueryDescriptor <T> q) { ExecuteContext <T> ctx = PocoHelper.ParseContext <T>(MetaData, q, null, true); var result = _repository.Count(ctx); return(result); }
public IHttpActionResult SearchPatientFromAppointment(PatientFromAppointment Appt) { ////bỏ dấu tiếng việt của KeySearch trước khi đưa vào try { Appt.PageSize = Appt.PageSize == -1 ? int.MaxValue : Appt.PageSize; object DtmFrom = null, DtmTo = null; if (Appt.DtmFrom != null && Appt.DtmFrom != "") { DtmFrom = Convert.ToDateTime(Appt.DtmFrom); } if (Appt.DtmTo != null && Appt.DtmTo != "") { DtmTo = Convert.ToDateTime(Appt.DtmTo);; } var objNames = new object[] { "KeySearch", "YearBthDtm", "Phone", "Mail", "DtmFrom", "DtmTo", "PageSize", "PageNumber" }; var objValues = new object[] { Appt.KeySearch, Appt.YearBthDtm, Appt.Phone, Appt.Mail, DtmFrom, DtmTo, Appt.PageSize, Appt.PageNumber }; var result = this.Repository.ExecuteStoreScalar("usp_SearchPatientFromApptByKeySearch", objNames, objValues); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public ResultLogin Login(string userName, string passWord) { var reader = LoginUser(userName, passWord); DatabaseInfo dbInfo = new DatabaseInfo(); if (reader != null) { string validatorStatus = reader.result; dbInfo = reader.dbInfo; LVLoginUser loginUser = new LVLoginUser(); loginUser = (LVLoginUser)reader.data; var listPocoType = GetListPocoType(); if (listPocoType != null) { PocoHelper.SetListPocoType(listPocoType); } else { PocoHelper.GenerateListPocoType(); } return(new ResultLogin() { code = validatorStatus, loginUser = loginUser }); } return(null); }
public IHttpActionResult ChangePwd(string ForgotPwdCode, string AccountPwd) { try { var objNames = new object[] { "ForgotPwdCode", "AccountPwd" }; var objValues = new object[] { ForgotPwdCode, AccountPwd }; var result = this.Repository.ExecuteStoreScalar("usp_ChangePwd", objNames, objValues); if (result != null) { foreach (DataRow dr in result.Tables[0].Rows) { if (dr["ReturnCode"].ToString() == "0") { string to = dr["EmailAddress"].ToString(); _sendmail.ChangePwdSuccess(to); } break; } } return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult ForgotPassword(string EmailAddress, string Url) { try { var objNames = new object[] { "EmailAddress" }; var objValues = new object[] { EmailAddress }; var result = this.Repository.ExecuteStoreScalar("usp_ForgotPassword", objNames, objValues); if (result != null) { foreach (DataRow dr in result.Tables[0].Rows) { if (dr["ReturnCode"].ToString() == "0") { string to = dr["EmailAddress"].ToString(); string ForgotPwdCode = dr["ForgotPwdCode"].ToString(); _sendmail.ForgotPassword(to, ForgotPwdCode, Url); } break; } } return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
/// <summary> /// 查询一行记录 /// </summary> /// <param name="id">主键</param> /// <returns></returns> public T FindById(object id) { //return _repository.FindById(id); var key = MetaData.TableInfo.TableName + ".FindById"; ExecuteContext <T> ctx; //缓存执行语句 //if (PocoExecuteContainer.TryGetValue(key, out object value)) //{ // ctx = new ExecuteContext<T>(); // Sql s = value as Sql; // s.Arguments[0] = id; // ctx.ExecuteContainer = s; //} //else //{ QueryDescriptor <T> q = QueryDescriptorBuilder.Build <T>(); q.QueryText = "[" + this.MetaData.TableInfo.TableName + "]." + this.MetaData.TableInfo.PrimaryKey + "=@0"; q.Parameters.Add(new QueryParameter("@0", id)); ctx = PocoHelper.ParseContext <T>(MetaData, q); // PocoExecuteContainer[key] = ctx.ExecuteContainer; //} var result = _repository.Single(ctx); return(result); }
public virtual async Task DeleteAsync <T>(MapperDb db, T poco, object primaryKeyValue) { string tableName = PocoHelper.GetTableName(poco); var primaryKey = PocoHelper.GetPrimaryKey(poco); string primaryKeyName = primaryKey.ColumnName; await this.DeleteAsync(db, primaryKeyValue, tableName, primaryKeyName).ConfigureAwait(false); }
public IHttpActionResult GetKey(string entity) { Type mtype = PocoHelper.GetTypeFromString(entity); var old = Activator.CreateInstance(mtype); var _pro = mtype.GetProperty("Key"); return(Ok(_pro.GetValue(old, null))); }
public virtual async Task UpdateAsync <T>(MapperDb db, T poco, object primaryKeyValue) { string tableName = PocoHelper.GetTableName(poco); var primaryKey = PocoHelper.GetPrimaryKey(poco); string primaryKeyName = primaryKey.ColumnName; bool isIdentity = primaryKey.IsIdentity; await this.UpdateAsync(db, poco, primaryKeyValue, tableName, primaryKeyName, isIdentity).ConfigureAwait(false); }
/// <summary> /// 更新记录 /// </summary> /// <param name="context">上下文</param> /// <returns></returns> public bool Update(UpdateContext <T> context) { Guard.NotNullOrEmpty <KeyValuePair <string, object> >(context.Sets, "sets"); ExecuteContext <T> ctx = new ExecuteContext <T>(PocoHelper.ParseUpdateSql <T>(MetaData, context)); var result = _repository.UpdateByQuery(ctx); return(result); }
/// <summary> /// 是否存在记录 /// </summary> /// <param name="context">上下文</param> /// <returns></returns> public bool Exists(QueryDescriptor <T> context) { Sql s = Sql.Builder.Append("SELECT TOP 1 1 AS result FROM [" + MetaData.TableInfo.TableName + "] ") .Append(PocoHelper.GetConditions(context)); ExecuteContext <T> ctx = new ExecuteContext <T>(s); var result = _repository.Exists(ctx); return(result); }
public virtual async Task <object> InsertAsync <T>(MapperDb db, T poco) { string tableName = PocoHelper.GetTableName(poco); var primaryKey = PocoHelper.GetPrimaryKey(poco); string primaryKeyName = primaryKey.ColumnName; bool autoincrement = primaryKey.AutoIncrement; return(await db.InsertAsync(tableName, primaryKeyName, autoincrement, poco).ConfigureAwait(false)); }
/// <summary> /// 查询数据 /// </summary> /// <param name="q">上下文</param> /// <returns></returns> public List <T> Query(QueryDescriptor <T> q) { ExecuteContext <T> ctx = PocoHelper.ParseContext <T>(MetaData, q); var pageDatas = _repository.Query(ctx); if (pageDatas != null) { return(pageDatas.ToList()); } return(null); }
/// <summary> /// 查询数据 /// </summary> /// <returns></returns> public List <T> FindAll() { ExecuteContext <T> ctx = PocoHelper.ParseContext <T>(MetaData, null); var pageDatas = _repository.Query(ctx); if (pageDatas != null) { return(pageDatas.ToList()); } return(null); }
/// <summary> /// 查询前N条记录 /// </summary> /// <param name="q"></param> /// <returns></returns> public List <T> Top(QueryDescriptor <T> q) { ExecuteContext <T> ctx = PocoHelper.ParseContext <T>(q); var datas = _repository.Top(ctx); if (datas != null) { return(datas.ToList()); } return(null); }
/// <summary> /// 查询前N条记录 /// </summary> /// <param name="q"></param> /// <returns></returns> public List <T> Top(QueryDescriptor <T> q) { ExecuteContext <TImpl> ctx = PocoHelper.ParseContext <T, TImpl>(MetaData, q); var result = _repository.Top(ctx); if (result != null) { return(result.ToList <T>()); } return(null); }
/// <summary> /// 查询一行记录 /// </summary> /// <param name="q">上下文</param> /// <returns></returns> public T Find(QueryDescriptor <T> q) { ExecuteContext <T> ctx = PocoHelper.ParseContext <T>(MetaData, q); Sql s = ctx.ExecuteContainer as Sql; string sql = s.SQL; sql = new Regex("^(SELECT){1}").Replace(sql, "SELECT TOP 1"); ctx.ExecuteContainer = Sql.Builder.Append(sql, s.Arguments); var result = _repository.Single(ctx); return(result); }
/// <summary> /// 删除记录 /// </summary> /// <param name="predicate">过滤条件</param> /// <returns></returns> public bool Delete(Expression <Func <T, bool> > predicate) { QueryDescriptor <T> q = QueryDescriptorBuilder.Build <T>(); q.Where(predicate); Sql s = Sql.Builder.Append("DELETE [" + MetaData.TableInfo.TableName + "] ") .Append(PocoHelper.GetConditions(q.QueryText, q.Parameters)); ExecuteContext <T> ctx = new ExecuteContext <T>(s); var result = _repository.DeleteByQuery(ctx); return(result); }
public IHttpActionResult RegAppointmentOnline(AppointmentOnline apointOnline) { try { object DOB = null, ApptDate = null, SubApptDate = null; DOB = DateTime.Parse(apointOnline.reg.DOB.ToString(), culture); ApptDate = DateTime.Parse(apointOnline.apoi.ApptDate.ToString(), culture); if (apointOnline.apoi.SubApptDate != null) { SubApptDate = DateTime.Parse(apointOnline.apoi.SubApptDate.ToString(), culture); } object AppTime = null, SubAppTime = null; AppTime = apointOnline.apoi.AppTime; SubAppTime = apointOnline.apoi.SubAppTime; //if (!string.IsNullOrWhiteSpace(apointOnline.apoi.AppTime)) // AppTime = TimeSpan.Parse(apointOnline.apoi.AppTime, culture); //if (!string.IsNullOrWhiteSpace(apointOnline.apoi.SubAppTime)) // SubAppTime = TimeSpan.Parse(apointOnline.apoi.SubAppTime, culture); var objName = new object[] { "LastName", "FirstName", "MobilePhoneNumber", "EmailAddress", "DOB" , "PPN", "ReqCfmBySMS", "OTP", "ApptDate", "AppTime", "WSID", "WDID", "TFID", "MedSerID", "V_ApptStatus" , "SubApptDate", "SubAppTime", "ReasonOrSymptom", "PersonID" }; var objParam = new object[] { apointOnline.reg.LastName, apointOnline.reg.FirstName, apointOnline.reg.MobilePhoneNumber , apointOnline.reg.EmailAddress, DOB, apointOnline.reg.PPN, apointOnline.reg.ReqCfmBySMS , apointOnline.reg.OTP, ApptDate, AppTime, apointOnline.apoi.WSID, apointOnline.apoi.WDID , apointOnline.apoi.TFID, apointOnline.apoi.MedSerID, apointOnline.apoi.V_ApptStatus , SubApptDate, SubAppTime, apointOnline.apoi.ReasonOrSymptom, apointOnline.reg.PersonID }; var result = this.Repository.ExecuteStoreScalar("usp_RegAppointmentOnline", objName, objParam); if (result != null) { foreach (DataRow dr in result.Tables[0].Rows) { if (dr["ReturnCode"].ToString() == "0") { string to = apointOnline.reg.EmailAddress; string subject = "Đăng Ký KCB Thành Công"; _sendmail.RegistrationInfoSuccess(to, subject, apointOnline.apoi, apointOnline.apoi.ApptDate, apointOnline.apoi.AppTime , "khoa", apointOnline.reg.LastName + "" + apointOnline.reg.FirstName, apointOnline.reg); } break; } } return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult ExecuteStore(ExecuteStoreDTO dto) { try { var result = this.Repository.ExecuteStoreScalar(dto.name, dto.objName, dto.objValue); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult AddUpdateAppointment(AppointmentDTO data) { try { //var objName = new object[] {"personJson","patientJson","healthInsuranceJson","patientMedRecordJson", // "medicalEncounterJSon","patientVitalSignJson","patientAdmissionJson","hIAdmissionJson", // "miscDocumentsJson","patientCommonMedRecordJson","patientTransactionJson", // "hospitalFeeTransactionJson","hosFeeTransDetailsJson","medicalClaimServiceJson", // "isHI","ConfigIsEnable","AccountID", var objName = new object[] { "radtFormJson", "patientMoreInforFormJson", "healthInsuranceFormJson", "FAMFormJson", /*"eprForm",*/ "reciveFormJson", "padForm", "patientVitalSignJson", /*"patientClassHistoryJson",*/ "patientTransactionJson", "hospitalFeeTransactionJson", "hosFeeTransDetailsJson", "medicalClaimServiceJson", "isHI", "ConfigIsEnable", "AccountID" }; var objParam = new object[] { //JsonConvert.SerializeObject(data.Person), //JsonConvert.SerializeObject(data.Patient), //JsonConvert.SerializeObject(data.HealthInsurance), //JsonConvert.SerializeObject(data.PatientMedRecord), //JsonConvert.SerializeObject(data.MedicalEncounter), JsonConvert.SerializeObject(data.RadtForm), JsonConvert.SerializeObject(data.PtMoreInfor), JsonConvert.SerializeObject(data.HIForm), JsonConvert.SerializeObject(data.FAMForm), JsonConvert.SerializeObject(data.ReciveForm), JsonConvert.SerializeObject(data.PADForm), JsonConvert.SerializeObject(data.PatientVitalSign), //JsonConvert.SerializeObject(data.PatientAdmission), //JsonConvert.SerializeObject(data.HIAdmission), //JsonConvert.SerializeObject(data.MiscDocuments), //JsonConvert.SerializeObject(data.PatientCommonMedRecord), JsonConvert.SerializeObject(data.PatientTransaction), JsonConvert.SerializeObject(data.HospitalFeeTransaction), JsonConvert.SerializeObject(data.HosFeeTransDetails), JsonConvert.SerializeObject(data.MedicalClaimService), //JsonConvert.SerializeObject(data.HIAdmission), //JsonConvert.SerializeObject(data.MiscDocuments), //JsonConvert.SerializeObject(data.PatientCommonMedRecord), data.isHI, data.ConfigIsEnable, data.AccountID }; var result = this.Repository.ExecuteStoreScalar("usp_InsertUpdateAppointment", objName, objParam); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult GetEmployeeById(long EmpID) { try { var objNames = new object[] { "EmpID", "language" }; var objValues = new object[] { EmpID, language }; var result = this.Repository.ExecuteStoreScalar("usp_GetEmployeeById", objNames, objValues); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult GetPatientFromAppointment(long?RegInfoID, long?PtID) { try { var objNames = new object[] { "RegInfoID", "PtID" }; var objValues = new object[] { RegInfoID, PtID }; var result = this.Repository.ExecuteStoreScalar("usp_GetPatientFromApptByRegInfoID", objNames, objValues); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult GetPrescriptionDetail(long AccountID, long RxID) { try { var objNames = new object[] { "AccountID", "RxID", "language" }; var objValues = new object[] { AccountID, RxID, language }; var result = this.Repository.ExecuteStoreScalar("usp_GetPrescriptionDetail", objNames, objValues); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult GetPatientVitalSignInfor(long PtComMedRecID) { try { var objName = new object[] { "PtComMedRecID" }; var objParam = new object[] { PtComMedRecID }; var result = this.Repository.ExecuteStoreScalar("usp_GetPatientVitalSignInfor", objName, objParam); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult GetInforPerson(long PersonID, long?V_PersonType) { try { var objName = new object[] { "PersonID", "V_PersonType" }; var objValue = new object[] { PersonID, V_PersonType }; var result = this.Repository.ExecuteStoreScalar("usp_GetInforPerson", objName, objValue); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult Getepr(long AdmID, long PtID) { try { var objName = new object[] { "AdmID", "PtID" }; var objValue = new object[] { AdmID, PtID }; var result = this.Repository.ExecuteStoreScalar("usp_GetEPR", objName, objValue); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }
public IHttpActionResult GetPatientInforByType(string Input, int TypeInput, int Type = 0) { try { var objName = new object[] { "Input", "TypeInput", "Type" }; var objValue = new object[] { Input, TypeInput, Type }; var result = this.Repository.ExecuteStoreScalar("usp_GetPatientInforByType", objName, objValue); return(Ok(PocoHelper.GetTableRows(result.Tables[0]))); } catch (Exception ex) { log.Error(ex.Message + "; param: Input = " + Input + ", TypeInput = " + TypeInput.ToString()); return(Content(HttpStatusCode.BadRequest, ex.Message)); } }