Beispiel #1
0
        public Guid InsertUpdateRuleSet(RuleSetDTO ruleSetDTO)
        {
            string spName = "apt_code.SmsAppointmentService.createUpdateRuleSet";

            try
            {
                using (var connection = m_providerFactory.CreateConnection())
                {
                    var oracleParameters = RuleSetQueryParamsHelper.getQPForCreateORUpdateRuleSet(ruleSetDTO);
                    var newGuid          = SaveAndReturnPK(spName, "l_ruleSetGuid", oracleParameters, connection);

                    return(newGuid);
                }
            }
            catch (Oracle.ManagedDataAccess.Client.OracleException ex)
            {
                s_log.ErrorException("InsertUpdateRuleSet Fails(Error from Oracle)", ex);
                throw new DBOperationException(ex.Message, ex.Number, DBExceptionScenarios.OracleExceptionOccured, ex);
            }
            catch (DBOperationException e)
            {
                s_log.WarnException("Error Occured in InsertUpdateRuleSet", e);
                throw;
            }
            catch (Exception ex)
            {
                s_log.ErrorException("InsertUpdateRuleSet Fails", ex);
                throw new DBOperationException(ex.Message, DBExceptionScenarios.ExceptionOccured, ex);
            }
        }
Beispiel #2
0
        public RuleSetDTO SelectRuleSetBy(Guid ruleSetGuid)
        {
            const string spName = "apt_code.SmsAppointmentService.getRuleSetDetails";

            try
            {
                using (var connection = m_providerFactory.CreateConnection())
                {
                    var oracleparameters = RuleSetQueryParamsHelper.GetRuleSetByIdQueryParams(ruleSetGuid);

                    var resultSet = connection.Query(spName, oracleparameters, commandType: CommandType.StoredProcedure);

                    if (resultSet == null)
                    {
                        s_log.Error("Select RuleSet By Id returned empty or null result.");
                        throw new DBOperationException("SelectRuleSetBy returned empty or null result.", GlobalOptions.DBExceptionScenarios.DBReturnedEmptyOrNullDataSet);
                    }

                    var mappedRuleSetDTOs = resultSet.ToList().Select(r => MapToRuleSetDTO(r)).ToList();

                    if (mappedRuleSetDTOs.Select(p => p.RuleSetGUID).Distinct().Count() > 1)
                    {
                        throw new DBOperationException("Select RuleSet By Id returned more than one ruleset.");
                    }

                    RuleSetDTO dtoToReturn = mappedRuleSetDTOs.FirstOrDefault();
                    if (dtoToReturn == null)
                    {
                        throw new DBOperationException("SelectRuleSetBy returned empty or null result.", GlobalOptions.DBExceptionScenarios.DBReturnedEmptyOrNullDataSet);
                    }

                    if (dtoToReturn.ExcludingOrgUnitIDs == null)
                    {
                        dtoToReturn.ExcludingOrgUnitIDs = new List <string>();
                    }

                    return(dtoToReturn);
                }
            }
            catch (OracleException ex)
            {
                s_log.ErrorException("SelectRuleSetBy(Guid RuleSetID) Fails(Error from Oracle)", ex);
                throw new DBOperationException(ex.Message, ex.Number, DBExceptionScenarios.OracleExceptionOccured, ex);
            }
            catch (DBOperationException e)
            {
                s_log.WarnException("Error Occured in SelectRuleSetBy Guid DB function.)", e);
                throw;
            }
            catch (Exception ex)
            {
                s_log.ErrorException("SelectRuleSetByID Fails", ex);
                throw new DBOperationException(ex.Message, DBExceptionScenarios.ExceptionOccured, ex);
            }
        }
Beispiel #3
0
        public List <RuleSetDTO> SelectRuleSetsOn(Guid?ruleSetGuid, long?departmentId, string searchTerm, bool?getActive, bool getHospitalLevel, long hospitalId)
        {
            const string spName = "apt_code.SmsAppointmentService.searchRuleset";

            try
            {
                using (var connection = m_providerFactory.CreateConnection())
                {
                    var oracleparams = RuleSetQueryParamsHelper.GetSelectRuleSetsOnQueryParams(ruleSetGuid, departmentId, searchTerm, getActive, getHospitalLevel, hospitalId);

                    var resultSet = connection.Query(spName, oracleparams, commandType: CommandType.StoredProcedure);
                    if (resultSet == null)
                    {
                        s_log.Error("SelectRuleSetsOn returned empty or null result.");
                        throw new DBOperationException("SelectRuleSetsOn returned empty or null result.", GlobalOptions.DBExceptionScenarios.DBReturnedEmptyOrNullDataSet);
                    }

                    var mappedRuleSetDTOs = resultSet.ToList().Select(r => (RuleSetDTO)MapToRuleSetDTO(r)).ToList();

                    // Group the DTOs by Ruleset GUID
                    var groupedByRuleSetGUID =
                        from ruleDto in mappedRuleSetDTOs
                        group ruleDto by ruleDto.RuleSetGUID into newGroup
                        orderby newGroup.Key
                        select newGroup;

                    return(groupedByRuleSetGUID.Select(ruleGroup => ruleGroup.FirstOrDefault()).ToList());
                }
            }
            catch (OracleException ex)
            {
                s_log.ErrorException("SelectRuleSetsOn Fails(Error from Oracle)", ex);
                throw new DBOperationException(ex.Message, ex.Number, DBExceptionScenarios.OracleExceptionOccured, ex);
            }
            catch (DBOperationException e)
            {
                s_log.WarnException("Error Occured in SelectRuleSetsOn", e);
                throw;
            }
            catch (Exception ex)
            {
                s_log.ErrorException("SelectRuleSetsOn Fails", ex);
                throw new DBOperationException(ex.Message, DBExceptionScenarios.ExceptionOccured, ex);
            }
        }
Beispiel #4
0
        public List <RuleSetDTO> SelectAllActiveRuleSets(long hospitslId)
        {
            string spName = "apt_code.SmsAppointmentService.getActiveRuleSetList";

            try
            {
                using (var connection = m_providerFactory.CreateConnection())
                {
                    var oracleParameters = RuleSetQueryParamsHelper.getQPForGetAllActiveRuleSets(hospitslId);
                    var resultSet        = connection.Query(spName, oracleParameters, commandType: CommandType.StoredProcedure);

                    if (resultSet == null)
                    {
                        s_log.Error("Select all active RuleSets returned empty or null result.");
                        throw new DBOperationException("SelectAllActiveRuleSets returned empty or null result.", GlobalOptions.DBExceptionScenarios.DBReturnedEmptyOrNullDataSet);
                    }

                    var mappedRuleSetDTOs = resultSet.ToList().Select(r => (RuleSetDTO)MapToRuleSetDTOForListItem(r)).ToList();

                    return(mappedRuleSetDTOs);
                }
            }
            catch (Oracle.ManagedDataAccess.Client.OracleException ex)
            {
                s_log.ErrorException("SelectAllActiveRuleSets Fails(Error from Oracle)", ex);
                throw new DBOperationException(ex.Message, ex.Number, DBExceptionScenarios.OracleExceptionOccured, ex);
            }
            catch (DBOperationException e)
            {
                s_log.WarnException("Error Occured in SelectAllActiveRuleSets", e);
                throw;
            }
            catch (Exception ex)
            {
                s_log.ErrorException("SelectAllActiveRuleSets Fails", ex);
                throw new DBOperationException(ex.Message, DBExceptionScenarios.ExceptionOccured, ex);
            }
        }