예제 #1
0
        public static RecordingLevel GetRecordingLevel(GetInteractionArguments args)
        {
            using (NexusContext ctx = new NexusContext())
            {
                Circuit circuit = ctx.Circuits.FirstOrDefault(c => c.Ani == args.Ani && c.SiteId == args.SiteId);
                if (circuit == null)
                {
                    throw new ArgumentException("Invalid ANI or Site ID");
                }

                return(GetRecordingLevel(args.Ani, args.SiteId, args.InmateId, args.ExternalIdentifier, circuit.RecordingLevel));
            }
        }
예제 #2
0
        private static RecordingLevel GetRecordingLevel(String ani, String siteId, String inmateId, String calledNumber, String initialRecordingLevel)
        {
            Int32  combinedRecordingLevel = 0;
            String strPinId = inmateId;

            if (!String.IsNullOrEmpty(strPinId))
            {
                strPinId = StringHelper.ApinToPinId(strPinId);
            }

            GlobalNumber global = GetGlobalNumbers(siteId).FirstOrDefault(x => x.Phone == calledNumber);

            using (NexusContext nexusContext = new NexusContext())
            {
                PinId    pin      = nexusContext.PinIds.FirstOrDefault(x => x.Pin == strPinId && x.SiteId == siteId);
                PinPhone pinPhone = nexusContext.PinPhones.FirstOrDefault(x => x.PhoneNumber == calledNumber && x.Pin == strPinId && x.SiteId == siteId);

                if (String.IsNullOrEmpty(initialRecordingLevel) && !String.IsNullOrEmpty((ani)))
                {
                    Circuit circuit = nexusContext.Circuits.FirstOrDefault(x => x.Ani == ani);
                    if (circuit != null)
                    {
                        initialRecordingLevel = circuit.RecordingLevel;
                    }
                }

                if (!String.IsNullOrEmpty(initialRecordingLevel))
                {
                    Int32.TryParse(initialRecordingLevel, out Int32 circuitRecordingLevel);
                    combinedRecordingLevel = circuitRecordingLevel;
                }

                if (pin != null && !String.IsNullOrEmpty(pin.RecordingLevel))
                {
                    Int32.TryParse(pin.RecordingLevel, out Int32 pinRecordingLevel);
                    combinedRecordingLevel |= pinRecordingLevel;
                }

                if (pinPhone != null && !String.IsNullOrEmpty(pinPhone.RecordingLevel))
                {
                    Int32.TryParse(pinPhone.RecordingLevel, out Int32 pinPhoneRecordingLevel);
                    combinedRecordingLevel |= pinPhoneRecordingLevel;
                }
                else if (global != null && global.Allowed)
                {
                    Int32.TryParse(global.RecordingLevelId, out Int32 globalRecordingLevel);
                    combinedRecordingLevel |= globalRecordingLevel;
                }

                if (combinedRecordingLevel == (Int32)RecordingLevel.Record)
                {
                    return(RecordingLevel.Record);
                }

                if ((combinedRecordingLevel & (Int32)RecordingLevel.DoNotRecord) > 0)
                {
                    return(RecordingLevel.DoNotRecord);
                }

                return(RecordingLevel.Impartial);
            }
        }