コード例 #1
0
 public Guid InsertOrUpdateTextTemplate(TextTemplateDTO templateDTO)
 {
     string spName = "apt_code.SmsAppointmentService.createUpdateSMSText";
     try
     {
         using (var connection = m_providerFactory.CreateConnection())
         {
             var oracleParameters = TextTemplateQueryParamsHelper.GetTextTemplateSaveUpdateQueryParams(templateDTO);
             var newGuid = SaveAndReturnPK(spName, "l_SMSTEXTID", oracleParameters, connection);
             return newGuid;
         }
     }
     catch (Oracle.ManagedDataAccess.Client.OracleException ex)
     {
         s_log.ErrorException("InsertOrUpdateTextTemplate (Error from Oracle)", ex);
         throw new DBOperationException(ex.Message, ex.Number, DBExceptionScenarios.OracleExceptionOccured, ex);
     }
     catch (DBOperationException e)
     {
         s_log.WarnException("Error Occured in InsertOrUpdateTextTemplate", e);
         throw;
     }
     catch (Exception ex)
     {
         s_log.ErrorException("InsertOrUpdateTextTemplate Fails", ex);
         throw new DBOperationException(ex.Message, DBExceptionScenarios.ExceptionOccured, ex);
     }
 }
        internal static OracleDynamicParameters GetTextTemplateSaveUpdateQueryParams(TextTemplateDTO textTemplate)
        {
            OracleDynamicParameters dynamicParameters = new OracleDynamicParameters();

            var isactive          = textTemplate.IsActive ? 1 : 0;
            var isAttachPSSLink   = textTemplate.AttachPSSLink ? 1 : 0;
            var isVideoAppoinment = textTemplate.IsVideoAppoinment ? 1 : 0;

            var levelOfCareParam = AssocativeArraysConverter
                                   .ConvertCollectionToPLSQLAssociativeArray(textTemplate.OfficialLevelOfCare, "p_offLevelOfCare");

            var contactTypeParam = AssocativeArraysConverter
                                   .ConvertCollectionToPLSQLAssociativeArray(textTemplate.ContactType, "p_contactType");

            dynamicParameters.AddDynamicParams(levelOfCareParam);
            dynamicParameters.AddDynamicParams(contactTypeParam);
            dynamicParameters.Add("p_oldSMSTextID", GuidConvert.ToRaw(textTemplate.TemplateGUID), OracleMappingType.Raw, ParameterDirection.Input);
            dynamicParameters.Add("p_ruleSetGuid", GuidConvert.ToRaw(textTemplate.RuleSetGUID), OracleMappingType.Raw, ParameterDirection.Input);
            dynamicParameters.Add("p_hospitalID", textTemplate.HospitalID, OracleMappingType.Long, ParameterDirection.Input);
            dynamicParameters.Add("p_departmentID", textTemplate.DepartmentID, OracleMappingType.Long, ParameterDirection.Input);
            dynamicParameters.Add("p_OPDID", textTemplate.OPDID, OracleMappingType.Long, ParameterDirection.Input);
            dynamicParameters.Add("p_locationID", textTemplate.LocationID, OracleMappingType.Long, ParameterDirection.Input);
            dynamicParameters.Add("p_sectionID", textTemplate.SectionID, OracleMappingType.Long, ParameterDirection.Input);
            dynamicParameters.Add("p_wardID", textTemplate.WardID, OracleMappingType.Long, ParameterDirection.Input);
            dynamicParameters.Add("p_SMSTextName", textTemplate.Name, OracleMappingType.Varchar2, ParameterDirection.Input);
            dynamicParameters.Add("p_SMSText", textTemplate.SMSText, OracleMappingType.Varchar2, ParameterDirection.Input);
            dynamicParameters.Add("p_SMSTextTempID", GuidConvert.ToRaw(textTemplate.GroupedTextGUID), OracleMappingType.Raw, ParameterDirection.Input);
            dynamicParameters.Add("p_validFrom", textTemplate.ValidFrom, OracleMappingType.Date, ParameterDirection.Input);
            dynamicParameters.Add("p_validTo", textTemplate.ValidTo, OracleMappingType.Date, ParameterDirection.Input);
            dynamicParameters.Add("p_isActive", isactive, OracleMappingType.Int16, ParameterDirection.Input);
            dynamicParameters.Add("p_sendPSSLink", isAttachPSSLink, OracleMappingType.Int16, ParameterDirection.Input);
            dynamicParameters.Add("p_isVideoCall", isVideoAppoinment, OracleMappingType.Int16, ParameterDirection.Input);
            dynamicParameters.Add("l_SMSTEXTID", null, OracleMappingType.Raw, ParameterDirection.ReturnValue, 16);
            return(dynamicParameters);
        }
コード例 #3
0
        private TextTemplateDTO MapModelToDataDTO(SMSText textTemplate)
        {
            var textTemplateDataDto = new TextTemplateDTO()
            {
                IsActive          = textTemplate.isActive,
                DepartmentID      = textTemplate.DepartmentId,
                SectionID         = textTemplate.SectionId,
                WardID            = textTemplate.WardId,
                OPDID             = textTemplate.OPDId,
                LocationID        = textTemplate.LocationId,
                AttachPSSLink     = textTemplate.isPSSLinkInclude,
                IsVideoAppoinment = textTemplate.IsVideoAppoinment,
                HospitalID        = textTemplate.HospitalId,
                Name                = textTemplate.TextTemplateName,
                ValidTo             = textTemplate.ValidTo,
                ValidFrom           = textTemplate.ValidFrom,
                OfficialLevelOfCare = textTemplate.OfficialLevelOfCare,
                ContactType         = textTemplate.ContactType,
                TemplateGUID        = (textTemplate.TextTemplateId == null || textTemplate.TextTemplateId == Guid.Empty) ? null : textTemplate.TextTemplateId,
                RuleSetGUID         = (textTemplate.RulesetId == null || textTemplate.RulesetId == Guid.Empty) ? null : textTemplate.RulesetId
            };

            if (textTemplate.GroupTemplateId != null && textTemplate.GroupTemplateId != Guid.Empty)
            {
                textTemplateDataDto.GroupedTextGUID = textTemplate.GroupTemplateId;
            }

            if (!string.IsNullOrEmpty(textTemplate.SMSTextTemplate))
            {
                textTemplateDataDto.SMSText = textTemplate.SMSTextTemplate;
            }

            return(textTemplateDataDto);
        }
コード例 #4
0
        private SMSText MapDataDtoToModel(TextTemplateDTO dto)
        {
            var smsText = new SMSText
            {
                TextTemplateId       = dto.TemplateGUID,
                DepartmentId         = dto.DepartmentID,
                TemplateDepartmentId = dto.TemplateDepartmentID,
                HospitalId           = dto.HospitalID,
                SectionId            = dto.SectionID,
                WardId              = dto.WardID,
                OPDId               = dto.OPDID,
                LocationId          = dto.LocationID,
                isPSSLinkInclude    = dto.AttachPSSLink,
                IsVideoAppoinment   = dto.IsVideoAppoinment,
                IsGenerateSMS       = dto.IsGenerateSMS,
                isActive            = dto.IsActive,
                TextTemplateName    = dto.Name,
                ValidTo             = dto.ValidTo,
                ValidFrom           = dto.ValidFrom,
                OfficialLevelOfCare = dto.OfficialLevelOfCare,
                ContactType         = dto.ContactType,
                RulesetId           = (dto.RuleSetGUID == null || dto.RuleSetGUID == Guid.Empty) ? null : dto.RuleSetGUID,
                RuleSetName         = dto.RuleSetName,
                SendSMSBeforeDays   = dto.SendSMSBeforeDays,
                EcludedOrgIds       = dto.ExcludedOrgUnits,
                SMSTextTemplate     = dto.SMSText
            };

            if (dto.GroupedTextGUID != null && dto.GroupedTextGUID != Guid.Empty)
            {
                smsText.GroupTemplateId = dto.GroupedTextGUID;
            }

            return(smsText);
        }
コード例 #5
0
        private TextTemplateDTO GetTextTemplate(Guid?templateId, Guid?ruleSetId,
                                                Guid?groupTextTemplate, long hospitalID, long?depId, long?locId,
                                                long?secId, long?wardId, long?opdId, List <long> offLevelCare,
                                                List <long> contactType, bool isVideo = false, string name = "Test Textemplate",
                                                string smsText = "Test SMS Text",
                                                bool isActive  = true)
        {
            var template = new TextTemplateDTO
            {
                HospitalID          = hospitalID,
                IsActive            = isActive,
                Name                = name,
                SMSText             = smsText,
                AttachPSSLink       = true,
                OPDID               = opdId,
                ValidFrom           = DateTime.Now,
                ValidTo             = DateTime.Now.AddDays(2),
                ContactType         = contactType,
                OfficialLevelOfCare = offLevelCare,
                IsVideoAppoinment   = isVideo
            };

            if (depId != null)
            {
                template.DepartmentID = (long)depId;
            }
            if (locId != null)
            {
                template.LocationID = (long)locId;
            }
            if (secId != null)
            {
                template.SectionID = (long)secId;
            }
            if (wardId != null)
            {
                template.WardID = (long)wardId;
            }
            if (templateId != null)
            {
                template.TemplateGUID = (Guid)templateId;
            }
            if (ruleSetId != null)
            {
                template.RuleSetGUID = (Guid)ruleSetId;
            }
            if (groupTextTemplate != null)
            {
                template.GroupedTextGUID = (Guid)groupTextTemplate;
            }

            return(template);
        }
コード例 #6
0
        public TextTemplateDTO MapToTextTemplateDTO(IDictionary<string, object> dictionary)
        {
            var smsTextId = dictionary["SMSTEXTGUID"];
            var textTemplateName = dictionary["SMSTEXTNAME"];
            var ruleSetGuid = dictionary["RULESETGUID"];
            var hospitalId = dictionary["HOSPITALID"];
            var departmentId = dictionary["DEPARTMENTID"];
            var opdId = dictionary["OPDID"];
            var locationId = dictionary["LOCATIONID"];
            var sectionId = dictionary["SECTIONID"];
            var wardId = dictionary["WARDID"];
            var officailLevelCare = dictionary["OFFICIALLEVELOFCARE"];
            var contactType = dictionary["CONTACTTYPE"];
            var GroupTemplateId = dictionary["SMSTEXTTEMPLATEGUID"];
            var smsText = dictionary["SMSTEXT"];
            var groupSMSText = dictionary["GROUPSMSTEXT"];
            var validFrom = dictionary["VALIDFROM"];
            var isPSSLinkAvailable = dictionary["SENDPSSAPPLINK"];
            var isVideoAppoinment = dictionary["ISVIDEO"];
            var isSMSGenerate = dictionary["GENERATESMS"];
            var validTo = dictionary["VALIDTO"];
            var isActive = dictionary["ISACTIVE"];
            var rulesetName = dictionary["RULESETNAME"];
            var sendbeforedays = dictionary["SENDBEFOREDAYS"];
            var excludedOrgUnits = dictionary["RESHIDS"];
            var templateDepartmentId = dictionary["TEXTDEPTID"];

            var smsTextDto = new TextTemplateDTO();

            if (smsTextId != null) smsTextDto.TemplateGUID = GuidConvert.FromRaw((byte[])smsTextId);
            if (ruleSetGuid != null) smsTextDto.RuleSetGUID = GuidConvert.FromRaw((byte[])ruleSetGuid);
            if (GroupTemplateId != null)
            {
                smsTextDto.GroupedTextGUID = GuidConvert.FromRaw((byte[])GroupTemplateId);
                if (groupSMSText != null) smsTextDto.SMSText = groupSMSText.ToString();
            }
            else
             if (smsText != null) smsTextDto.SMSText = smsText.ToString();

            if (textTemplateName != null) smsTextDto.Name = textTemplateName.ToString();

            if (hospitalId != null) smsTextDto.HospitalID = (long)hospitalId;
            if (departmentId != null) smsTextDto.DepartmentID = (long)departmentId;
            if (templateDepartmentId != null) smsTextDto.TemplateDepartmentID = (long)templateDepartmentId;
            if (opdId != null) smsTextDto.OPDID = (long)opdId;
            if (locationId != null) smsTextDto.LocationID = (long)locationId;
            if (sectionId != null) smsTextDto.SectionID = (long)sectionId;
            if (wardId != null) smsTextDto.WardID = (long)wardId;

            if (contactType != null)
            {
                smsTextDto.ContactType = contactType.ToString().Split(',').Select(conType => Convert.ToInt64(conType)).ToList();
            }
            if (officailLevelCare != null)
            {
                smsTextDto.OfficialLevelOfCare = officailLevelCare.ToString().Split(',').Select(offcarelvl => Convert.ToInt64(offcarelvl)).ToList();
            }

            if (validFrom != null) smsTextDto.ValidFrom = (DateTime)validFrom;
            if (validTo != null) smsTextDto.ValidTo = (DateTime)validTo;
            if (isActive != null) smsTextDto.IsActive = (Convert.ToInt16(isActive) == 0 ? false : true);
            if (isPSSLinkAvailable != null) smsTextDto.AttachPSSLink = (Convert.ToInt16(isPSSLinkAvailable) == 0 ? false : true);
            if (isVideoAppoinment != null) smsTextDto.IsVideoAppoinment = (Convert.ToInt16(isVideoAppoinment) == 0 ? false : true);
            if (isSMSGenerate != null) 
                smsTextDto.IsGenerateSMS = (Convert.ToInt16(isSMSGenerate) == 0 ? false : true);

            if (rulesetName != null) smsTextDto.RuleSetName = rulesetName.ToString();

            if (excludedOrgUnits != null) smsTextDto.ExcludedOrgUnits = excludedOrgUnits.ToString().Split(',').ToList();
            if (sendbeforedays != null) smsTextDto.SendSMSBeforeDays = Convert.ToInt32(sendbeforedays);
            return smsTextDto;
        }
コード例 #7
0
 public Guid SaveTextTemplate(TextTemplateDTO templateDTO)
 {
     return(m_textTemplateDataStore.InsertOrUpdateTextTemplate(templateDTO));
 }