Beispiel #1
0
        public async void ShouldGetRegistrationByFilter(
            string testName, string fromAsString, string toAsString, string[] inDateAStrings, DateTime[] expectInDates
            )
        {
            //given
            var indates = inDateAStrings.Select(DateTime.Parse).ToArray();

            var taskGrant = _tgBuilder
                            .Create(DateTime.Parse(fromAsString), DateTime.Parse(toAsString))
                            .WithAutoTaskAndTask()
                            .WithPlaces(indates)
                            .Build();

            var filter = new Filter
            {
                From      = DateTime.Parse(fromAsString),
                To        = DateTime.Parse(toAsString),
                OtmGuid   = taskGrant.Otm.TaskGuid,
                OtmCipher = "ПТП-101-2000-100",
                IssType   = IssType.Phone,
                IssValue  = "334-22-33",
                User      = "******",
                Password  = "******"
            };

            var expect = _converter.Convert(filter, taskGrant.AutoTask.places.Where(x => expectInDates.Contains(x.InDate)).Select(x => new Place
            {
                Cid    = x.Cid,
                InDate = x.InDate,
                Lac    = x.Lac,
                MCC    = x.MCC,
                MNC    = x.MNC
            }).ToArray());


            var request = new RegistrationInfoRequest
            {
                QueryParamsHashCode = _decoder.EncryptDecrypt(JsonConvert.SerializeObject(filter))
            };

            //when
            var actual = await _magAdapterClient.GetAllRegistrationsByParamsAsync(request);

            //then
            actual.Should().BeEquivalentTo(expect);
        }
Beispiel #2
0
        public RegistrationInfoResponse GetRegistrationInfo(RegistrationInfoRequest request)
        {
            if (request == null || string.IsNullOrWhiteSpace(request.QueryParamsHashCode))
            {
                _logger.Error("Неверный фильтр");
                throw new NotFoundParmsException();
            }

            Filter filter;

            try
            {
                var decodeRequest = _decoder.EncryptDecrypt(request.QueryParamsHashCode);
                filter = _serealizer.Serealaze <Filter>(decodeRequest);
            }
            catch (Exception exception)
            {
                _logger.Error("Ошибка получения фильра", exception);
                throw new NotFoundParmsException();
            }

            if (!filter.IsCorrectFilter())
            {
                _logger.Error("Не корректный фильр");
                throw new NotFoundParmsException();
            }

            try
            {
                var places = _mtbContext.GetPlaces(filter);
                return(_registrationInfoResponseConverter.Convert(filter, places));
            }
            catch (Exception e)
            {
                _logger.Error("Ошибка получения данных", e);
                throw e;
            }
        }