Esempio n. 1
0
        /// <summary>
        /// Removes duplicate records based upon the USI, choosing Billing over Provisioning.  
        /// </summary>
        /// <param name="billingSubscribers">List of subscribers found in Billing matching the search criteria</param>
        /// <param name="provisioningSubscribers">List of subscribers found in Provisioning matching the search criteria</param>
        /// <param name="searchCriteria">Search parameters</param>
        /// <returns>List of subscribers matching the search criteria, with duplicate records removed (based upon USI), prefering Billing. </returns>
        private List<SubscriberSearchResult> CreateCompositeSearchSubscriberResponse(List<SubscriberSearchResult> billingSubscribers, List<SubscriberSearchResult> provisioningSubscribers, SearchFieldsDto searchCriteria)
        {
            var usiComparer = new UsiComparer();
            var compositeResponse = new List<SubscriberSearchResult>();
            var matches = new List<SubscriberSearchResult>();

            if (billingSubscribers == null || billingSubscribers.Count == 0)
            {
                return provisioningSubscribers;
            }

            if (provisioningSubscribers == null || provisioningSubscribers.Count == 0)
            {
                return billingSubscribers;
            }

            billingSubscribers.ForEach(x =>
            {
                var provisioningSubscriber = provisioningSubscribers.FirstOrDefault(y => y.ID == x.ID);
                if (provisioningSubscriber != null)
                {
                    x.LocationID = provisioningSubscriber.LocationID;
                }
            });

            matches.AddRange(billingSubscribers.Intersect(provisioningSubscribers, usiComparer));
            matches.ForEach(a =>
            {
                a.ExistsInProvisioning = true;
                a.ExistsInBilling = true;
            });

            compositeResponse.AddRange(matches);
            compositeResponse.AddRange(provisioningSubscribers.Except(matches, usiComparer));

            if (string.IsNullOrEmpty(searchCriteria.EquipmentId))
            {
                compositeResponse.AddRange(billingSubscribers.Where(s => !string.IsNullOrEmpty(s.ID)).Except(matches, usiComparer));
            }

            return compositeResponse;
        }
Esempio n. 2
0
        /// <summary>
        /// Search both Provisioning and Billing for subscribers.  
        /// </summary>
        /// <param name="searchCriteriaDto">Search parameters</param>
        /// <param name="userDto">Currently logged in user</param>
        /// <param name="searchResultStatusString">RETURN value containing the status of collection</param>
        /// <returns>List collection containing found distinct USIs based upon search criteria</returns>
        public List<SubscriberSearchResult> SearchSubscribers(SearchFieldsDto searchCriteriaDto, UserDto userDto, out string searchResultStatusString)
        {
            var billingCriteria = TypeAdapter.Adapt<SearchFieldsDto, BillingSearchFieldsDto>(searchCriteriaDto);
            var billingList = new List<SubscriberSearchResult>();
            var provisioningList = new List<SubscriberSearchResult>();
            var searchResultStatus = SearchResultStatus.Error;

            var taskArray = new List<Task>();
            Task<List<SubscriberDto>> provisioningServiceTask = null;

            //Provision Search
            if (!billingCriteria.ExcludeProvisioning && searchCriteriaDto.HasProvisioningFields)
            {

                provisioningServiceTask = Task.Factory.StartNew(
                    () => _rosettianService.SearchSubscribers(searchCriteriaDto, userDto) ??
                        new List<SubscriberDto>());

                taskArray.Add(provisioningServiceTask);
            }

            Task<List<BillingSearchSubscriberDto>> billingServiceTask = null;
            //Billing Search
            if (!billingCriteria.ExcludeDPI && searchCriteriaDto.HasBillingFields)
            {

                billingServiceTask = Task.Factory.StartNew(
                    () => _billingClient.SearchSubscriber(billingCriteria, userDto) ??
                          new List<BillingSearchSubscriberDto>());

                taskArray.Add(billingServiceTask);
            }

            try
            {
                Task.WaitAll(taskArray.ToArray());
            }
            catch (AggregateException ae)
            {
                ae.InnerExceptions.ToList().ForEach(innerException =>
                {
                    _errorLoggingService.LogErrorNoContext(innerException);
                    if (innerException.Message.Contains("Unable to determine DPI environment."))
                    {
                        throw new ArgumentException("No subscribers found. Please add the state if this is a pending install.");
                    }
                });
            }
            finally
            {

                    foreach (var task in taskArray)
                    {

                        if (task.Status == TaskStatus.RanToCompletion)
                        {
                            if (task == billingServiceTask)
                            {
                                searchResultStatus = searchResultStatus | SearchResultStatus.BillingPartialSuccess;
                                billingList =
                                    billingServiceTask.Result.Select(MapBillingResponseToSubscriberSearchResult)
                                        .ToList();
                            }

                            if (task == provisioningServiceTask)
                            {
                                searchResultStatus = searchResultStatus | SearchResultStatus.ProvisioningPartialSuccess;
                                provisioningList =
                                    provisioningServiceTask.Result.Select(
                                        MapProvisioningResponseToSubscriberSearchResult).ToList();
                            }
                        }
                    }

            }

            searchResultStatusString = searchResultStatus.GetStringValue();
            return CreateCompositeSearchSubscriberResponse(billingList, provisioningList, searchCriteriaDto);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the residential gateway device and other IP Capable devices.
        /// </summary>
        /// <param name="criteriaDto">The criteria dto.</param>
        /// <param name="userDto">The user dto.</param>
        /// <returns></returns>
        public CompositeEquipment LoadCompositeEquipment(SearchFieldsDto criteriaDto, UserDto userDto)
        {
            var devices = _rosettianService.SearchEquipment(criteriaDto, userDto);

            if (devices == null || !devices.Any())
            {
                return new CompositeEquipment
                {
                    ErrorDetails = new ErrorDetails
                    {
                        Code = ResidentialGatewayErrorCode.GatewayNotFound.ToString(),
                        Message =
                            @"RG not Found on Account. Provide the RG serial number and click the button below to associate."
                    },
                };
            }

            // retrieve video devices
            var videoDevices = devices.FindAll(d => d.Type.IptvCapable).ConvertAll<EquipmentDto>(a =>
            {
                var loadedEquipment = _rosettianService.LoadEquipment(a.SerialNumber, true, userDto);
                if (loadedEquipment != null && loadedEquipment.CustomFields != null && loadedEquipment.CustomFields.Any())
                {
                    a.CustomFields = loadedEquipment.CustomFields;
                }
                return a;
            });

            // retrieve RGs
            var rgEquipments =
                devices.FindAll(
                    a => (a.Type != null &&
                                    (a.Type.Category == EquipmentCategoryDto.RGDataPort ||
                                    a.Type.Category == EquipmentCategoryDto.RGVoicePort)));

            // return CompositeEquipment with Active RG not Found error when there's no active RG
            if (!rgEquipments.Any(a => a.Status.Equals("ACTIVE", StringComparison.OrdinalIgnoreCase)))
            {
                return new CompositeEquipment
                {
                    ErrorDetails = new ErrorDetails
                    {
                        Code = ResidentialGatewayErrorCode.GatewayNotFound.ToString(),
                        Message = @"Active RG not Found on Account. Provide the RG serial number and click the button below to associate."
                    },
                    VideoDevices = videoDevices,
                    OtherRGEquipments =
                        rgEquipments.GroupBy(a => a.SerialNumber.Substring(0, a.SerialNumber.Length - 3))
                            .Select(g => g.First())
                            .ToList()
                };
            }

            // return CompositeEquipment
            var rgActiveEquipment = rgEquipments.Find(a => a.Status.Equals("ACTIVE", StringComparison.OrdinalIgnoreCase));
            rgEquipments.RemoveAll(r => r.SerialNumber.StartsWith(rgActiveEquipment.SerialNumber.Substring(0, rgActiveEquipment.SerialNumber.Length - 3)));
            return new CompositeEquipment
            {
                ResidentialEquipment = _rosettianService.LoadEquipment(rgActiveEquipment.SerialNumber, true, userDto),
                VideoDevices = videoDevices,
                OtherRGEquipments = rgEquipments.GroupBy(a => a.SerialNumber.Substring(0, a.SerialNumber.Length - 3)).Select(g => g.First()).ToList()
            };
        }
Esempio n. 4
0
        /// <summary>
        /// Loads the video devices.
        /// </summary>
        /// <param name="criteriaDto">The criteria dto.</param>
        /// <param name="userDto">The user dto.</param>
        /// <returns></returns>
        public IEnumerable<EquipmentDto> LoadVideoDevices(SearchFieldsDto criteriaDto, UserDto userDto)
        {
            var videoDevices = new List<EquipmentDto>();

            var devices = _rosettianService.SearchEquipment(criteriaDto, userDto);

            if (devices == null || devices.Count() == 0)
            {
                return videoDevices;
            }

            if (!devices.FindAll(d => d.Type.IptvCapable).Any())
            {
                return videoDevices;
            }

            videoDevices = devices.FindAll(d => d.Type.IptvCapable).ConvertAll<EquipmentDto>(a =>
            {
                var loadedEquipment = _rosettianService.LoadEquipment(a.SerialNumber, true, userDto);
                if (loadedEquipment != null && loadedEquipment.CustomFields != null &&
                    loadedEquipment.CustomFields.Any())
                {
                    var selectedRoom = loadedEquipment.CustomFields.ToList().Find(cf => cf.Label == "ROOM_LOCATION");
                    if (selectedRoom != null)
                    {
                        a.CustomFields.Add(new CustomFieldDto
                        {
                            Category = selectedRoom.Category,
                            Label = "SELECTED_ROOM",
                            Value = selectedRoom.Value,
                            ValueType = selectedRoom.ValueType,
                            MaxLength = selectedRoom.MaxLength,
                            MinLength = selectedRoom.MinLength

                        });
                    }
                    a.CustomFields.AddRange(
                        _rosettianService.GetCustomFields(userDto).ToList().FindAll(cf => cf.Label == "ROOM_LOCATION"));
                }

                return a;
            });

            return videoDevices;
        }
Esempio n. 5
0
        /// <summary>
        /// Finds the equipments with device port information. 
        /// It is applicable not only for RGs, But also for equipments.
        /// </summary>
        /// <param name="serialNumber">The serial number.</param>
        /// <param name="userDto"></param>
        /// <returns></returns>
        public List<EquipmentDto> FindEquipments(string serialNumber, UserDto userDto)
        {
            var criteria = new SearchFieldsDto { EquipmentId = serialNumber };
            var equipments = this._rosettianService.SearchEquipment(criteria, userDto);
            //TODO: Replace following with rosettian operation that retrieves ports. That operation was not ready yet.
            List<string> devicePorts = new List<string> { "P01", "P02", "D01" };
            List<EquipmentDto> matchedEquipments = new List<EquipmentDto>();

            if (devicePorts.Any(a => serialNumber.EndsWith(a)))
            {
                serialNumber = serialNumber.Substring(0, serialNumber.Length - 3);
            }

            if (equipments != null && equipments.Any())
            {
                devicePorts.ForEach(p =>
                {
                    var matches = equipments.FindAll(e => e.SerialNumber.Equals(String.Format("{0}{1}", serialNumber, p)
                        , StringComparison.OrdinalIgnoreCase));

                    if (matches.Any())
                    {
                        matchedEquipments.AddRange(matches);
                    }
                });
            }

            return matchedEquipments;
        }